A deep learning project that classifies food images into 7 categories using a CNN-based EfficientNet model built with PyTorch.
The system provides a simple Gradio web interface where users can upload an image and instantly get predictions.
✅ Image classification using EfficientNet
✅ 7 food categories
✅ Upload image and predict instantly
✅ Clean Gradio web interface
✅ GPU supported training (CUDA)
✅ Lightweight and fast inference
The model classifies images into:
- 🥟 Samosa
- 🍕 Pizza
- 🥩 Steak
- 🍣 Sushi
- 🧁 Cup Cakes
- 🍟 French Fries
- 🍳 Omelette
| Tool | Purpose |
|---|---|
| PyTorch | Model training & inference |
| EfficientNet | CNN architecture |
| Torchvision | Pretrained models & transforms |
| Gradio | Web UI for predictions |
| CUDA | GPU acceleration |
food-classifier/
│
├── dataset/ # food images dataset
├── models/ # saved trained weights (.pth)
├── train.py # training script
├── predict.py # inference code
├── app.py # gradio interface
├── requirements.txt
└── README.md
git clone https://github.com/yourusername/food-classifier.git
cd food-classifierpython -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windowspip install -r requirements.txtor manually:
pip install torch torchvision gradio pillow opencv-python numpypython train.py- Architecture: EfficientNet (CNN)
- Framework: PyTorch
- Loss Function: CrossEntropyLoss
- Optimizer: Adam
- Classes: 7
- GPU supported (CUDA)
The trained model will be saved inside:
models/model.pth
python app.pyThen open in browser:
http://127.0.0.1:7860
- Upload an image
- Image is preprocessed
- EfficientNet extracts features
- Model predicts class
- Label + confidence shown on screen
Upload:
📸 samosa.jpg
Output:
Prediction: Samosa
Confidence: 96.3%
EfficientNet is used because:
✅ High accuracy
✅ Fewer parameters
✅ Faster training
✅ Good for small datasets
- Add webcam support
- Add top-3 predictions
- Mobile deployment
- Convert to TorchScript
- Deploy on HuggingFace Spaces
- Add more food classes
Pull requests are welcome.
Feel free to open issues for improvements or suggestions.
MIT License
Anshu Singh
ML Enthusiast
Built as a hands-on CNN + PyTorch learning project 🚀