IrisDeng commited on
Commit
8948605
·
verified ·
1 Parent(s): 16f5ed7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -4,20 +4,14 @@ from transformers import pipeline
4
  from gtts import gTTS
5
 
6
  st.set_page_config(page_title="Image to Audio Story", page_icon="🦜")
 
 
7
 
8
 
9
  def extract_image_caption(image_data):
10
- """
11
- 利用预训练模型从图像中提取描述性文字。
12
- """
13
  img_obj = Image.open(image_data)
14
- caption_pipeline = pipeline(
15
- "image-to-text",
16
- model="Salesforce/blip-image-captioning-base",
17
- )
18
  caption_results = caption_pipeline(img_obj)
19
- caption_text = caption_results[0]['generated_text']
20
- return caption_text
21
 
22
 
23
  def compose_story_from_caption(caption_detail):
 
4
  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):
 
 
 
12
  img_obj = Image.open(image_data)
 
 
 
 
13
  caption_results = caption_pipeline(img_obj)
14
+ return caption_results[0]['generated_text']
 
15
 
16
 
17
  def compose_story_from_caption(caption_detail):