tahirsher commited on
Commit
d8997e3
·
verified ·
1 Parent(s): be877c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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 steps based on punctuation (e.g., ".", "!", "?")
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.write(f"{i}. {step}")
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.")