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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: CTP Project
|
| 3 |
emoji: ⚡
|
|
|
|
| 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 DPlateMate will identify the food with a high level of confidence. It uses 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 doesn't stop at identification—it also suggests healthier alternatives for the classified dish using the power of OpenAI's GPT models.
|
| 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. **Hugging Face Inference API**: To generate key ingredients for classified dishes.
|
| 31 |
+
4. **OpenAI GPT-4**: To provide healthier recipe alternatives and insights.
|
| 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 Qwen NLP model suggests the main ingredients for the identified dish.
|
| 84 |
+
|
| 85 |
+
### **4. Healthier Alternatives**
|
| 86 |
+
OpenAI GPT-4 generates a healthy recipe alternative for the dish, explaining why it is a better choice.
|
| 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 (OpenAI GPT-4) |
|
| 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**
|
| 124 |
+
A user uploads an image of a pizza.
|
| 125 |
+
|
| 126 |
+
2. **Classification Output**
|
| 127 |
+
- Food: Pizza (97.65% confidence)
|
| 128 |
+
|
| 129 |
+
3. **Ingredients**
|
| 130 |
+
- Generated: Flour, cheese, tomato sauce, olive oil, basil.
|
| 131 |
+
|
| 132 |
+
4. **Healthier Alternative**
|
| 133 |
+
- "Try a cauliflower crust pizza with reduced-fat cheese and fresh vegetables. It's lower in carbs and calories while being equally delicious!"
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
+
|
| 137 |
+
## Future Enhancements
|
| 138 |
+
|
| 139 |
+
- **Multi-dish Recognition**: Support for identifying multiple dishes in a single image.
|
| 140 |
+
- **Nutritional Analysis**: Detailed breakdown of macronutrients and calories.
|
| 141 |
+
- **Meal Planning**: Suggesting weekly meal plans based on user preferences.
|
| 142 |
+
|
| 143 |
+
---
|
| 144 |
+
|
| 145 |
+
## Screenshots
|
| 146 |
+
|
| 147 |
+
**1. Homepage**
|
| 148 |
+

|
| 149 |
+
|
| 150 |
+
**2. Classification Result**
|
| 151 |
+

|
| 152 |
+
|
| 153 |
+
---
|
| 154 |
+
|
| 155 |
+
## Contributing
|
| 156 |
+
|
| 157 |
+
We welcome contributions! To contribute:
|
| 158 |
+
1. Fork the repository.
|
| 159 |
+
2. Create a feature branch.
|
| 160 |
+
3. Submit a pull request with a detailed description of your changes.
|
| 161 |
+
|
| 162 |
+
---
|
| 163 |
+
|
| 164 |
+
## License
|
| 165 |
+
|
| 166 |
+
This project is licensed under the MIT License.
|
| 167 |
+
|
| 168 |
+
---
|
| 169 |
+
|
| 170 |
+
## Contact
|
| 171 |
+
|
| 172 |
+
Developed by Muhammad Hassan Butt.
|
| 173 |
+
Feel free to reach out via [GitHub](https://github.com/yourusername) or [LinkedIn](https://linkedin.com/in/yourprofile).
|
| 174 |
+
|
| 175 |
+
Happy cooking with **PlateMate**! 🎉
|
| 176 |
---
|
| 177 |
title: CTP Project
|
| 178 |
emoji: ⚡
|
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from openai.error import OpenAIError # For specific exception handling
|
|
| 8 |
|
| 9 |
# Set page configuration
|
| 10 |
st.set_page_config(
|
| 11 |
-
page_title="
|
| 12 |
page_icon="🍽️",
|
| 13 |
layout="centered",
|
| 14 |
initial_sidebar_state="expanded",
|
|
|
|
| 8 |
|
| 9 |
# Set page configuration
|
| 10 |
st.set_page_config(
|
| 11 |
+
page_title="Plate Mate - Your Culinary Assistant",
|
| 12 |
page_icon="🍽️",
|
| 13 |
layout="centered",
|
| 14 |
initial_sidebar_state="expanded",
|