File size: 4,935 Bytes
08d66df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
---
license: mit
title: SmartVision AI
sdk: streamlit
emoji: πŸš€
colorFrom: red
colorTo: red
short_description: Multi-domain smart object detection and classification syste
---

# SmartVision AI – Complete Vision Pipeline (YOLOv8 + CNN Classifiers + Streamlit Dashboard)

SmartVision AI is a fully integrated **Computer Vision system** that combines:

- **Object Detection** using YOLOv8  
- **Image Classification** using 4 deep-learning models:  
  **VGG16**, **ResNet50**, **MobileNetV2**, **EfficientNetB0**  
- A complete **Streamlit-based Dashboard** for inference, comparison, metrics visualization, and webcam snapshots  
- A modified dataset built on a **25‑class COCO subset**

This README explains setup, architecture, training, deployment, and usage.

---

## πŸš€ Features

### βœ… 1. Image Classification (4 Models)
Each model is fine‑tuned on your custom 25‑class dataset:
- **VGG16**
- **ResNet50**
- **MobileNetV2**
- **EfficientNetB0**

Outputs:
- Top‑1 class prediction  
- Top‑5 predictions  
- Class probabilities  

---

### 🎯 2. Object Detection – YOLOv8s
YOLO detects multiple objects in images or webcam snapshots.

Features:
- Bounding boxes  
- Confidence scores  
- Optional classification verification using ResNet50  
- Annotated images saved automatically  

---

### πŸ”— 3. Integrated Classification + Detection Pipeline
For each YOLO‑detected box:
1. Crop region  
2. Classify using chosen CNN model  
3. Display YOLO label + classifier label  
4. Draw combined annotated results  

---

### πŸ“Š 4. Metrics Dashboard
Displays:
- Accuracy  
- Weighted F1 score  
- Top‑5 accuracy  
- Images per second  
- Model size  
- YOLOv8 mAP scores  
- Confusion matrices  
- Comparison bar charts  

---

### πŸ“· 5. Webcam Snapshot Detection
Take a photo via webcam β†’ YOLO detection β†’ annotated results.

---

## πŸ“ Project Structure

```
SmartVision_AI/
β”‚
β”œβ”€β”€ app.py                     # Main Streamlit App
β”œβ”€β”€ saved_models/              # Trained weights (VGG16, ResNet, MobileNetV2, EfficientNet)
β”œβ”€β”€ yolo_runs/                 # YOLOv8 training folder
β”œβ”€β”€ smartvision_dataset/       # 25-class dataset
β”‚   β”œβ”€β”€ classification/
β”‚   β”‚   β”œβ”€β”€ train/
β”‚   β”‚   β”œβ”€β”€ val/
β”‚   β”‚   └── test/
β”‚   └── detection/             # Labels + images for YOLOv8
β”‚
β”œβ”€β”€ smartvision_metrics/       # Accuracy, F1, confusion matrices
β”œβ”€β”€ scripts/                   # Weight converters, training scripts
β”œβ”€β”€ inference_outputs/         # Annotated results
β”œβ”€β”€ requirements.txt           
└── README.md                  
```

---

## βš™οΈ Installation

### 1️⃣ Clone Repository

```
git clone https://github.com/<your-username>/SmartVision_AI.git
cd SmartVision_AI
```

### 2️⃣ Install Dependencies

```
pip install -r requirements.txt
```

### 3️⃣ Install YOLOv8 (Ultralytics)

```
pip install ultralytics
```

---

## ▢️ Run Streamlit App

```
streamlit run app.py
```

App will open at:

```
http://localhost:8501
```

---

## πŸ‹οΈ Training Workflow

### 1️⃣ Classification Models
Each model has:
- Stage 1 β†’ Train head with frozen backbone  
- Stage 2 β†’ Unfreeze top layers + fine‑tune  

Scripts:
```
scripts/train_mobilenetv2.py
scripts/train_efficientnetb0.py
scripts/train_resnet50.py
scripts/train_vgg16.py
```

### 2️⃣ YOLO Training

```
yolo task=detect mode=train model=yolov8s.pt data=data.yaml epochs=50 imgsz=640
```

Outputs saved to:
```
yolo_runs/smartvision_yolov8s/
```

---

## πŸ§ͺ Supported Classes (25 COCO Classes)

```
airplane, bed, bench, bicycle, bird, bottle, bowl,
bus, cake, car, cat, chair, couch, cow, cup, dog,
elephant, horse, motorcycle, person, pizza, potted plant,
stop sign, traffic light, truck
```

---

## 🧰 Deployment on Hugging Face Spaces

You can deploy using **Streamlit SDK**.

### Steps:
1. Create public repository on GitHub  
2. Push project files  
3. Create new Hugging Face Space β†’ select **Streamlit**  
4. Connect GitHub repo  
5. Add `requirements.txt`  
6. Enable **GPU** for YOLO (optional)  
7. Deploy πŸš€  

---

## 🧾 requirements.txt Example

```
streamlit
tensorflow==2.13.0
ultralytics
numpy
pandas
Pillow
matplotlib
scikit-learn
opencv-python-headless
```

---

## πŸ“„ .gitignore Example

```
saved_models/
*.h5
*.pt
*.weights.h5
yolo_runs/
smartvision_metrics/
inference_outputs/
__pycache__/
*.pyc
.DS_Store
env/
```

---

## πŸ™‹ Developer

**SmartVision AI Project**  
Yogesh Kumar V
M.Sc. Seed Science & Technology (TNAU)  
Passion: AI, Computer Vision, Agribusiness Technology  

---

## 🏁 Conclusion

SmartVision AI integrates:
- Multi‑model classification  
- YOLO detection  
- Streamlit visualization  
- Full evaluation suite  

Perfect for:
- Research  
- Demonstrations  
- CV/AI portfolio  
- Real‑world image understanding  

---

Enjoy using SmartVision AI! πŸš€πŸ§