1
0
mirror of https://github.com/huggingface/diffusers.git synced 2026-01-27 17:22:53 +03:00

[pipeline utils] sanitize pretrained_model_name_or_path (#5173)

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 <patrick.v.platen@gmail.com>
This commit is contained in:
Hengwen Tong
2023-09-26 02:22:41 +08:00
committed by GitHub
parent 539846a7d5
commit dfdf85d32c

View File

@@ -1033,6 +1033,10 @@ class DiffusionPipeline(ConfigMixin, PushToHubMixin):
# 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,