koey811 commited on
Commit
620b014
·
verified ·
1 Parent(s): 9fda940

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -27,11 +27,11 @@ def generate_caption(image):
27
 
28
  def generate_story(caption):
29
  # Generate the story based on the caption using the GPT-2 model
30
- prompt = f"Could you please suggest a story or fairytale in 100 words based on the {caption}\n\n"
31
- story = story_generator(prompt, max_length=500, num_return_sequences=1)[0]["generated_text"]
32
 
33
  # Extract the story text from the generated output
34
- story = story.strip()
35
 
36
  # Post-process the story (example: remove inappropriate words)
37
  inappropriate_words = ["violence", "horror", "scary", "adult", "death", "gun", "shoot"]
 
27
 
28
  def generate_story(caption):
29
  # Generate the story based on the caption using the GPT-2 model
30
+ prompt = f"Write a short, simple children's story in 100 words based on the following image description:\n\n{caption}\n\nStory:"
31
+ story = story_generator(prompt, max_length=200, num_return_sequences=1)[0]["generated_text"]
32
 
33
  # Extract the story text from the generated output
34
+ story = story.split("Story:")[1].strip()
35
 
36
  # Post-process the story (example: remove inappropriate words)
37
  inappropriate_words = ["violence", "horror", "scary", "adult", "death", "gun", "shoot"]