baohuynhbk14 commited on
Commit
ef6b1b7
·
1 Parent(s): ccf317f

Remove unused image files and update bot function names for clarity

Browse files
app.py CHANGED
@@ -216,7 +216,7 @@ def predict(message,
216
  response, conv_history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
217
  return response, conv_history
218
 
219
- def http_bot(
220
  state,
221
  temperature,
222
  top_p,
@@ -226,7 +226,7 @@ def http_bot(
226
  request: gr.Request,
227
  ):
228
 
229
- logger.info(f"http_bot. ip: {request.client.host}")
230
  start_tstamp = time.time()
231
  if hasattr(state, "skip_next") and state.skip_next:
232
  # This generate call is skipped due to invalid inputs
@@ -276,7 +276,7 @@ def http_bot(
276
  top_p,
277
  repetition_penalty)
278
 
279
- # response = "This is a test response"
280
  buffer = ""
281
  for new_text in response:
282
  buffer += new_text
@@ -289,7 +289,7 @@ def http_bot(
289
  ) + (disable_btn,) * 5
290
 
291
  except Exception as e:
292
- logger.error(f"Error in http_bot: {e} \n{traceback.format_exc()}")
293
  state.update_message(Conversation.ASSISTANT, server_error_msg, None)
294
  yield (
295
  state,
@@ -333,11 +333,11 @@ def http_bot(
333
  # <h1 style="font-size: 28px; font-weight: bold;">Expanding Performance Boundaries of Open-Source Multimodal Models with Model, Data, and Test-Time Scaling</h1>
334
  title_html = """
335
  <div style="text-align: center;">
336
- <img src="https://lh3.googleusercontent.com/pw/AP1GczMmW-aFQ4dNaR_LCAllh4UZLLx9fTZ1ITHeGVMWx-1bwlIWz4VsWJSGb3_9C7CQfvboqJH41y2Sbc5ToC9ZmKeV4-buf_DEevIMU0HtaLWgHAPOqBiIbG6LaE8CvDqniLZzvB9UX8TR_-YgvYzPFt2z=w1472-h832-s-no-gm?authuser=0" style="height: 100; width: 100%;">
337
- <p>🔥Vintern-1B-v3_5🔥</p>
338
- <p>An Efficient Multimodal Large Language Model for Vietnamese</p>
339
- <a href="https://huggingface.co/papers/2408.12480">[📖 Vintern Paper]</a>
340
- <a href="https://huggingface.co/5CD-AI">[🤗 Huggingface]</a>
341
  </div>
342
  """
343
 
@@ -375,45 +375,45 @@ block_css = """
375
  }
376
  """
377
 
378
- # js = """
379
- # function createWaveAnimation() {
380
- # const text = document.getElementById('text');
381
- # var i = 0;
382
- # setInterval(function() {
383
- # const colors = [
384
- # 'red, orange, yellow, green, blue, indigo, violet, purple',
385
- # 'orange, yellow, green, blue, indigo, violet, purple, red',
386
- # 'yellow, green, blue, indigo, violet, purple, red, orange',
387
- # 'green, blue, indigo, violet, purple, red, orange, yellow',
388
- # 'blue, indigo, violet, purple, red, orange, yellow, green',
389
- # 'indigo, violet, purple, red, orange, yellow, green, blue',
390
- # 'violet, purple, red, orange, yellow, green, blue, indigo',
391
- # 'purple, red, orange, yellow, green, blue, indigo, violet',
392
- # ];
393
- # const angle = 45;
394
- # const colorIndex = i % colors.length;
395
- # text.style.background = `linear-gradient(${angle}deg, ${colors[colorIndex]})`;
396
- # text.style.webkitBackgroundClip = 'text';
397
- # text.style.backgroundClip = 'text';
398
- # text.style.color = 'transparent';
399
- # text.style.fontSize = '28px';
400
- # text.style.width = 'auto';
401
- # text.textContent = 'Vintern-1B';
402
- # text.style.fontWeight = 'bold';
403
- # i += 1;
404
- # }, 200);
405
- # const params = new URLSearchParams(window.location.search);
406
- # url_params = Object.fromEntries(params);
407
- # // console.log(url_params);
408
- # // console.log('hello world...');
409
- # // console.log(window.location.search);
410
- # // console.log('hello world...');
411
- # // alert(window.location.search)
412
- # // alert(url_params);
413
- # return url_params;
414
- # }
415
-
416
- # """
417
 
418
 
419
  def build_demo():
@@ -426,14 +426,14 @@ def build_demo():
426
 
427
  with gr.Blocks(
428
  title="Vintern-1B-v3_5-Demo",
429
- theme=gr.themes.Default(),
430
  css=block_css,
 
431
  ) as demo:
432
  state = gr.State()
433
 
434
  with gr.Row():
435
  with gr.Column(scale=2):
436
- # gr.Image('./gallery/logo-47b364d3.jpg')
437
  gr.HTML(title_html)
438
 
439
  with gr.Accordion("Settings", open=False) as setting_row:
@@ -487,25 +487,33 @@ def build_demo():
487
  [
488
  {
489
  "files": [
490
- "gallery/14.jfif",
 
 
 
 
 
 
 
 
491
  ],
492
- "text": "Please help me analyze this picture.",
493
  }
494
  ],
495
  [
496
  {
497
  "files": [
498
- "gallery/1-2.PNG",
499
  ],
500
- "text": "Implement this flow chart using python",
501
  }
502
  ],
503
  [
504
  {
505
  "files": [
506
- "gallery/15.PNG",
507
  ],
508
- "text": "Please help me analyze this picture.",
509
  }
510
  ],
511
  ],
@@ -570,7 +578,7 @@ def build_demo():
570
  [state, system_prompt],
571
  [state, chatbot, textbox] + btn_list,
572
  ).then(
573
- http_bot,
574
  [
575
  state,
576
  temperature,
@@ -588,7 +596,7 @@ def build_demo():
588
  [state, textbox, system_prompt],
589
  [state, chatbot, textbox] + btn_list,
590
  ).then(
591
- http_bot,
592
  [
593
  state,
594
  temperature,
@@ -604,7 +612,7 @@ def build_demo():
604
  [state, textbox, system_prompt],
605
  [state, chatbot, textbox] + btn_list,
606
  ).then(
607
- http_bot,
608
  [
609
  state,
610
  temperature,
 
216
  response, conv_history = model.chat(tokenizer, pixel_values, question, generation_config, history=history, return_history=True)
217
  return response, conv_history
218
 
219
+ def ai_bot(
220
  state,
221
  temperature,
222
  top_p,
 
226
  request: gr.Request,
227
  ):
228
 
229
+ logger.info(f"ai_bot. ip: {request.client.host}")
230
  start_tstamp = time.time()
231
  if hasattr(state, "skip_next") and state.skip_next:
232
  # This generate call is skipped due to invalid inputs
 
276
  top_p,
277
  repetition_penalty)
278
 
279
+ response = "This is a test response"
280
  buffer = ""
281
  for new_text in response:
282
  buffer += new_text
 
289
  ) + (disable_btn,) * 5
290
 
291
  except Exception as e:
292
+ logger.error(f"Error in ai_bot: {e} \n{traceback.format_exc()}")
293
  state.update_message(Conversation.ASSISTANT, server_error_msg, None)
294
  yield (
295
  state,
 
333
  # <h1 style="font-size: 28px; font-weight: bold;">Expanding Performance Boundaries of Open-Source Multimodal Models with Model, Data, and Test-Time Scaling</h1>
334
  title_html = """
335
  <div style="text-align: center;">
336
+ <img src="https://lh3.googleusercontent.com/pw/AP1GczMmW-aFQ4dNaR_LCAllh4UZLLx9fTZ1ITHeGVMWx-1bwlIWz4VsWJSGb3_9C7CQfvboqJH41y2Sbc5ToC9ZmKeV4-buf_DEevIMU0HtaLWgHAPOqBiIbG6LaE8CvDqniLZzvB9UX8TR_-YgvYzPFt2z=w1472-h832-s-no-gm?authuser=0" style="height: 90px; width: 95%;">
337
+ <p style="font-size: 20px;">🔥Vintern-1B-v3_5🔥</p>
338
+ <p style="font-size: 14px;">An Efficient Multimodal Large Language Model for Vietnamese</p>
339
+ <a href="https://huggingface.co/papers/2408.12480" style="font-size: 13px;">[📖 Vintern Paper]</a>
340
+ <a href="https://huggingface.co/5CD-AI" style="font-size: 13px;">[🤗 Huggingface]</a>
341
  </div>
342
  """
343
 
 
375
  }
376
  """
377
 
378
+ js = """
379
+ function createWaveAnimation() {
380
+ const text = document.getElementById('text');
381
+ var i = 0;
382
+ setInterval(function() {
383
+ const colors = [
384
+ 'red, orange, yellow, green, blue, indigo, violet, purple',
385
+ 'orange, yellow, green, blue, indigo, violet, purple, red',
386
+ 'yellow, green, blue, indigo, violet, purple, red, orange',
387
+ 'green, blue, indigo, violet, purple, red, orange, yellow',
388
+ 'blue, indigo, violet, purple, red, orange, yellow, green',
389
+ 'indigo, violet, purple, red, orange, yellow, green, blue',
390
+ 'violet, purple, red, orange, yellow, green, blue, indigo',
391
+ 'purple, red, orange, yellow, green, blue, indigo, violet',
392
+ ];
393
+ const angle = 45;
394
+ const colorIndex = i % colors.length;
395
+ text.style.background = `linear-gradient(${angle}deg, ${colors[colorIndex]})`;
396
+ text.style.webkitBackgroundClip = 'text';
397
+ text.style.backgroundClip = 'text';
398
+ text.style.color = 'transparent';
399
+ text.style.fontSize = '28px';
400
+ text.style.width = 'auto';
401
+ text.textContent = 'Vintern-1B';
402
+ text.style.fontWeight = 'bold';
403
+ i += 1;
404
+ }, 200);
405
+ const params = new URLSearchParams(window.location.search);
406
+ url_params = Object.fromEntries(params);
407
+ // console.log(url_params);
408
+ // console.log('hello world...');
409
+ // console.log(window.location.search);
410
+ // console.log('hello world...');
411
+ // alert(window.location.search)
412
+ // alert(url_params);
413
+ return url_params;
414
+ }
415
+
416
+ """
417
 
418
 
419
  def build_demo():
 
426
 
427
  with gr.Blocks(
428
  title="Vintern-1B-v3_5-Demo",
429
+ theme='SebastianBravo/simci_css',
430
  css=block_css,
431
+ js=js,
432
  ) as demo:
433
  state = gr.State()
434
 
435
  with gr.Row():
436
  with gr.Column(scale=2):
 
437
  gr.HTML(title_html)
438
 
439
  with gr.Accordion("Settings", open=False) as setting_row:
 
487
  [
488
  {
489
  "files": [
490
+ "samples/1.jpg",
491
+ ],
492
+ "text": "Hãy trích xuất thông tin từ hình ảnh này và trả về kết quả dạng markdown.",
493
+ }
494
+ ],
495
+ [
496
+ {
497
+ "files": [
498
+ "samples/2.png",
499
  ],
500
+ "text": "Bạn một nhà sáng tạo nội dung tài năng. Hãy viết một kịch bản quảng cáo cho sản phẩm này.",
501
  }
502
  ],
503
  [
504
  {
505
  "files": [
506
+ "samples/3.jpeg",
507
  ],
508
+ "text": "Hãy viết lại một email cho các chủ hộ về nội dung của bảng thông báo.",
509
  }
510
  ],
511
  [
512
  {
513
  "files": [
514
+ "samples/4.jpeg",
515
  ],
516
+ "text": "Hãy viết trích xuất nội dung của hoá đơn dạng JSON.",
517
  }
518
  ],
519
  ],
 
578
  [state, system_prompt],
579
  [state, chatbot, textbox] + btn_list,
580
  ).then(
581
+ ai_bot,
582
  [
583
  state,
584
  temperature,
 
596
  [state, textbox, system_prompt],
597
  [state, chatbot, textbox] + btn_list,
598
  ).then(
599
+ ai_bot,
600
  [
601
  state,
602
  temperature,
 
612
  [state, textbox, system_prompt],
613
  [state, chatbot, textbox] + btn_list,
614
  ).then(
615
+ ai_bot,
616
  [
617
  state,
618
  temperature,
conversation.py CHANGED
@@ -47,8 +47,8 @@ class Conversation:
47
  Conversation.ASSISTANT,
48
  ]
49
  )
50
- mandatory_system_message = "我是书生·万象,英文名是InternVL,是由上海人工智能实验室、清华大学及多家合作单位联合开发的多模态大语言模型。"
51
- system_message: str = "请尽可能详细地回答用户的问题。"
52
  messages: List[Dict[str, Any]] = field(default_factory=lambda: [])
53
  max_image_limit: int = 4
54
  skip_next: bool = False
 
47
  Conversation.ASSISTANT,
48
  ]
49
  )
50
+ mandatory_system_message = ""
51
+ system_message: str = ""
52
  messages: List[Dict[str, Any]] = field(default_factory=lambda: [])
53
  max_image_limit: int = 4
54
  skip_next: bool = False
gallery/1-2.PNG DELETED

Git LFS Details

  • SHA256: 647e5f2be9dc368abc34f7ff946ea97e9dba9d29f9959bfa005f64261871679a
  • Pointer size: 132 Bytes
  • Size of remote file: 1.09 MB
gallery/10.PNG DELETED
Binary file (123 kB)
 
gallery/14.jfif DELETED
Binary file (112 kB)
 
gallery/15.PNG DELETED
Binary file (202 kB)
 
gallery/2.PNG DELETED

Git LFS Details

  • SHA256: 82e796006de988ac2b88fe603a2891d157b956875f7b8ba0c8aa7ae405afe032
  • Pointer size: 132 Bytes
  • Size of remote file: 1.22 MB
gallery/astro_on_unicorn.png DELETED

Git LFS Details

  • SHA256: db8d3e76317a2bcd7b8c6dfca55194372dca82d669c0789c96616b237ae54f81
  • Pointer size: 132 Bytes
  • Size of remote file: 1.47 MB
gallery/cheetah.png DELETED

Git LFS Details

  • SHA256: 7dc83b042237cc5dd6092e8a8d0aba10d08a78c979304729d35b29d8049aba6c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.58 MB
gallery/child_1.jpg DELETED
Binary file (34.9 kB)
 
gallery/child_2.jpg DELETED
Binary file (35.3 kB)
 
gallery/child_3.jpg DELETED
Binary file (28.5 kB)
 
gallery/farmer_sunset.png DELETED

Git LFS Details

  • SHA256: 9e966b2fcfe4d7b29a31f8b8f1c49017fcee025af4f50f66cbd19986d5929898
  • Pointer size: 132 Bytes
  • Size of remote file: 1.22 MB
gallery/friends.png DELETED

Git LFS Details

  • SHA256: 9904e3e32261eaa7882a011cc3f7ab85a39e5f709c365952a582a11a49811eef
  • Pointer size: 132 Bytes
  • Size of remote file: 1.48 MB
gallery/prod_1.jpeg DELETED
Binary file (48.9 kB)
 
gallery/prod_11.jpg DELETED
Binary file (92.1 kB)
 
gallery/prod_12.png DELETED
Binary file (329 kB)
 
gallery/prod_17.jpg DELETED
Binary file (70.4 kB)
 
gallery/prod_4.png DELETED
Binary file (462 kB)
 
gallery/prod_9.jpg DELETED
Binary file (313 kB)
 
gallery/prod_en_17.png DELETED

Git LFS Details

  • SHA256: 2e0637eefbd3a3dde2133e7cf71724206eee614adb31435701248e7afb9cd039
  • Pointer size: 132 Bytes
  • Size of remote file: 1.89 MB
gallery/puppy.png DELETED

Git LFS Details

  • SHA256: 2d53d33fb104081d4eece46ea0889e21ba9ebfde3d1c274c63da7781bb04887e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.21 MB
gallery/viking.png DELETED

Git LFS Details

  • SHA256: ce197152f12be175ad91d7e4f99085793e4a2aa9e2e2b548e078c746c14fbedf
  • Pointer size: 132 Bytes
  • Size of remote file: 1.5 MB
gallery/water.jpg DELETED
Binary file (668 kB)
 
gallery/wizard.png DELETED

Git LFS Details

  • SHA256: a50dbb5aead995ce996e88b9ba43ba2eb20588e97fc7b52afbf7b273d036eaf8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.53 MB
samples/1.jpg ADDED
samples/2.png ADDED
samples/3.jpeg ADDED
samples/4.jpeg ADDED