Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,10 +16,11 @@ def generate_recipe(recipe_name):
|
|
16 |
"""Generate cooking method given a recipe name."""
|
17 |
prompt = f"Recipe Name: {recipe_name}\nInstructions: "
|
18 |
inputs = tokenizer(prompt, return_tensors="pt")
|
19 |
-
outputs = model.generate(inputs["input_ids"], max_length=512,
|
|
|
20 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
21 |
# Return only the method part, splitting after 'Method:'
|
22 |
-
return generated_text.split("
|
23 |
|
24 |
# Create Gradio interface
|
25 |
interface = gr.Interface(
|
|
|
16 |
"""Generate cooking method given a recipe name."""
|
17 |
prompt = f"Recipe Name: {recipe_name}\nInstructions: "
|
18 |
inputs = tokenizer(prompt, return_tensors="pt")
|
19 |
+
outputs = model.generate(inputs["input_ids"], max_length=512,temperature=0.7, # Sampling randomness
|
20 |
+
top_p=0.9, num_return_sequences=1, do_sample=True)
|
21 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
22 |
# Return only the method part, splitting after 'Method:'
|
23 |
+
return generated_text.split("Recipe Name:")[-1].strip()
|
24 |
|
25 |
# Create Gradio interface
|
26 |
interface = gr.Interface(
|