Update app.py
Browse files
app.py
CHANGED
@@ -431,41 +431,86 @@ with gr.Blocks(css=css_tech_theme) as demo:
|
|
431 |
# outputs=[eval_status, overall_accuracy_display],
|
432 |
# )
|
433 |
|
434 |
-
with gr.TabItem("π€ Submission"):
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
|
471 |
with gr.TabItem("π
Leaderboard"):
|
|
|
431 |
# outputs=[eval_status, overall_accuracy_display],
|
432 |
# )
|
433 |
|
434 |
+
# with gr.TabItem("π€ Submission"):
|
435 |
+
# with gr.Row():
|
436 |
+
# file_input = gr.File(label="Upload Prediction CSV", file_types=[".csv"], interactive=True)
|
437 |
+
# model_name_input = gr.Textbox(label="Model Name", placeholder="Enter your model name")
|
438 |
+
# with gr.Row():
|
439 |
+
# overall_accuracy_display = gr.Number(label="Overall Accuracy", interactive=False)
|
440 |
+
# eval_button = gr.Button("Evaluate")
|
441 |
+
# eval_status = gr.Textbox(label="Evaluation Status", interactive=False)
|
442 |
+
# submit_button = gr.Button("Prove and Submit to Leaderboard", visible=False) # Initially hidden
|
443 |
+
# def handle_evaluation(file, model_name):
|
444 |
+
# # Check if required inputs are provided
|
445 |
+
# if not file:
|
446 |
+
# return "Error: Please upload a prediction file.", 0, gr.update(visible=False)
|
447 |
+
# if not model_name or model_name.strip() == "":
|
448 |
+
# return "Error: Please enter a model name.", 0, gr.update(visible=False)
|
449 |
+
# # Perform evaluation
|
450 |
+
# status, leaderboard = evaluate_predictions(file, model_name, add_to_leaderboard=False)
|
451 |
+
# if leaderboard.empty:
|
452 |
+
# overall_accuracy = 0
|
453 |
+
# else:
|
454 |
+
# overall_accuracy = leaderboard.iloc[-1]["Overall Accuracy"]
|
455 |
+
# # Show the submit button after evaluation
|
456 |
+
# return status, overall_accuracy, gr.update(visible=True)
|
457 |
+
# def handle_submission(file, model_name):
|
458 |
+
# # Handle leaderboard submission
|
459 |
+
# status, _ = evaluate_predictions(file, model_name, add_to_leaderboard=True)
|
460 |
+
# return f"Submission to leaderboard completed: {status}"
|
461 |
+
# eval_button.click(
|
462 |
+
# handle_evaluation,
|
463 |
+
# inputs=[file_input, model_name_input],
|
464 |
+
# outputs=[eval_status, overall_accuracy_display, submit_button],)
|
465 |
+
# submit_button.click(
|
466 |
+
# handle_submission,
|
467 |
+
# inputs=[file_input, model_name_input],
|
468 |
+
# outputs=[eval_status],)
|
469 |
+
with gr.TabItem("π€ Submission"):
|
470 |
+
with gr.Markdown("""
|
471 |
+
<div class="submission-section">
|
472 |
+
<h2>Submit Your Predictions</h2>
|
473 |
+
<p>Upload your prediction file and provide your model name to evaluate and submit to the leaderboard.</p>
|
474 |
+
</div>
|
475 |
+
"""):
|
476 |
+
with gr.Row(elem_id="submission-fields"):
|
477 |
+
file_input = gr.File(label="Upload Prediction CSV", file_types=[".csv"], interactive=True)
|
478 |
+
model_name_input = gr.Textbox(label="Model Name", placeholder="Enter your model name")
|
479 |
+
with gr.Row(elem_id="submission-results"):
|
480 |
+
overall_accuracy_display = gr.Number(label="Overall Accuracy", interactive=False)
|
481 |
+
with gr.Row(elem_id="submission-buttons"):
|
482 |
+
eval_button = gr.Button("Evaluate")
|
483 |
+
submit_button = gr.Button("Prove and Submit to Leaderboard", visible=False)
|
484 |
+
eval_status = gr.Textbox(label="Evaluation Status", interactive=False)
|
485 |
+
def handle_evaluation(file, model_name):
|
486 |
+
# Check if required inputs are provided
|
487 |
+
if not file:
|
488 |
+
return "Error: Please upload a prediction file.", 0, gr.update(visible=False)
|
489 |
+
if not model_name or model_name.strip() == "":
|
490 |
+
return "Error: Please enter a model name.", 0, gr.update(visible=False)
|
491 |
+
# Perform evaluation
|
492 |
+
status, leaderboard = evaluate_predictions(file, model_name, add_to_leaderboard=False)
|
493 |
+
if leaderboard.empty:
|
494 |
+
overall_accuracy = 0
|
495 |
+
else:
|
496 |
+
overall_accuracy = leaderboard.iloc[-1]["Overall Accuracy"]
|
497 |
+
# Show the submit button after evaluation
|
498 |
+
return status, overall_accuracy, gr.update(visible=True)
|
499 |
+
def handle_submission(file, model_name):
|
500 |
+
# Handle leaderboard submission
|
501 |
+
status, _ = evaluate_predictions(file, model_name, add_to_leaderboard=True)
|
502 |
+
return f"Submission to leaderboard completed: {status}"
|
503 |
+
eval_button.click(
|
504 |
+
handle_evaluation,
|
505 |
+
inputs=[file_input, model_name_input],
|
506 |
+
outputs=[eval_status, overall_accuracy_display, submit_button],
|
507 |
+
)
|
508 |
+
submit_button.click(
|
509 |
+
handle_submission,
|
510 |
+
inputs=[file_input, model_name_input],
|
511 |
+
outputs=[eval_status],
|
512 |
+
)
|
513 |
+
|
514 |
|
515 |
|
516 |
with gr.TabItem("π
Leaderboard"):
|