File size: 4,840 Bytes
38caa61
039472f
38caa61
039472f
 
38caa61
039472f
 
38caa61
039472f
38caa61
039472f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
---

title: Food Manu Frontend
emoji: πŸ†
colorFrom: red
colorTo: gray
sdk: docker
pinned: false
license: mit
---


Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

# 🍽️ Menu Extractor & Food Image Generator

An AI-powered web application that extracts menu items from restaurant menu images and generates beautiful food images for each item using advanced machine learning models.

## 🌟 Features

- **πŸ“Έ Menu Image Upload**: Upload menu images or capture them directly using your camera
- **πŸ€– AI Menu Extraction**: Uses Google's Gemini AI to extract menu items, descriptions, and prices
- **🎨 Food Image Generation**: Generates high-quality food images using Stable Diffusion
- **πŸ’» Beautiful Frontend**: Modern, responsive web interface with live preview
- **πŸ“± Mobile Friendly**: Works seamlessly on desktop and mobile devices
- **πŸ”„ Code Generation**: Automatically generates clean HTML code for the extracted menu

## πŸš€ Demo

Try the live demo: [Menu Extractor & Food Generator](https://huggingface.co/spaces/your-username/menu-extractor)

## πŸ› οΈ Technology Stack

- **Backend**: Flask (Python)
- **AI Models**: 
  - Google Gemini 1.5 Flash (Menu extraction)
  - Stable Diffusion v1.5 (Image generation)
- **Frontend**: HTML, CSS, JavaScript
- **Image Processing**: Pillow (PIL)
- **Deployment**: Hugging Face Spaces

## πŸ“‹ Requirements

- Python 3.9+
- CUDA-compatible GPU (recommended for faster image generation)
- Google Gemini API key

## πŸ”§ Installation

1. Clone the repository:
```bash

git clone https://github.com/your-username/menu-extractor.git

cd menu-extractor

```

2. Install dependencies:
```bash

pip install -r requirements.txt

```

3. Set up environment variables:
Create a `.env` file and add your Gemini API key:
```

GEMINI_API_KEY=your_gemini_api_key_here

```

4. Run the application:
```bash

python app.py

```

5. Open your browser and navigate to `http://localhost:7860`

## 🌐 Deployment on Hugging Face Spaces

1. Create a new Space on [Hugging Face Spaces](https://huggingface.co/spaces)
2. Choose "Docker" as the SDK
3. Upload the following files:
   - `app.py`
   - `templates/index.html`
   - `Dockerfile`
   - `requirements.txt`
   - `README.md`
4. Add your `GEMINI_API_KEY` in the Space settings under "Variables and secrets"
5. Your app will be automatically deployed!

## πŸ“– How to Use

1. **Upload Image**: Choose to upload a menu image from your device or take a photo using your camera
2. **Extract Menu**: Click "Extract Menu Items" to process the image with AI
3. **View Results**: See the beautiful menu layout with generated food images
4. **Get Code**: Switch to code view to copy the generated HTML for your own use

## 🎯 Use Cases

- **Restaurant Owners**: Quickly digitize physical menus
- **Web Developers**: Generate menu websites for restaurant clients  
- **Food Bloggers**: Create visual menu content
- **Menu Design**: Prototype digital menu layouts

## πŸ”‘ API Keys Setup

### Google Gemini API
1. Visit [Google AI Studio](https://makersuite.google.com/)
2. Create a new API key
3. Add it to your environment variables as `GEMINI_API_KEY`

## ⚑ Performance Notes

- **CPU Mode**: Image generation will be slower but still functional
- **GPU Mode**: Significantly faster image generation with CUDA-compatible GPU
- **Memory**: Requires ~4GB RAM for optimal performance

## πŸ› Troubleshooting

### Common Issues:

1. **Model Loading Error**: Ensure you have sufficient disk space and memory
2. **API Key Error**: Verify your Gemini API key is correctly set
3. **Image Processing Error**: Check that uploaded images are in supported formats (JPG, PNG)

## πŸ“„ License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the project
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## πŸ™ Acknowledgments

- [Google Gemini](https://deepmind.google/technologies/gemini/) for menu extraction
- [Stable Diffusion](https://stability.ai/) for food image generation
- [Hugging Face](https://huggingface.co/) for hosting and deployment
- [Flask](https://flask.palletsprojects.com/) for the web framework

## πŸ“ž Support

If you encounter any issues or have questions, please [open an issue](https://github.com/your-username/menu-extractor/issues) on GitHub.

---

Made with ❀️ by [Your Name](https://github.com/your-username)