Spaces:
Runtime error
Runtime error
Commit
Β·
66797b4
1
Parent(s):
cbab169
Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,9 @@ from minigpt4.processors import *
|
|
27 |
from minigpt4.runners import *
|
28 |
from minigpt4.tasks import *
|
29 |
|
|
|
|
|
|
|
30 |
|
31 |
def parse_args():
|
32 |
parser = argparse.ArgumentParser(description="Demo")
|
@@ -411,12 +414,13 @@ def example_trigger(text_input, image, upload_flag, replace_flag, img_list):
|
|
411 |
return upload_flag, replace_flag
|
412 |
|
413 |
|
414 |
-
def gradio_ask(user_message, chatbot, chat_state, gr_img, img_list, upload_flag, replace_flag):
|
415 |
if len(user_message) == 0:
|
416 |
text_box_show = 'Input should not be empty!'
|
417 |
else:
|
418 |
text_box_show = ''
|
419 |
-
|
|
|
420 |
if isinstance(gr_img, dict):
|
421 |
gr_img, mask = gr_img['image'], gr_img['mask']
|
422 |
else:
|
@@ -449,9 +453,10 @@ def gradio_ask(user_message, chatbot, chat_state, gr_img, img_list, upload_flag,
|
|
449 |
visual_img, _ = visualize_all_bbox_together(gr_img, user_message)
|
450 |
if visual_img is not None:
|
451 |
file_path = save_tmp_img(visual_img)
|
|
|
452 |
chatbot = chatbot + [[(file_path,), None]]
|
453 |
|
454 |
-
return text_box_show, chatbot, chat_state, img_list, upload_flag, replace_flag
|
455 |
|
456 |
|
457 |
def gradio_answer(chatbot, chat_state, img_list, temperature):
|
@@ -621,8 +626,8 @@ with gr.Blocks() as demo:
|
|
621 |
|
622 |
text_input.submit(
|
623 |
gradio_ask,
|
624 |
-
[text_input, chatbot, chat_state, image, img_list, upload_flag, replace_flag],
|
625 |
-
[text_input, chatbot, chat_state, img_list, upload_flag, replace_flag], queue=False
|
626 |
).success(
|
627 |
gradio_stream_answer,
|
628 |
[chatbot, chat_state, img_list, temperature],
|
@@ -636,8 +641,8 @@ with gr.Blocks() as demo:
|
|
636 |
|
637 |
send.click(
|
638 |
gradio_ask,
|
639 |
-
[text_input, chatbot, chat_state, image, img_list, upload_flag, replace_flag],
|
640 |
-
[text_input, chatbot, chat_state, img_list, upload_flag, replace_flag]
|
641 |
).success(
|
642 |
gradio_stream_answer,
|
643 |
[chatbot, chat_state, img_list, temperature],
|
|
|
27 |
from minigpt4.runners import *
|
28 |
from minigpt4.tasks import *
|
29 |
|
30 |
+
import warnings
|
31 |
+
|
32 |
+
warnings.filterwarnings("ignore")
|
33 |
|
34 |
def parse_args():
|
35 |
parser = argparse.ArgumentParser(description="Demo")
|
|
|
414 |
return upload_flag, replace_flag
|
415 |
|
416 |
|
417 |
+
def gradio_ask(user_message, chatbot, chat_state, gr_img, img_list, upload_flag, replace_flag, path_list):
|
418 |
if len(user_message) == 0:
|
419 |
text_box_show = 'Input should not be empty!'
|
420 |
else:
|
421 |
text_box_show = ''
|
422 |
+
if not isinstance(path_list, list):
|
423 |
+
path_list = []
|
424 |
if isinstance(gr_img, dict):
|
425 |
gr_img, mask = gr_img['image'], gr_img['mask']
|
426 |
else:
|
|
|
453 |
visual_img, _ = visualize_all_bbox_together(gr_img, user_message)
|
454 |
if visual_img is not None:
|
455 |
file_path = save_tmp_img(visual_img)
|
456 |
+
path_list.append(file_path)
|
457 |
chatbot = chatbot + [[(file_path,), None]]
|
458 |
|
459 |
+
return text_box_show, chatbot, chat_state, img_list, upload_flag, replace_flag, path_list
|
460 |
|
461 |
|
462 |
def gradio_answer(chatbot, chat_state, img_list, temperature):
|
|
|
626 |
|
627 |
text_input.submit(
|
628 |
gradio_ask,
|
629 |
+
[text_input, chatbot, chat_state, image, img_list, upload_flag, replace_flag, path_list],
|
630 |
+
[text_input, chatbot, chat_state, img_list, upload_flag, replace_flag, path_list], queue=False
|
631 |
).success(
|
632 |
gradio_stream_answer,
|
633 |
[chatbot, chat_state, img_list, temperature],
|
|
|
641 |
|
642 |
send.click(
|
643 |
gradio_ask,
|
644 |
+
[text_input, chatbot, chat_state, image, img_list, upload_flag, replace_flag, path_list],
|
645 |
+
[text_input, chatbot, chat_state, img_list, upload_flag, replace_flag, path_list]
|
646 |
).success(
|
647 |
gradio_stream_answer,
|
648 |
[chatbot, chat_state, img_list, temperature],
|