smtsead commited on
Commit
5d3ae61
·
verified ·
1 Parent(s): 796d097

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -10,16 +10,13 @@ def img2text(url):
10
  text = image_to_text_model(url)[0]["generated_text"]
11
  return text
12
 
13
- # Function to convert text to a kid-friendly story
14
  def text2story(text):
15
  # Initialize the text generation pipeline
16
  text_generator = pipeline("text-generation", model="distilbert/distilgpt2")
17
 
18
- # Create a prompt to ensure the story is kid-friendly and happy
19
- prompt = f"Write a happy and fun story for kids aged 3-10 based on the following scenario: {text}. The story should be suitable for children and should not contain any magical elements. Keep the story under 95 words."
20
-
21
- # Generate the story
22
- story = text_generator(prompt, max_length=95, num_return_sequences=1)[0]['generated_text']
23
 
24
  return story
25
 
 
10
  text = image_to_text_model(url)[0]["generated_text"]
11
  return text
12
 
13
+ # Function to convert text to a story
14
  def text2story(text):
15
  # Initialize the text generation pipeline
16
  text_generator = pipeline("text-generation", model="distilbert/distilgpt2")
17
 
18
+ # Generate the story directly from the input text
19
+ story = text_generator(text, max_length=95, num_return_sequences=1)[0]['generated_text']
 
 
 
20
 
21
  return story
22