https://github.com/akremjomaa/pastry-object-detection
This project focuses on object detection applied to pastry products, including pain au chocolat, รฉclair, muffin, donut, and tart. The goal is to fine-tune YOLOv11 object detection model, to accurately detect and classify these pastries within images
https://github.com/akremjomaa/pastry-object-detection
computer-vision fine-tuning object-detection yolov11
Last synced: 7 months ago
JSON representation
This project focuses on object detection applied to pastry products, including pain au chocolat, รฉclair, muffin, donut, and tart. The goal is to fine-tune YOLOv11 object detection model, to accurately detect and classify these pastries within images
- Host: GitHub
- URL: https://github.com/akremjomaa/pastry-object-detection
- Owner: akremjomaa
- License: mit
- Created: 2025-02-17T16:03:59.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-17T16:15:32.000Z (8 months ago)
- Last Synced: 2025-02-17T17:26:40.444Z (8 months ago)
- Topics: computer-vision, fine-tuning, object-detection, yolov11
- Language: Jupyter Notebook
- Homepage:
- Size: 8.59 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ๐ฉ Pastry Object Detection using YOLOv11
## ๐ Project Overview
This project focuses on **object detection** applied to pastry products, including **pain au chocolat, รฉclair, muffin, donut, and tart**. The goal is to fine-tune **YOLOv11**, a state-of-the-art object detection model, to accurately detect and classify these pastries within images.This project was entirely **developed and trained using Google Colab**, leveraging its cloud-based GPU acceleration for efficient model training.
We collected and annotated a **small dataset (100 images)**, conducted multiple training experiments with different hyperparameter configurations, and evaluated the modelโs performance using quantitative and qualitative metrics.
---
## ๐ Features
- โ **Fine-tuned YOLOv11 model** for pastry detection.
- โ **Custom dataset** with annotated images.
- โ **Data augmentation** using **Albumentations** to enhance generalization.
- โ **Hyperparameter optimization** through multiple training attempts.
- โ **Evaluation and visualization** of model performance on test images.---
## ๐ Dataset Structure
The dataset consists of **100 images**, split as follows:- **Training set**: 70 images
- **Validation set**: 20 images
- **Test set**: 10 imagesEach image is labeled with bounding boxes and stored in YOLO format. The dataset includes five classes:
1. **Pain au chocolat**
2. **รclair**
3. **Muffin**
4. **Donut**
5. **Tart**---
## โ๏ธ Installation
### 1๏ธโฃ Clone the repository
```bash
git clone https://github.com/akremjomaa/Pastry-Object-Detection.git
cd Pastry-Object-Detection
```### 2๏ธโฃ Install dependencies
```bash
pip install ultralytics albumentations opencv-python matplotlib
```---
## ๐๏ธโโ๏ธ Model Training
To train the YOLOv11 model, run the following command:
```python
from ultralytics import YOLO# Load the pretrained YOLOv11 model
model = YOLO("yolo11n.pt")# Train the model
model.train(data="dataset_yolov11/data.yaml", epochs=50, imgsz=640, batch=16, patience=10, lr0=0.01, lrf=0.0001)
```---
## ๐ Evaluation
Once the model is trained, evaluate its performance using:
```python
# Load best model
best_model = YOLO("runs/detect/train/weights/best.pt")# Validate the model
metrics = best_model.val()
print(f"mAP50-95: {metrics.box.map}")
```### **Results Analysis**
- ๐ **Confusion matrix** shows correct and incorrect classifications.
- ๐ **F1-score curve** helps determine the optimal confidence threshold.
- ๐ **Visual predictions** on test images to assess model accuracy.---
## ๐ฏ Predictions on Test Images
Run the model on new images:
```python
from PIL import Image# Load test image
test_image = Image.open("dataset_yolov11/test/images/sample.jpg")# Predict
results = best_model.predict(source=test_image, save=True)
```The predictions are stored in the `runs/detect/predict/` directory.
---
## ๐ License
This project is open-source and available under the **MIT License**.---
## ๐ค Author
**Akrem JOMAA**
๐ง Contact: [akrem.jomaa@univ-lyon2.fr](mailto:akrem.jomaa@univ-lyon2.fr)
๐ LinkedIn: [akremjomaa](www.linkedin.com/in/akremjomaa)
๐ GitHub: [github.com/akremjomaa](https://github.com/akremjomaa)---
๐ **If you find this project useful, don't forget to star โญ the repository!**