inoki-giskard commited on
Commit
d8e445d
1 Parent(s): 139fa70

Disallow model URL in model id text input

Browse files
text_classification.py CHANGED
@@ -391,10 +391,6 @@ def text_classification_fix_column_mapping(column_mapping, ppl, d_id, config, sp
391
  feature_map_df,
392
  )
393
 
394
- def strip_model_id_from_url(model_id):
395
- if model_id.startswith("https://huggingface.co/"):
396
- return "/".join(model_id.split("/")[-2:])
397
- return model_id
398
 
399
  def check_hf_token_validity(hf_token):
400
  if hf_token == "":
 
391
  feature_map_df,
392
  )
393
 
 
 
 
 
394
 
395
  def check_hf_token_validity(hf_token):
396
  if hf_token == "":
text_classification_ui_helpers.py CHANGED
@@ -16,7 +16,6 @@ from io_utils import (
16
  )
17
  from run_jobs import save_job_to_pipe
18
  from text_classification import (
19
- strip_model_id_from_url,
20
  check_model_task,
21
  preload_hf_inference_api,
22
  get_example_prediction,
@@ -45,7 +44,6 @@ ds_config = None
45
 
46
  def get_related_datasets_from_leaderboard(model_id, dataset_id_input):
47
  records = leaderboard.records
48
- model_id = strip_model_id_from_url(model_id)
49
  model_records = records[records["model_id"] == model_id]
50
  datasets_unique = list(model_records["dataset_id"].unique())
51
 
@@ -183,8 +181,7 @@ def list_labels_and_features_from_dataset(ds_labels, ds_features, model_labels,
183
 
184
  def precheck_model_ds_enable_example_btn(
185
  model_id, dataset_id, dataset_config, dataset_split
186
- ):
187
- model_id = strip_model_id_from_url(model_id)
188
  model_task = check_model_task(model_id)
189
  preload_hf_inference_api(model_id)
190
 
@@ -254,7 +251,6 @@ def align_columns_and_show_prediction(
254
  uid,
255
  inference_token,
256
  ):
257
- model_id = strip_model_id_from_url(model_id)
258
  model_task = check_model_task(model_id)
259
  if model_task is None or model_task != "text-classification":
260
  gr.Warning(NOT_TEXT_CLASSIFICATION_MODEL_RAW)
 
16
  )
17
  from run_jobs import save_job_to_pipe
18
  from text_classification import (
 
19
  check_model_task,
20
  preload_hf_inference_api,
21
  get_example_prediction,
 
44
 
45
  def get_related_datasets_from_leaderboard(model_id, dataset_id_input):
46
  records = leaderboard.records
 
47
  model_records = records[records["model_id"] == model_id]
48
  datasets_unique = list(model_records["dataset_id"].unique())
49
 
 
181
 
182
  def precheck_model_ds_enable_example_btn(
183
  model_id, dataset_id, dataset_config, dataset_split
184
+ ):
 
185
  model_task = check_model_task(model_id)
186
  preload_hf_inference_api(model_id)
187
 
 
251
  uid,
252
  inference_token,
253
  ):
 
254
  model_task = check_model_task(model_id)
255
  if model_task is None or model_task != "text-classification":
256
  gr.Warning(NOT_TEXT_CLASSIFICATION_MODEL_RAW)