Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load your model or pipeline
|
| 5 |
+
recipe_generator = pipeline("text-generation", model="your-model-name")
|
| 6 |
+
|
| 7 |
+
def generate_recipe(ingredients):
|
| 8 |
+
prompt = f"Ingredients: {ingredients}\nRecipe:"
|
| 9 |
+
recipe = recipe_generator(prompt, max_length=200)[0]['generated_text']
|
| 10 |
+
# Dummy values for calories and sugars
|
| 11 |
+
calories = "200 kcal"
|
| 12 |
+
sugars = "10g"
|
| 13 |
+
return recipe, calories, sugars
|
| 14 |
+
|
| 15 |
+
# Create the Gradio interface
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=generate_recipe,
|
| 18 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter ingredients here..."),
|
| 19 |
+
outputs=["text", "text", "text"],
|
| 20 |
+
title="Recipe Generator",
|
| 21 |
+
description="Enter ingredients to get a recipe suggestion along with calories and sugars."
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# Launch the interface
|
| 25 |
+
iface.launch()
|