Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ except ImportError:
|
|
15 |
import torch
|
16 |
|
17 |
# Load the image captioning model
|
18 |
-
caption_model = pipeline("image-to-text", model="
|
19 |
|
20 |
# Load the GPT-2 model for story generation
|
21 |
story_generator = pipeline("text-generation", model="openai-community/gpt2")
|
@@ -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"
|
31 |
-
story = story_generator(prompt, max_length=
|
32 |
return story
|
33 |
|
34 |
def convert_to_audio(story):
|
|
|
15 |
import torch
|
16 |
|
17 |
# Load the image captioning model
|
18 |
+
caption_model = pipeline("image-to-text", model="unography/blip-large-long-cap")
|
19 |
|
20 |
# Load the GPT-2 model for story generation
|
21 |
story_generator = pipeline("text-generation", model="openai-community/gpt2")
|
|
|
27 |
|
28 |
def generate_story(caption):
|
29 |
# Generate the story based on the caption using the GPT-2 model
|
30 |
+
prompt = f"As a storyteller, please based on the image described as '{caption}', create a interesting and attractive story for children aged 3-10. Keep it positive and happy in tone. Also, add more imagination, and starting with wordings'one upon a time'"
|
31 |
+
story = story_generator(prompt, max_length=100, num_return_sequences=1)[0]["generated_text"]
|
32 |
return story
|
33 |
|
34 |
def convert_to_audio(story):
|