|
18 | 18 | import requests |
19 | 19 | import torch |
20 | 20 | from huggingface_hub import hf_hub_download |
| 21 | +from huggingface_hub.utils import validate_hf_hub_args |
21 | 22 |
|
22 | 23 | from ..utils import ( |
23 | | - DIFFUSERS_CACHE, |
24 | | - HF_HUB_OFFLINE, |
25 | 24 | deprecate, |
26 | 25 | is_accelerate_available, |
27 | 26 | is_omegaconf_available, |
@@ -52,6 +51,7 @@ def from_ckpt(cls, *args, **kwargs): |
52 | 51 | return cls.from_single_file(*args, **kwargs) |
53 | 52 |
|
54 | 53 | @classmethod |
| 54 | + @validate_hf_hub_args |
55 | 55 | def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
56 | 56 | r""" |
57 | 57 | Instantiate a [`DiffusionPipeline`] from pretrained pipeline weights saved in the `.ckpt` or `.safetensors` |
@@ -81,7 +81,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
81 | 81 | local_files_only (`bool`, *optional*, defaults to `False`): |
82 | 82 | Whether to only load local model weights and configuration files or not. If set to `True`, the model |
83 | 83 | won't be downloaded from the Hub. |
84 | | - use_auth_token (`str` or *bool*, *optional*): |
| 84 | + token (`str` or *bool*, *optional*): |
85 | 85 | The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from |
86 | 86 | `diffusers-cli login` (stored in `~/.huggingface`) is used. |
87 | 87 | revision (`str`, *optional*, defaults to `"main"`): |
@@ -154,12 +154,12 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
154 | 154 |
|
155 | 155 | original_config_file = kwargs.pop("original_config_file", None) |
156 | 156 | config_files = kwargs.pop("config_files", None) |
157 | | - cache_dir = kwargs.pop("cache_dir", DIFFUSERS_CACHE) |
| 157 | + cache_dir = kwargs.pop("cache_dir", None) |
158 | 158 | resume_download = kwargs.pop("resume_download", False) |
159 | 159 | force_download = kwargs.pop("force_download", False) |
160 | 160 | proxies = kwargs.pop("proxies", None) |
161 | | - local_files_only = kwargs.pop("local_files_only", HF_HUB_OFFLINE) |
162 | | - use_auth_token = kwargs.pop("use_auth_token", None) |
| 161 | + local_files_only = kwargs.pop("local_files_only", None) |
| 162 | + token = kwargs.pop("token", None) |
163 | 163 | revision = kwargs.pop("revision", None) |
164 | 164 | extract_ema = kwargs.pop("extract_ema", False) |
165 | 165 | image_size = kwargs.pop("image_size", None) |
@@ -253,7 +253,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
253 | 253 | resume_download=resume_download, |
254 | 254 | proxies=proxies, |
255 | 255 | local_files_only=local_files_only, |
256 | | - use_auth_token=use_auth_token, |
| 256 | + token=token, |
257 | 257 | revision=revision, |
258 | 258 | force_download=force_download, |
259 | 259 | ) |
@@ -293,6 +293,7 @@ class FromOriginalVAEMixin: |
293 | 293 | """ |
294 | 294 |
|
295 | 295 | @classmethod |
| 296 | + @validate_hf_hub_args |
296 | 297 | def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
297 | 298 | r""" |
298 | 299 | Instantiate a [`AutoencoderKL`] from pretrained ControlNet weights saved in the original `.ckpt` or |
@@ -322,7 +323,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
322 | 323 | local_files_only (`bool`, *optional*, defaults to `False`): |
323 | 324 | Whether to only load local model weights and configuration files or not. If set to True, the model |
324 | 325 | won't be downloaded from the Hub. |
325 | | - use_auth_token (`str` or *bool*, *optional*): |
| 326 | + token (`str` or *bool*, *optional*): |
326 | 327 | The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from |
327 | 328 | `diffusers-cli login` (stored in `~/.huggingface`) is used. |
328 | 329 | revision (`str`, *optional*, defaults to `"main"`): |
@@ -379,12 +380,12 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
379 | 380 | ) |
380 | 381 |
|
381 | 382 | config_file = kwargs.pop("config_file", None) |
382 | | - cache_dir = kwargs.pop("cache_dir", DIFFUSERS_CACHE) |
| 383 | + cache_dir = kwargs.pop("cache_dir", None) |
383 | 384 | resume_download = kwargs.pop("resume_download", False) |
384 | 385 | force_download = kwargs.pop("force_download", False) |
385 | 386 | proxies = kwargs.pop("proxies", None) |
386 | | - local_files_only = kwargs.pop("local_files_only", HF_HUB_OFFLINE) |
387 | | - use_auth_token = kwargs.pop("use_auth_token", None) |
| 387 | + local_files_only = kwargs.pop("local_files_only", None) |
| 388 | + token = kwargs.pop("token", None) |
388 | 389 | revision = kwargs.pop("revision", None) |
389 | 390 | image_size = kwargs.pop("image_size", None) |
390 | 391 | scaling_factor = kwargs.pop("scaling_factor", None) |
@@ -425,7 +426,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
425 | 426 | resume_download=resume_download, |
426 | 427 | proxies=proxies, |
427 | 428 | local_files_only=local_files_only, |
428 | | - use_auth_token=use_auth_token, |
| 429 | + token=token, |
429 | 430 | revision=revision, |
430 | 431 | force_download=force_download, |
431 | 432 | ) |
@@ -490,6 +491,7 @@ class FromOriginalControlnetMixin: |
490 | 491 | """ |
491 | 492 |
|
492 | 493 | @classmethod |
| 494 | + @validate_hf_hub_args |
493 | 495 | def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
494 | 496 | r""" |
495 | 497 | Instantiate a [`ControlNetModel`] from pretrained ControlNet weights saved in the original `.ckpt` or |
@@ -519,7 +521,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
519 | 521 | local_files_only (`bool`, *optional*, defaults to `False`): |
520 | 522 | Whether to only load local model weights and configuration files or not. If set to True, the model |
521 | 523 | won't be downloaded from the Hub. |
522 | | - use_auth_token (`str` or *bool*, *optional*): |
| 524 | + token (`str` or *bool*, *optional*): |
523 | 525 | The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from |
524 | 526 | `diffusers-cli login` (stored in `~/.huggingface`) is used. |
525 | 527 | revision (`str`, *optional*, defaults to `"main"`): |
@@ -555,12 +557,12 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
555 | 557 | from ..pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt |
556 | 558 |
|
557 | 559 | config_file = kwargs.pop("config_file", None) |
558 | | - cache_dir = kwargs.pop("cache_dir", DIFFUSERS_CACHE) |
| 560 | + cache_dir = kwargs.pop("cache_dir", None) |
559 | 561 | resume_download = kwargs.pop("resume_download", False) |
560 | 562 | force_download = kwargs.pop("force_download", False) |
561 | 563 | proxies = kwargs.pop("proxies", None) |
562 | | - local_files_only = kwargs.pop("local_files_only", HF_HUB_OFFLINE) |
563 | | - use_auth_token = kwargs.pop("use_auth_token", None) |
| 564 | + local_files_only = kwargs.pop("local_files_only", None) |
| 565 | + token = kwargs.pop("token", None) |
564 | 566 | num_in_channels = kwargs.pop("num_in_channels", None) |
565 | 567 | use_linear_projection = kwargs.pop("use_linear_projection", None) |
566 | 568 | revision = kwargs.pop("revision", None) |
@@ -603,7 +605,7 @@ def from_single_file(cls, pretrained_model_link_or_path, **kwargs): |
603 | 605 | resume_download=resume_download, |
604 | 606 | proxies=proxies, |
605 | 607 | local_files_only=local_files_only, |
606 | | - use_auth_token=use_auth_token, |
| 608 | + token=token, |
607 | 609 | revision=revision, |
608 | 610 | force_download=force_download, |
609 | 611 | ) |
|
0 commit comments