Spaces:
Runtime error
Runtime error
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,12 +1,151 @@
|
|
| 1 |
-
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: MAE Waste Classifier
|
| 3 |
+
emoji: ποΈ
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: blue
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
models:
|
| 12 |
+
- ysfad/mae-waste-classifier
|
| 13 |
+
datasets:
|
| 14 |
+
- garythung/trashnet
|
| 15 |
+
tags:
|
| 16 |
+
- computer-vision
|
| 17 |
+
- image-classification
|
| 18 |
+
- waste-management
|
| 19 |
+
- recycling
|
| 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**
|