An open API service indexing awesome lists of open source software.

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

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 images

Each 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!**