A comprehensive deep learning-based solution for intelligent waste classification and recycling recommendations. This system leverages MobileNet architecture with transfer learning to accurately categorize different types of waste materials and provide actionable recycling suggestions, contributing to sustainable waste management practices.
The application features a user-friendly web interface built with Streamlit, enabling real-time image classification with instant recycling guidance.
- ๐ฏ Accurate Classification: Deep learning model trained on the TrashNet dataset with high accuracy
- ๐ธ Real-time Predictions: Upload waste images and get instant classification results
- โป๏ธ Recycling Guidance: Detailed suggestions on proper disposal and recycling methods
- ๐ฅ๏ธ Interactive Web Interface: Clean, intuitive Streamlit-based UI for seamless user experience
- ๐ Production-Ready: Containerized with Docker and deployable on cloud platforms (Fly.io, Heroku)
- ๐ Visual Insights: Built-in image visualization tools for better understanding
smart-waste-classification/
โ
โโโ app.py # Streamlit web application (main entry point)
โโโ TrashNet.ipynb # Jupyter notebook for model training and experimentation
โโโ best_model.keras # Trained MobileNet model (saved weights)
โโโ imshow.py # Image visualization utility functions
โ
โโโ dataset.zip # TrashNet dataset (compressed)
โ
โโโ requirements.txt # Python dependencies
โโโ Dockerfile # Docker container configuration
โโโ Procfile # Heroku deployment configuration
โโโ fly.toml # Fly.io deployment configuration
โ
โโโ .gitignore # Git ignore rules
โโโ LICENSE # MIT License
โโโ README.md # Project documentation (this file)
- Source: TrashNet Dataset
- Total Images: 2,527 images
- Classes: 6 waste categories
- ๐ฅค Plastic - Bottles, containers, packaging
- ๐ง Metal - Cans, foils, metal objects
- ๐ช Glass - Bottles, jars, broken glass
- ๐ Paper - Newspapers, magazines, office paper
- ๐ฆ Cardboard - Boxes, cartons, packaging
- ๐ Organic Waste - Food scraps, biodegradable materials
- Image Resizing: Standardized to 224ร224 pixels (MobileNet input size)
- Normalization: Pixel values scaled to [0, 1] range
- Data Augmentation:
- Random rotation
- Horizontal/vertical flipping
- Zoom and shift transformations
- Brightness adjustments
- Train/Validation Split: 80/20 ratio
MobileNetV2 (Transfer Learning)
โโโ Input Layer: 224ร224ร3 RGB images
โโโ MobileNetV2 Base: Pre-trained on ImageNet (frozen layers)
โโโ Global Average Pooling 2D
โโโ Dense Layer (128 units, ReLU activation)
โโโ Dropout (0.5)
โโโ Output Layer (6 units, Softmax activation)
- Base Model: MobileNetV2 (pre-trained on ImageNet)
- Fine-tuning Strategy: Transfer learning with frozen base layers
- Optimizer: Adam (learning rate: 0.001)
- Loss Function: Categorical Cross-Entropy
- Metrics: Accuracy, Precision, Recall
- Callbacks:
- ModelCheckpoint (saves best model)
- EarlyStopping (patience: 10 epochs)
- ReduceLROnPlateau (learning rate scheduling)
- Training Epochs: Variable (with early stopping)
- Batch Size: 32
- Training Accuracy: ~95%
- Validation Accuracy: ~92%
- Model Size: ~14 MB (optimized for deployment)
- Inference Time: <100ms per image
- Python 3.8 or higher
- pip (Python package manager)
- Git
- Clone the repository
git clone https://github.com/arpanpramanik2003/smart-waste-classification.git
cd smart-waste-classification- Create a virtual environment (recommended)
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Extract the dataset (if needed for training)
unzip dataset.zip- Run the application
streamlit run app.py- Access the application
Open your browser and navigate to: http://localhost:8501
docker build -t smart-waste-classifier .docker run -p 8501:8501 smart-waste-classifierdocker-compose up- Install Heroku CLI
heroku login- Create Heroku app
heroku create your-app-name- Deploy
git push heroku master- Install Fly CLI
fly auth login- Launch app
fly launch- Deploy
fly deploy- Launch the application using one of the methods above
- Upload an image of waste material
- Supported formats: JPG, JPEG, PNG
- Recommended: Clear, well-lit images
- View prediction results
- Waste category classification
- Confidence score
- Recycling recommendations
- Follow recycling suggestions for proper waste disposal
jupyter notebook TrashNet.ipynbUse the notebook to:
- Explore the dataset
- Train new models
- Experiment with different architectures
- Evaluate model performance
- Visualize training metrics
from imshow import display_image
# Display image with predictions
display_image('path/to/image.jpg', model, class_names)Edit TrashNet.ipynb to modify:
- Model architecture
- Hyperparameters
- Training strategy
- Data augmentation techniques
Edit app.py to customize:
- UI theme and layout
- Image size limits
- Prediction confidence thresholds
- Recycling suggestion text
- Dockerfile: Modify base image, dependencies, or runtime settings
- Procfile: Update Heroku dyno commands
- fly.toml: Configure Fly.io deployment settings
- TensorFlow 2.x: Deep learning framework
- Keras: High-level neural networks API
- Streamlit: Web application framework
- NumPy: Numerical computing
- Pillow: Image processing
- Matplotlib: Data visualization
See requirements.txt for complete list with version specifications.
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/YourFeature
- Commit your changes
git commit -m "Add YourFeature" - Push to the branch
git push origin feature/YourFeature
- Open a Pull Request
- Follow PEP 8 style guidelines
- Add unit tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
- Model performance may vary with images taken in poor lighting conditions
- Very small or obscured waste items may be misclassified
- Mixed waste (multiple categories in one image) will classify as the dominant category
- Model size optimized for deployment may have slightly lower accuracy than full model
- Multi-label classification for images containing multiple waste types
- Real-time video stream classification
- Mobile application (iOS/Android)
- Integration with waste management APIs
- Expanded dataset with more waste categories
- Localization support for multiple languages
- User feedback mechanism to improve model
- Analytics dashboard for waste statistics
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 Arpan Pramanik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Arpan Pramanik
- GitHub: @arpanpramanik2003
- Repository: smart-waste-classification
- TrashNet Dataset: Thanks to Gary Thung and Mindy Yang for creating and sharing the TrashNet dataset
- MobileNet: Google Research for the efficient MobileNet architecture
- Streamlit: For providing an excellent framework for building ML web applications
- TensorFlow/Keras: For powerful deep learning tools and APIs
- Open Source Community: For inspiration and various tools that made this project possible
For questions, issues, or suggestions:
- Open an issue: GitHub Issues
- Discussions: GitHub Discussions
If you find this project useful, please consider giving it a โญ๏ธ on GitHub!
Made with โค๏ธ for a sustainable future