Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,8 +27,8 @@ 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"Write a short, simple children's story
|
31 |
-
story = story_generator(prompt, max_length=
|
32 |
|
33 |
# Extract the story text from the generated output
|
34 |
story = story.split("Story:")[1].strip()
|
|
|
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 approximately 100 words based on the following image description:\n\n{caption}\n\nStory:"
|
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("Story:")[1].strip()
|