Parameters: pretrained_model_name_or_path_or_dict (`str` or `list[str]` or `os.PathLike` or `list[os.PathLike]` or `dict` or `list[dict]`): Can be either: - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained mod
(
self,
pretrained_model_name_or_path_or_dict: str | list[str] | dict[str, torch.Tensor],
subfolder: str | list[str],
weight_name: str | list[str],
image_encoder_folder: str | None = "image_encoder",
**kwargs,
)
| 56 | |
| 57 | @validate_hf_hub_args |
| 58 | def load_ip_adapter( |
| 59 | self, |
| 60 | pretrained_model_name_or_path_or_dict: str | list[str] | dict[str, torch.Tensor], |
| 61 | subfolder: str | list[str], |
| 62 | weight_name: str | list[str], |
| 63 | image_encoder_folder: str | None = "image_encoder", |
| 64 | **kwargs, |
| 65 | ): |
| 66 | """ |
| 67 | Parameters: |
| 68 | pretrained_model_name_or_path_or_dict (`str` or `list[str]` or `os.PathLike` or `list[os.PathLike]` or `dict` or `list[dict]`): |
| 69 | Can be either: |
| 70 | |
| 71 | - A string, the *model id* (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on |
| 72 | the Hub. |
| 73 | - A path to a *directory* (for example `./my_model_directory`) containing the model weights saved |
| 74 | with [`ModelMixin.save_pretrained`]. |
| 75 | - A [torch state |
| 76 | dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). |
| 77 | subfolder (`str` or `list[str]`): |
| 78 | The subfolder location of a model file within a larger model repository on the Hub or locally. If a |
| 79 | list is passed, it should have the same length as `weight_name`. |
| 80 | weight_name (`str` or `list[str]`): |
| 81 | The name of the weight file to load. If a list is passed, it should have the same length as |
| 82 | `subfolder`. |
| 83 | image_encoder_folder (`str`, *optional*, defaults to `image_encoder`): |
| 84 | The subfolder location of the image encoder within a larger model repository on the Hub or locally. |
| 85 | Pass `None` to not load the image encoder. If the image encoder is located in a folder inside |
| 86 | `subfolder`, you only need to pass the name of the folder that contains image encoder weights, e.g. |
| 87 | `image_encoder_folder="image_encoder"`. If the image encoder is located in a folder other than |
| 88 | `subfolder`, you should pass the path to the folder that contains image encoder weights, for example, |
| 89 | `image_encoder_folder="different_subfolder/image_encoder"`. |
| 90 | cache_dir (`str | os.PathLike`, *optional*): |
| 91 | Path to a directory where a downloaded pretrained model configuration is cached if the standard cache |
| 92 | is not used. |
| 93 | force_download (`bool`, *optional*, defaults to `False`): |
| 94 | Whether or not to force the (re-)download of the model weights and configuration files, overriding the |
| 95 | cached versions if they exist. |
| 96 | |
| 97 | proxies (`dict[str, str]`, *optional*): |
| 98 | A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', |
| 99 | 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. |
| 100 | local_files_only (`bool`, *optional*, defaults to `False`): |
| 101 | Whether to only load local model weights and configuration files or not. If set to `True`, the model |
| 102 | won't be downloaded from the Hub. |
| 103 | token (`str` or *bool*, *optional*): |
| 104 | The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from |
| 105 | `diffusers-cli login` (stored in `~/.huggingface`) is used. |
| 106 | revision (`str`, *optional*, defaults to `"main"`): |
| 107 | The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier |
| 108 | allowed by Git. |
| 109 | low_cpu_mem_usage (`bool`, *optional*, defaults to `True` if torch version >= 1.9.0 else `False`): |
| 110 | Speed up model loading only loading the pretrained weights and not initializing the weights. This also |
| 111 | tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model. |
| 112 | Only supported for PyTorch >= 1.9.0. If you are using an older version of PyTorch, setting this |
| 113 | argument to `True` will raise an error. |
| 114 | """ |
| 115 |