Update app.py
Browse files
app.py
CHANGED
@@ -167,10 +167,12 @@ def evaluate_single_data(data, client, executor, prompt_template, prompt_type):
|
|
167 |
text_result = exe_result[0]['text']
|
168 |
except:
|
169 |
text_result = None
|
|
|
170 |
try:
|
171 |
images_result = exe_result[0]['images']
|
172 |
except:
|
173 |
images_result = None
|
|
|
174 |
|
175 |
messages, new_image_clue_idx = update_messages_with_excu_content(messages, images_result, text_result, image_clue_idx)
|
176 |
image_clue_idx = new_image_clue_idx
|
@@ -273,12 +275,14 @@ def create_demo():
|
|
273 |
image_input = gr.Image(label="Upload Image", type="pil")
|
274 |
question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
|
275 |
submit_btn = gr.Button("Submit")
|
|
|
|
|
|
|
276 |
|
277 |
with gr.Row():
|
278 |
output = gr.HTML(label="Response")
|
279 |
|
280 |
# 添加JSON下载功能
|
281 |
-
json_output = gr.JSON(label="Messages JSON", visible=False)
|
282 |
download_btn = gr.Button("Download Messages as JSON")
|
283 |
|
284 |
# 处理提交
|
@@ -288,26 +292,26 @@ def create_demo():
|
|
288 |
outputs=[output, json_output]
|
289 |
)
|
290 |
|
291 |
-
# 添加下载功能
|
292 |
-
download_btn.click(
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
)
|
311 |
|
312 |
gr.Markdown("""
|
313 |
## Examples
|
|
|
167 |
text_result = exe_result[0]['text']
|
168 |
except:
|
169 |
text_result = None
|
170 |
+
print("text result is none.")
|
171 |
try:
|
172 |
images_result = exe_result[0]['images']
|
173 |
except:
|
174 |
images_result = None
|
175 |
+
print("image result is none.")
|
176 |
|
177 |
messages, new_image_clue_idx = update_messages_with_excu_content(messages, images_result, text_result, image_clue_idx)
|
178 |
image_clue_idx = new_image_clue_idx
|
|
|
275 |
image_input = gr.Image(label="Upload Image", type="pil")
|
276 |
question = gr.Textbox(label="Question", placeholder="Ask a question about the image...")
|
277 |
submit_btn = gr.Button("Submit")
|
278 |
+
|
279 |
+
with gr.Column(scale=1):
|
280 |
+
json_output = gr.JSON(label="Messages JSON", visible=False)
|
281 |
|
282 |
with gr.Row():
|
283 |
output = gr.HTML(label="Response")
|
284 |
|
285 |
# 添加JSON下载功能
|
|
|
286 |
download_btn = gr.Button("Download Messages as JSON")
|
287 |
|
288 |
# 处理提交
|
|
|
292 |
outputs=[output, json_output]
|
293 |
)
|
294 |
|
295 |
+
# # 添加下载功能
|
296 |
+
# download_btn.click(
|
297 |
+
# fn=lambda x: x,
|
298 |
+
# inputs=[json_output],
|
299 |
+
# outputs=[],
|
300 |
+
# _js="""
|
301 |
+
# function(json_str) {
|
302 |
+
# const blob = new Blob([JSON.stringify(json_str, null, 2)], { type: 'application/json' });
|
303 |
+
# const url = URL.createObjectURL(blob);
|
304 |
+
# const a = document.createElement('a');
|
305 |
+
# a.href = url;
|
306 |
+
# a.download = 'messages_' + new Date().toISOString().replace(/[:.]/g, '-') + '.json';
|
307 |
+
# document.body.appendChild(a);
|
308 |
+
# a.click();
|
309 |
+
# document.body.removeChild(a);
|
310 |
+
# URL.revokeObjectURL(url);
|
311 |
+
# return [];
|
312 |
+
# }
|
313 |
+
# """
|
314 |
+
# )
|
315 |
|
316 |
gr.Markdown("""
|
317 |
## Examples
|