Spaces:
Sleeping
Sleeping
Commit
•
4045dfc
1
Parent(s):
125b0cb
add suggested dataset
Browse files- app_leaderboard.py +4 -1
- app_text_classification.py +15 -4
- leaderboard.py +3 -0
- text_classification_ui_helpers.py +12 -0
app_leaderboard.py
CHANGED
@@ -7,6 +7,7 @@ from fetch_utils import (check_dataset_and_get_config,
|
|
7 |
check_dataset_and_get_split)
|
8 |
from text_classification_ui_helpers import LEADERBOARD
|
9 |
|
|
|
10 |
|
11 |
def get_records_from_dataset_repo(dataset_id):
|
12 |
dataset_config = check_dataset_and_get_config(dataset_id)
|
@@ -74,7 +75,8 @@ def get_display_df(df):
|
|
74 |
|
75 |
|
76 |
def get_demo():
|
77 |
-
records = get_records_from_dataset_repo(LEADERBOARD)
|
|
|
78 |
|
79 |
model_ids = get_model_ids(records)
|
80 |
dataset_ids = get_dataset_ids(records)
|
@@ -124,6 +126,7 @@ def get_demo():
|
|
124 |
outputs=[leaderboard_df],
|
125 |
)
|
126 |
def filter_table(model_id, dataset_id, columns, task):
|
|
|
127 |
# filter the table based on task
|
128 |
df = records[(records["task"] == task)]
|
129 |
# filter the table based on the model_id and dataset_id
|
|
|
7 |
check_dataset_and_get_split)
|
8 |
from text_classification_ui_helpers import LEADERBOARD
|
9 |
|
10 |
+
import leaderboard
|
11 |
|
12 |
def get_records_from_dataset_repo(dataset_id):
|
13 |
dataset_config = check_dataset_and_get_config(dataset_id)
|
|
|
75 |
|
76 |
|
77 |
def get_demo():
|
78 |
+
leaderboard.records = get_records_from_dataset_repo(LEADERBOARD)
|
79 |
+
records = leaderboard.records
|
80 |
|
81 |
model_ids = get_model_ids(records)
|
82 |
dataset_ids = get_dataset_ids(records)
|
|
|
126 |
outputs=[leaderboard_df],
|
127 |
)
|
128 |
def filter_table(model_id, dataset_id, columns, task):
|
129 |
+
records = leaderboard.records
|
130 |
# filter the table based on task
|
131 |
df = records[(records["task"] == task)]
|
132 |
# filter the table based on the model_id and dataset_id
|
app_text_classification.py
CHANGED
@@ -4,6 +4,7 @@ import gradio as gr
|
|
4 |
|
5 |
from io_utils import get_logs_file, read_scanners, write_scanners
|
6 |
from text_classification_ui_helpers import (
|
|
|
7 |
align_columns_and_show_prediction,
|
8 |
check_dataset,
|
9 |
deselect_run_inference,
|
@@ -34,10 +35,13 @@ def get_demo():
|
|
34 |
placeholder=EXAMPLE_MODEL_ID + " (press enter to confirm)",
|
35 |
)
|
36 |
|
37 |
-
|
38 |
-
label="
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
with gr.Row():
|
43 |
dataset_config_input = gr.Dropdown(label="Dataset Config", visible=False, allow_custom_value=True)
|
@@ -149,6 +153,13 @@ def get_demo():
|
|
149 |
outputs=[inference_token, run_inference],
|
150 |
)
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
gr.on(
|
153 |
triggers=[label.change for label in column_mappings],
|
154 |
fn=write_column_mapping_to_config,
|
|
|
4 |
|
5 |
from io_utils import get_logs_file, read_scanners, write_scanners
|
6 |
from text_classification_ui_helpers import (
|
7 |
+
get_related_datasets_from_leaderboard,
|
8 |
align_columns_and_show_prediction,
|
9 |
check_dataset,
|
10 |
deselect_run_inference,
|
|
|
35 |
placeholder=EXAMPLE_MODEL_ID + " (press enter to confirm)",
|
36 |
)
|
37 |
|
38 |
+
with gr.Column():
|
39 |
+
no_dataset_checkbox = gr.Checkbox(label="Recommend a dataset", value=False, visible=True)
|
40 |
+
|
41 |
+
dataset_id_input = gr.Textbox(
|
42 |
+
label="Hugging Face Dataset id",
|
43 |
+
placeholder=EXAMPLE_DATA_ID + " (press enter to confirm)",
|
44 |
+
)
|
45 |
|
46 |
with gr.Row():
|
47 |
dataset_config_input = gr.Dropdown(label="Dataset Config", visible=False, allow_custom_value=True)
|
|
|
153 |
outputs=[inference_token, run_inference],
|
154 |
)
|
155 |
|
156 |
+
gr.on(
|
157 |
+
triggers=[model_id_input.change, no_dataset_checkbox.change],
|
158 |
+
fn=get_related_datasets_from_leaderboard,
|
159 |
+
inputs=[model_id_input, no_dataset_checkbox],
|
160 |
+
outputs=[dataset_id_input],
|
161 |
+
)
|
162 |
+
|
163 |
gr.on(
|
164 |
triggers=[label.change for label in column_mappings],
|
165 |
fn=write_column_mapping_to_config,
|
leaderboard.py
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
|
3 |
+
records = pd.DataFrame()
|
text_classification_ui_helpers.py
CHANGED
@@ -4,6 +4,7 @@ import logging
|
|
4 |
import os
|
5 |
import threading
|
6 |
import uuid
|
|
|
7 |
|
8 |
import datasets
|
9 |
import gradio as gr
|
@@ -42,6 +43,17 @@ HF_GSK_HUB_HF_TOKEN = "GSK_HF_TOKEN"
|
|
42 |
HF_GSK_HUB_UNLOCK_TOKEN = "GSK_HUB_UNLOCK_TOKEN"
|
43 |
|
44 |
LEADERBOARD = "giskard-bot/evaluator-leaderboard"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
logger = logging.getLogger(__file__)
|
|
|
4 |
import os
|
5 |
import threading
|
6 |
import uuid
|
7 |
+
import leaderboard
|
8 |
|
9 |
import datasets
|
10 |
import gradio as gr
|
|
|
43 |
HF_GSK_HUB_UNLOCK_TOKEN = "GSK_HUB_UNLOCK_TOKEN"
|
44 |
|
45 |
LEADERBOARD = "giskard-bot/evaluator-leaderboard"
|
46 |
+
def get_related_datasets_from_leaderboard(model_id, rec_dataset=False):
|
47 |
+
if not rec_dataset:
|
48 |
+
return gr.Textbox(placeholder="Please enter your dataset id.", visible=True)
|
49 |
+
records = leaderboard.records
|
50 |
+
model_records = records[records["model_id"] == model_id]
|
51 |
+
print(model_records)
|
52 |
+
datasets_unique = model_records["dataset_id"].unique()
|
53 |
+
print(datasets_unique)
|
54 |
+
if len(datasets_unique) == 0:
|
55 |
+
return gr.Textbox(placeholder="Sorry, we don't have recommendations for this model yet.", visible=True)
|
56 |
+
return gr.Textbox(label="Recommended Datasets", value=datasets_unique[0], visible=True)
|
57 |
|
58 |
|
59 |
logger = logging.getLogger(__file__)
|