Spaces:
Sleeping
Sleeping
Commit ·
b2714d6
1
Parent(s): 0fdcf58
done
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175# 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.---## Features1. **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.2. **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.3. **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.4. **Sample Images**Choose from predefined food images to try the app's features instantly.5. **Interactive Sidebar**Learn more about the AI models powering PlateMate and their purpose in making your culinary journey exciting and informative.---## Technologies Used1. **Streamlit**: For a responsive and user-friendly web interface.2. **Hugging Face Transformers**: To classify food images using a custom pretrained model (`Shresthadev403/food-image-classification`).3. **GPT-4 as a RAG System**: Combines retrieval-based data with generative capabilities to suggest healthier alternatives based on AI-generated insights.4. **Hugging Face Inference API**: To generate key ingredients for classified dishes.5. **Python Libraries**: PIL for image handling, os for file operations.---## Installation Guide### Prerequisites- Python 3.8 or later- Pip- Streamlit### Steps1. Clone the repository:```bashgit clone https://huggingface.co/spaces/LuckyHappyFish/CTP_Projectcd CTP_Project```2. Install dependencies:```bashpip install -r requirements.txt```3. Add your API keys:- Create a `.streamlit/secrets.toml` file in the project directory:```toml[HF_API_KEY]value = "your_huggingface_api_key"[openai]value = "your_openai_api_key"```4. Run the app:```bashstreamlit run app.py```5. 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```plaintext+-----------------------------------------------------------+| || 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 Case1. **Upload an Image**: A user uploads an image of a pizza.2. **Classification Output**: Food: Pizza (97.65% confidence)3. **Ingredients**: Generated: Flour, cheese, tomato sauce, olive oil, basil.4. **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.---## ContributingWe welcome contributions! To contribute:1. Fork the repository.2. Create a feature branch.3. Submit a pull request with a detailed description of your changes.---## LicenseThis project is licensed under the MIT License.---## ContactDeveloped by Muhammad Hassan Butt.Feel free to reach out via [GitHub](https://github.com/yourusername) or [LinkedIn](https://linkedin.com/in/yourprofile).Happy cooking with **PlateMate**! 🎉---## Hugging Face Configuration```yamltitle: PlateMateemoji: 🍽️colorFrom: purplecolorTo: greensdk: streamlitsdk_version: 1.40.1app_file: app.pypinned: falseshort_description: Food classification with GPT-4-powered healthier alternatives.```12345678910111213---title: CTP Projectemoji: ⚡colorFrom: purplecolorTo: greensdk: streamlitsdk_version: 1.40.1app_file: app.pypinned: falseshort_description: Food image recognition models that recognizes food.---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
README.md+6-168