user
Browse files
app.py
CHANGED
@@ -489,11 +489,17 @@ with gr.Blocks(title="ASR Text Correction Leaderboard") as demo:
|
|
489 |
with gr.Row():
|
490 |
submit_btn = gr.Button("Submit Results")
|
491 |
|
492 |
-
def submit_method(name,
|
493 |
if not name:
|
494 |
return "Please enter a method name", leaderboard
|
495 |
|
496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
if success:
|
498 |
updated_df, _ = create_leaderboard()
|
499 |
return "Method added successfully!", updated_df
|
@@ -505,7 +511,6 @@ with gr.Blocks(title="ASR Text Correction Leaderboard") as demo:
|
|
505 |
return updated_df
|
506 |
|
507 |
# Connect buttons to functions
|
508 |
-
submit_args = [method_name] + list(source_inputs.values())
|
509 |
submit_btn.click(
|
510 |
submit_method,
|
511 |
inputs=[method_name] + list(source_inputs.values()),
|
@@ -514,5 +519,36 @@ with gr.Blocks(title="ASR Text Correction Leaderboard") as demo:
|
|
514 |
|
515 |
refresh_btn.click(refresh_and_report, outputs=[leaderboard])
|
516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
if __name__ == "__main__":
|
518 |
demo.launch()
|
|
|
489 |
with gr.Row():
|
490 |
submit_btn = gr.Button("Submit Results")
|
491 |
|
492 |
+
def submit_method(name, *args):
|
493 |
if not name:
|
494 |
return "Please enter a method name", leaderboard
|
495 |
|
496 |
+
# Convert args to a dictionary of source:value pairs
|
497 |
+
values = {}
|
498 |
+
for i, source in enumerate(all_sources):
|
499 |
+
if i < len(args):
|
500 |
+
values[source] = args[i]
|
501 |
+
|
502 |
+
success = add_user_method(name, **values)
|
503 |
if success:
|
504 |
updated_df, _ = create_leaderboard()
|
505 |
return "Method added successfully!", updated_df
|
|
|
511 |
return updated_df
|
512 |
|
513 |
# Connect buttons to functions
|
|
|
514 |
submit_btn.click(
|
515 |
submit_method,
|
516 |
inputs=[method_name] + list(source_inputs.values()),
|
|
|
519 |
|
520 |
refresh_btn.click(refresh_and_report, outputs=[leaderboard])
|
521 |
|
522 |
+
# Add a new method to the leaderboard
|
523 |
+
def add_user_method(name, **values):
|
524 |
+
# Create a new method entry
|
525 |
+
method = {"name": name}
|
526 |
+
|
527 |
+
# Add values for each source
|
528 |
+
for source, value in values.items():
|
529 |
+
if value and value.strip():
|
530 |
+
try:
|
531 |
+
# Convert to float and ensure it's a percentage
|
532 |
+
float_value = float(value)
|
533 |
+
# Store as decimal (divide by 100 if it's a percentage greater than 1)
|
534 |
+
method[source] = float_value / 100 if float_value > 1 else float_value
|
535 |
+
except ValueError:
|
536 |
+
# Skip invalid values
|
537 |
+
continue
|
538 |
+
|
539 |
+
# Calculate overall average if we have values
|
540 |
+
if len(method) > 1: # More than just the name
|
541 |
+
values_list = [v for k, v in method.items() if k != "name" and isinstance(v, (int, float))]
|
542 |
+
if values_list:
|
543 |
+
method["OVERALL"] = np.mean(values_list)
|
544 |
+
|
545 |
+
# Add to user methods
|
546 |
+
user_methods.append(method)
|
547 |
+
|
548 |
+
# Save to file
|
549 |
+
save_user_methods()
|
550 |
+
|
551 |
+
return True
|
552 |
+
|
553 |
if __name__ == "__main__":
|
554 |
demo.launch()
|