Update app.py
Browse files
app.py
CHANGED
@@ -15,13 +15,6 @@ def extract_image_caption(image_data):
|
|
15 |
|
16 |
|
17 |
def compose_story_from_caption(caption_detail):
|
18 |
-
"""
|
19 |
-
根据图像描述创作一篇充满创意的儿童故事。
|
20 |
-
"""
|
21 |
-
story_pipeline = pipeline(
|
22 |
-
"text-generation",
|
23 |
-
model="Qwen/Qwen2-1.5B",
|
24 |
-
)
|
25 |
prompt_text = (
|
26 |
"You are a talented and imaginative storyteller for children aged 3 to 10. "
|
27 |
"Using the details derived from the image below, craft a captivating tale that goes beyond merely describing the scene. "
|
@@ -33,12 +26,8 @@ def compose_story_from_caption(caption_detail):
|
|
33 |
story_text = story_results[0]['generated_text']
|
34 |
|
35 |
if "Story:" in story_text:
|
36 |
-
|
37 |
-
|
38 |
-
story = story_text.strip()
|
39 |
-
|
40 |
-
return story
|
41 |
-
|
42 |
|
43 |
def convert_text_to_audio(text_content, audio_path="output.mp3"):
|
44 |
"""
|
|
|
15 |
|
16 |
|
17 |
def compose_story_from_caption(caption_detail):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
prompt_text = (
|
19 |
"You are a talented and imaginative storyteller for children aged 3 to 10. "
|
20 |
"Using the details derived from the image below, craft a captivating tale that goes beyond merely describing the scene. "
|
|
|
26 |
story_text = story_results[0]['generated_text']
|
27 |
|
28 |
if "Story:" in story_text:
|
29 |
+
return story_text.split("Story:", 1)[1].strip()
|
30 |
+
return story_text.strip()
|
|
|
|
|
|
|
|
|
31 |
|
32 |
def convert_text_to_audio(text_content, audio_path="output.mp3"):
|
33 |
"""
|