Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
# Load the model (this runs only once!) | |
generator = pipeline("text2text-generation", model="LahiruProjects/recipe-generator-flan-t5") | |
def generate_recipe(name, ingredients, calories, time): | |
prompt = f"""Create a step-by-step recipe for "{name}" using these ingredients: {', '.join(ingredients.split(','))}. | |
Keep it under {calories} calories and make sure it's ready in less than {time} minutes.""" | |
result = generator(prompt) | |
return result[0]["generated_text"] | |
# Gradio interface | |
iface = gr.Interface( | |
fn=generate_recipe, | |
inputs=[ | |
gr.Textbox(label="Recipe Name"), | |
gr.Textbox(label="Ingredients (comma-separated)"), | |
gr.Number(label="Max Calories", value=400), | |
gr.Number(label="Max Cooking Time (minutes)", value=30) | |
], | |
outputs="text", | |
title="π³ Recipe Generator (FLAN-T5)", | |
description="Generate a step-by-step recipe based on ingredients, calorie limit, and time" | |
) | |
iface.launch() | |