BinhQuocNguyen's picture
Upload README.md with huggingface_hub
8937d8e verified
---
title: Food Recognition API
emoji: πŸ•
colorFrom: blue
colorTo: red
sdk: gradio
sdk_version: 4.44.1
app_file: app.py
pinned: false
license: mit
short_description: FastAPI food recognition service
---
# πŸ• Food Recognition API
A FastAPI web service that uses a Vision Transformer model to recognize 10 different types of food from images.
## 🎯 Features
- **FastAPI Backend** - RESTful API with comprehensive endpoints
- **Gradio Interface** - User-friendly web interface
- **Vision Transformer** - State-of-the-art image classification
- **Real-time Predictions** - Instant food recognition
- **Multiple Input Methods** - File upload and base64 support
## 🍽️ Supported Food Types
1. Apple Pie
2. Caesar Salad
3. Chocolate Cake
4. Cup Cakes
5. Donuts
6. Hamburger
7. Ice Cream
8. Pancakes
9. Pizza
10. Waffles
## πŸ“‘ API Endpoints
- **`/`** - Gradio web interface
- **`/health`** - Health check and model status
- **`/classes`** - Get supported food classes
- **`/model-info`** - Detailed model information
- **`/docs`** - Interactive API documentation
## πŸš€ Usage
### Web Interface
Simply upload an image using the Gradio interface above!
### API Usage
```python
import requests
# Upload image file
with open('food_image.jpg', 'rb') as f:
files = {'file': f}
response = requests.post('https://your-space-url.hf.space/predict', files=files)
result = response.json()
print(result)
```
### Health Check
```bash
curl https://your-space-url.hf.space/health
```
## πŸ“Š Model Performance
- **Accuracy**: 68%
- **F1 Score**: 66.5%
- **Architecture**: Vision Transformer (ViT-Base)
- **Training Data**: Custom food dataset
- **Classes**: 10 food categories
## πŸ”§ Technical Details
- **Framework**: FastAPI + Gradio
- **Model**: Hugging Face Transformers
- **Backend**: PyTorch
- **Deployment**: Hugging Face Spaces
## πŸ“ Model Information
- **Model ID**: `BinhQuocNguyen/food-recognition-vit`
- **Model URL**: https://huggingface.co/BinhQuocNguyen/food-recognition-vit
- **Training Time**: ~84 minutes
- **Image Size**: 224x224 pixels
## πŸ› οΈ Local Development
```bash
# Clone the repository
git clone https://github.com/your-username/food-recognition-api
# Install dependencies
pip install -r requirements_spaces.txt
# Run locally
python app.py
```
## πŸ“„ License
MIT License - Feel free to use and modify for your projects.
## 🀝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## πŸ“ž Support
If you encounter any issues or have questions, please open an issue on the repository.