Skip to content

This project utilizes MobileNet and the TrashNet dataset to classify waste into different categories and provide recycling suggestions. Built with TensorFlow and Streamlit, it allows users to upload an image of trash and get instant classification results along with eco-friendly disposal recommendations.

License

Notifications You must be signed in to change notification settings

arpanpramanik2003/smart-waste-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Smart Waste Classification & Recycling Suggestion System

License: MIT Python 3.8+ TensorFlow Streamlit

๐Ÿ“– Overview

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.

โœจ Key Features

  • ๐ŸŽฏ 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

๐Ÿ—‚๏ธ Project Structure

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)

๐Ÿ—„๏ธ Dataset

TrashNet Dataset

  • 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

Data Preprocessing

  • 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

๐Ÿ—๏ธ Model Architecture

Base Architecture

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)

Training Configuration

  • 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

Model Performance

  • Training Accuracy: ~95%
  • Validation Accuracy: ~92%
  • Model Size: ~14 MB (optimized for deployment)
  • Inference Time: <100ms per image

๐Ÿš€ Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • pip (Python package manager)
  • Git

Local Setup

  1. Clone the repository
git clone https://github.com/arpanpramanik2003/smart-waste-classification.git
cd smart-waste-classification
  1. Create a virtual environment (recommended)
python -m venv venv

# On Windows
venv\Scripts\activate

# On macOS/Linux
source venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Extract the dataset (if needed for training)
unzip dataset.zip
  1. Run the application
streamlit run app.py
  1. Access the application

Open your browser and navigate to: http://localhost:8501

๐Ÿณ Docker Deployment

Build Docker Image

docker build -t smart-waste-classifier .

Run Docker Container

docker run -p 8501:8501 smart-waste-classifier

Docker Compose (Optional)

docker-compose up

โ˜๏ธ Cloud Deployment

Heroku Deployment

  1. Install Heroku CLI
heroku login
  1. Create Heroku app
heroku create your-app-name
  1. Deploy
git push heroku master

Fly.io Deployment

  1. Install Fly CLI
fly auth login
  1. Launch app
fly launch
  1. Deploy
fly deploy

๐Ÿ’ป Usage Guide

Web Application

  1. Launch the application using one of the methods above
  2. Upload an image of waste material
    • Supported formats: JPG, JPEG, PNG
    • Recommended: Clear, well-lit images
  3. View prediction results
    • Waste category classification
    • Confidence score
    • Recycling recommendations
  4. Follow recycling suggestions for proper waste disposal

Jupyter Notebook (Training/Experimentation)

jupyter notebook TrashNet.ipynb

Use the notebook to:

  • Explore the dataset
  • Train new models
  • Experiment with different architectures
  • Evaluate model performance
  • Visualize training metrics

Image Visualization Utility

from imshow import display_image

# Display image with predictions
display_image('path/to/image.jpg', model, class_names)

๐Ÿ”ง Configuration & Customization

Model Customization

Edit TrashNet.ipynb to modify:

  • Model architecture
  • Hyperparameters
  • Training strategy
  • Data augmentation techniques

Application Customization

Edit app.py to customize:

  • UI theme and layout
  • Image size limits
  • Prediction confidence thresholds
  • Recycling suggestion text

Deployment Configuration

  • Dockerfile: Modify base image, dependencies, or runtime settings
  • Procfile: Update Heroku dyno commands
  • fly.toml: Configure Fly.io deployment settings

๐Ÿ“ฆ Dependencies

Core Dependencies

  • 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

Full Dependencies

See requirements.txt for complete list with version specifications.

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/YourFeature
  3. Commit your changes
    git commit -m "Add YourFeature"
  4. Push to the branch
    git push origin feature/YourFeature
  5. Open a Pull Request

Contribution Guidelines

  • Follow PEP 8 style guidelines
  • Add unit tests for new features
  • Update documentation as needed
  • Ensure all tests pass before submitting PR

๐Ÿ› Known Issues & Limitations

  • 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

๐Ÿ”ฎ Future Enhancements

  • 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

๐Ÿ“„ License

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.

๐Ÿ‘จโ€๐Ÿ’ป Author

Arpan Pramanik

๐Ÿ™ Acknowledgments

  • 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

๐Ÿ“ž Support & Contact

For questions, issues, or suggestions:

๐ŸŒŸ Star This Repository

If you find this project useful, please consider giving it a โญ๏ธ on GitHub!


Made with โค๏ธ for a sustainable future

About

This project utilizes MobileNet and the TrashNet dataset to classify waste into different categories and provide recycling suggestions. Built with TensorFlow and Streamlit, it allows users to upload an image of trash and get instant classification results along with eco-friendly disposal recommendations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages