Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,11 +27,11 @@ 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"
|
31 |
-
story = story_generator(prompt, max_length=
|
32 |
|
33 |
# Extract the story text from the generated output
|
34 |
-
story = story.strip()
|
35 |
|
36 |
# Post-process the story (example: remove inappropriate words)
|
37 |
inappropriate_words = ["violence", "horror", "scary", "adult", "death", "gun", "shoot"]
|
|
|
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 in 100 words based on the following image description:\n\n{caption}\n\nStory:"
|
31 |
+
story = story_generator(prompt, max_length=200, num_return_sequences=1)[0]["generated_text"]
|
32 |
|
33 |
# Extract the story text from the generated output
|
34 |
+
story = story.split("Story:")[1].strip()
|
35 |
|
36 |
# Post-process the story (example: remove inappropriate words)
|
37 |
inappropriate_words = ["violence", "horror", "scary", "adult", "death", "gun", "shoot"]
|