Update app.py
Browse files
app.py
CHANGED
@@ -10,78 +10,59 @@ LAST_UPDATED = "OCT 2nd 2024"
|
|
10 |
|
11 |
column_names = {
|
12 |
"MODEL": "Model",
|
13 |
-
"
|
14 |
-
"
|
15 |
-
"AMI WER": "AMI",
|
16 |
-
"Earnings22 WER": "Earnings22",
|
17 |
-
"Gigaspeech WER": "Gigaspeech",
|
18 |
-
"LS Clean WER": "LS Clean",
|
19 |
-
"LS Other WER": "LS Other",
|
20 |
-
"SPGISpeech WER": "SPGISpeech",
|
21 |
-
"Tedlium WER": "Tedlium",
|
22 |
-
"Voxpopuli WER": "Voxpopuli",
|
23 |
}
|
24 |
|
|
|
25 |
eval_queue_repo, requested_models, csv_results = load_all_info_from_dataset_hub()
|
26 |
|
27 |
if not csv_results.exists():
|
28 |
raise Exception(f"CSV file {csv_results} does not exist locally")
|
29 |
-
|
30 |
-
#
|
31 |
original_df = pd.read_csv(csv_results)
|
32 |
|
33 |
-
#
|
34 |
def formatter(x):
|
35 |
if type(x) is str:
|
36 |
-
|
37 |
-
else:
|
38 |
-
|
39 |
-
return x
|
40 |
|
41 |
for col in original_df.columns:
|
42 |
if col == "model":
|
43 |
original_df[col] = original_df[col].apply(lambda x: x.replace(x, make_clickable_model(x)))
|
44 |
else:
|
45 |
-
original_df[col] = original_df[col].apply(formatter)
|
46 |
-
|
47 |
original_df.rename(columns=column_names, inplace=True)
|
48 |
-
original_df.sort_values(by='
|
49 |
|
50 |
COLS = [c.name for c in fields(AutoEvalColumn)]
|
51 |
TYPES = [c.type for c in fields(AutoEvalColumn)]
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
# Determine the selected checkboxes
|
57 |
-
dataset_selection = []
|
58 |
-
if chbcoco2017:
|
59 |
-
dataset_selection.append("ESB Datasets tests only")
|
60 |
-
|
61 |
-
if len(dataset_selection) == 0:
|
62 |
-
return styled_error("You need to select at least one dataset")
|
63 |
-
|
64 |
base_model_on_hub, error_msg = is_model_on_hub(model_text)
|
65 |
|
66 |
if not base_model_on_hub:
|
67 |
return styled_error(f"Base model '{model_text}' {error_msg}")
|
68 |
-
|
69 |
# Construct the output dictionary
|
70 |
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
71 |
-
required_datasets = ', '.join(dataset_selection)
|
72 |
eval_entry = {
|
73 |
"date": current_time,
|
74 |
"model": model_text,
|
75 |
-
"
|
76 |
}
|
77 |
-
|
78 |
-
# Prepare file path
|
79 |
DIR_OUTPUT_REQUESTS.mkdir(parents=True, exist_ok=True)
|
80 |
-
|
81 |
-
|
82 |
-
filename = model_text.replace("/","@") + "@@" + fn_datasets
|
83 |
if filename in requested_models:
|
84 |
-
return styled_error(f"A request for this model '{model_text}'
|
85 |
try:
|
86 |
filename_ext = filename + ".txt"
|
87 |
out_filepath = DIR_OUTPUT_REQUESTS / filename_ext
|
@@ -89,18 +70,18 @@ def request_model(model_text, chbcoco2017):
|
|
89 |
# Write the results to a text file
|
90 |
with open(out_filepath, "w") as f:
|
91 |
f.write(json.dumps(eval_entry))
|
92 |
-
|
93 |
upload_file(filename, out_filepath)
|
94 |
-
|
95 |
# Include file in the list of uploaded files
|
96 |
requested_models.append(filename)
|
97 |
-
|
98 |
# Remove the local file
|
99 |
out_filepath.unlink()
|
100 |
|
101 |
return styled_message("π€ Your request has been submitted and will be evaluated soon!</p>")
|
102 |
except Exception as e:
|
103 |
-
return styled_error(f"Error submitting request
|
104 |
|
105 |
with gr.Blocks() as demo:
|
106 |
gr.HTML(BANNER, elem_id="banner")
|
@@ -114,7 +95,7 @@ with gr.Blocks() as demo:
|
|
114 |
elem_id="leaderboard-table",
|
115 |
interactive=False,
|
116 |
visible=True,
|
117 |
-
|
118 |
|
119 |
with gr.TabItem("π Metrics", elem_id="od-benchmark-tab-table", id=1):
|
120 |
gr.Markdown(METRICS_TAB_TEXT, elem_classes="markdown-text")
|
@@ -122,20 +103,13 @@ with gr.Blocks() as demo:
|
|
122 |
with gr.TabItem("βοΈβ¨ Request a model here!", elem_id="od-benchmark-tab-table", id=2):
|
123 |
with gr.Column():
|
124 |
gr.Markdown("# βοΈβ¨ Request results for a new model here!", elem_classes="markdown-text")
|
125 |
-
|
126 |
-
gr.Markdown(
|
127 |
-
|
128 |
-
|
129 |
-
chb_coco2017 = gr.Checkbox(label="COCO validation 2017 dataset", visible=False, value=True, interactive=False)
|
130 |
-
with gr.Column():
|
131 |
-
mdw_submission_result = gr.Markdown()
|
132 |
-
btn_submitt = gr.Button(value="π Request")
|
133 |
-
btn_submitt.click(request_model,
|
134 |
-
[model_name_textbox, chb_coco2017],
|
135 |
-
mdw_submission_result)
|
136 |
|
137 |
gr.Markdown(f"Last updated on **{LAST_UPDATED}**", elem_classes="markdown-text")
|
138 |
-
|
139 |
with gr.Row():
|
140 |
with gr.Accordion("π Citation", open=False):
|
141 |
gr.Textbox(
|
|
|
10 |
|
11 |
column_names = {
|
12 |
"MODEL": "Model",
|
13 |
+
"WER": "WER β¬οΈ",
|
14 |
+
"CER": "CER β¬οΈ",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
|
17 |
+
# Load evaluation results
|
18 |
eval_queue_repo, requested_models, csv_results = load_all_info_from_dataset_hub()
|
19 |
|
20 |
if not csv_results.exists():
|
21 |
raise Exception(f"CSV file {csv_results} does not exist locally")
|
22 |
+
|
23 |
+
# Read CSV with data and parse columns
|
24 |
original_df = pd.read_csv(csv_results)
|
25 |
|
26 |
+
# Format the columns
|
27 |
def formatter(x):
|
28 |
if type(x) is str:
|
29 |
+
return x
|
30 |
+
else:
|
31 |
+
return round(x, 2)
|
|
|
32 |
|
33 |
for col in original_df.columns:
|
34 |
if col == "model":
|
35 |
original_df[col] = original_df[col].apply(lambda x: x.replace(x, make_clickable_model(x)))
|
36 |
else:
|
37 |
+
original_df[col] = original_df[col].apply(formatter)
|
38 |
+
|
39 |
original_df.rename(columns=column_names, inplace=True)
|
40 |
+
original_df.sort_values(by='WER β¬οΈ', inplace=True)
|
41 |
|
42 |
COLS = [c.name for c in fields(AutoEvalColumn)]
|
43 |
TYPES = [c.type for c in fields(AutoEvalColumn)]
|
44 |
|
45 |
+
def request_model(model_text):
|
46 |
+
# Check if the model exists on the Hub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
base_model_on_hub, error_msg = is_model_on_hub(model_text)
|
48 |
|
49 |
if not base_model_on_hub:
|
50 |
return styled_error(f"Base model '{model_text}' {error_msg}")
|
51 |
+
|
52 |
# Construct the output dictionary
|
53 |
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
|
54 |
eval_entry = {
|
55 |
"date": current_time,
|
56 |
"model": model_text,
|
57 |
+
"dataset": "vargha/common_voice_fa"
|
58 |
}
|
59 |
+
|
60 |
+
# Prepare file path
|
61 |
DIR_OUTPUT_REQUESTS.mkdir(parents=True, exist_ok=True)
|
62 |
+
|
63 |
+
filename = model_text.replace("/", "@")
|
|
|
64 |
if filename in requested_models:
|
65 |
+
return styled_error(f"A request for this model '{model_text}' was already made.")
|
66 |
try:
|
67 |
filename_ext = filename + ".txt"
|
68 |
out_filepath = DIR_OUTPUT_REQUESTS / filename_ext
|
|
|
70 |
# Write the results to a text file
|
71 |
with open(out_filepath, "w") as f:
|
72 |
f.write(json.dumps(eval_entry))
|
73 |
+
|
74 |
upload_file(filename, out_filepath)
|
75 |
+
|
76 |
# Include file in the list of uploaded files
|
77 |
requested_models.append(filename)
|
78 |
+
|
79 |
# Remove the local file
|
80 |
out_filepath.unlink()
|
81 |
|
82 |
return styled_message("π€ Your request has been submitted and will be evaluated soon!</p>")
|
83 |
except Exception as e:
|
84 |
+
return styled_error(f"Error submitting request: {e}")
|
85 |
|
86 |
with gr.Blocks() as demo:
|
87 |
gr.HTML(BANNER, elem_id="banner")
|
|
|
95 |
elem_id="leaderboard-table",
|
96 |
interactive=False,
|
97 |
visible=True,
|
98 |
+
)
|
99 |
|
100 |
with gr.TabItem("π Metrics", elem_id="od-benchmark-tab-table", id=1):
|
101 |
gr.Markdown(METRICS_TAB_TEXT, elem_classes="markdown-text")
|
|
|
103 |
with gr.TabItem("βοΈβ¨ Request a model here!", elem_id="od-benchmark-tab-table", id=2):
|
104 |
with gr.Column():
|
105 |
gr.Markdown("# βοΈβ¨ Request results for a new model here!", elem_classes="markdown-text")
|
106 |
+
model_name_textbox = gr.Textbox(label="Model name (user_name/model_name)")
|
107 |
+
mdw_submission_result = gr.Markdown()
|
108 |
+
btn_submit = gr.Button(value="π Request")
|
109 |
+
btn_submit.click(request_model, [model_name_textbox], mdw_submission_result)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
gr.Markdown(f"Last updated on **{LAST_UPDATED}**", elem_classes="markdown-text")
|
112 |
+
|
113 |
with gr.Row():
|
114 |
with gr.Accordion("π Citation", open=False):
|
115 |
gr.Textbox(
|