Skip to content

Commit

Permalink
[pipeline utils] sanitize pretrained_model_name_or_path (#5173)
Browse files Browse the repository at this point in the history
Make sure the repo_id is valid before sending it to huggingface_hub to get a more understandable error message.

Re #5110

Co-authored-by: Patrick von Platen <[email protected]>
  • Loading branch information
kevint324 and patrickvonplaten authored Sep 25, 2023
1 parent 539846a commit dfdf85d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/diffusers/pipelines/pipeline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,10 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P
# 1. Download the checkpoints and configs
# use snapshot download here to get it working from from_pretrained
if not os.path.isdir(pretrained_model_name_or_path):
if pretrained_model_name_or_path.count("/") > 1:
raise ValueError(
f"The provided pretrained_model_name_or_path \"{pretrained_model_name_or_path}\""
" is neither a valid local path nor a valid repo id. Please check the parameter.")
cached_folder = cls.download(
pretrained_model_name_or_path,
cache_dir=cache_dir,
Expand Down

0 comments on commit dfdf85d

Please sign in to comment.