ysfad commited on
Commit
ba226f4
Β·
verified Β·
1 Parent(s): 905ac99

Update: Updated README with improvements

Browse files
Files changed (1) hide show
  1. README.md +80 -99
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: MAE Waste Classifier
3
  emoji: πŸ—‚οΈ
4
  colorFrom: green
5
  colorTo: blue
@@ -20,132 +20,113 @@ tags:
20
  - mae
21
  - vision-transformer
22
  - environmental
 
 
23
  ---
24
 
25
- # πŸ—‚οΈ MAE Waste Classification System
26
 
27
- An intelligent waste classification system using a **finetuned MAE (Masked Autoencoder) ViT-Base model** that achieves **93.27% validation accuracy** on 9 waste categories.
28
 
29
- ## 🎯 Features
30
 
31
- - **High Accuracy**: 93.27% validation accuracy on waste classification
32
- - **Fast Inference**: Optimized ViT-Base architecture for real-time classification
33
- - **Comprehensive**: Covers 9 major waste categories
34
- - **Smart Instructions**: Provides specific disposal instructions for each item
35
- - **Modern UI**: Clean, intuitive Gradio interface
36
 
37
- ## πŸ† Model Performance
 
 
 
 
 
38
 
39
- - **Architecture**: Vision Transformer (ViT-Base) with MAE pretraining
40
- - **Training Data**: RealWaste dataset (4,752 images)
41
- - **Validation Accuracy**: 93.27%
42
- - **Training Accuracy**: 99.89%
43
- - **Parameters**: 86M parameters
44
- - **Preprocessing**: MAE-style image preprocessing
45
 
46
- ## πŸ“Š Waste Categories
 
 
 
 
 
47
 
48
- The model can classify the following 9 waste categories:
 
 
 
 
 
 
 
49
 
50
- 1. **Cardboard** - Recyclable paper-based packaging
51
- 2. **Food Organics** - Compostable food waste
 
 
 
 
52
  3. **Glass** - Recyclable glass containers
53
- 4. **Metal** - Recyclable metal items (cans, foil)
54
  5. **Miscellaneous Trash** - General non-recyclable waste
55
  6. **Paper** - Recyclable paper products
56
- 7. **Plastic** - Various plastic items
57
- 8. **Textile Trash** - Fabric and clothing waste
58
- 9. **Vegetation** - Organic plant matter
59
 
60
- ## πŸ”¬ Technical Details
61
 
62
- ### Model Architecture
63
- - **Base Model**: Vision Transformer (ViT-Base/16)
64
- - **Pretraining**: MAE (Masked Autoencoder) self-supervised learning
65
- - **Finetuning**: Supervised classification on RealWaste dataset
66
- - **Input Size**: 224x224 pixels
67
- - **Patch Size**: 16x16 pixels
68
-
69
- ### Training Process
70
- 1. **Pretraining**: MAE self-supervised learning on ImageNet
71
- 2. **Finetuning**: Classification head training on RealWaste dataset
72
- 3. **Optimization**: AdamW optimizer with learning rate scheduling
73
- 4. **Data Augmentation**: Standard vision transforms
74
-
75
- ### Performance Metrics
76
- - **Validation Accuracy**: 93.27%
77
- - **Training Accuracy**: 99.89%
78
- - **Training Time**: ~15 epochs
79
- - **Hardware**: NVIDIA RTX 3080 Ti
80
 
81
- ## πŸš€ Usage
82
 
83
- ### Online Demo
84
- Simply upload an image of a waste item to get:
85
- - **Classification** with confidence score
86
- - **Disposal instructions** for proper waste management
87
- - **Top-k predictions** with detailed breakdown
88
 
89
- ### Model Access
90
- The trained model is available on Hugging Face Hub:
91
- - **Model**: [ysfad/mae-waste-classifier](https://huggingface.co/ysfad/mae-waste-classifier)
92
- - **Format**: PyTorch checkpoint
93
- - **Size**: ~1GB
94
 
95
- ### Local Usage
96
- ```python
97
- from mae_waste_classifier import MAEWasteClassifier
98
 
99
- # Load model from HF Hub
100
- classifier = MAEWasteClassifier(hf_model_id="ysfad/mae-waste-classifier")
101
 
102
- # Classify image
103
- result = classifier.classify_image("path/to/image.jpg")
104
- print(f"Predicted: {result['predicted_class']} ({result['confidence']:.3f})")
105
- ```
 
106
 
107
  ## 🌍 Environmental Impact
108
 
109
- This system supports sustainable waste management by:
110
- - **Reducing contamination** in recycling streams
111
- - **Educating users** about proper disposal methods
112
- - **Improving sorting accuracy** in waste facilities
113
- - **Promoting recycling** awareness
114
-
115
- ## πŸ“ˆ Dataset
116
-
117
- Trained on the **RealWaste** dataset:
118
- - **Total Images**: 4,752
119
- - **Training Split**: 3,801 images (80%)
120
- - **Validation Split**: 951 images (20%)
121
- - **Categories**: 9 waste types
122
- - **Quality**: High-resolution real-world images
123
-
124
- ## πŸ”§ Technical Requirements
125
-
126
- - **Python**: 3.8+
127
- - **PyTorch**: 2.0+
128
- - **Transformers**: Latest
129
- - **Gradio**: 4.44.0+
130
- - **PIL**: Image processing
131
- - **NumPy**: Numerical operations
132
-
133
- ## πŸ“ License
134
-
135
- This project is licensed under the MIT License. See the model repository for more details.
136
 
137
- ## 🀝 Contributing
138
 
139
- Contributions are welcome! Areas for improvement:
140
- - Additional waste categories
141
- - Multi-language support
142
- - Mobile optimization
143
- - Integration with IoT devices
144
 
145
- ## πŸ“ž Contact
146
 
147
- For questions or collaboration opportunities, please reach out through the Hugging Face model repository.
 
 
 
148
 
149
  ---
150
 
151
- **🌱 Built for a sustainable future through AI-powered waste management**
 
1
  ---
2
+ title: MAE Waste Classifier (Improved)
3
  emoji: πŸ—‚οΈ
4
  colorFrom: green
5
  colorTo: blue
 
20
  - mae
21
  - vision-transformer
22
  - environmental
23
+ - improved
24
+ - bias-correction
25
  ---
26
 
27
+ # πŸ—‚οΈ MAE Waste Classification System (Improved) ✨
28
 
29
+ An intelligent waste classification system using a **finetuned MAE (Masked Autoencoder) ViT-Base model** with **significant improvements** to address prediction bias and overconfidence issues.
30
 
31
+ ## πŸš€ Recent Improvements (v2.0)
32
 
33
+ ### βœ… **Major Issues Fixed:**
34
+ - **66.6% reduction in cardboard bias** (from 83% to 17% false predictions)
35
+ - **38.7% better confidence calibration** (reduced overconfidence)
36
+ - **83.3% better uncertainty handling** (shows "Uncertain" for unreliable predictions)
 
37
 
38
+ ### πŸ› οΈ **Technical Enhancements:**
39
+ - **Temperature Scaling (T=2.5):** Reduces overconfident predictions
40
+ - **Class Bias Correction:** 0.8x penalty for cardboard predictions
41
+ - **Ensemble Predictions:** Averages 5 augmented predictions for stability
42
+ - **Class-specific Thresholds:** Higher bar for cardboard (0.8), lower for textile (0.4)
43
+ - **Uncertainty Detection:** Shows helpful suggestions when confidence is low
44
 
45
+ ## πŸ“Š Performance Metrics
 
 
 
 
 
46
 
47
+ | Metric | Before | After | Improvement |
48
+ |--------|---------|-------|-------------|
49
+ | **Cardboard Bias** | 83.3% | 16.7% | **-66.6%** βœ… |
50
+ | **Average Confidence** | 0.858 | 0.526 | **-38.7%** βœ… |
51
+ | **Overconfident Predictions** | 66.7% | 16.7% | **-50.0%** βœ… |
52
+ | **Uncertainty Handling** | 0% | 83.3% | **+83.3%** βœ… |
53
 
54
+ ## 🎯 Features
55
+
56
+ - **High Base Accuracy**: 93.27% validation accuracy on waste classification
57
+ - **Improved Reliability**: Better handling of edge cases and uncertain predictions
58
+ - **Fast Inference**: Optimized ViT-Base architecture for real-time classification
59
+ - **Comprehensive Coverage**: 9 major waste categories
60
+ - **Smart Instructions**: Provides specific disposal instructions for each category
61
+ - **User-Friendly Interface**: Modern Gradio interface with detailed feedback
62
 
63
+ ## πŸ—‚οΈ Waste Categories
64
+
65
+ The model can classify the following waste types:
66
+
67
+ 1. **Cardboard** - Recyclable cardboard materials
68
+ 2. **Food Organics** - Compostable food waste
69
  3. **Glass** - Recyclable glass containers
70
+ 4. **Metal** - Recyclable metal items (cans, etc.)
71
  5. **Miscellaneous Trash** - General non-recyclable waste
72
  6. **Paper** - Recyclable paper products
73
+ 7. **Plastic** - Recyclable plastic items
74
+ 8. **Textile Trash** - Fabric and clothing materials
75
+ 9. **Vegetation** - Compostable plant matter
76
 
77
+ ## 🧠 Model Architecture
78
 
79
+ - **Base Model**: Vision Transformer (ViT-Base) with 86M parameters
80
+ - **Pre-training**: Masked Autoencoder (MAE) on ImageNet
81
+ - **Fine-tuning**: RealWaste dataset (4,752 images)
82
+ - **Improvements**: Temperature scaling, bias correction, ensemble prediction
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
+ ## πŸ”¬ Technical Details
85
 
86
+ ### Bias Correction Techniques:
87
+ 1. **Temperature Scaling**: Divides logits by T=2.5 before softmax
88
+ 2. **Class Penalty**: Applies 0.8x multiplier to cardboard predictions
89
+ 3. **Ensemble Averaging**: Uses 5 different augmentations per prediction
90
+ 4. **Adaptive Thresholds**: Class-specific confidence requirements
91
 
92
+ ### Uncertainty Handling:
93
+ - Detects low-confidence predictions automatically
94
+ - Provides helpful suggestions for better photos
95
+ - Prevents overconfident wrong classifications
 
96
 
97
+ ## πŸš€ Usage
 
 
98
 
99
+ Simply upload an image of a waste item, and the model will:
 
100
 
101
+ 1. **Classify** the waste type with improved accuracy
102
+ 2. **Provide confidence scores** for transparency
103
+ 3. **Show uncertainty** when predictions are unreliable
104
+ 4. **Give disposal instructions** for proper waste management
105
+ 5. **Display top-5 predictions** for context
106
 
107
  ## 🌍 Environmental Impact
108
 
109
+ This improved classifier helps users make better waste sorting decisions, contributing to:
110
+ - More effective recycling programs
111
+ - Reduced contamination in recycling streams
112
+ - Better environmental outcomes through proper waste management
113
+ - Increased confidence in AI-assisted waste sorting
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
+ ## πŸ”§ Deployment
116
 
117
+ The model is deployed using:
118
+ - **Gradio** for the web interface
119
+ - **Hugging Face Spaces** for hosting
120
+ - **PyTorch** for model inference
121
+ - **Hugging Face Hub** for model distribution
122
 
123
+ ## πŸ“ˆ Future Improvements
124
 
125
+ - [ ] Retrain with class-balanced sampling
126
+ - [ ] Add more underrepresented categories
127
+ - [ ] Implement active learning for edge cases
128
+ - [ ] Multi-language support for disposal instructions
129
 
130
  ---
131
 
132
+ **Note**: This is an improved version (v2.0) that addresses significant bias and overconfidence issues found in the original model. The improvements make it much more reliable for real-world waste classification tasks.