pratikshahp commited on
Commit
755e467
·
verified ·
1 Parent(s): 4f1da91

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load a model from Hugging Face for recipe generation
5
+ model = pipeline("text-generation", model="gpt2") # Replace with a recipe-specific model if available
6
+
7
+ # Recipe generation function
8
+ def suggest_recipes(ingredients):
9
+ prompt = f"Suggest some recipes using the following ingredients: {ingredients}. Include preparation time for each recipe."
10
+ response = model(prompt, max_length=150, num_return_sequences=3)
11
+
12
+ # Parse model output into a readable format
13
+ recipes = []
14
+ for i, recipe in enumerate(response):
15
+ recipes.append(f"Recipe {i+1}: {recipe['generated_text']}")
16
+
17
+ return "\n\n".join(recipes)
18
+
19
+ # Gradio interface
20
+ with gr.Blocks() as app:
21
+ gr.Markdown("# Recipe Suggestion App")
22
+ gr.Markdown("Provide the ingredients you have, and this app will suggest recipes along with preparation times!")
23
+
24
+ with gr.Row():
25
+ ingredients_input = gr.Textbox(label="Enter Ingredients (comma-separated):", placeholder="e.g., eggs, milk, flour")
26
+
27
+ recipe_output = gr.Textbox(label="Suggested Recipes:", lines=10, interactive=False)
28
+
29
+ generate_button = gr.Button("Get Recipes")
30
+
31
+ generate_button.click(suggest_recipes, inputs=ingredients_input, outputs=recipe_output)
32
+
33
+ # Launch the app
34
+ app.launch()