File size: 2,838 Bytes
fdd1d98 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | ---
tags:
- image-classification
- pytorch
- waste-classification
- mobilenetv2
- computer-vision
- recycling
license: mit
metrics:
- accuracy
pipeline_tag: image-classification
---
# ποΈ Smart Waste Classification Model
A fine-tuned **MobileNetV2** model for classifying waste items into 6 categories using computer vision.
## Model Performance
- **Validation Accuracy**: 97.46%
- **Framework**: PyTorch
- **Architecture**: MobileNetV2
## Classes
| Class | Description | Color |
|-------|-------------|-------|
| π΅ **plastic** | Bottles, bags, containers | Blue |
| π **paper** | Newspapers, cardboard, magazines | Brown |
| π **metal** | Cans, foil, batteries | Gray |
| π **glass** | Bottles, jars | Green |
| π’ **organic** | Food waste, plant matter | Dark Green |
| β« **non-recyclable** | Mixed/contaminated waste | Black |
## Quick Usage
```python
import torch
from torchvision import models, transforms
from PIL import Image
from huggingface_hub import hf_hub_download
# Download model
model_path = hf_hub_download(repo_id="karthikeya09/smart_image_recognation", filename="best_model.pth")
# Load model
model = models.mobilenet_v2(weights=None)
model.classifier = torch.nn.Sequential(
torch.nn.Dropout(p=0.2),
torch.nn.Linear(1280, 6)
)
checkpoint = torch.load(model_path, map_location='cpu')
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Define transforms
transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])
# Predict
classes = ['glass', 'metal', 'non-recyclable', 'organic', 'paper', 'plastic']
image = Image.open('your_image.jpg').convert('RGB')
input_tensor = transform(image).unsqueeze(0)
with torch.no_grad():
outputs = model(input_tensor)
probs = torch.nn.functional.softmax(outputs, dim=1)
confidence, predicted = torch.max(probs, 1)
print(f'Predicted: {classes[predicted.item()]} ({confidence.item()*100:.1f}%)')
```
## Training Details
- **Dataset**: ~21,000 waste images
- **Training Split**: 70% train, 15% val, 15% test
- **Optimizer**: Adam (lr=0.001)
- **Class Weights**: Used to handle class imbalance
- **Data Augmentation**: Random crop, flip, rotation, color jitter
- **Input Size**: 224x224 RGB
## Dataset Distribution
| Category | Images |
|----------|--------|
| Organic | 6,620 |
| Glass | 4,022 |
| Paper | 3,882 |
| Metal | 3,428 |
| Plastic | 1,870 |
| Non-recyclable | 1,394 |
## Model Architecture
```
MobileNetV2 (pretrained on ImageNet)
βββ classifier
βββ Dropout(p=0.2)
βββ Linear(1280, 6)
```
## License
MIT License
## Author
**K Karthikeya Gupta**
|