koey811 commited on
Commit
b54ef0a
·
verified ·
1 Parent(s): 06ff161

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -25,8 +25,7 @@ def generate_caption(image):
25
  return caption
26
 
27
  def generate_story(caption):
28
- # Generate the story based on the caption using the GPT-2 model
29
- prompt = f"Startig with 'Once upon a time...', also, based on the image described as '{caption}', here is a short, simple, and engaging story for children aged 3-10. The story should be easy to understand, use age-appropriate language, and convey a positive message. Focus on the main elements in the image and create a story that sparks their imagination:\n\n"
30
  story = story_generator(prompt, max_length=500, num_return_sequences=1)[0]["generated_text"]
31
 
32
  # Extract the story text from the generated output
@@ -36,7 +35,7 @@ def generate_story(caption):
36
  inappropriate_words = ["violence", "horror", "scary"]
37
  for word in inappropriate_words:
38
  story = story.replace(word, "")
39
-
40
  # Limit the story to approximately 100 words
41
  words = story.split()
42
  if len(words) > 100:
 
25
  return caption
26
 
27
  def generate_story(caption):
28
+ prompt = f"Once upon a time, based on the image described as '{caption}', here is a short, simple, and engaging story for children aged 3-10. The story should be easy to understand, use age-appropriate language, and convey a positive message. Focus on the main elements in the image and create a story that sparks their imagination:\n\n"
 
29
  story = story_generator(prompt, max_length=500, num_return_sequences=1)[0]["generated_text"]
30
 
31
  # Extract the story text from the generated output
 
35
  inappropriate_words = ["violence", "horror", "scary"]
36
  for word in inappropriate_words:
37
  story = story.replace(word, "")
38
+
39
  # Limit the story to approximately 100 words
40
  words = story.split()
41
  if len(words) > 100: