Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
6.1.0
metadata
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
- Apple Pie
- Caesar Salad
- Chocolate Cake
- Cup Cakes
- Donuts
- Hamburger
- Ice Cream
- Pancakes
- Pizza
- 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
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
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
# 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.