This repository contains an end-to-end multi-class food object detection system built using YOLO (Ultralytics) and deployed via a Streamlit web application.
The project covers the full pipeline from raw dataset preprocessing to model training, evaluation, and deployment for inference.
Automatic food recognition is an important component in applications such as:
- dietary monitoring,
- nutrition analysis,
- smart food logging systems, and
- assistive technologies.
Manual food annotation is time-consuming and error-prone. This project aims to leverage deep learning–based object detection to automatically detect and classify multiple food items in a single image.
- Develop a multi-class food detection model using YOLO
- Perform systematic dataset preprocessing and cleaning
- Train and evaluate the model using standard object detection metrics
- Deploy the trained model in an interactive web application
- Provide a reproducible and well-documented pipeline
The overall workflow of the project is shown below:
- Raw dataset collection (UECFood256)
- Data inspection and cleaning
- Annotation format conversion (Pascal VOC → YOLO)
- Dataset splitting (train / validation / test)
- Model training and evaluation
- Deployment for real-time inference
Due to large file upload issues, use the following link to download the raw dataset: https://binusianorg-my.sharepoint.com/personal/nicholas_victorio_binus_ac_id/_layouts/15/guestaccess.aspx?share=IgA7Q6ah7klrSYZXQSfG43TPAQtcaT7a1LOBqFARY7cd22g&e=GGZUaO
- UECFood256 Dataset
- Original annotation format: Pascal VOC (XML)
- Missing labels
- Missing or corrupted images
- Duplicate samples
- Inconsistent class indexing
| Folder | Description |
|---|---|
raw/ |
Original dataset (unchanged) |
dataset/ |
Temporary working copy for preprocessing |
dataset_raw/ |
Frozen early-stage snapshot |
dataset_working/ |
Cleaned and converted dataset |
dataset_final/ |
Final YOLO dataset (train/val/test) |
Preprocessing steps include:
- Validation of image–label pairs
- Removal of corrupted and duplicate files
- Conversion from Pascal VOC (XML) to YOLO format
- Normalization of class indices
- Train / validation / test split
The final dataset follows the YOLO directory structure and is used exclusively for model training and evaluation.
- Model family: YOLO (Ultralytics)
- Variant: YOLO11s
- Task: Multi-class object detection
- Input size:
640 × 640
YOLO is chosen for its balance between accuracy and real-time inference speed, making it suitable for interactive applications.
- Framework: Ultralytics YOLO
- Optimizer: AdamW
- Loss: YOLO detection loss
- Training conducted on a GPU-enabled environment
- Early stopping applied to prevent overfitting
Model performance is evaluated using:
- Precision
- Recall
- mAP@0.5
- mAP@0.5–0.95
Evaluation is performed on both validation and test datasets to assess generalization.
The trained model is deployed as a Streamlit web application with the following capabilities:
- Image upload inference
- Real-time webcam detection
- Adjustable confidence and IoU thresholds
- Class-based filtering
- Visual bounding box rendering
The application is designed for inference only and does not support training.
Key components of the app:
- Sidebar controls for inference parameters
- Main view for image or webcam detection
- Tabular output of detected classes and confidence scores
project-root/
├── app.py
├── classes.txt
├── requirements.txt
├── best.pt
├── data/
│ ├── raw/
│ ├── dataset_working/
│ └── dataset_final/
│ ├── train/
│ │ ├── images/
│ │ └── labels/
│ ├── val/
│ │ ├── images/
│ │ └── labels/
│ └── test/
│ ├── images/
│ └── labels/
├── report/
│ └── Report.pdf
├── Presentation.pptx
└── README.md
How to Run
1️⃣ Install dependencies
pip install -r requirements.txt
2️⃣ Run the application
streamlit run app.py
3️⃣ Open in browser
http://localhost:8501
-
Performance depends on dataset quality and class balance
-
Webcam mode requires local execution
-
Nutrition estimation is not included in this version
-
Integrate food segmentation for portion estimation
-
Integration of Calorie and Nutritional Estimation
-
Improve class balance and data augmentation
-
Creation of a Proprietar and High-Quality Dataset
-
Expansion of Class Diversity for Comprehensive Coverage
This project is licensed under the MIT License - see the LICENSE file for details.
This project is intended for academic and research purposes.
- [Author Nicholas Victorio]
- [Author Kenneth Owen]
- [Author Nixon Raine Vicsant]
Developed as part of a Deep Learning academic project.