Spaces:
Sleeping
Sleeping
Commit
·
b2714d6
1
Parent(s):
0fdcf58
done
Browse files
README.md
CHANGED
|
@@ -1,175 +1,13 @@
|
|
| 1 |
-
# PlateMate - Your Culinary Assistant 🍽️
|
| 2 |
-
|
| 3 |
-
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.
|
| 4 |
-
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
## Features
|
| 8 |
-
|
| 9 |
-
1. **Food Image Classification**
|
| 10 |
-
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.
|
| 11 |
-
|
| 12 |
-
2. **Ingredient Suggestion**
|
| 13 |
-
Once classified, PlateMate provides a concise, AI-generated list of main ingredients for the dish, helping you understand what goes into your favorite foods.
|
| 14 |
-
|
| 15 |
-
3. **Healthier Alternatives**
|
| 16 |
-
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.
|
| 17 |
-
|
| 18 |
-
4. **Sample Images**
|
| 19 |
-
Choose from predefined food images to try the app's features instantly.
|
| 20 |
-
|
| 21 |
-
5. **Interactive Sidebar**
|
| 22 |
-
Learn more about the AI models powering PlateMate and their purpose in making your culinary journey exciting and informative.
|
| 23 |
-
|
| 24 |
-
---
|
| 25 |
-
|
| 26 |
-
## Technologies Used
|
| 27 |
-
|
| 28 |
-
1. **Streamlit**: For a responsive and user-friendly web interface.
|
| 29 |
-
2. **Hugging Face Transformers**: To classify food images using a custom pretrained model (`Shresthadev403/food-image-classification`).
|
| 30 |
-
3. **GPT-4 as a RAG System**: Combines retrieval-based data with generative capabilities to suggest healthier alternatives based on AI-generated insights.
|
| 31 |
-
4. **Hugging Face Inference API**: To generate key ingredients for classified dishes.
|
| 32 |
-
5. **Python Libraries**: PIL for image handling, os for file operations.
|
| 33 |
-
|
| 34 |
-
---
|
| 35 |
-
|
| 36 |
-
## Installation Guide
|
| 37 |
-
|
| 38 |
-
### Prerequisites
|
| 39 |
-
- Python 3.8 or later
|
| 40 |
-
- Pip
|
| 41 |
-
- Streamlit
|
| 42 |
-
|
| 43 |
-
### Steps
|
| 44 |
-
1. Clone the repository:
|
| 45 |
-
```bash
|
| 46 |
-
git clone https://huggingface.co/spaces/LuckyHappyFish/CTP_Project
|
| 47 |
-
cd CTP_Project
|
| 48 |
-
```
|
| 49 |
-
|
| 50 |
-
2. Install dependencies:
|
| 51 |
-
```bash
|
| 52 |
-
pip install -r requirements.txt
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
3. Add your API keys:
|
| 56 |
-
- Create a `.streamlit/secrets.toml` file in the project directory:
|
| 57 |
-
```toml
|
| 58 |
-
[HF_API_KEY]
|
| 59 |
-
value = "your_huggingface_api_key"
|
| 60 |
-
|
| 61 |
-
[openai]
|
| 62 |
-
value = "your_openai_api_key"
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
4. Run the app:
|
| 66 |
-
```bash
|
| 67 |
-
streamlit run app.py
|
| 68 |
-
```
|
| 69 |
-
|
| 70 |
-
5. Open the app in your browser at `http://localhost:8501`.
|
| 71 |
-
|
| 72 |
-
---
|
| 73 |
-
|
| 74 |
-
## How It Works
|
| 75 |
-
|
| 76 |
-
### **1. Upload Image**
|
| 77 |
-
Users can upload a food image or select a sample. The app displays the image in the interface.
|
| 78 |
-
|
| 79 |
-
### **2. Image Classification**
|
| 80 |
-
Using the Hugging Face image classification pipeline, the app identifies the food item in the image.
|
| 81 |
-
|
| 82 |
-
### **3. Ingredient Generation**
|
| 83 |
-
The Hugging Face NLP model suggests the main ingredients for the identified dish.
|
| 84 |
-
|
| 85 |
-
### **4. Healthier Alternatives with GPT-4 RAG**
|
| 86 |
-
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.
|
| 87 |
-
|
| 88 |
-
---
|
| 89 |
-
|
| 90 |
-
## Architecture Diagram
|
| 91 |
-
|
| 92 |
-
```plaintext
|
| 93 |
-
+-----------------------------------------------------------+
|
| 94 |
-
| |
|
| 95 |
-
| PlateMate Architecture |
|
| 96 |
-
| |
|
| 97 |
-
+-----------------------------------------------------------+
|
| 98 |
-
| |
|
| 99 |
-
| User Interface (Streamlit) |
|
| 100 |
-
| - Upload Image |
|
| 101 |
-
| - Display Results |
|
| 102 |
-
| |
|
| 103 |
-
+-----------------------------------------------------------+
|
| 104 |
-
| |
|
| 105 |
-
| Backend Processing |
|
| 106 |
-
| - Image Classification (Hugging Face Transformers) |
|
| 107 |
-
| - Ingredients (Hugging Face Inference API) |
|
| 108 |
-
| - Healthy Recipes (GPT-4 RAG) |
|
| 109 |
-
| |
|
| 110 |
-
+-----------------------------------------------------------+
|
| 111 |
-
| |
|
| 112 |
-
| External Services |
|
| 113 |
-
| - Hugging Face API |
|
| 114 |
-
| - OpenAI API |
|
| 115 |
-
| |
|
| 116 |
-
+-----------------------------------------------------------+
|
| 117 |
-
```
|
| 118 |
-
|
| 119 |
-
---
|
| 120 |
-
|
| 121 |
-
## Example Use Case
|
| 122 |
-
|
| 123 |
-
1. **Upload an Image**: A user uploads an image of a pizza.
|
| 124 |
-
2. **Classification Output**: Food: Pizza (97.65% confidence)
|
| 125 |
-
3. **Ingredients**: Generated: Flour, cheese, tomato sauce, olive oil, basil.
|
| 126 |
-
4. **Healthier Alternative**:
|
| 127 |
-
"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!"
|
| 128 |
-
|
| 129 |
-
---
|
| 130 |
-
|
| 131 |
-
## Future Enhancements
|
| 132 |
-
|
| 133 |
-
- **Multi-dish Recognition**: Support for identifying multiple dishes in a single image.
|
| 134 |
-
- **Nutritional Analysis**: Detailed breakdown of macronutrients and calories.
|
| 135 |
-
- **Meal Planning**: Suggesting weekly meal plans based on user preferences.
|
| 136 |
-
|
| 137 |
-
---
|
| 138 |
-
|
| 139 |
-
## Contributing
|
| 140 |
-
|
| 141 |
-
We welcome contributions! To contribute:
|
| 142 |
-
1. Fork the repository.
|
| 143 |
-
2. Create a feature branch.
|
| 144 |
-
3. Submit a pull request with a detailed description of your changes.
|
| 145 |
-
|
| 146 |
-
---
|
| 147 |
-
|
| 148 |
-
## License
|
| 149 |
-
|
| 150 |
-
This project is licensed under the MIT License.
|
| 151 |
-
|
| 152 |
---
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
Developed by Muhammad Hassan Butt.
|
| 157 |
-
Feel free to reach out via [GitHub](https://github.com/yourusername) or [LinkedIn](https://linkedin.com/in/yourprofile).
|
| 158 |
-
|
| 159 |
-
Happy cooking with **PlateMate**! 🎉
|
| 160 |
-
|
| 161 |
-
---
|
| 162 |
-
|
| 163 |
-
## Hugging Face Configuration
|
| 164 |
-
|
| 165 |
-
```yaml
|
| 166 |
-
title: PlateMate
|
| 167 |
-
emoji: 🍽️
|
| 168 |
colorFrom: purple
|
| 169 |
colorTo: green
|
| 170 |
sdk: streamlit
|
| 171 |
sdk_version: 1.40.1
|
| 172 |
app_file: app.py
|
| 173 |
pinned: false
|
| 174 |
-
short_description: Food
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: CTP Project
|
| 3 |
+
emoji: ⚡
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: green
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.40.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
short_description: Food image recognition models that recognizes food.
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|