Spaces:
Runtime error
Runtime error
Reduced global variables
Browse files
app.py
CHANGED
@@ -291,239 +291,243 @@ tr.row_odd {
|
|
291 |
|
292 |
"""
|
293 |
|
294 |
-
|
295 |
-
gr.
|
|
|
296 |
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
],
|
331 |
-
column_widths=["150px"],
|
332 |
-
datatype="markdown",
|
333 |
-
label="Descriptions of the tasks",
|
334 |
-
visible=False,
|
335 |
-
interactive=False,
|
336 |
-
elem_classes="leaderboard-table-legend",
|
337 |
-
)
|
338 |
-
|
339 |
-
with gr.Row():
|
340 |
-
tournament_results_title = gr.Markdown(
|
341 |
-
value="## Tournament results for selected model",
|
342 |
-
visible=False,
|
343 |
-
)
|
344 |
-
|
345 |
-
with gr.Row():
|
346 |
-
tournament_results_dropdown = gr.Dropdown(
|
347 |
-
value=None,
|
348 |
-
choices=submission_ids_and_titles,
|
349 |
-
label="Select model",
|
350 |
-
visible=False,
|
351 |
-
interactive=True,
|
352 |
)
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
elem_classes="leaderboard-table-model-details",
|
362 |
)
|
|
|
|
|
|
|
363 |
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
tournament_results_dropdown,
|
369 |
-
],
|
370 |
-
outputs=[
|
371 |
-
leaderboard_table,
|
372 |
-
leaderboard_table_legend,
|
373 |
-
tournament_results_title,
|
374 |
-
tournament_results_dropdown,
|
375 |
-
model_tournament_results_table,
|
376 |
-
],
|
377 |
-
)
|
378 |
-
|
379 |
-
tournament_results_dropdown.change(
|
380 |
-
fn=fetch_model_tournament_results_table,
|
381 |
-
inputs=[
|
382 |
-
tournament_results_dropdown,
|
383 |
-
category_of_tasks,
|
384 |
-
],
|
385 |
-
outputs=model_tournament_results_table,
|
386 |
)
|
387 |
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
detail_dropdown = gr.Dropdown(
|
392 |
-
choices=submission_ids_and_titles,
|
393 |
-
label="Select model",
|
394 |
-
interactive=True,
|
395 |
-
)
|
396 |
-
|
397 |
-
with gr.Row():
|
398 |
-
model_description = gr.Text(value='', label='Model description', visible=False, interactive=False)
|
399 |
-
model_url = gr.Text(value='', label='Model url', visible=False, interactive=False)
|
400 |
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
424 |
)
|
425 |
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
value=0,
|
430 |
-
step=1,
|
431 |
-
)
|
432 |
-
submission_inputs["precision"] = gr.Dropdown(
|
433 |
-
label="Precision",
|
434 |
-
choices=("float32", "bfloat32", "float16", "bfloat16", "8bit", "4bit"),
|
435 |
)
|
436 |
-
submission_inputs["description"] = gr.Textbox(label='Description', type='text')
|
437 |
-
submission_inputs["link_to_model"] = gr.Textbox(label='Link to model', type='text')
|
438 |
-
|
439 |
-
submission_inputs["submission_file"] = gr.File(label='Upload your results', type='filepath')
|
440 |
-
|
441 |
-
pre_submission_btn = gr.Button(value='Pre-submit model', interactive=True)
|
442 |
|
443 |
-
|
444 |
-
|
445 |
-
visible=False
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
inputs=list(submission_inputs.values()),
|
469 |
-
outputs=[
|
470 |
-
pre_submission_btn,
|
471 |
-
submit_prompt,
|
472 |
-
submission_btn_yes,
|
473 |
-
submission_btn_no,
|
474 |
-
pre_submit_info,
|
475 |
-
pre_submit_table,
|
476 |
-
],
|
477 |
-
)
|
478 |
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
|
518 |
-
main
|
519 |
-
on_application_load,
|
520 |
-
inputs=None,
|
521 |
-
outputs=[
|
522 |
-
leaderboard_table,
|
523 |
-
detail_dropdown,
|
524 |
-
category_of_tasks,
|
525 |
-
tournament_results_dropdown,
|
526 |
-
]
|
527 |
-
)
|
528 |
|
529 |
-
|
|
|
|
291 |
|
292 |
"""
|
293 |
|
294 |
+
def gradio_app():
|
295 |
+
with gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css=custom_css) as main:
|
296 |
+
gr.Markdown(HEADER_MARKDOWN)
|
297 |
|
298 |
+
with gr.Tabs():
|
299 |
+
with leaderboard_server.var_lock.ro:
|
300 |
+
submission_ids_and_titles = get_submission_ids_and_titles()
|
301 |
+
|
302 |
+
with gr.TabItem('Leaderboard'):
|
303 |
+
with gr.Column():
|
304 |
+
gr.Markdown(LEADERBOARD_TAB_TITLE_MARKDOWN)
|
305 |
+
|
306 |
+
with gr.Row():
|
307 |
+
category_of_tasks = gr.Dropdown(
|
308 |
+
choices=[leaderboard_server.TASKS_CATEGORY_OVERALL] + sorted(leaderboard_server.TASKS_CATEGORIES),
|
309 |
+
value=leaderboard_server.TASKS_CATEGORY_OVERALL,
|
310 |
+
label="Category of benchmarks",
|
311 |
+
interactive=True,
|
312 |
+
)
|
313 |
+
|
314 |
+
with gr.Row():
|
315 |
+
leaderboard_table = gr.DataFrame(
|
316 |
+
leaderboard_server.get_leaderboard(category=leaderboard_server.TASKS_CATEGORY_OVERALL),
|
317 |
+
interactive=False,
|
318 |
+
label=None,
|
319 |
+
visible=True,
|
320 |
+
datatype="markdown",
|
321 |
+
elem_classes="leaderboard-table",
|
322 |
+
)
|
323 |
+
|
324 |
+
with gr.Row():
|
325 |
+
leaderboard_table_legend = gr.DataFrame(
|
326 |
+
value=None,
|
327 |
+
headers=[
|
328 |
+
"Abbr.", # "task abbreviation"
|
329 |
+
"Name",
|
330 |
+
"URL",
|
331 |
+
],
|
332 |
+
column_widths=["150px"],
|
333 |
+
datatype="markdown",
|
334 |
+
label="Descriptions of the tasks",
|
335 |
+
visible=False,
|
336 |
+
interactive=False,
|
337 |
+
elem_classes="leaderboard-table-legend",
|
338 |
+
)
|
339 |
+
|
340 |
+
with gr.Row():
|
341 |
+
tournament_results_title = gr.Markdown(
|
342 |
+
value="## Tournament results for selected model",
|
343 |
+
visible=False,
|
344 |
+
)
|
345 |
+
|
346 |
+
with gr.Row():
|
347 |
+
tournament_results_dropdown = gr.Dropdown(
|
348 |
+
value=None,
|
349 |
+
choices=submission_ids_and_titles,
|
350 |
+
label="Select model",
|
351 |
+
visible=False,
|
352 |
+
interactive=True,
|
353 |
+
)
|
354 |
+
|
355 |
+
with gr.Row():
|
356 |
+
model_tournament_results_table = gr.DataFrame(
|
357 |
+
value=None,
|
358 |
+
datatype="markdown",
|
359 |
+
label="The model won against…",
|
360 |
+
visible=False,
|
361 |
+
interactive=False,
|
362 |
+
elem_classes="leaderboard-table-model-details",
|
363 |
+
)
|
364 |
+
|
365 |
+
category_of_tasks.change(
|
366 |
+
fn=change_leaderboard_category,
|
367 |
+
inputs=[
|
368 |
+
category_of_tasks,
|
369 |
+
tournament_results_dropdown,
|
370 |
+
],
|
371 |
+
outputs=[
|
372 |
+
leaderboard_table,
|
373 |
+
leaderboard_table_legend,
|
374 |
+
tournament_results_title,
|
375 |
+
tournament_results_dropdown,
|
376 |
+
model_tournament_results_table,
|
377 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
)
|
379 |
+
|
380 |
+
tournament_results_dropdown.change(
|
381 |
+
fn=fetch_model_tournament_results_table,
|
382 |
+
inputs=[
|
383 |
+
tournament_results_dropdown,
|
384 |
+
category_of_tasks,
|
385 |
+
],
|
386 |
+
outputs=model_tournament_results_table,
|
|
|
387 |
)
|
388 |
+
|
389 |
+
with gr.TabItem('Model details'):
|
390 |
+
gr.Markdown(MORE_DETAILS_MARKDOWN)
|
391 |
|
392 |
+
detail_dropdown = gr.Dropdown(
|
393 |
+
choices=submission_ids_and_titles,
|
394 |
+
label="Select model",
|
395 |
+
interactive=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
)
|
397 |
|
398 |
+
with gr.Row():
|
399 |
+
model_description = gr.Text(value='', label='Model description', visible=False, interactive=False)
|
400 |
+
model_url = gr.Text(value='', label='Model url', visible=False, interactive=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
|
402 |
+
detail_dropdown.change(
|
403 |
+
fn=fetch_model_detail,
|
404 |
+
inputs=[detail_dropdown],
|
405 |
+
outputs=[model_description, model_url],
|
406 |
+
)
|
407 |
|
408 |
+
with gr.TabItem('Submission'):
|
409 |
+
with gr.Column():
|
410 |
+
gr.Markdown(SUBMISSION_TAB_TITLE_MARKDOWN)
|
411 |
+
|
412 |
+
submission_inputs = dict.fromkeys(SUBMISSION_INPUTS)
|
413 |
+
|
414 |
+
with gr.Row():
|
415 |
+
submission_inputs["team_name"] = gr.Textbox(label='Team name', type='text')
|
416 |
+
submission_inputs["model_name"] = gr.Textbox(label='Model name', type='text')
|
417 |
+
submission_inputs["model_type"] = gr.Dropdown(
|
418 |
+
label="Model type",
|
419 |
+
choices=("chat", "pretrained", "ensemble"),
|
420 |
+
)
|
421 |
+
submission_inputs["parameters"] = gr.Number(
|
422 |
+
label='Parameters (B)',
|
423 |
+
value=0.01,
|
424 |
+
step=0.01,
|
425 |
+
)
|
426 |
+
|
427 |
+
with gr.Row():
|
428 |
+
submission_inputs["input_length"] = gr.Number(
|
429 |
+
label='Input length (# tokens)',
|
430 |
+
value=0,
|
431 |
+
step=1,
|
432 |
+
)
|
433 |
+
submission_inputs["precision"] = gr.Dropdown(
|
434 |
+
label="Precision",
|
435 |
+
choices=("float32", "bfloat32", "float16", "bfloat16", "8bit", "4bit"),
|
436 |
+
)
|
437 |
+
submission_inputs["description"] = gr.Textbox(label='Description', type='text')
|
438 |
+
submission_inputs["link_to_model"] = gr.Textbox(label='Link to model', type='text')
|
439 |
+
|
440 |
+
submission_inputs["submission_file"] = gr.File(label='Upload your results', type='filepath')
|
441 |
+
|
442 |
+
pre_submission_btn = gr.Button(value='Pre-submit model', interactive=True)
|
443 |
+
|
444 |
+
submit_prompt = gr.Markdown(
|
445 |
+
SUBMISSION_DETAILS_MARKDOWN,
|
446 |
+
visible=False
|
447 |
)
|
448 |
|
449 |
+
pre_submit_info = gr.Markdown(
|
450 |
+
RANKING_AFTER_SUBMISSION_MARKDOWN,
|
451 |
+
visible=False
|
|
|
|
|
|
|
|
|
|
|
|
|
452 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
454 |
+
pre_submit_table = gr.DataFrame(pd.DataFrame(), interactive=False, label=None, visible=False)
|
455 |
+
|
456 |
+
submission_btn_yes = gr.Button(value='Submit model', interactive=False, visible=False)
|
457 |
+
submission_btn_no = gr.Button(value='Reverse process', interactive=False, visible=False)
|
458 |
+
|
459 |
+
with Modal(visible=False) as modal_submit:
|
460 |
+
gr.Markdown(MODAL_SUBMIT_MARKDOWN)
|
461 |
+
modal_submit_yes = gr.Button("Yes", interactive=True)
|
462 |
+
modal_submit_no = gr.Button("No", interactive=True)
|
463 |
+
|
464 |
+
pre_submission_btn.click(
|
465 |
+
fn=on_submit_pressed,
|
466 |
+
outputs=[pre_submission_btn],
|
467 |
+
).then( # TODO: Zjistit proč to neběží konkurentně.
|
468 |
+
fn=process_submission,
|
469 |
+
inputs=list(submission_inputs.values()),
|
470 |
+
outputs=[
|
471 |
+
pre_submission_btn,
|
472 |
+
submit_prompt,
|
473 |
+
submission_btn_yes,
|
474 |
+
submission_btn_no,
|
475 |
+
pre_submit_info,
|
476 |
+
pre_submit_table,
|
477 |
+
],
|
478 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
|
480 |
+
submission_btn_yes.click(
|
481 |
+
fn=show_modal,
|
482 |
+
outputs=[modal_submit]
|
483 |
+
)
|
484 |
|
485 |
+
modal_submit_yes.click(
|
486 |
+
fn=submit_results,
|
487 |
+
outputs=[
|
488 |
+
pre_submission_btn,
|
489 |
+
submission_btn_yes,
|
490 |
+
submission_btn_no,
|
491 |
+
submit_prompt,
|
492 |
+
pre_submit_info,
|
493 |
+
pre_submit_table,
|
494 |
+
leaderboard_table,
|
495 |
+
modal_submit,
|
496 |
+
detail_dropdown,
|
497 |
+
category_of_tasks,
|
498 |
+
tournament_results_dropdown,
|
499 |
+
],
|
500 |
+
)
|
501 |
|
502 |
+
modal_submit_no.click(
|
503 |
+
fn=hide_modal,
|
504 |
+
outputs=[modal_submit]
|
505 |
+
)
|
506 |
|
507 |
+
submission_btn_no.click(
|
508 |
+
fn=erase_pre_submit,
|
509 |
+
outputs=[
|
510 |
+
pre_submission_btn,
|
511 |
+
submission_btn_yes,
|
512 |
+
submission_btn_no,
|
513 |
+
submit_prompt,
|
514 |
+
pre_submit_info,
|
515 |
+
pre_submit_table,
|
516 |
+
],
|
517 |
+
)
|
518 |
+
|
519 |
+
main.load(
|
520 |
+
on_application_load,
|
521 |
+
inputs=None,
|
522 |
+
outputs=[
|
523 |
+
leaderboard_table,
|
524 |
+
detail_dropdown,
|
525 |
+
category_of_tasks,
|
526 |
+
tournament_results_dropdown,
|
527 |
+
]
|
528 |
+
)
|
529 |
|
530 |
+
return main
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
531 |
|
532 |
+
app = gradio_app()
|
533 |
+
app.launch()
|