IrisDeng commited on
Commit
9436c95
·
verified ·
1 Parent(s): 8948605

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -13
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
- story = story_text.split("Story:", 1)[1].strip()
37
- else:
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
  """