diff --git a/corener/utils/model.py b/corener/utils/model.py index fbab798..52b3b5b 100644 --- a/corener/utils/model.py +++ b/corener/utils/model.py @@ -3,10 +3,9 @@ from typing import Optional, Union from transformers import AutoConfig -from transformers.modeling_utils import ( - HUGGINGFACE_CO_RESOLVE_ENDPOINT, +from huggingface_hub.utils import ( EntryNotFoundError, - HTTPError, + HfHubHTTPError, RepositoryNotFoundError, RevisionNotFoundError, cached_path, @@ -16,6 +15,7 @@ load_state_dict, ) + from corener.utils import set_logger set_logger() @@ -150,14 +150,14 @@ def load_weights_and_config( raise EnvironmentError( f"{pretrained_model_name_or_path} does not appear to have a file named {filename}." ) - except HTTPError as err: + except HfHubHTTPError as err: raise EnvironmentError( f"There was a specific connection error when trying to load {pretrained_model_name_or_path}:\n" f"{err}" ) except ValueError: raise EnvironmentError( - f"We couldn't connect to '{HUGGINGFACE_CO_RESOLVE_ENDPOINT}' to load this model, couldn't find it in the cached " + f"We couldn't connect to 'HuggingFace' to load this model, couldn't find it in the cached " f"files and it looks like {pretrained_model_name_or_path} is not the path to a directory " f"containing a file named {WEIGHTS_NAME}.\n" "Checkout your internet connection or see how to run the library in offline mode at "