Skip to content

Proving that classical ML can still shine — 76% accuracy on trash classification (plastic, paper, glass, metal).

License

Notifications You must be signed in to change notification settings

ojayballer/Trash-image-classifier

Repository files navigation

🗑️ Trash Classifier — Classical Machine Learning Approach

A machine learning web app that classifies trash into **plastic, paper, glass, or metal** using classical ML techniques (no deep learning).  
Deployed with Flask on Render.  

🚀 Installation and Live Demo

💻 Run Locally

Clone the repo:

git clone https://github.com/ojayballer/Trash-image-classifier.git
cd Trash-image-classifier

Set up a virtual environment:

python -m venv venv
source venv/bin/activate   # Linux/Mac
venv\Scripts\activate      # Windows

Install dependencies:

pip install -r requirements.txt

Run the Flask app:

python app.py

Open in browser:

👉 http://127.0.0.1:5000/

Live Demo

👉 Try it online: [Trash Classifier on Render](https://trash-image-classifier.onrender.com)  

Upload a **.jpg image** of trash (e.g., bottle, newspaper, soda can) and the model will predict its category in real time

Features

✅ 76% accuracy (benchmark was 67%)  
✅ Can detect multiple items in one image (e.g., paper + metal together)  
✅ Fully deployed as a Flask web app on Render  
✅ Robust preprocessing and optimized feature extraction  

⚙️ Tech Stack

Language: Python
Libraries: scikit-learn, scikit-image, NumPy, Pillow, Flask
Dataset: TrashNet & similar Kaggle datasets
Deployment: Flask + Render

🖼️ Sample UI

Web App Interface

Web App Interface

Example Prediction

Prediction Example

🧠 Methodology

Data Preprocessing

Converted all images to grayscale

Resized to 64×64

Normalized pixel values

Feature Engineering

HOG: captured edges and orientations

LBP: captured textures

GLCM: captured spatial patterns (contrast, homogeneity, correlation)

Final feature vector = HOG + LBP + GLCM

Model Training

Tried SVM, Random Forest, Logistic Regression

Selected the best performing model

Saved with joblib

Evaluation

Achieved 76% accuracy (benchmark was 67%)

Works with images containing multiple objects

🌍 Real-World Impact

Waste management is a global challenge.
This project shows how AI — even classical ML without deep learning — can help automate recycling systems by detecting and sorting waste more efficiently.

🙌 Acknowledgments

Inspired by 20+ research papers on trash classification

Dataset: Kaggle TrashNet

Thanks to the open-source community 💙

🏷️ License

This project is licensed under the MIT License — free to use and modify

About

Proving that classical ML can still shine — 76% accuracy on trash classification (plastic, paper, glass, metal).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published