r""" Load a model or scheduler configuration. Parameters: pretrained_model_name_or_path (`str` or `os.PathLike`, *optional*): Can be either: - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained model hos
(
cls,
pretrained_model_name_or_path: str | os.PathLike,
return_unused_kwargs=False,
return_commit_hash=False,
**kwargs,
)
| 323 | @classmethod |
| 324 | @validate_hf_hub_args |
| 325 | def load_config( |
| 326 | cls, |
| 327 | pretrained_model_name_or_path: str | os.PathLike, |
| 328 | return_unused_kwargs=False, |
| 329 | return_commit_hash=False, |
| 330 | **kwargs, |
| 331 | ) -> tuple[dict[str, Any], dict[str, Any]]: |
| 332 | r""" |
| 333 | Load a model or scheduler configuration. |
| 334 | |
| 335 | Parameters: |
| 336 | pretrained_model_name_or_path (`str` or `os.PathLike`, *optional*): |
| 337 | Can be either: |
| 338 | |
| 339 | - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on |
| 340 | the Hub. |
| 341 | - A path to a *directory* (for example `./my_model_directory`) containing model weights saved with |
| 342 | [`~ConfigMixin.save_config`]. |
| 343 | |
| 344 | cache_dir (`str | os.PathLike`, *optional*): |
| 345 | Path to a directory where a downloaded pretrained model configuration is cached if the standard cache |
| 346 | is not used. |
| 347 | force_download (`bool`, *optional*, defaults to `False`): |
| 348 | Whether or not to force the (re-)download of the model weights and configuration files, overriding the |
| 349 | cached versions if they exist. |
| 350 | proxies (`dict[str, str]`, *optional*): |
| 351 | A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', |
| 352 | 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. |
| 353 | output_loading_info(`bool`, *optional*, defaults to `False`): |
| 354 | Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. |
| 355 | local_files_only (`bool`, *optional*, defaults to `False`): |
| 356 | Whether to only load local model weights and configuration files or not. If set to `True`, the model |
| 357 | won't be downloaded from the Hub. |
| 358 | token (`str` or *bool*, *optional*): |
| 359 | The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from |
| 360 | `diffusers-cli login` (stored in `~/.huggingface`) is used. |
| 361 | revision (`str`, *optional*, defaults to `"main"`): |
| 362 | The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier |
| 363 | allowed by Git. |
| 364 | subfolder (`str`, *optional*, defaults to `""`): |
| 365 | The subfolder location of a model file within a larger model repository on the Hub or locally. |
| 366 | return_unused_kwargs (`bool`, *optional*, defaults to `False): |
| 367 | Whether unused keyword arguments of the config are returned. |
| 368 | return_commit_hash (`bool`, *optional*, defaults to `False): |
| 369 | Whether the `commit_hash` of the loaded configuration are returned. |
| 370 | |
| 371 | Returns: |
| 372 | `dict`: |
| 373 | A dictionary of all the parameters stored in a JSON configuration file. |
| 374 | |
| 375 | """ |
| 376 | cache_dir = kwargs.pop("cache_dir", None) |
| 377 | local_dir = kwargs.pop("local_dir", None) |
| 378 | local_dir_use_symlinks = kwargs.pop("local_dir_use_symlinks", "auto") |
| 379 | force_download = kwargs.pop("force_download", False) |
| 380 | proxies = kwargs.pop("proxies", None) |
| 381 | token = kwargs.pop("token", None) |
| 382 | local_files_only = kwargs.pop("local_files_only", False) |