ashuwhy commited on
Commit
8b91980
·
verified ·
1 Parent(s): 1ede408

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +156 -3
README.md CHANGED
@@ -1,3 +1,156 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Waste Classification Model
2
+
3
+ ## Model Files
4
+ Due to their large size, the model files are hosted externally:
5
+
6
+ - [efficientnetv2s_waste_classifier.keras](https://huggingface.co/ashuwhy/waste-classification/resolve/main/efficientnetv2s_waste_classifier.keras) (86.88 MB) - Base model
7
+ - [efficientnetv2s_waste_classifier_fine_tuned.keras](https://huggingface.co/ashuwhy/waste-classification/resolve/main/efficientnetv2s_waste_classifier_fine_tuned.keras) (198.11 MB) - Fine-tuned model
8
+ - [efficientnetv2s_waste_classifier_final.keras](https://huggingface.co/ashuwhy/waste-classification/resolve/main/efficientnetv2s_waste_classifier_final.keras) (198.11 MB) - Final saved model
9
+
10
+ Please download these files and place them in this directory before using the model.
11
+
12
+ ## Overview
13
+ This repository contains a deep learning model for waste classification, a critical component of the Smart Waste Management and Recycling Optimization Platform (SWMRO). The model is designed to classify waste items into 7 categories using EfficientNetV2S architecture, optimized for performance on Mac M2 chips.
14
+
15
+ ![Waste Classification](https://img.shields.io/badge/AI-Waste%20Classification-brightgreen)
16
+ ![TensorFlow](https://img.shields.io/badge/Framework-TensorFlow-orange)
17
+ ![EfficientNetV2S](https://img.shields.io/badge/Model-EfficientNetV2S-blue)
18
+ ![Accuracy](https://img.shields.io/badge/Accuracy-High%20Precision-success)
19
+
20
+ ## Purpose
21
+ The waste classification model serves as the AI backbone for automated waste sorting in the SWMRO platform. It enables:
22
+
23
+ - **Accurate Waste Categorization**: Identifies waste items across 7 different categories
24
+ - **Recycling Optimization**: Improves recycling efficiency through precise classification
25
+ - **Environmental Impact**: Reduces landfill waste by ensuring proper waste sorting
26
+ - **Integration with SWMRO**: Powers the platform's waste analysis capabilities
27
+
28
+ ## Model Architecture
29
+
30
+ ### Technical Specifications
31
+ - **Base Model**: EfficientNetV2S (pre-trained on ImageNet)
32
+ - **Input Size**: 224x224 pixels (RGB)
33
+ - **Classes**: 7 waste categories
34
+ - **Training Approach**: Transfer learning with fine-tuning
35
+ - **Optimization**: Adam optimizer with learning rate scheduling
36
+ - **Regularization**: Dropout (0.5) and BatchNormalization
37
+
38
+ ### Waste Categories
39
+ The model classifies waste into the following categories:
40
+ 1. **Cardboard** → RECYCLABLE
41
+ 2. **Glass** → RECYCLABLE
42
+ 3. **Metal** → RECYCLABLE
43
+ 4. **Paper** → RECYCLABLE
44
+ 5. **Plastic** → RECYCLABLE
45
+ 6. **Compost** → ORGANIC
46
+ 7. **Trash** → GENERAL
47
+ 8. **Hazardous** → HAZARDOUS [not used in the current model but used in swmro, this is just for future upgrade]
48
+
49
+ ## Training Process
50
+
51
+ The model was trained using a comprehensive approach:
52
+
53
+ 1. **Data Preparation**:
54
+ - Dataset split into training (80%) and validation (20%) sets
55
+ - Extensive data augmentation (flips, rotations, zoom, contrast, brightness)
56
+
57
+ 2. **Transfer Learning**:
58
+ - Initial training with frozen EfficientNetV2S base
59
+ - Fine-tuning of later blocks for domain adaptation
60
+
61
+ 3. **Optimization Strategy**:
62
+ - Early stopping to prevent overfitting
63
+ - Learning rate reduction on plateau
64
+ - Model checkpointing to save best weights
65
+
66
+ ## Performance
67
+
68
+ The model achieves high accuracy in waste classification tasks, making it suitable for real-world applications. Performance metrics include:
69
+ - High classification accuracy across all waste categories
70
+ - Robust performance on varied waste item appearances
71
+ - Efficient inference time suitable for real-time applications
72
+
73
+ ## Integration with SWMRO
74
+
75
+ This model integrates with the SWMRO platform to:
76
+ - Power the waste analysis module
77
+ - Support the citizen portal for waste identification
78
+ - Provide data for the sustainability dashboard
79
+ - Enhance recycling efficiency metrics
80
+
81
+ ## Usage
82
+
83
+ ### Requirements
84
+ ```
85
+ tensorflow>=2.8.0
86
+ numpy>=1.19.5
87
+ pillow>=8.0.0
88
+ matplotlib>=3.4.0
89
+ seaborn>=0.11.0
90
+ scikit-learn>=1.0.0
91
+ ```
92
+
93
+ ### Inference Example
94
+ ```python
95
+ import tensorflow as tf
96
+ from PIL import Image
97
+ import numpy as np
98
+
99
+ # Load the model
100
+ model = tf.keras.models.load_model('efficientnetv2s_waste_classifier_final.keras')
101
+
102
+ # Class names
103
+ class_names = ['cardboard', 'compost', 'glass', 'metal', 'paper', 'plastic', 'trash']
104
+
105
+ # Mapping to backend categories
106
+ mapping = {
107
+ 'cardboard': 'RECYCLABLE',
108
+ 'glass': 'RECYCLABLE',
109
+ 'metal': 'RECYCLABLE',
110
+ 'paper': 'RECYCLABLE',
111
+ 'plastic': 'RECYCLABLE',
112
+ 'compost': 'ORGANIC',
113
+ 'trash': 'GENERAL'
114
+ }
115
+
116
+ # Preprocess image
117
+ def preprocess_image(image_path):
118
+ img = Image.open(image_path).resize((224, 224))
119
+ img_array = tf.keras.preprocessing.image.img_to_array(img)
120
+ img_array = tf.expand_dims(img_array, 0)
121
+ return img_array / 255.0
122
+
123
+ # Classify waste
124
+ def classify_waste(image_path):
125
+ preprocessed_img = preprocess_image(image_path)
126
+ predictions = model.predict(preprocessed_img)
127
+ predicted_class = class_names[np.argmax(predictions[0])]
128
+ confidence = np.max(predictions[0])
129
+ backend_category = mapping[predicted_class]
130
+
131
+ return {
132
+ 'detailed_class': predicted_class,
133
+ 'backend_category': backend_category,
134
+ 'confidence': float(confidence)
135
+ }
136
+ ```
137
+
138
+ ## Future Improvements
139
+
140
+ Planned enhancements for the model include:
141
+ - Expanding the dataset with more diverse waste items
142
+ - Implementing model quantization for edge deployment
143
+ - Exploring MobileNetV3 for mobile applications
144
+ - Adding multi-label classification for mixed waste
145
+
146
+ ## License
147
+
148
+ This project is part of the SWMRO project and is available under the MIT License.
149
+
150
+ ## Acknowledgments
151
+
152
+ - The model architecture is based on EfficientNetV2S by Google Research
153
+ - Training utilized TensorFlow and Keras frameworks
154
+ - Special thanks to contributors of waste classification datasets
155
+
156
+ © 2025 Ashutosh Sharma. All rights reserved.