larry1129 commited on
Commit
e3d517e
1 Parent(s): c4ef0c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -45,6 +45,8 @@ def load_language_model():
45
  return language_tokenizer, language_model
46
 
47
  # 从图片生成描述
 
 
48
  def generate_image_description(image):
49
  vqa_processor, vqa_model = load_vqa_model()
50
  conversation = [
@@ -65,6 +67,8 @@ def generate_image_description(image):
65
  return image_description
66
 
67
  # 使用纯语言模型生成最终回答
 
 
68
  def generate_language_response(instruction, image_description):
69
  language_tokenizer, language_model = load_language_model()
70
  prompt = f"""### Instruction:
 
45
  return language_tokenizer, language_model
46
 
47
  # 从图片生成描述
48
+ # 定义生成响应的函数,并使用 @spaces.GPU 装饰
49
+ @spaces.GPU(duration=40) # 建议将 duration 增加到 120
50
  def generate_image_description(image):
51
  vqa_processor, vqa_model = load_vqa_model()
52
  conversation = [
 
67
  return image_description
68
 
69
  # 使用纯语言模型生成最终回答
70
+ # 定义生成响应的函数,并使用 @spaces.GPU 装饰
71
+ @spaces.GPU(duration=40) # 建议将 duration 增加到 120
72
  def generate_language_response(instruction, image_description):
73
  language_tokenizer, language_model = load_language_model()
74
  prompt = f"""### Instruction: