ANON-STUDIOS-254 commited on
Commit
af0efac
1 Parent(s): 26c988d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +173 -3
README.md CHANGED
@@ -1,3 +1,173 @@
1
- ---
2
- license: cc-by-nc-4.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-4.0
3
+ ---
4
+ ### Mazingira 254: Environmental Insight Analyzer
5
+
6
+ **License**: CC BY-NC 4.0
7
+ **Model Type**: Convolutional Neural Network (CNN)
8
+ **Framework**: TensorFlow
9
+ **Model Size**: 2.46 MB
10
+ **Tags**: environmental-psychology, sustainability, climate-action, image-classification, CNN
11
+
12
+ ---
13
+
14
+ ### Model Description
15
+
16
+ **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.
17
+
18
+ **Classification Categories**:
19
+ 1. Climate Resilient Housing
20
+ 2. Environmental Education
21
+ 3. Green Urban Planning
22
+ 4. Pollution Mitigation Measures
23
+ 5. Proxemics and Sustainable Behavior
24
+ 6. Restorative Environments
25
+ 7. Sustainable Architecture
26
+ 8. Territoriality and Adaptation
27
+ 9. Waste Management Systems
28
+
29
+ ---
30
+
31
+ ### Intended Use
32
+
33
+ The Mazingira 254 model can be applied in the following areas:
34
+ - **Educational Tools**: Facilitates environmental education and awareness.
35
+ - **Urban Planning and Architecture**: Assists planners and architects in assessing sustainability-related visual elements.
36
+ - **Content Analysis**: Analyzes and categorizes environmental themes in social media content.
37
+ - **Environmental Psychology Research**: Provides insights for psychological and behavioral research related to environmental themes.
38
+
39
+ ---
40
+
41
+ ### Model Architecture
42
+
43
+ - **Input**: Images resized to 224x224 pixels.
44
+ - **Layers**:
45
+ - Convolutional layers for feature extraction with ReLU activations.
46
+ - Max-pooling layers for dimensionality reduction.
47
+ - Fully connected layers for classification.
48
+ - Softmax activation for output, representing the probability of each theme.
49
+
50
+ ---
51
+
52
+ ### Training Details
53
+
54
+ - **Training Data**: Labeled images representing each environmental theme.
55
+ - **Loss Function**: Categorical Cross-Entropy Loss.
56
+ - **Optimizer**: Adam optimizer.
57
+ - **Learning Rate**: 0.001.
58
+ - **Training Epochs**: 50.
59
+ - **Evaluation Metrics**: Accuracy, Precision, Recall, and F1-Score.
60
+
61
+ ---
62
+
63
+ ### Evaluation Results
64
+
65
+ - **Training Accuracy**: [To be filled]
66
+ - **Validation Accuracy**: [To be filled]
67
+
68
+ ---
69
+
70
+ ### How to Use the Model
71
+
72
+ #### Input Format
73
+ The model expects color images of 224x224 pixels, with pixel values normalized to the range [-1, 1].
74
+
75
+ ```python
76
+ import gradio as gr
77
+ from keras.models import load_model
78
+ from PIL import Image, ImageOps
79
+ import numpy as np
80
+
81
+ # Load the pre-trained Keras model for Mazingira 254
82
+ model = load_model("/content/keras_model.h5", compile=False)
83
+
84
+ # Load class labels for environmental themes
85
+ with open("/content/labels.txt", "r") as file:
86
+ class_names = [line.strip() for line in file.readlines()]
87
+
88
+ def classify_image(img):
89
+ size = (224, 224)
90
+ image = ImageOps.fit(img, size, Image.Resampling.LANCZOS)
91
+ image_array = np.asarray(image)
92
+ normalized_image_array = (image_array.astype(np.float32) / 127.5) - 1
93
+ data = normalized_image_array.reshape((1, 224, 224, 3))
94
+
95
+ prediction = model.predict(data)
96
+ index = np.argmax(prediction)
97
+ class_name = class_names[index]
98
+ confidence_score = prediction[0][index]
99
+
100
+ return {
101
+ "Detected Theme": class_name,
102
+ "Confidence Score": f"{confidence_score:.2f}"
103
+ }
104
+
105
+ # Custom CSS for green and earth tone aesthetics
106
+ custom_css = """
107
+ body {
108
+ font-family: 'Arial', sans-serif;
109
+ background-color: #e0f7e8;
110
+ color: #2e7d32;
111
+ }
112
+
113
+ .gradio-container {
114
+ border-radius: 10px;
115
+ padding: 20px;
116
+ background: linear-gradient(135deg, #a5d6a7, #1b5e20);
117
+ box-shadow: 0px 4px 15px rgba(0, 0, 0, 0.2);
118
+ }
119
+
120
+ .gradio-container h1 {
121
+ font-family: 'Arial', sans-serif;
122
+ font-size: 2.5em;
123
+ text-align: center;
124
+ color: #ffffff;
125
+ }
126
+
127
+ .gradio-button {
128
+ background-color: #2e7d32;
129
+ border: none;
130
+ color: white;
131
+ padding: 10px 20px;
132
+ font-size: 1em;
133
+ cursor: pointer;
134
+ border-radius: 5px;
135
+ }
136
+
137
+ .gradio-button:hover {
138
+ background-color: #66bb6a;
139
+ }
140
+ """
141
+
142
+ # Gradio Interface
143
+ interface = gr.Interface(
144
+ fn=classify_image,
145
+ inputs=gr.Image(type="pil", label="Upload an Image"),
146
+ outputs=gr.JSON(label="Environmental Theme Detection"),
147
+ title="Mazingira 254: Environmental Insight Analyzer",
148
+ description="Upload an image, and our AI will analyze it for environmental themes related to sustainability and resilience.",
149
+ allow_flagging="never",
150
+ css=custom_css
151
+ )
152
+
153
+ interface.launch()
154
+ ```
155
+
156
+ ### Output
157
+ The output is a dictionary containing:
158
+ - **Detected Theme**: Predicted environmental theme (e.g., "Green Urban Planning").
159
+ - **Confidence Score**: Confidence score for the predicted theme (range: 0 to 1).
160
+
161
+ ---
162
+
163
+ ### Limitations
164
+ - **Generalization**: May struggle with images not similar to the training set.
165
+ - **Cultural Sensitivity**: Environmental design and behaviors vary globally, which may affect results.
166
+ - **Complex Contexts**: Images with overlapping themes may lead to misclassification.
167
+
168
+ ---
169
+
170
+ ### Ethical Considerations
171
+ - **Bias**: Results may reflect biases in the training data.
172
+ - **Privacy**: Ensure compliance with privacy standards when using personal or sensitive images.
173
+ - **Interpretation**: Misclassification of themes could impact decisions, so exercise caution in high-stakes applications.