Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,14 +25,19 @@ def generate_caption(image):
|
|
25 |
caption = caption_model(image)[0]["generated_text"]
|
26 |
return caption
|
27 |
|
28 |
-
def generate_story(caption):
|
29 |
# Generate the story based on the caption using the GPT-2 model
|
30 |
-
prompt = f"Starting with '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):
|
|
|
25 |
caption = caption_model(image)[0]["generated_text"]
|
26 |
return caption
|
27 |
|
28 |
+
#def generate_story(caption):
|
29 |
# Generate the story based on the caption using the GPT-2 model
|
30 |
+
#prompt = f"Starting with '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 generate_story(caption):
|
39 |
+
# Generate the story based on the caption
|
40 |
+
story = story_generator(caption, max_length=200, num_return_sequences=1)[0]["generated_text"]
|
41 |
return story
|
42 |
|
43 |
def convert_to_audio(story):
|