littlebird13 commited on
Commit
1cfc855
1 Parent(s): 539d48e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -22
app.py CHANGED
@@ -22,14 +22,7 @@ from http import HTTPStatus
22
  from dashscope import MultiModalConversation
23
  import dashscope
24
  API_KEY = os.environ['API_KEY']
25
- ENDPOINT = os.environ['ENDPOINT']
26
- AK_ID = os.environ['AK_ID']
27
- AK = os.environ['AK']
28
- BUCKET_NAME = os.environ['BUCKET_NAME']
29
  dashscope.api_key = API_KEY
30
- endpoint = ENDPOINT
31
- auth = oss2.Auth(AK_ID, AK)
32
- bucket = oss2.Bucket(auth, endpoint, BUCKET_NAME)
33
 
34
  REVISION = 'v1.0.4'
35
  BOX_TAG_PATTERN = r"<box>([\s\S]*?)</box>"
@@ -115,10 +108,7 @@ def _launch_demo(args):
115
  for q, a in history_cp:
116
  if isinstance(q, (tuple, list)):
117
  if is_video_file(q[0]):
118
- key = q[0].split(os.sep)[-2]
119
- bucket.put_object_from_file(key, q[0])
120
- url = bucket.sign_url('GET', key, 3600)
121
- content.append({'video': url})
122
  else:
123
  content.append({'image': f'file://{q[0]}'})
124
  else:
@@ -205,13 +195,13 @@ def _launch_demo(args):
205
  with gr.Blocks() as demo:
206
  gr.Markdown("""\
207
  <p align="center"><img src="https://modelscope.oss-cn-beijing.aliyuncs.com/resource/qwen.png" style="height: 80px"/><p>""")
208
- gr.Markdown("""<center><font size=8>Qwen2-VL-72B</center>""")
209
  gr.Markdown(
210
  """\
211
- <center><font size=3>This WebUI is based on Qwen2-VL-72B, developed by Alibaba Cloud.</center>""")
212
- gr.Markdown("""<center><font size=3>本WebUI基于Qwen2-VL-72B。</center>""")
213
 
214
- chatbot = gr.Chatbot(label='Qwen2-VL-72B', elem_classes="control-height", height=500)
215
  query = gr.Textbox(lines=2, label='Input')
216
  task_history = gr.State([])
217
 
@@ -221,13 +211,13 @@ def _launch_demo(args):
221
  regen_btn = gr.Button("🤔️ Regenerate (重试)")
222
  empty_bin = gr.Button("🧹 Clear History (清除历史)")
223
 
224
- submit_btn.click(add_text, [chatbot, task_history, query], [chatbot, task_history],concurrency_limit = 40).then(
225
  predict, [chatbot, task_history], [chatbot], show_progress=True
226
  )
227
- submit_btn.click(reset_user_input, [], [query],concurrency_limit = 40)
228
- empty_bin.click(reset_state, [task_history], [chatbot], show_progress=True,concurrency_limit = 40)
229
- regen_btn.click(regenerate, [chatbot, task_history], [chatbot], show_progress=True,concurrency_limit = 40)
230
- addfile_btn.upload(add_file, [chatbot, task_history, addfile_btn], [chatbot, task_history], show_progress=True,concurrency_limit = 40)
231
 
232
  gr.Markdown("""\
233
  <font size=2>Note: This demo is governed by the original license of Qwen2-VL. \
@@ -236,9 +226,8 @@ including hate speech, violence, pornography, deception, etc. \
236
  (注:本演示受Qwen2-VL的许可协议限制。我们强烈建议,用户不应传播及不应允许他人传播以下内容,\
237
  包括但不限于仇恨言论、暴力、色情、欺诈相关的有害信息。)""")
238
 
239
- demo.queue(api_open=False,default_concurrency_limit=40).launch(
240
  share=args.share,
241
- max_threads=40,
242
  # inbrowser=args.inbrowser,
243
  # server_port=args.server_port,
244
  # server_name=args.server_name,
 
22
  from dashscope import MultiModalConversation
23
  import dashscope
24
  API_KEY = os.environ['API_KEY']
 
 
 
 
25
  dashscope.api_key = API_KEY
 
 
 
26
 
27
  REVISION = 'v1.0.4'
28
  BOX_TAG_PATTERN = r"<box>([\s\S]*?)</box>"
 
108
  for q, a in history_cp:
109
  if isinstance(q, (tuple, list)):
110
  if is_video_file(q[0]):
111
+ content.append({'video': f'file://{q[0]}'})
 
 
 
112
  else:
113
  content.append({'image': f'file://{q[0]}'})
114
  else:
 
195
  with gr.Blocks() as demo:
196
  gr.Markdown("""\
197
  <p align="center"><img src="https://modelscope.oss-cn-beijing.aliyuncs.com/resource/qwen.png" style="height: 80px"/><p>""")
198
+ gr.Markdown("""<center><font size=8>Qwen2-VL-Max</center>""")
199
  gr.Markdown(
200
  """\
201
+ <center><font size=3>This WebUI is based on Qwen2-VL-Max, developed by Alibaba Cloud.</center>""")
202
+ gr.Markdown("""<center><font size=3>本WebUI基于Qwen2-VL-Max。</center>""")
203
 
204
+ chatbot = gr.Chatbot(label='Qwen2-VL-Max', elem_classes="control-height", height=500)
205
  query = gr.Textbox(lines=2, label='Input')
206
  task_history = gr.State([])
207
 
 
211
  regen_btn = gr.Button("🤔️ Regenerate (重试)")
212
  empty_bin = gr.Button("🧹 Clear History (清除历史)")
213
 
214
+ submit_btn.click(add_text, [chatbot, task_history, query], [chatbot, task_history]).then(
215
  predict, [chatbot, task_history], [chatbot], show_progress=True
216
  )
217
+ submit_btn.click(reset_user_input, [], [query])
218
+ empty_bin.click(reset_state, [task_history], [chatbot], show_progress=True)
219
+ regen_btn.click(regenerate, [chatbot, task_history], [chatbot], show_progress=True)
220
+ addfile_btn.upload(add_file, [chatbot, task_history, addfile_btn], [chatbot, task_history], show_progress=True)
221
 
222
  gr.Markdown("""\
223
  <font size=2>Note: This demo is governed by the original license of Qwen2-VL. \
 
226
  (注:本演示受Qwen2-VL的许可协议限制。我们强烈建议,用户不应传播及不应允许他人传播以下内容,\
227
  包括但不限于仇恨言论、暴力、色情、欺诈相关的有害信息。)""")
228
 
229
+ demo.queue().launch(
230
  share=args.share,
 
231
  # inbrowser=args.inbrowser,
232
  # server_port=args.server_port,
233
  # server_name=args.server_name,