File size: 2,852 Bytes
4d42d1c | 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 | # β»οΈ Waste Category Image Classifier (Streamlit + Keras)
An interactive web app for classifying waste images into **10 distinct categories** using a custom-trained Convolutional Neural Network (CNN). Built with **TensorFlow/Keras** and deployed via **Streamlit**, this app demonstrates the power of deep learning in sustainability-oriented image classification.
---
## π Demo
Upload an image and instantly get a class prediction with confidence and full class-wise probabilities.

---
## π§ Model Summary
- **Architecture**: Custom CNN
- **Input Shape**: 224Γ224 RGB
- **Layers**:
- Convolutional layers with BatchNorm and ReLU
- MaxPooling
- Global Average Pooling
- Dense layers with Dropout
- **Optimizer**: Adam (`lr=1e-5`)
- **Loss**: Categorical Crossentropy
- **Final Layer**: Softmax (10 classes)
---
## π Dataset
The dataset consists of images from 10 waste-related categories:
| Class | Count |
|---------------|-------|
| battery | 944 |
| biological | 997 |
| cardboard | 1825 |
| clothes | 5327 |
| glass | 3061 |
| metal | 1020 |
| paper | 1680 |
| plastic | 1984 |
| shoes | 1977 |
| trash | 947 |
### π Data Split
| Split | Images |
|-----------|--------|
| Training | 15,806 |
| Validation| 1,976 |
| Testing | 1,980 |
### π§Ό Preprocessing
- All images resized to `224Γ224`
- Normalized using: `rescale=1./255`
---
## ποΈ Model Architecture (Keras Sequential)
```python
Input(shape=(224, 224, 3)) β
Conv2D(32) β BN β ReLU β
Conv2D(64) β BN β ReLU β MaxPool(4Γ4) β
Conv2D(128) β BN β ReLU β
Conv2D(128) β BN β ReLU β MaxPool(2Γ2) β
Conv2D(256) β BN β ReLU β MaxPool(2Γ2) β
Conv2D(512) β BN β ReLU β MaxPool(2Γ2) β
GlobalAveragePooling β
Dense(256) β Dropout(0.4) β
Dense(10, activation='softmax')
````
---
## π₯οΈ Web App Features
* β
Upload image and classify in real-time
* π Display confidence score
* π Class probabilities table/bar chart
* π§ Show model architecture summary in sidebar
---
## π¦ Installation & Run Locally
1. **Clone the repo**
```bash
git clone https://github.com/Amr1Moussa/NTI-final_projects.git
cd NTI-final_projects
```
2. **(Optional)** Create a virtual environment
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install dependencies**
```bash
pip install -r requirements.txt
```
4. **Run the app**
```bash
streamlit run app.py
```
---
## π Requirements
See `requirements.txt`:
```txt
streamlit
tensorflow
numpy
pillow
pandas
matplotlib
```
## π License
MIT License β use freely, contribute openly, credit kindly.
|