Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,8 +5,8 @@ from transformers import pipeline
|
|
5 |
pipe = pipeline("text-generation", model="mrm8488/gpt2-finetuned-recipes-cooking_v2")
|
6 |
|
7 |
def clean_recipe(text):
|
8 |
-
# Split the generated text into
|
9 |
-
steps = text.split('.')
|
10 |
|
11 |
# Remove any extra spaces and filter out empty or repetitive steps
|
12 |
cleaned_steps = []
|
@@ -41,8 +41,8 @@ if st.button("Generate Recipe"):
|
|
41 |
recipe_steps = generate_recipe(dish_name)
|
42 |
st.subheader("Recipe:")
|
43 |
|
44 |
-
# Display the recipe in bullet points
|
45 |
for i, step in enumerate(recipe_steps, 1):
|
46 |
-
st.
|
47 |
else:
|
48 |
st.error("Please enter a dish name.")
|
|
|
5 |
pipe = pipeline("text-generation", model="mrm8488/gpt2-finetuned-recipes-cooking_v2")
|
6 |
|
7 |
def clean_recipe(text):
|
8 |
+
# Split the generated text into sentences using both "." and other common delimiters
|
9 |
+
steps = text.replace("\n", " ").split('.')
|
10 |
|
11 |
# Remove any extra spaces and filter out empty or repetitive steps
|
12 |
cleaned_steps = []
|
|
|
41 |
recipe_steps = generate_recipe(dish_name)
|
42 |
st.subheader("Recipe:")
|
43 |
|
44 |
+
# Display the recipe in bullet points (numbered list)
|
45 |
for i, step in enumerate(recipe_steps, 1):
|
46 |
+
st.markdown(f"{i}. {step}")
|
47 |
else:
|
48 |
st.error("Please enter a dish name.")
|