r""" Instantiate a pretrained PyTorch model from a pretrained model configuration. The model is set in evaluation mode - `model.eval()` - by default, and dropout modules are deactivated. To train the model, set it back in training mode with `model.train()`. Paramete
(cls, pretrained_model_name_or_path: str | os.PathLike | None, **kwargs)
| 858 | @classmethod |
| 859 | @validate_hf_hub_args |
| 860 | def from_pretrained(cls, pretrained_model_name_or_path: str | os.PathLike | None, **kwargs) -> Self: |
| 861 | r""" |
| 862 | Instantiate a pretrained PyTorch model from a pretrained model configuration. |
| 863 | |
| 864 | The model is set in evaluation mode - `model.eval()` - by default, and dropout modules are deactivated. To |
| 865 | train the model, set it back in training mode with `model.train()`. |
| 866 | |
| 867 | Parameters: |
| 868 | pretrained_model_name_or_path (`str` or `os.PathLike`, *optional*): |
| 869 | Can be either: |
| 870 | |
| 871 | - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on |
| 872 | the Hub. |
| 873 | - A path to a *directory* (for example `./my_model_directory`) containing the model weights saved |
| 874 | with [`~ModelMixin.save_pretrained`]. |
| 875 | |
| 876 | cache_dir (`str | os.PathLike`, *optional*): |
| 877 | Path to a directory where a downloaded pretrained model configuration is cached if the standard cache |
| 878 | is not used. |
| 879 | torch_dtype (`torch.dtype`, *optional*): |
| 880 | Override the default `torch.dtype` and load the model with another dtype. |
| 881 | force_download (`bool`, *optional*, defaults to `False`): |
| 882 | Whether or not to force the (re-)download of the model weights and configuration files, overriding the |
| 883 | cached versions if they exist. |
| 884 | proxies (`dict[str, str]`, *optional*): |
| 885 | A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', |
| 886 | 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. |
| 887 | output_loading_info (`bool`, *optional*, defaults to `False`): |
| 888 | Whether or not to also return a dictionary containing missing keys, unexpected keys and error messages. |
| 889 | local_files_only(`bool`, *optional*, defaults to `False`): |
| 890 | Whether to only load local model weights and configuration files or not. If set to `True`, the model |
| 891 | won't be downloaded from the Hub. |
| 892 | token (`str` or *bool*, *optional*): |
| 893 | The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from |
| 894 | `diffusers-cli login` (stored in `~/.huggingface`) is used. |
| 895 | revision (`str`, *optional*, defaults to `"main"`): |
| 896 | The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier |
| 897 | allowed by Git. |
| 898 | from_flax (`bool`, *optional*, defaults to `False`): |
| 899 | Load the model weights from a Flax checkpoint save file. |
| 900 | subfolder (`str`, *optional*, defaults to `""`): |
| 901 | The subfolder location of a model file within a larger model repository on the Hub or locally. |
| 902 | mirror (`str`, *optional*): |
| 903 | Mirror source to resolve accessibility issues if you're downloading a model in China. We do not |
| 904 | guarantee the timeliness or safety of the source, and you should refer to the mirror site for more |
| 905 | information. |
| 906 | device_map (`int | str | torch.device` or `dict[str, int | str | torch.device]`, *optional*): |
| 907 | A map that specifies where each submodule should go. It doesn't need to be defined for each |
| 908 | parameter/buffer name; once a given module name is inside, every submodule of it will be sent to the |
| 909 | same device. Defaults to `None`, meaning that the model will be loaded on CPU. |
| 910 | |
| 911 | Examples: |
| 912 | |
| 913 | ```py |
| 914 | >>> from diffusers import AutoModel |
| 915 | >>> import torch |
| 916 | |
| 917 | >>> # This works. |
no test coverage detected