Spaces:
Sleeping
PlateMate - Your Culinary Assistant 🍽️
PlateMate is a smart and interactive web app that uses state-of-the-art AI technologies to classify food images, provide key ingredients for your favorite dishes, and suggest healthier alternatives to enjoy guilt-free meals. Whether you're a home chef looking for inspiration or a health enthusiast, PlateMate has something for everyone.
Features
Food Image Classification
Upload an image of any dish, and PlateMate will identify the food with a high level of confidence using a pretrained image classification model tailored for food.Ingredient Suggestion
Once classified, PlateMate provides a concise, AI-generated list of main ingredients for the dish, helping you understand what goes into your favorite foods.Healthier Alternatives
PlateMate goes beyond basic suggestions with GPT-4-powered Retrieval-Augmented Generation (RAG) to provide personalized, healthier alternatives for your favorite dishes. This cutting-edge approach ensures the recommendations are both relevant and grounded in accurate information.Sample Images
Choose from predefined food images to try the app's features instantly.Interactive Sidebar
Learn more about the AI models powering PlateMate and their purpose in making your culinary journey exciting and informative.
Technologies Used
- Streamlit: For a responsive and user-friendly web interface.
- Hugging Face Transformers: To classify food images using a custom pretrained model (
Shresthadev403/food-image-classification
). - GPT-4 as a RAG System: Combines retrieval-based data with generative capabilities to suggest healthier alternatives based on AI-generated insights.
- Hugging Face Inference API: To generate key ingredients for classified dishes.
- Python Libraries: PIL for image handling, os for file operations.
Installation Guide
Prerequisites
- Python 3.8 or later
- Pip
- Streamlit
Steps
Clone the repository:
git clone https://huggingface.co/spaces/LuckyHappyFish/CTP_Project cd CTP_Project
Install dependencies:
pip install -r requirements.txt
Add your API keys:
- Create a
.streamlit/secrets.toml
file in the project directory:[HF_API_KEY] value = "your_huggingface_api_key" [openai] value = "your_openai_api_key"
- Create a
Run the app:
streamlit run app.py
Open the app in your browser at
http://localhost:8501
.
How It Works
1. Upload Image
Users can upload a food image or select a sample. The app displays the image in the interface.
2. Image Classification
Using the Hugging Face image classification pipeline, the app identifies the food item in the image.
3. Ingredient Generation
The Hugging Face NLP model suggests the main ingredients for the identified dish.
4. Healthier Alternatives with GPT-4 RAG
GPT-4, integrated as a RAG system, retrieves relevant nutritional data and combines it with generative capabilities to suggest healthier, personalized recipe alternatives. This ensures scientifically accurate and context-aware recommendations.
Architecture Diagram
+-----------------------------------------------------------+
| |
| PlateMate Architecture |
| |
+-----------------------------------------------------------+
| |
| User Interface (Streamlit) |
| - Upload Image |
| - Display Results |
| |
+-----------------------------------------------------------+
| |
| Backend Processing |
| - Image Classification (Hugging Face Transformers) |
| - Ingredients (Hugging Face Inference API) |
| - Healthy Recipes (GPT-4 RAG) |
| |
+-----------------------------------------------------------+
| |
| External Services |
| - Hugging Face API |
| - OpenAI API |
| |
+-----------------------------------------------------------+
Example Use Case
- Upload an Image: A user uploads an image of a pizza.
- Classification Output: Food: Pizza (97.65% confidence)
- Ingredients: Generated: Flour, cheese, tomato sauce, olive oil, basil.
- Healthier Alternative:
"Try a cauliflower crust pizza with reduced-fat cheese and fresh vegetables. GPT-4 RAG ensures that this option is both lower in calories and higher in nutritional value, offering the best balance between health and flavor!"
Future Enhancements
- Multi-dish Recognition: Support for identifying multiple dishes in a single image.
- Nutritional Analysis: Detailed breakdown of macronutrients and calories.
- Meal Planning: Suggesting weekly meal plans based on user preferences.
Contributing
We welcome contributions! To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request with a detailed description of your changes.
License
This project is licensed under the MIT License.
Contact
Developed by Muhammad Hassan Butt.
Feel free to reach out via GitHub or LinkedIn.
Happy cooking with PlateMate! 🎉
Hugging Face Configuration
title: PlateMate
emoji: 🍽️
colorFrom: purple
colorTo: green
sdk: streamlit
sdk_version: 1.40.1
app_file: app.py
pinned: false
short_description: Food classification with GPT-4-powered healthier alternatives.