File size: 5,189 Bytes
7206810
 
 
 
 
 
 
033c3b5
7206810
 
03efa53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: Utensil Detector
emoji: 🍽️
colorFrom: pink
colorTo: purple
sdk: streamlit
sdk_version: "1.32.0"
app_file: app/app.py
pinned: false
---

# 🍽️ Utensils Object Detection System

Welcome to **Utensils Object Detection System** β€” an end-to-end pipeline that detects Utensils items like plates, glasses, spoons, and forkss using a custom-trained deep learning model.

This project was built **from scratch** (no Roboflow or auto-annotation tools!) and demonstrates a full lifecycle: dataset creation, model training, performance evaluation, and an interactive demo app.

---

## πŸ—οΈ Project Overview

We set out to solve a real-world problem:
> _β€œCan we reliably detect common Utensils items in images, videos, or real-time webcam streams using only a small, custom-labeled dataset?”_

To achieve this, we:
βœ… Collected & annotated a custom dataset (100–500 images)
βœ… Built a clean Python codebase to handle training, inference, and deployment
βœ… Delivered an interactive demo using **Streamlit / Flask**

---

## πŸ“ Project Structure

```
β”œβ”€β”€ app/                # Streamlit or Flask app for demo
β”‚   └── app.py
β”œβ”€β”€ dataset/            # Custom dataset (images + labels)
β”‚   β”œβ”€β”€ images/
β”‚   └── labels/
β”œβ”€β”€ inference/          # Inference scripts (image, video, webcam)
β”‚   β”œβ”€β”€ detect_image.py
β”‚   β”œβ”€β”€ detect_video.py
β”‚   └── detect_webcam.py
β”œβ”€β”€ runs/detect/        # Training results & saved weights
β”‚   β”œβ”€β”€ weights/
β”‚   β”œβ”€β”€ results.png
β”‚   └── Other Metrics ...
β”œβ”€β”€ training/           # Training pipeline
β”‚   β”œβ”€β”€ train.py
β”‚   └── model_training.ipynb
β”œβ”€β”€ data.yaml           # Dataset config
β”œβ”€β”€ requirements.txt    # Python dependencies
└── README.md           # This file
```

---

## πŸ—‚οΈ Dataset

- **Images collected:** Manually photographed or sourced from public domain (Kaggle)
- **Classes:** Example β€” plate, fork, spoon, glass
- **Annotation tool:** [LabelImg](https://github.com/heartexlabs/labelImg)
- **Format:** YOLO txt labels

---

## πŸ‹οΈβ€β™‚οΈ Model Training

- **Framework:** YOLOv8
- **Training script:** `training/train.py`
- **Best checkpoint:** `runs/detect/weights/best.pt`
- **Metrics logged:** loss curves, mAP, precision, recall, F1

---

## πŸ” Inference & Results

- Run detection on:
  - Static images β†’ `inference/detect_image.py`
  - Video files β†’ `inference/detect_video.py`
  - Real-time webcam β†’ `inference/detect_webcam.py`

- Visual outputs include:
  - Bounding boxes with class names and confidence
  - Confusion matrix
  - Precision-recall, F1 curves

---

## 🌐 Interactive Demo

Launch the demo app:
```bash
pip install -r requirements.txt
streamlit run app/app.py 
```

Features:
- Upload image or video and get detections
- View predicted bounding boxes + class names + confidence scores
- (Optional) Real-time webcam support

---

## πŸš€ Getting Started

1️⃣ Clone the repo:
```bash
git clone https://github.com/yourusername/Utensils-object-detection.git
cd Utensils-object-detection
```

2️⃣ Install dependencies:
```bash
pip install -r requirements.txt
```

3️⃣ Run training:
```bash
python training/train.py --data data.yaml
```

4️⃣ Try inference:
```bash
python inference/detect_image.py --source path/to/image.jpg
```

5️⃣ Launch app:
```bash
streamlit run app/app.py
```
Model summary (fused): 92 layers, 25,842,076 parameters, 0 gradients, 78.7 GFLOPs
                 Class     Images  Instances      Box(P          R      mAP50  mAP50-95): 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 3/3 [00:02<00:00,  1.48it/s]
                   all         40         40      0.681      0.725      0.731      0.468
                  fork         10         10      0.338        0.2      0.265      0.113
                 glass         10         10      0.643        0.9      0.888      0.432
                 plate         10         10          1          1      0.995      0.833
                 spoon         10         10      0.744        0.8      0.776      0.496
---

## πŸ“Š Performance

| Metric         | Value    |
|---------------|----------|
| mAP@0.5       | 78.0%    |
| mAP@0.5:0.95  | 50.8%    |
| Precision     | 85.5%    |
| Recall        | 67.5%    |

> _These numbers are based on our custom dataset; actual results may vary depending on data size and quality._

---

## πŸ’‘ Challenges & Learnings

- **Challenge:** Small dataset size β†’ risk of overfitting
- **Solution:** Data augmentation and careful validation splitting
- **Challenge:** Labeling errors β†’ noisy annotations
- **Solution:** Manual re-checking of all labels
- **Challenge:** Real-time inference speed
- **Solution:** Optimized image preprocessing pipeline


---

## πŸ›‘οΈ License & Acknowledgments

- Built using open-source tools: [Ultralytics YOLO](https://github.com/ultralytics/yolov5), [Streamlit](https://streamlit.io/)
- Dataset annotated manually, no pre-annotated sources used
- No external pre-trained models on non-custom data

---

If you like this project, ⭐ the repo and feel free to contribute!
Happy detecting! 🍳🍴πŸ₯„