Commit
·
1c7ff5f
1
Parent(s):
04e4741
moved all constants + added status for uploaded tresults
Browse files
app.py
CHANGED
@@ -6,51 +6,12 @@ from utils import (
|
|
6 |
create_html_image,
|
7 |
)
|
8 |
import os
|
9 |
-
from datasets import load_dataset
|
10 |
import gradio as gr
|
11 |
|
|
|
|
|
12 |
if __name__ == "__main__":
|
13 |
|
14 |
-
# Evaluation dataset path
|
15 |
-
DATA_PATH = "atlasia/Arabic-LID-Leaderboard"
|
16 |
-
|
17 |
-
# All Metrics
|
18 |
-
metrics = [
|
19 |
-
'f1_score',
|
20 |
-
'precision',
|
21 |
-
'recall',
|
22 |
-
'specificity',
|
23 |
-
'false_positive_rate',
|
24 |
-
'false_negative_rate',
|
25 |
-
'negative_predictive_value',
|
26 |
-
'n_test_samples',
|
27 |
-
]
|
28 |
-
# Default metrics to display
|
29 |
-
default_metrics = [
|
30 |
-
'f1_score',
|
31 |
-
'precision',
|
32 |
-
'recall',
|
33 |
-
'false_positive_rate',
|
34 |
-
'false_negative_rate'
|
35 |
-
]
|
36 |
-
# default language to display
|
37 |
-
default_languages = [
|
38 |
-
'Morocco',
|
39 |
-
'MSA',
|
40 |
-
'Egypt',
|
41 |
-
'Algeria',
|
42 |
-
'Tunisia',
|
43 |
-
'Levantine',
|
44 |
-
]
|
45 |
-
|
46 |
-
# Load test dataset
|
47 |
-
test_dataset = load_dataset(DATA_PATH, split='test')
|
48 |
-
|
49 |
-
# Supported dialects
|
50 |
-
all_target_languages = list(test_dataset.unique("dialect"))
|
51 |
-
supported_dialects = all_target_languages + ['All']
|
52 |
-
languages_to_display_one_vs_all = all_target_languages # everything except All
|
53 |
-
|
54 |
with gr.Blocks() as app:
|
55 |
base_path = os.path.dirname(__file__)
|
56 |
local_image_path = os.path.join(base_path, 'open_arabic_lid_arena.png')
|
@@ -58,8 +19,8 @@ if __name__ == "__main__":
|
|
58 |
gr.HTML(create_html_image(local_image_path))
|
59 |
gr.Markdown("# 🏅 Open Arabic Dialect Identification Leaderboard")
|
60 |
|
61 |
-
#
|
62 |
-
with gr.Tab("
|
63 |
gr.Markdown("""
|
64 |
Complete leaderboard across multiple arabic dialects.
|
65 |
Compare the performance of different models across various metrics such as FNR, FPR, and other clasical metrics.
|
@@ -97,13 +58,13 @@ if __name__ == "__main__":
|
|
97 |
Let's work together to improve Arabic dialect identification! 🚀
|
98 |
""")
|
99 |
|
100 |
-
#
|
101 |
-
with gr.Tab("One-vs-All leaderboard"
|
102 |
|
103 |
gr.Markdown("""
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
showing **how often it misclassifies other dialects as the target dialect**.
|
108 |
"""
|
109 |
)
|
@@ -138,8 +99,8 @@ if __name__ == "__main__":
|
|
138 |
model_path = gr.Textbox(label="Model Path", placeholder='path/to/model')
|
139 |
model_path_bin = gr.Textbox(label=".bin filename", placeholder='model.bin')
|
140 |
gr.Markdown("### **⚠️ To ensure correct results, tick this when the model's labels are the iso_codes**")
|
141 |
-
use_mapping = gr.Checkbox(label="Does not map to country")
|
142 |
-
eval_button = gr.Button("Evaluate", value=False)
|
143 |
|
144 |
# Status message area
|
145 |
status_message = gr.Markdown(value="")
|
@@ -160,7 +121,7 @@ if __name__ == "__main__":
|
|
160 |
model = ... # Load your model here
|
161 |
|
162 |
# Load evaluation benchmark
|
163 |
-
eval_dataset = load_dataset("atlasia/
|
164 |
|
165 |
# Predict labels using your model
|
166 |
eval_dataset['preds'] = eval_dataset['text'].apply(lambda text: predict_label(text, model)) # predict_label is a function that you need to define for your model
|
@@ -182,7 +143,15 @@ if __name__ == "__main__":
|
|
182 |
uploaded_model_name = gr.Textbox(label="Model name", placeholder='Your model/team name')
|
183 |
file = gr.File(label="Upload your results")
|
184 |
upload_button = gr.Button("Upload")
|
185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
186 |
|
187 |
# Update multilangual table when any input changes
|
188 |
country_selector.change(
|
|
|
6 |
create_html_image,
|
7 |
)
|
8 |
import os
|
|
|
9 |
import gradio as gr
|
10 |
|
11 |
+
from constants import *
|
12 |
+
|
13 |
if __name__ == "__main__":
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
with gr.Blocks() as app:
|
16 |
base_path = os.path.dirname(__file__)
|
17 |
local_image_path = os.path.join(base_path, 'open_arabic_lid_arena.png')
|
|
|
19 |
gr.HTML(create_html_image(local_image_path))
|
20 |
gr.Markdown("# 🏅 Open Arabic Dialect Identification Leaderboard")
|
21 |
|
22 |
+
# Multi-dialects leaderboard
|
23 |
+
with gr.Tab("Multi-dialects model leaderboard"):
|
24 |
gr.Markdown("""
|
25 |
Complete leaderboard across multiple arabic dialects.
|
26 |
Compare the performance of different models across various metrics such as FNR, FPR, and other clasical metrics.
|
|
|
58 |
Let's work together to improve Arabic dialect identification! 🚀
|
59 |
""")
|
60 |
|
61 |
+
# Dialect confusion leaderboard
|
62 |
+
with gr.Tab("Dialect confusion leaderboard"): # use to be "One-vs-All leaderboard"
|
63 |
|
64 |
gr.Markdown("""
|
65 |
+
Detailed analysis of how well models distinguish specific dialects from others.
|
66 |
+
For each target dialect, see how often models incorrectly classify other dialects as the target.
|
67 |
+
Lower `false_positive_rate` indicate better ability to identify the true dialect by
|
68 |
showing **how often it misclassifies other dialects as the target dialect**.
|
69 |
"""
|
70 |
)
|
|
|
99 |
model_path = gr.Textbox(label="Model Path", placeholder='path/to/model')
|
100 |
model_path_bin = gr.Textbox(label=".bin filename", placeholder='model.bin')
|
101 |
gr.Markdown("### **⚠️ To ensure correct results, tick this when the model's labels are the iso_codes**")
|
102 |
+
use_mapping = gr.Checkbox(label="Does not map to country", value=True) # Initially enabled
|
103 |
+
eval_button = gr.Button("Evaluate", value=False) # Initially disabled
|
104 |
|
105 |
# Status message area
|
106 |
status_message = gr.Markdown(value="")
|
|
|
121 |
model = ... # Load your model here
|
122 |
|
123 |
# Load evaluation benchmark
|
124 |
+
eval_dataset = load_dataset("atlasia/Arabic-LID-Leaderboard", split='test').to_pandas() # do not change this line :)
|
125 |
|
126 |
# Predict labels using your model
|
127 |
eval_dataset['preds'] = eval_dataset['text'].apply(lambda text: predict_label(text, model)) # predict_label is a function that you need to define for your model
|
|
|
143 |
uploaded_model_name = gr.Textbox(label="Model name", placeholder='Your model/team name')
|
144 |
file = gr.File(label="Upload your results")
|
145 |
upload_button = gr.Button("Upload")
|
146 |
+
|
147 |
+
# Status message area
|
148 |
+
status_message = gr.Markdown(value="")
|
149 |
+
def update_status_message():
|
150 |
+
return "### **⚠️Evaluating... Please wait...**"
|
151 |
+
|
152 |
+
upload_button.click(update_status_message, outputs=[status_message])
|
153 |
+
|
154 |
+
upload_button.click(process_results_file, inputs=[file, uploaded_model_name], outputs=[leaderboard_table, status_message])
|
155 |
|
156 |
# Update multilangual table when any input changes
|
157 |
country_selector.change(
|