|
52 | 52 | from paddle.utils.download import is_url as is_remote_url |
53 | 53 | from tqdm.auto import tqdm |
54 | 54 |
|
55 | | -from paddlenlp.utils.downloader import get_path_from_url_with_filelock, hf_file_exists |
| 55 | +from paddlenlp.utils.downloader import get_path_from_url_with_filelock |
56 | 56 | from paddlenlp.utils.env import ( |
57 | 57 | CONFIG_NAME, |
58 | 58 | LEGACY_CONFIG_NAME, |
@@ -367,28 +367,7 @@ def resolve_weight_file_from_hf_hub(repo_id: str, cache_dir: str, support_conver |
367 | 367 | support_conversion (bool): whether support converting pytorch weight file to paddle weight file |
368 | 368 | subfolder (str, optional) An optional value corresponding to a folder inside the repo. |
369 | 369 | """ |
370 | | - is_local = os.path.isdir(repo_id) |
371 | | - if not is_local: |
372 | | - if hf_file_exists(repo_id, PADDLE_WEIGHTS_NAME, subfolder=subfolder): |
373 | | - file_name = PADDLE_WEIGHTS_NAME |
374 | | - assert ( |
375 | | - support_conversion is False |
376 | | - ), "Please call set convert_from_torch for paddle weights on huggingface hub, eg. Model.from_pretrained(model_name, from_hf_hub=True, convert_from_torch=False)" |
377 | | - elif hf_file_exists(repo_id, PYTORCH_WEIGHTS_NAME, subfolder=subfolder): |
378 | | - if not support_conversion: |
379 | | - raise EntryNotFoundError( |
380 | | - f"can not download `{PADDLE_WEIGHTS_NAME} from https://huggingface.co/{repo_id}` " |
381 | | - "and current model doesn't support conversion from pytorch weight file to paddle weight file" |
382 | | - ) |
383 | | - file_name = PYTORCH_WEIGHTS_NAME |
384 | | - else: |
385 | | - raise EntryNotFoundError( |
386 | | - message=f"can not find the paddle/pytorch weight file from: https://huggingface.co/{repo_id}", |
387 | | - response=None, |
388 | | - ) |
389 | | - else: |
390 | | - # for local file, we use support_conversion to select paddle or torch weight. |
391 | | - file_name = PYTORCH_WEIGHTS_NAME if support_conversion else PADDLE_WEIGHTS_NAME |
| 370 | + file_name = PYTORCH_WEIGHTS_NAME if support_conversion else PADDLE_WEIGHTS_NAME |
392 | 371 |
|
393 | 372 | file_name_list = [SAFE_WEIGHTS_NAME] + [file_name] + [PYTORCH_WEIGHTS_INDEX_NAME] + [SAFE_WEIGHTS_INDEX_NAME] |
394 | 373 | resolved_file = None |
|
0 commit comments