Spaces:
Runtime error
Runtime error
Update perf.
Browse files
app.py
CHANGED
@@ -119,25 +119,6 @@ def handle_regeneration(chatbot, task_history):
|
|
119 |
print("After:", task_history, chatbot)
|
120 |
return get_chat_response(chatbot, task_history)
|
121 |
|
122 |
-
chatbot = []
|
123 |
-
task_history = []
|
124 |
-
|
125 |
-
def main_function(text, image):
|
126 |
-
global chatbot, task_history
|
127 |
-
if text:
|
128 |
-
chatbot, task_history = handle_text_input(chatbot, task_history, text)
|
129 |
-
if image:
|
130 |
-
chatbot, task_history = handle_file_upload(chatbot, task_history, image)
|
131 |
-
chatbot, task_history = get_chat_response(chatbot, task_history)
|
132 |
-
formatted_response = chatbot[-1][1] # Get the latest response from the chatbot
|
133 |
-
return formatted_response
|
134 |
-
|
135 |
-
def clear_history_fn():
|
136 |
-
global chatbot, task_history
|
137 |
-
chatbot.clear()
|
138 |
-
task_history.clear()
|
139 |
-
return "History cleared."
|
140 |
-
|
141 |
# Custom CSS
|
142 |
css = '''
|
143 |
.gradio-container {
|
@@ -152,21 +133,25 @@ with gr.Blocks(css=css) as demo:
|
|
152 |
"Special thanks to [@Artificialguybr](https://twitter.com/artificialguybr) for the inspiration from his code.\n"
|
153 |
"### Qwen-VL: A Multimodal Large Vision Language Model by Alibaba Cloud\n"
|
154 |
)
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
]
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
theme=None,
|
165 |
-
css=css
|
166 |
-
).launch()
|
167 |
-
gr.Markdown("### Key Features:\n- **Strong Performance**: Surpasses existing LVLMs on multiple English benchmarks including Zero-shot Captioning and VQA.\n- **Multi-lingual Support**: Supports English, Chinese, and multi-lingual conversation.\n- **High Resolution**: Utilizes 448*448 resolution for fine-grained recognition and understanding.")
|
168 |
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
171 |
demo.launch(share=True)
|
172 |
|
|
|
119 |
print("After:", task_history, chatbot)
|
120 |
return get_chat_response(chatbot, task_history)
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
# Custom CSS
|
123 |
css = '''
|
124 |
.gradio-container {
|
|
|
133 |
"Special thanks to [@Artificialguybr](https://twitter.com/artificialguybr) for the inspiration from his code.\n"
|
134 |
"### Qwen-VL: A Multimodal Large Vision Language Model by Alibaba Cloud\n"
|
135 |
)
|
136 |
+
chatbot = gr.Chatbot(label='Qwen-VL-Chat', elem_classes="control-height", height=520)
|
137 |
+
query = gr.Textbox(lines=2, label='Input')
|
138 |
+
task_history = gr.State([])
|
139 |
+
|
140 |
+
with gr.Row():
|
141 |
+
upload_btn = gr.UploadButton("π Upload", file_types=["image"])
|
142 |
+
submit_btn = gr.Button("π Submit")
|
143 |
+
regen_btn = gr.Button("π€οΈ Regenerate")
|
144 |
+
clear_btn = gr.Button("π§Ή Clear History")
|
|
|
|
|
|
|
|
|
145 |
|
146 |
+
gr.Markdown("### Key Features:\n- **Strong Performance**: Surpasses existing LVLMs on multiple English benchmarks including Zero-shot Captioning and VQA.\n- **Multi-lingual Support**: Supports English, Chinese, and multi-lingual conversation.\n- **High Resolution**: Utilizes 448*448 resolution for fine-grained recognition and understanding.")
|
147 |
+
submit_btn.click(handle_text_input, [chatbot, task_history, query], [chatbot, task_history]).then(
|
148 |
+
get_chat_response, [chatbot, task_history], [chatbot], show_progress=True
|
149 |
+
)
|
150 |
+
submit_btn.click(clear_input, [], [query])
|
151 |
+
clear_btn.click(clear_history, [task_history], [chatbot], show_progress=True)
|
152 |
+
regen_btn.click(handle_regeneration, [chatbot, task_history], [chatbot], show_progress=True)
|
153 |
+
upload_btn.upload(handle_file_upload, [chatbot, task_history, upload_btn], [chatbot, task_history], show_progress=True)
|
154 |
+
|
155 |
|
156 |
demo.launch(share=True)
|
157 |
|