Spaces:
Sleeping
Sleeping
ZeroCommand
commited on
Commit
·
983e75b
1
Parent(s):
a2a18b3
change textbox to dropdown
Browse files
app_text_classification.py
CHANGED
@@ -19,7 +19,6 @@ MAX_LABELS = 40
|
|
19 |
MAX_FEATURES = 20
|
20 |
|
21 |
EXAMPLE_MODEL_ID = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
22 |
-
EXAMPLE_DATA_ID = "tweet_eval"
|
23 |
CONFIG_PATH = "./config.yaml"
|
24 |
|
25 |
|
@@ -36,11 +35,11 @@ def get_demo():
|
|
36 |
)
|
37 |
|
38 |
with gr.Column():
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
label="Hugging Face Dataset id",
|
43 |
-
placeholder=EXAMPLE_DATA_ID + " (press enter to confirm)",
|
44 |
)
|
45 |
|
46 |
with gr.Row():
|
@@ -154,9 +153,9 @@ def get_demo():
|
|
154 |
)
|
155 |
|
156 |
gr.on(
|
157 |
-
triggers=[model_id_input.change
|
158 |
fn=get_related_datasets_from_leaderboard,
|
159 |
-
inputs=[model_id_input
|
160 |
outputs=[dataset_id_input],
|
161 |
)
|
162 |
|
|
|
19 |
MAX_FEATURES = 20
|
20 |
|
21 |
EXAMPLE_MODEL_ID = "cardiffnlp/twitter-roberta-base-sentiment-latest"
|
|
|
22 |
CONFIG_PATH = "./config.yaml"
|
23 |
|
24 |
|
|
|
35 |
)
|
36 |
|
37 |
with gr.Column():
|
38 |
+
dataset_id_input = gr.Dropdown(
|
39 |
+
choices=[],
|
40 |
+
value="",
|
41 |
+
allow_custom_value=True,
|
42 |
label="Hugging Face Dataset id",
|
|
|
43 |
)
|
44 |
|
45 |
with gr.Row():
|
|
|
153 |
)
|
154 |
|
155 |
gr.on(
|
156 |
+
triggers=[model_id_input.change],
|
157 |
fn=get_related_datasets_from_leaderboard,
|
158 |
+
inputs=[model_id_input],
|
159 |
outputs=[dataset_id_input],
|
160 |
)
|
161 |
|
text_classification_ui_helpers.py
CHANGED
@@ -43,17 +43,13 @@ HF_GSK_HUB_HF_TOKEN = "GSK_HF_TOKEN"
|
|
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
|
47 |
-
if not rec_dataset:
|
48 |
-
return gr.update()
|
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.
|
56 |
-
return gr.
|
57 |
|
58 |
|
59 |
logger = logging.getLogger(__file__)
|
|
|
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):
|
|
|
|
|
47 |
records = leaderboard.records
|
48 |
model_records = records[records["model_id"] == model_id]
|
|
|
49 |
datasets_unique = model_records["dataset_id"].unique()
|
|
|
50 |
if len(datasets_unique) == 0:
|
51 |
+
return gr.update()
|
52 |
+
return gr.update(choices=datasets_unique, value=datasets_unique[0])
|
53 |
|
54 |
|
55 |
logger = logging.getLogger(__file__)
|