File size: 4,576 Bytes
7b9b0ca 53d1aef 7b9b0ca 53d1aef |
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
---
language: en
license: mit
tags:
- image-classification
- pytorch
- garbage-classification
- waste-management
- environmental
datasets:
- garbage-classification-dataset
metrics:
- accuracy
- cross-entropy-loss
library_name: pytorch
pipeline_tag: image-classification
---
# Garbage Classification Model (LargeNet)
## Model Description
This is a PyTorch-based convolutional neural network trained to classify images of garbage into 7 categories:
- **Battery**: Used batteries and battery waste
- **Biological**: Organic and biodegradable waste
- **Cardboard**: Cardboard boxes and packaging
- **Glass**: Glass bottles, jars, and containers
- **Metal**: Metal cans, foil, and containers
- **Paper**: Paper waste, documents, and newspaper
- **Plastic**: Plastic bottles, bags, and containers
The model uses a custom CNN architecture called "LargeNet" that processes 128x128 RGB images.
## Model Architecture
```
LargeNet(
(conv1): Conv2d(3, 5, kernel_size=5)
(pool): MaxPool2d(kernel_size=2, stride=2)
(conv2): Conv2d(5, 10, kernel_size=5)
(fc1): Linear(in_features=8410, out_features=32)
(fc2): Linear(in_features=32, out_features=7)
)
```
**Architecture Details:**
- Input: 128x128 RGB images
- 2 Convolutional layers with ReLU activation
- MaxPooling after each convolution
- 2 Fully connected layers
- Output: 7 classes with softmax probabilities
## Training Details
**Training Hyperparameters:**
- Batch size: 64
- Learning rate: 0.01
- Optimizer: SGD
- Loss function: CrossEntropyLoss
- Best epoch: 61
- Training dataset: Garbage Classification Dataset (2100 images)
**Data Preprocessing:**
- Images resized to 128x128 pixels
- Normalized with mean=[0.5, 0.5, 0.5] and std=[0.5, 0.5, 0.5]
- Data split: 72% train, 18% validation, 10% test
## Usage
### Quick Start
```python
from inference import GarbageClassifier
# Initialize the classifier
classifier = GarbageClassifier(".")
# Classify an image
result = classifier.predict("path/to/garbage_image.jpg")
print(f"Predicted class: {result['class']}")
print(f"Confidence: {result['confidence']:.2%}")
print(f"All probabilities: {result['all_probabilities']}")
```
### Manual Usage
```python
import torch
from PIL import Image
from torchvision import transforms
from model import load_model
# Load model
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = load_model("pytorch_model.bin", device)
# Prepare image
transform = transforms.Compose([
transforms.Resize((128, 128)),
transforms.ToTensor(),
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
])
image = Image.open("image.jpg").convert('RGB')
image_tensor = transform(image).unsqueeze(0).to(device)
# Predict
with torch.no_grad():
outputs = model(image_tensor)
probabilities = torch.nn.functional.softmax(outputs, dim=1)
_, predicted = torch.max(probabilities, 1)
class_names = ["battery", "biological", "cardboard", "glass", "metal", "paper", "plastic"]
print(f"Predicted class: {class_names[predicted.item()]}")
```
## Model Performance
The model achieved competitive performance on the garbage classification task. For detailed metrics and performance analysis, please refer to the training logs and evaluation results.
## Limitations and Bias
- The model is trained on a specific garbage dataset and may not generalize well to all types of waste
- Performance may vary with different lighting conditions, image quality, and garbage appearances
- The dataset may have regional or cultural biases in garbage representation
- Works best with clear, well-lit images of individual garbage items
## Intended Use
This model is intended for:
- Educational purposes in waste management and environmental studies
- Prototype development for waste sorting applications
- Research in automated recycling systems
- Environmental awareness applications
**Not recommended for:**
- Production waste sorting systems without additional validation
- Critical infrastructure without human oversight
- Scenarios requiring 100% accuracy
## Citation
If you use this model, please cite:
```
@misc{garbage-classifier-largenet,
author = {Your Name},
title = {Garbage Classification Model},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/your-username/garbage-classifier-largenet}
}
```
## License
MIT License
## Contact
For questions or feedback, please open an issue on the model repository.
|