A deep learning web app that classifies waste images into Biodegradable or Non-Biodegradable using a custom CNN (Convolutional Neural Network) built with TensorFlow / Keras. Users can either upload a photo or capture one live from their webcam, and get an instant prediction from a friendly Flask web interface.
Deployed URL: https://cnnwasteclassification-1.onrender.com/
- ✅ Local / CLI-based prediction works fine — running
python app.pyfrom the terminal gives correct predictions (see example terminal output below). - ❌ Prediction does NOT work when deployed — the model does not return predictions on the deployed Render server (
https://cnnwasteclassification-1.onrender.com/). The app opens and loads the page, but the prediction feature fails after deployment on the server.
Example of a local terminal run (works as expected):
(tf_keras) PS D:\Projects\waste_classification_app> python app.py
WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.
* Serving Flask app 'app'
* Debug mode: on
* Running on http://127.0.0.1:5000
1/1 [==============================] - 3s 3s/step
127.0.0.1 - - [14/Sep/2026 10:06:46] "POST /predict_webcam HTTP/1.1" 200 -
1/1 [==============================] - 0s 117ms/step
127.0.0.1 - - [14/Sep/2026 10:06:48] "POST /upload HTTP/1.1" 200 -
- 📷 Image Upload – predict from any image file (JPG / PNG).
- 🎥 Live Webcam Prediction – capture a frame from your camera and classify it instantly.
- 🧠 CNN Model – powered by a TensorFlow/Keras model trained for waste recognition.
- 🌐 Clean Web UI – simple, mobile-friendly Flask frontend.
| Layer | Technology |
|---|---|
| Backend | Python 3.10, Flask |
| Machine Learning | TensorFlow 2.12, Keras, NumPy |
| Image Processing | OpenCV, Pillow |
| Frontend | HTML, CSS, JavaScript (Webcam API) |
| Deployment | Render (gunicorn) |
waste_classification_app/
│
├── app.py # Flask backend: routes, model loading & prediction logic
├── requirements.txt # Python dependencies
├── .gitignore # Files/folders excluded from Git
├── .python-version # Recommended Python version (3.10)
├── README.md # This file
│
├── model/
│ ├── keras_model.h5 # Trained CNN model (TensorFlow/Keras format)
│ └── labels.txt # Class labels used during training (Class 1, Class 2)
│
├── templates/
│ └── index.html # Main page (upload form + webcam capture UI)
│
├── statics/
│ └── style.css # Stylesheet for the app
│
├── uploads/ # Folder where uploaded images are saved (git-ignored)
│
└── .vscode/
└── launch.json # VS Code debug configuration
Note: Local Python environments (
venv/,tf_keras/,tf_old/) are git-ignored and should not be committed.
Before getting started, make sure you have installed:
- Python 3.10 – recommended version for TensorFlow 2.12. Download from python.org.
- Git – git-scm.com
- A webcam (optional, only needed for live webcam predictions).
On Windows, make sure "Add Python to PATH" is checked during installation.
Follow these steps to run the project locally on your machine.
git clone https://github.com/your-username/waste_classification_app.git
cd waste_classification_appWindows:
python -m venv venv
venv\Scripts\activatemacOS / Linux:
python3 -m venv venv
source venv/bin/activateYour terminal prompt should now show (venv).
pip install --upgrade pip
pip install -r requirements.txtTensorFlow is a large package, so the installation may take a few minutes.
python app.pyYou should see output similar to:
* Running on http://127.0.0.1:5000
Open your browser and visit: http://127.0.0.1:5000
- Upload an image – click Choose File, select an image of waste (e.g., a plastic bottle, paper, food waste), and press Predict.
- Webcam prediction – allow camera access, point it at an object, and click Capture & Predict.
- The app will display the result: Biodegradable or Non-Biodegradable.
- Model loading – The app loads the pre-trained CNN (
model/keras_model.h5) once at startup (app.py). - Preprocessing – Every input image is resized to 224 × 224 pixels and normalized to a 0–1 range.
- Prediction – The model outputs a probability score for each class:
- Class 1 → Biodegradable
- Class 2 → Non-Biodegradable
- Response – The result is rendered back on the page via Flask templates.
The model is compatible with a Google Teachable Machine exported Keras model (it maps directly to the same input shape and class count).
This project is ready to deploy on Render:
-
Push the repository to GitHub.
-
In Render, create a New Web Service and connect the repo.
-
The build will install dependencies from
requirements.txtand start with gunicorn (included in requirements). -
Start command (set in Render if prompted):
gunicorn app:app
Set the Python runtime to 3.10 in the Render service settings for best TensorFlow compatibility.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is for educational purposes. If you plan to use it commercially, make sure the model and dataset used for training are properly licensed.