inoki-giskard commited on
Commit
5559b52
1 Parent(s): 053c12c

Add a loading status

Browse files
app_text_classification.py CHANGED
@@ -43,6 +43,10 @@ def get_demo():
43
  dataset_config_input = gr.Dropdown(label="Dataset Config", visible=False, allow_custom_value=True)
44
  dataset_split_input = gr.Dropdown(label="Dataset Split", visible=False, allow_custom_value=True)
45
 
 
 
 
 
46
  with gr.Row():
47
  example_btn = gr.Button(
48
  "Validate model & dataset",
@@ -51,8 +55,6 @@ def get_demo():
51
  interactive=False,
52
  )
53
 
54
- with gr.Row():
55
- first_line_ds = gr.DataFrame(label="Dataset preview", visible=False)
56
  with gr.Row():
57
  example_input = gr.HTML(visible=False)
58
  with gr.Row():
@@ -118,19 +120,19 @@ def get_demo():
118
  dataset_id_input.change(
119
  check_dataset,
120
  inputs=[dataset_id_input],
121
- outputs=[dataset_config_input, dataset_split_input, first_line_ds],
122
  )
123
 
124
  dataset_config_input.change(
125
  check_dataset,
126
  inputs=[dataset_id_input, dataset_config_input],
127
- outputs=[dataset_config_input, dataset_split_input, first_line_ds],
128
  )
129
 
130
  dataset_split_input.change(
131
  check_dataset,
132
  inputs=[dataset_id_input, dataset_config_input, dataset_split_input],
133
- outputs=[dataset_config_input, dataset_split_input, first_line_ds],
134
  )
135
 
136
  scanners.change(write_scanners, inputs=[scanners, uid_label])
@@ -180,7 +182,7 @@ def get_demo():
180
  dataset_config_input,
181
  dataset_split_input,
182
  ],
183
- outputs=[example_btn],
184
  )
185
 
186
  gr.on(
@@ -200,6 +202,7 @@ def get_demo():
200
  example_prediction,
201
  column_mapping_accordion,
202
  run_btn,
 
203
  *column_mappings,
204
  ],
205
  )
 
43
  dataset_config_input = gr.Dropdown(label="Dataset Config", visible=False, allow_custom_value=True)
44
  dataset_split_input = gr.Dropdown(label="Dataset Split", visible=False, allow_custom_value=True)
45
 
46
+ with gr.Row():
47
+ first_line_ds = gr.DataFrame(label="Dataset preview", visible=False)
48
+ with gr.Row():
49
+ loading_status = gr.HTML(visible=True)
50
  with gr.Row():
51
  example_btn = gr.Button(
52
  "Validate model & dataset",
 
55
  interactive=False,
56
  )
57
 
 
 
58
  with gr.Row():
59
  example_input = gr.HTML(visible=False)
60
  with gr.Row():
 
120
  dataset_id_input.change(
121
  check_dataset,
122
  inputs=[dataset_id_input],
123
+ outputs=[dataset_config_input, dataset_split_input, first_line_ds, loading_status],
124
  )
125
 
126
  dataset_config_input.change(
127
  check_dataset,
128
  inputs=[dataset_id_input, dataset_config_input],
129
+ outputs=[dataset_config_input, dataset_split_input, first_line_ds, loading_status],
130
  )
131
 
132
  dataset_split_input.change(
133
  check_dataset,
134
  inputs=[dataset_id_input, dataset_config_input, dataset_split_input],
135
+ outputs=[dataset_config_input, dataset_split_input, first_line_ds, loading_status],
136
  )
137
 
138
  scanners.change(write_scanners, inputs=[scanners, uid_label])
 
182
  dataset_config_input,
183
  dataset_split_input,
184
  ],
185
+ outputs=[example_btn, loading_status],
186
  )
187
 
188
  gr.on(
 
202
  example_prediction,
203
  column_mapping_accordion,
204
  run_btn,
205
+ loading_status,
206
  *column_mappings,
207
  ],
208
  )
text_classification_ui_helpers.py CHANGED
@@ -73,12 +73,14 @@ def check_dataset(dataset_id, dataset_config=None, dataset_split=None):
73
  gr.Dropdown(configs, value=configs[0], visible=True),
74
  gr.Dropdown(splits, value=splits[0], visible=True),
75
  gr.DataFrame(pd.DataFrame(), visible=False),
 
76
  )
77
  elif dataset_split == None:
78
  return (
79
  gr.Dropdown(configs, value=dataset_config, visible=True),
80
  gr.Dropdown(splits, value=splits[0], visible=True),
81
  gr.DataFrame(pd.DataFrame(), visible=False),
 
82
  )
83
 
84
  dataset_dict = datasets.load_dataset(dataset_id, dataset_config)
@@ -87,6 +89,7 @@ def check_dataset(dataset_id, dataset_config=None, dataset_split=None):
87
  gr.Dropdown(configs, value=dataset_config, visible=True),
88
  gr.Dropdown(splits, value=dataset_split, visible=True),
89
  gr.DataFrame(dataframe, visible=True),
 
90
  )
91
 
92
 
@@ -192,15 +195,15 @@ def precheck_model_ds_enable_example_btn(
192
  ppl = check_model(model_id)
193
  if ppl is None or not isinstance(ppl, TextClassificationPipeline):
194
  gr.Warning("Please check your model.")
195
- return gr.update(interactive=False)
196
  ds_labels, ds_features = get_labels_and_features_from_dataset(
197
  dataset_id, dataset_config, dataset_split
198
  )
199
  if not isinstance(ds_labels, list) or not isinstance(ds_features, list):
200
  gr.Warning(CHECK_CONFIG_OR_SPLIT_RAW)
201
- return gr.update(interactive=False)
202
 
203
- return gr.update(interactive=True)
204
 
205
 
206
  def align_columns_and_show_prediction(
@@ -214,6 +217,7 @@ def align_columns_and_show_prediction(
214
  gr.update(visible=False),
215
  gr.update(visible=False, open=False),
216
  gr.update(interactive=False),
 
217
  *[gr.update(visible=False) for _ in range(MAX_LABELS + MAX_FEATURES)],
218
  )
219
 
@@ -243,6 +247,7 @@ def align_columns_and_show_prediction(
243
  gr.update(visible=False),
244
  gr.update(visible=False, open=False),
245
  gr.update(interactive=False),
 
246
  *dropdown_placement,
247
  )
248
 
@@ -264,6 +269,7 @@ def align_columns_and_show_prediction(
264
  gr.update(visible=False),
265
  gr.update(visible=True, open=True),
266
  gr.update(interactive=True),
 
267
  *column_mappings,
268
  )
269
 
@@ -275,6 +281,7 @@ def align_columns_and_show_prediction(
275
  gr.update(value=prediction_output, visible=True),
276
  gr.update(visible=True, open=False),
277
  gr.update(interactive=True),
 
278
  *column_mappings,
279
  )
280
 
 
73
  gr.Dropdown(configs, value=configs[0], visible=True),
74
  gr.Dropdown(splits, value=splits[0], visible=True),
75
  gr.DataFrame(pd.DataFrame(), visible=False),
76
+ "",
77
  )
78
  elif dataset_split == None:
79
  return (
80
  gr.Dropdown(configs, value=dataset_config, visible=True),
81
  gr.Dropdown(splits, value=splits[0], visible=True),
82
  gr.DataFrame(pd.DataFrame(), visible=False),
83
+ "",
84
  )
85
 
86
  dataset_dict = datasets.load_dataset(dataset_id, dataset_config)
 
89
  gr.Dropdown(configs, value=dataset_config, visible=True),
90
  gr.Dropdown(splits, value=dataset_split, visible=True),
91
  gr.DataFrame(dataframe, visible=True),
92
+ "",
93
  )
94
 
95
 
 
195
  ppl = check_model(model_id)
196
  if ppl is None or not isinstance(ppl, TextClassificationPipeline):
197
  gr.Warning("Please check your model.")
198
+ return gr.update(interactive=False), ""
199
  ds_labels, ds_features = get_labels_and_features_from_dataset(
200
  dataset_id, dataset_config, dataset_split
201
  )
202
  if not isinstance(ds_labels, list) or not isinstance(ds_features, list):
203
  gr.Warning(CHECK_CONFIG_OR_SPLIT_RAW)
204
+ return gr.update(interactive=False), ""
205
 
206
+ return gr.update(interactive=True), ""
207
 
208
 
209
  def align_columns_and_show_prediction(
 
217
  gr.update(visible=False),
218
  gr.update(visible=False, open=False),
219
  gr.update(interactive=False),
220
+ "",
221
  *[gr.update(visible=False) for _ in range(MAX_LABELS + MAX_FEATURES)],
222
  )
223
 
 
247
  gr.update(visible=False),
248
  gr.update(visible=False, open=False),
249
  gr.update(interactive=False),
250
+ "",
251
  *dropdown_placement,
252
  )
253
 
 
269
  gr.update(visible=False),
270
  gr.update(visible=True, open=True),
271
  gr.update(interactive=True),
272
+ "",
273
  *column_mappings,
274
  )
275
 
 
281
  gr.update(value=prediction_output, visible=True),
282
  gr.update(visible=True, open=False),
283
  gr.update(interactive=True),
284
+ "",
285
  *column_mappings,
286
  )
287