The RecipeAI Gradio App is a tool that generates recipes from food images. It leverages state-of-the-art AI models to interpret images of food, generate a description, and then use that description to provide a recipe. This project uses a combination of Hugging Face's transformers
, langchain
, OpenAI
, and Gradio
to create an easy-to-use web interface for recipe generation.
Try the app: https://sabagul-cooking-with-ai-recipebot.hf.space
- Image-to-Text Conversion: Utilizes Salesforce's BLIP model to convert food images into textual descriptions.
- Recipe Generation: Uses OpenAI's GPT-3.5 model to generate a list of ingredients and a step-by-step recipe based on the description from the image.
- User-Friendly Interface: Provides an interactive web interface with Gradio to upload images and receive recipes.
To run the RecipeAI Gradio App, you'll need to install the required packages. You can install them using pip. Run the following commands:
pip install datasets huggingface_hub
pip install -U transformers
pip install bitsandbytes==0.41.3 accelerate==0.25.0
pip install langchain
pip install openai langchain_openai
pip install typing_extensions
pip install pyttsx3
pip install gtts
pip install gradio
pip install langchain-community langchain-core
-
Obtain OpenAI API Key: You need an OpenAI API key to access GPT-3.5. Make sure to set your OpenAI API key as an environment variable or provide it in the code.
-
Code Configuration:
- Ensure you have the API key in your environment:
from google.colab import userdata OPENAI_API_KEY = userdata.get('OPENAI_API_KEY')
- Update the model initialization if needed:
llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0, max_tokens=512, openai_api_key=OPENAI_API_KEY)
- Ensure you have the API key in your environment:
-
Run the Application:
- Execute the script to start the Gradio app:
iface.launch(debug=True)
- Execute the script to start the Gradio app:
- Upload Image: Use the Gradio interface to upload an image of food.
- Receive Recipe: The app will display the list of ingredients and a step-by-step recipe based on the image provided.
Here's how to use the application:
- Open the app interface.
- Upload an image of the food item.
- Wait for the recipe to be generated and displayed on the screen.