ZeroCommand commited on
Commit
60bd510
1 Parent(s): cdcc48e

fix test token bug and add icons to wording

Browse files
text_classification.py CHANGED
@@ -389,7 +389,8 @@ def check_hf_token_validity(hf_token):
389
  return False
390
  # use inference api to check the token
391
  payload = {"inputs": "This is a test", "options": {"use_cache": True}}
392
- response = hf_inference_api("cardiffnlp/twitter-roberta-base-sentiment-latest", hf_token, payload)
 
393
  if "error" in response:
394
  return False
395
  return True
 
389
  return False
390
  # use inference api to check the token
391
  payload = {"inputs": "This is a test", "options": {"use_cache": True}}
392
+ # use a tiny model to test the token
393
+ response = hf_inference_api("cross-encoder/ms-marco-TinyBERT-L-2-v2", hf_token, payload)
394
  if "error" in response:
395
  return False
396
  return True
text_classification_ui_helpers.py CHANGED
@@ -329,11 +329,8 @@ def enable_run_btn(uid, run_inference, inference_token, model_id, dataset_id, da
329
  logger.warn("Column mapping is not valid")
330
  return gr.update(interactive=False)
331
 
332
- _, prediction_response = get_example_prediction(
333
- model_id, dataset_id, dataset_config, dataset_split, inference_token
334
- )
335
- if not isinstance(prediction_response, HuggingFaceInferenceAPIResponse):
336
- logger.warn("Failed to get example prediction from inference API with this token")
337
  return gr.update(interactive=False)
338
  return gr.update(interactive=True)
339
 
 
329
  logger.warn("Column mapping is not valid")
330
  return gr.update(interactive=False)
331
 
332
+ if not check_hf_token_validity(inference_token):
333
+ logger.warn("HF token is not valid")
 
 
 
334
  return gr.update(interactive=False)
335
  return gr.update(interactive=True)
336
 
wordings.py CHANGED
@@ -38,13 +38,13 @@ PREDICTION_SAMPLE_MD = """
38
 
39
  MAPPING_STYLED_ERROR_WARNING = """
40
  <h3 style="text-align: center;color: orange; background-color: #fff0f3; border-radius: 8px; padding: 10px; ">
41
- Sorry, we cannot auto-align the labels/features of your dataset and model. Please double check.
42
  </h3>
43
  """
44
 
45
  UNMATCHED_MODEL_DATASET_STYLED_ERROR = """
46
  <h3 style="text-align: center;color: #fa5f5f; background-color: #fbe2e2; border-radius: 8px; padding: 10px; ">
47
- Your model and dataset have different numbers of labels. Please double check your model and dataset.
48
  </h3>
49
  """
50
 
 
38
 
39
  MAPPING_STYLED_ERROR_WARNING = """
40
  <h3 style="text-align: center;color: orange; background-color: #fff0f3; border-radius: 8px; padding: 10px; ">
41
+ ⚠️ We cannot auto-align the labels/features of your dataset and model. Please double check the info below before your submission.
42
  </h3>
43
  """
44
 
45
  UNMATCHED_MODEL_DATASET_STYLED_ERROR = """
46
  <h3 style="text-align: center;color: #fa5f5f; background-color: #fbe2e2; border-radius: 8px; padding: 10px; ">
47
+ Your model and dataset have different numbers of labels. Please double check your model and dataset.
48
  </h3>
49
  """
50