Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,9 @@ def normalize_text(text):
|
|
31 |
return text
|
32 |
|
33 |
def calculate_metrics(predictions_df):
|
34 |
-
"""
|
|
|
|
|
35 |
results = []
|
36 |
for _, row in predictions_df.iterrows():
|
37 |
id_val = row["id"]
|
@@ -58,7 +60,9 @@ def calculate_metrics(predictions_df):
|
|
58 |
return avg_wer, avg_cer, results
|
59 |
|
60 |
def process_submission(submitter_name, csv_file):
|
61 |
-
"""
|
|
|
|
|
62 |
try:
|
63 |
df = pd.read_csv(csv_file)
|
64 |
if len(df) == 0:
|
@@ -105,7 +109,9 @@ def process_submission(submitter_name, csv_file):
|
|
105 |
return f"Submission failed: An error occurred while processing your file - {str(e)}", None
|
106 |
|
107 |
def load_and_format_leaderboard():
|
108 |
-
"""
|
|
|
|
|
109 |
if os.path.exists(leaderboard_file):
|
110 |
leaderboard = pd.read_csv(leaderboard_file)
|
111 |
leaderboard["WER"] = leaderboard["WER"].apply(lambda x: f"{x:.4f}")
|
|
|
31 |
return text
|
32 |
|
33 |
def calculate_metrics(predictions_df):
|
34 |
+
"""
|
35 |
+
Calculate WER and CER for predictions against the reference dataset.
|
36 |
+
"""
|
37 |
results = []
|
38 |
for _, row in predictions_df.iterrows():
|
39 |
id_val = row["id"]
|
|
|
60 |
return avg_wer, avg_cer, results
|
61 |
|
62 |
def process_submission(submitter_name, csv_file):
|
63 |
+
"""
|
64 |
+
Process the uploaded CSV, calculate metrics, and update the leaderboard.
|
65 |
+
"""
|
66 |
try:
|
67 |
df = pd.read_csv(csv_file)
|
68 |
if len(df) == 0:
|
|
|
109 |
return f"Submission failed: An error occurred while processing your file - {str(e)}", None
|
110 |
|
111 |
def load_and_format_leaderboard():
|
112 |
+
"""
|
113 |
+
Load the leaderboard and format WER/CER for display.
|
114 |
+
"""
|
115 |
if os.path.exists(leaderboard_file):
|
116 |
leaderboard = pd.read_csv(leaderboard_file)
|
117 |
leaderboard["WER"] = leaderboard["WER"].apply(lambda x: f"{x:.4f}")
|