ysfad commited on
Commit
c46d32e
·
verified ·
1 Parent(s): ad06b8b

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +104 -0
README.md ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: pytorch
3
+ tags:
4
+ - waste-classification
5
+ - mae
6
+ - vision-transformer
7
+ - environmental
8
+ - recycling
9
+ license: mit
10
+ datasets:
11
+ - RealWaste
12
+ metrics:
13
+ - accuracy
14
+ model-index:
15
+ - name: MAE Waste Classifier
16
+ results:
17
+ - task:
18
+ type: image-classification
19
+ name: Waste Classification
20
+ dataset:
21
+ type: RealWaste
22
+ name: RealWaste Dataset
23
+ metrics:
24
+ - type: accuracy
25
+ value: 0.9327
26
+ name: Validation Accuracy
27
+ ---
28
+
29
+ # MAE Waste Classifier
30
+
31
+ A finetuned MAE (Masked Autoencoder) ViT-Base model for waste classification achieving **93.27% validation accuracy** on 9 waste categories.
32
+
33
+ ## Model Details
34
+
35
+ - **Architecture**: Vision Transformer (ViT-Base) with MAE pretraining
36
+ - **Parameters**: ~86M
37
+ - **Input Size**: 224x224 RGB images
38
+ - **Classes**: 9 waste categories
39
+ - **Validation Accuracy**: 93.27%
40
+
41
+ ## Categories
42
+
43
+ 1. **Cardboard** - Flatten and place in recycling bin. Remove any tape or staples.
44
+ 2. **Food Organics** - Compost in organic waste bin or home composter.
45
+ 3. **Glass** - Rinse and place in glass recycling. Remove lids and caps.
46
+ 4. **Metal** - Rinse aluminum/steel cans and place in recycling bin.
47
+ 5. **Miscellaneous Trash** - Dispose in general waste bin. Cannot be recycled.
48
+ 6. **Paper** - Place clean paper in recycling. Remove plastic windows from envelopes.
49
+ 7. **Plastic** - Check recycling number. Rinse containers before recycling.
50
+ 8. **Textile Trash** - Donate if reusable, otherwise dispose in textile recycling.
51
+ 9. **Vegetation** - Compost in organic waste or use for mulch in garden.
52
+
53
+ ## Usage
54
+
55
+ ```python
56
+ import torch
57
+ import timm
58
+ from PIL import Image
59
+ from torchvision import transforms
60
+
61
+ # Load model
62
+ model = timm.create_model('vit_base_patch16_224', pretrained=False, num_classes=9)
63
+ checkpoint = torch.load('best_model.pth', map_location='cpu')
64
+ model.load_state_dict(checkpoint['model_state_dict'])
65
+ model.eval()
66
+
67
+ # Preprocessing
68
+ transform = transforms.Compose([
69
+ transforms.Resize((224, 224)),
70
+ transforms.ToTensor(),
71
+ transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
72
+ ])
73
+
74
+ # Inference
75
+ image = Image.open('waste_item.jpg').convert('RGB')
76
+ input_tensor = transform(image).unsqueeze(0)
77
+
78
+ with torch.no_grad():
79
+ outputs = model(input_tensor)
80
+ probabilities = torch.nn.functional.softmax(outputs, dim=1)
81
+ predicted_class = torch.argmax(probabilities, dim=1).item()
82
+
83
+ categories = ['Cardboard', 'Food Organics', 'Glass', 'Metal', 'Miscellaneous Trash', 'Paper', 'Plastic', 'Textile Trash', 'Vegetation']
84
+ print(f"Predicted: {categories[predicted_class]}")
85
+ ```
86
+
87
+ ## Training Details
88
+
89
+ - **Dataset**: RealWaste (4,752 images)
90
+ - **Pretraining**: MAE on ImageNet
91
+ - **Finetuning**: 15 epochs on RealWaste
92
+ - **Optimizer**: AdamW
93
+ - **Hardware**: NVIDIA RTX 3080 Ti
94
+
95
+ ## Performance
96
+
97
+ - **Validation Accuracy**: 93.27%
98
+ - **Training Accuracy**: 99.89%
99
+ - **Model Size**: ~350MB
100
+ - **Inference Speed**: ~50ms per image (GPU)
101
+
102
+ ## Environmental Impact
103
+
104
+ This model helps improve recycling efficiency by providing accurate waste classification and proper disposal instructions.