Update app.py

#1
by xieqilenb - opened
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -5,7 +5,7 @@ from gtts import gTTS
5
 
6
  st.set_page_config(page_title="Image to Audio Story", page_icon="🦜")
7
  caption_pipeline = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
8
- story_pipeline = pipeline("text-generation", model="Qwen/Qwen2-1.5B")
9
 
10
 
11
  def extract_image_caption(image_data):
@@ -24,7 +24,7 @@ def compose_story_from_caption(caption_detail):
24
  f"Image Details: {caption_detail}\n\nStory:"
25
  )
26
 
27
- story_results = story_pipeline(prompt_text, num_return_sequences=1, max_length=150)
28
  story_text = story_results[0]['generated_text']
29
 
30
  # 提取故事
@@ -33,9 +33,7 @@ def compose_story_from_caption(caption_detail):
33
  else:
34
  story = story_text.strip()
35
 
36
- # ζ£€ζŸ₯ι•ΏεΊ¦
37
- if 80 <= len(story.split()) <= 100:
38
- return story
39
 
40
  def convert_text_to_audio(text_content, audio_path="output.mp3"):
41
  """
 
5
 
6
  st.set_page_config(page_title="Image to Audio Story", page_icon="🦜")
7
  caption_pipeline = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
8
+ story_pipeline = pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
9
 
10
 
11
  def extract_image_caption(image_data):
 
24
  f"Image Details: {caption_detail}\n\nStory:"
25
  )
26
 
27
+ story_results = story_pipeline(prompt_text, num_return_sequences=1, max_new_tokens=150)
28
  story_text = story_results[0]['generated_text']
29
 
30
  # 提取故事
 
33
  else:
34
  story = story_text.strip()
35
 
36
+ return story
 
 
37
 
38
  def convert_text_to_audio(text_content, audio_path="output.mp3"):
39
  """