LahiruProjects commited on
Commit
be1f0f3
Β·
verified Β·
1 Parent(s): 6c9ef97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -1,7 +1,27 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load the model (this runs only once!)
5
+ generator = pipeline("text2text-generation", model="LahiruProjects/recipe-generator-flan-t5")
6
 
7
+ def generate_recipe(name, ingredients, calories, time):
8
+ prompt = f"""Create a step-by-step recipe for "{name}" using these ingredients: {', '.join(ingredients.split(','))}.
9
+ Keep it under {calories} calories and make sure it's ready in less than {time} minutes."""
10
+ result = generator(prompt)
11
+ return result[0]["generated_text"]
12
+
13
+ # Gradio interface
14
+ iface = gr.Interface(
15
+ fn=generate_recipe,
16
+ inputs=[
17
+ gr.Textbox(label="Recipe Name"),
18
+ gr.Textbox(label="Ingredients (comma-separated)"),
19
+ gr.Number(label="Max Calories", value=400),
20
+ gr.Number(label="Max Cooking Time (minutes)", value=30)
21
+ ],
22
+ outputs="text",
23
+ title="🍳 Recipe Generator (FLAN-T5)",
24
+ description="Generate a step-by-step recipe based on ingredients, calorie limit, and time"
25
+ )
26
+
27
+ iface.launch()