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.

![demo-screenshot](https://github.com/user-attachments/assets/b10da05a-33e3-46b1-9468-bc0b88823414)

---

## 🧠 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.