End-to-end project for simple classification food project
- Find dataset
- Exploratory Data Analysis (EDA)
- Training model
- An end-to-end pipeline for training
- ResNet
- EfficientNet
- Ensemble learning
- Web app
- Setup streamlit
- Setup FastAPI
- Deployment
- Docker
The dataset for this project is the Food-101 dataset from Kaggle. It contains 101,000 images across 101 different food categories. Each category has 1,000 images (750 training, 250 testing).
You can also check other datasets in the Source of Datasets file.
The EDA for this project is in the EDA notebook file.
TL;DR:
- 101 classes with 1000 images each
- 75% training and 25% testing
- Various image sizes (mostly 512x512)
Model: ResNet, EfficientNet
For detailed information on model training, refer to the Training README.
You can check the inference pipeline in the inference script file.
For detailed information on final results, refer to the Evaluation README.
The application consists of a backend built with FastAPI and a frontend built with Streamlit. The backend handles image classification tasks using various pre-trained models, while the frontend allows users to upload images, select models, and get predictions.
For detailed information on the backend, refer to the Backend README. For detailed information on the frontend, refer to the Frontend README.
To run the backend locally, use the following command:
cd app/backend
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000
To run the frontend locally, use the following command:
cd app/frontend
pip install -r requirements.txt
streamlit run app.py
To run the app using Docker, follow these steps:
-
Pull the Docker images:
docker pull bfcmath/classifood-backend:1.0 docker pull bfcmath/classifood-frontend:1.0
-
Run the containers:
docker run --name backend --network app-network -p 8000:8000 bfcmath/classifood-backend:1.0 docker run --name frontend --network app-network -p 8501:8501 -e DOCKER_ENV=true bfcmath/classifood-frontend:1.0
-
Build and run the containers (Optional):
If you want to build the images locally, you can use the following command:
docker-compose up --build
This will start both the backend and frontend services. The backend will be accessible at http://localhost:8000
and the frontend at http://localhost:8501
.
- Thanks to Saber (aka Mai Duc Minh Huy) for the idea of confidence-weighted prediction.
- Thanks to ktranowl (aka Khoa Tran) and Nho (aka Dinh Nho Hoang) for helping me with Docker.