koey811 commited on
Commit
c7a3c41
·
verified ·
1 Parent(s): 3ac0172

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -27,8 +27,12 @@ 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"As a storyteller, please based on the image described as '{caption}', create a interesting and attractive story for children aged 3-10. Keep it positive and happy in tone. Also, add more imagination, and starting with wordings'one upon a time'"
31
- story = story_generator(prompt, max_length=100, num_return_sequences=1)[0]["generated_text"]
 
 
 
 
32
  return story
33
 
34
  def convert_to_audio(story):
 
27
 
28
  def generate_story(caption):
29
  # Generate the story based on the caption using the GPT-2 model
30
+ prompt = f"Once upon a time, based on the image described as '{caption}', here is a short and interesting story for children aged 3-10. The story is positive and happy in tone, with added imagination:\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.split("\n\n")[1].strip()
35
+
36
  return story
37
 
38
  def convert_to_audio(story):