Spaces:
Running
Running
Upload 5 files
Browse files- Model.ipynb +0 -0
- README.md +86 -13
- app.py +1 -1
Model.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
README.md
CHANGED
|
@@ -1,13 +1,86 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FoodVision: Automated Food Detection Using YOLOv8
|
| 2 |
+
|
| 3 |
+
## Project Overview
|
| 4 |
+
FoodVision is a deep learning-based food detection system that utilizes YOLOv8 to identify and classify various food items in images. The system is capable of detecting 55 different food classes with a focus on fruits and vegetables, making it useful for dietary monitoring and nutritional analysis.
|
| 5 |
+
|
| 6 |
+
## Features
|
| 7 |
+
- Real-time food detection using YOLOv8
|
| 8 |
+
- Support for 55 different food classes
|
| 9 |
+
- Calorie estimation per 100g of detected food items
|
| 10 |
+
- Web interface using Streamlit
|
| 11 |
+
- Support for both image upload and camera capture
|
| 12 |
+
- Bounding box visualization with confidence scores
|
| 13 |
+
|
| 14 |
+
## Model Architecture
|
| 15 |
+
- Base model: YOLOv8n (nano version)
|
| 16 |
+
- Input size: 640x640 pixels
|
| 17 |
+
- Batch size: 32
|
| 18 |
+
- Learning rate: 3e-4
|
| 19 |
+
- Training epochs: 45
|
| 20 |
+
|
| 21 |
+
## Performance Metrics
|
| 22 |
+
- mAP50: ~0.8 (80% accuracy at 50% IoU)
|
| 23 |
+
- Precision: ~0.8
|
| 24 |
+
- Recall: ~0.75
|
| 25 |
+
|
| 26 |
+
## Installation
|
| 27 |
+
|
| 28 |
+
1. Clone the repository:
|
| 29 |
+
```bash
|
| 30 |
+
git clone [email protected]:2302660/aai3001_final_project.git
|
| 31 |
+
cd aai3001_final_project
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
2. Install the required dependencies:
|
| 35 |
+
```bash
|
| 36 |
+
pip install -r requirements.txt
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
## Usage
|
| 40 |
+
|
| 41 |
+
1. Run the Streamlit application:
|
| 42 |
+
```bash
|
| 43 |
+
streamlit run Sapp.py
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
2. Use the web interface to:
|
| 47 |
+
- Upload images or capture them using your camera
|
| 48 |
+
- View detected food items with bounding boxes
|
| 49 |
+
- See confidence scores and calorie information
|
| 50 |
+
|
| 51 |
+
## Project Structure
|
| 52 |
+
```
|
| 53 |
+
.
|
| 54 |
+
βββ Model.ipynb # Notebook for model training and evaluation
|
| 55 |
+
βββ cal.py # Core calorie calculation and detection functions
|
| 56 |
+
βββ Sapp.py # Streamlit web application
|
| 57 |
+
βββ best.pt # Trained model weights (not included in repo)
|
| 58 |
+
βββ README.md # Project documentation
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
## Supported Food Classes
|
| 62 |
+
The model can detect 55 different food items including:
|
| 63 |
+
- Green foods: asparagus, avocados, broccoli, cabbage, etc.
|
| 64 |
+
- White/Beige foods: banana, cauliflower, garlic, mushroom, etc.
|
| 65 |
+
- Purple/Red foods: beetroot, blackberry, cherry, eggplant, etc.
|
| 66 |
+
- Orange/Yellow foods: apricot, carrot, corn, mango, etc.
|
| 67 |
+
|
| 68 |
+
## Live Demo
|
| 69 |
+
You can try out the live demo at:
|
| 70 |
+
- [Hugging Face Space](https://nightey3s-aai3001-final-project.hf.space/)
|
| 71 |
+
- [Project Files](https://huggingface.co/spaces/nightey3s/aai3001_final_project/tree/main)
|
| 72 |
+
|
| 73 |
+
## Team Members
|
| 74 |
+
- Brian Tham
|
| 75 |
+
- Hong Ziyang
|
| 76 |
+
- Javier Si Zhao Hong
|
| 77 |
+
- Timothy Zoe Delaya
|
| 78 |
+
|
| 79 |
+
## Course Information
|
| 80 |
+
AAI3001 Deep Learning and Computer Vision, Trimester 1, 2024
|
| 81 |
+
Singapore Institute of Technology
|
| 82 |
+
|
| 83 |
+
## Future Work
|
| 84 |
+
- Expand the dataset to include more food categories.
|
| 85 |
+
- Implement portion size estimation.
|
| 86 |
+
- Compare uploaded food images with dietary recommendations.
|
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from cal import load_model, predict_image, calculate_calories
|
|
| 8 |
model = load_model()
|
| 9 |
|
| 10 |
# Set up the sidebar
|
| 11 |
-
st.sidebar.title("
|
| 12 |
st.sidebar.write("Upload an image or use your camera to take a picture.")
|
| 13 |
|
| 14 |
option = st.sidebar.selectbox(
|
|
|
|
| 8 |
model = load_model()
|
| 9 |
|
| 10 |
# Set up the sidebar
|
| 11 |
+
st.sidebar.title("FoodVision")
|
| 12 |
st.sidebar.write("Upload an image or use your camera to take a picture.")
|
| 13 |
|
| 14 |
option = st.sidebar.selectbox(
|