Mazingira 254: Environmental Insight Analyzer

License: CC BY-NC 4.0
Model Type: Convolutional Neural Network (CNN)
Framework: TensorFlow
Model Size: 2.46 MB
Tags: environmental-psychology, sustainability, climate-action, image-classification, CNN


Model Description

Mazingira 254 is a deep learning model designed to classify images into key themes related to environmental psychology and sustainable development. By processing visual inputs, Mazingira 254 provides insights into sustainable practices, resilient design, and restorative environments. The model outputs the detected environmental theme along with a confidence score.

Classification Categories:

  1. Climate Resilient Housing
  2. Environmental Education
  3. Green Urban Planning
  4. Pollution Mitigation Measures
  5. Proxemics and Sustainable Behavior
  6. Restorative Environments
  7. Sustainable Architecture
  8. Territoriality and Adaptation
  9. Waste Management Systems

Intended Use

The Mazingira 254 model can be applied in the following areas:

  • Educational Tools: Facilitates environmental education and awareness.
  • Urban Planning and Architecture: Assists planners and architects in assessing sustainability-related visual elements.
  • Content Analysis: Analyzes and categorizes environmental themes in social media content.
  • Environmental Psychology Research: Provides insights for psychological and behavioral research related to environmental themes.

Model Architecture

  • Input: Images resized to 224x224 pixels.
  • Layers:
    • Convolutional layers for feature extraction with ReLU activations.
    • Max-pooling layers for dimensionality reduction.
    • Fully connected layers for classification.
    • Softmax activation for output, representing the probability of each theme.

Training Details

  • Training Data: Labeled images representing each environmental theme.
  • Loss Function: Categorical Cross-Entropy Loss.
  • Optimizer: Adam optimizer.
  • Learning Rate: 0.001.
  • Training Epochs: 50.
  • Evaluation Metrics: Accuracy, Precision, Recall, and F1-Score.

Evaluation Results

  • Training Accuracy: [To be filled]
  • Validation Accuracy: [To be filled]

How to Use the Model

Input Format

The model expects color images of 224x224 pixels, with pixel values normalized to the range [-1, 1].

import gradio as gr
from keras.models import load_model
from PIL import Image, ImageOps
import numpy as np

# Load the pre-trained Keras model for Mazingira 254
model = load_model("/content/keras_model.h5", compile=False)

# Load class labels for environmental themes
with open("/content/labels.txt", "r") as file:
    class_names = [line.strip() for line in file.readlines()]

def classify_image(img):
    size = (224, 224)
    image = ImageOps.fit(img, size, Image.Resampling.LANCZOS)
    image_array = np.asarray(image)
    normalized_image_array = (image_array.astype(np.float32) / 127.5) - 1
    data = normalized_image_array.reshape((1, 224, 224, 3))

    prediction = model.predict(data)
    index = np.argmax(prediction)
    class_name = class_names[index]
    confidence_score = prediction[0][index]

    return {
        "Detected Theme": class_name,
        "Confidence Score": f"{confidence_score:.2f}"
    }

# Custom CSS for green and earth tone aesthetics
custom_css = """
body {
    font-family: 'Arial', sans-serif;
    background-color: #e0f7e8;
    color: #2e7d32;
}

.gradio-container {
    border-radius: 10px;
    padding: 20px;
    background: linear-gradient(135deg, #a5d6a7, #1b5e20);
    box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.2);
}

.gradio-container h1 {
    font-family: 'Arial', sans-serif;
    font-size: 2.5em;
    text-align: center;
    color: #ffffff;
}

.gradio-button {
    background-color: #2e7d32;
    border: none;
    color: white;
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    border-radius: 5px;
}

.gradio-button:hover {
    background-color: #66bb6a;
}
"""

# Gradio Interface
interface = gr.Interface(
    fn=classify_image,
    inputs=gr.Image(type="pil", label="Upload an Image"),
    outputs=gr.JSON(label="Environmental Theme Detection"),
    title="Mazingira 254: Environmental Insight Analyzer",
    description="Upload an image, and our AI will analyze it for environmental themes related to sustainability and resilience.",
    allow_flagging="never",
    css=custom_css
)

interface.launch()

Output

The output is a dictionary containing:

  • Detected Theme: Predicted environmental theme (e.g., "Green Urban Planning").
  • Confidence Score: Confidence score for the predicted theme (range: 0 to 1).

Limitations

  • Generalization: May struggle with images not similar to the training set.
  • Cultural Sensitivity: Environmental design and behaviors vary globally, which may affect results.
  • Complex Contexts: Images with overlapping themes may lead to misclassification.

Ethical Considerations

  • Bias: Results may reflect biases in the training data.
  • Privacy: Ensure compliance with privacy standards when using personal or sensitive images.
  • Interpretation: Misclassification of themes could impact decisions, so exercise caution in high-stakes applications.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference API
Unable to determine this model's library. Check the docs .