mirror of
https://github.com/Vision-CAIR/MiniGPT-4.git
synced 2025-04-07 11:30:45 +00:00
remove unnecessary input and output
This commit is contained in:
parent
22d8888ca2
commit
7fc77104c5
19
demo.py
19
demo.py
@ -75,7 +75,8 @@ def gradio_reset(chat_state, img_list):
|
|||||||
img_list = []
|
img_list = []
|
||||||
return None, gr.update(value=None, interactive=True), gr.update(placeholder='Please upload your image first', interactive=False),gr.update(value="Upload & Start Chat", interactive=True), chat_state, img_list
|
return None, gr.update(value=None, interactive=True), gr.update(placeholder='Please upload your image first', interactive=False),gr.update(value="Upload & Start Chat", interactive=True), chat_state, img_list
|
||||||
|
|
||||||
def upload_img(gr_img, text_input, chat_state):
|
|
||||||
|
def upload_img(gr_img, chat_state):
|
||||||
if gr_img is None:
|
if gr_img is None:
|
||||||
return None, None, gr.update(interactive=True), chat_state, None
|
return None, None, gr.update(interactive=True), chat_state, None
|
||||||
chat_state = CONV_VISION.copy()
|
chat_state = CONV_VISION.copy()
|
||||||
@ -99,7 +100,8 @@ def gradio_answer(chatbot, chat_state, img_list, num_beams, temperature):
|
|||||||
max_new_tokens=300,
|
max_new_tokens=300,
|
||||||
max_length=2000)[0]
|
max_length=2000)[0]
|
||||||
chatbot[-1][1] = llm_message
|
chatbot[-1][1] = llm_message
|
||||||
return chatbot, chat_state, img_list
|
return chatbot, chat_state
|
||||||
|
|
||||||
|
|
||||||
title = """<h1 align="center">Demo of MiniGPT-4</h1>"""
|
title = """<h1 align="center">Demo of MiniGPT-4</h1>"""
|
||||||
description = """<h3>This is the demo of MiniGPT-4. Upload your images and start chatting!</h3>"""
|
description = """<h3>This is the demo of MiniGPT-4. Upload your images and start chatting!</h3>"""
|
||||||
@ -143,11 +145,14 @@ with gr.Blocks() as demo:
|
|||||||
chatbot = gr.Chatbot(label='MiniGPT-4')
|
chatbot = gr.Chatbot(label='MiniGPT-4')
|
||||||
text_input = gr.Textbox(label='User', placeholder='Please upload your image first', interactive=False)
|
text_input = gr.Textbox(label='User', placeholder='Please upload your image first', interactive=False)
|
||||||
|
|
||||||
upload_button.click(upload_img, [image, text_input, chat_state], [image, text_input, upload_button, chat_state, img_list])
|
upload_button.click(upload_img, [image, chat_state],
|
||||||
|
[image, text_input, upload_button, chat_state, img_list])
|
||||||
|
|
||||||
text_input.submit(gradio_ask, [text_input, chatbot, chat_state], [text_input, chatbot, chat_state]).then(
|
text_input \
|
||||||
gradio_answer, [chatbot, chat_state, img_list, num_beams, temperature], [chatbot, chat_state, img_list]
|
.submit(gradio_ask, [text_input, chatbot, chat_state], [text_input, chatbot, chat_state]) \
|
||||||
)
|
.then(gradio_answer, [chatbot, chat_state, img_list, num_beams, temperature], [chatbot, chat_state])
|
||||||
clear.click(gradio_reset, [chat_state, img_list], [chatbot, image, text_input, upload_button, chat_state, img_list], queue=False)
|
|
||||||
|
clear.click(gradio_reset, [chat_state, img_list], [chatbot, image, text_input, upload_button, chat_state, img_list],
|
||||||
|
queue=False)
|
||||||
|
|
||||||
demo.launch(share=True, enable_queue=True)
|
demo.launch(share=True, enable_queue=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user