From 5573bb36145bed6d60cad407295b2b5f5e2936de Mon Sep 17 00:00:00 2001 From: Steven Liu <steven.liu@huggingface.co> Date: Mon, 8 May 2023 12:27:55 -0700 Subject: [PATCH 1/3] clarify safetensor docstring --- src/diffusers/loaders.py | 8 ++++---- src/diffusers/models/modeling_utils.py | 8 ++++---- src/diffusers/pipelines/pipeline_utils.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/diffusers/loaders.py b/src/diffusers/loaders.py index f41d0ffe72e3..79e6cd5a4a52 100644 --- a/src/diffusers/loaders.py +++ b/src/diffusers/loaders.py @@ -1205,10 +1205,10 @@ def from_ckpt(cls, pretrained_model_link_or_path, **kwargs): The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git. - use_safetensors (`bool`, *optional* ): - If set to `True`, the pipeline will be loaded from `safetensors` weights. If set to `None` (the - default). The pipeline will load using `safetensors` if the safetensors weights are available *and* if - `safetensors` is installed. If the to `False` the pipeline will *not* use `safetensors`. + use_safetensors (`bool`, *optional*, defaults to `None`): + If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the + `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from + `safetensors` weights. If the to `False` the pipeline will *not* use `safetensors`. extract_ema (`bool`, *optional*, defaults to `False`): Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights or not. Defaults to `False`. Pass `True` to extract the EMA weights. EMA weights usually yield higher quality images for diff --git a/src/diffusers/models/modeling_utils.py b/src/diffusers/models/modeling_utils.py index 6644042077d2..016503ba2e45 100644 --- a/src/diffusers/models/modeling_utils.py +++ b/src/diffusers/models/modeling_utils.py @@ -406,10 +406,10 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P variant (`str`, *optional*): If specified load weights from `variant` filename, *e.g.* pytorch_model.<variant>.bin. `variant` is ignored when using `from_flax`. - use_safetensors (`bool`, *optional* ): - If set to `True`, the pipeline will forcibly load the models from `safetensors` weights. If set to - `None` (the default). The pipeline will load using `safetensors` if safetensors weights are available - *and* if `safetensors` is installed. If the to `False` the pipeline will *not* use `safetensors`. + use_safetensors (`bool`, *optional*, defaults to `None`): + If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the + `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from + `safetensors` weights. If the to `False` the pipeline will *not* use `safetensors`. <Tip> diff --git a/src/diffusers/pipelines/pipeline_utils.py b/src/diffusers/pipelines/pipeline_utils.py index 82bcda54938d..44c3caf021c1 100644 --- a/src/diffusers/pipelines/pipeline_utils.py +++ b/src/diffusers/pipelines/pipeline_utils.py @@ -814,10 +814,10 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P also tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model. This is only supported when torch version >= 1.9.0. If you are using an older version of torch, setting this argument to `True` will raise an error. - use_safetensors (`bool`, *optional* ): - If set to `True`, the pipeline will be loaded from `safetensors` weights. If set to `None` (the - default). The pipeline will load using `safetensors` if the safetensors weights are available *and* if - `safetensors` is installed. If the to `False` the pipeline will *not* use `safetensors`. + use_safetensors (`bool`, *optional*, defaults to `None`): + If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the + `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from + `safetensors` weights. If the to `False` the pipeline will *not* use `safetensors`. kwargs (remaining dictionary of keyword arguments, *optional*): Can be used to overwrite load - and saveable variables - *i.e.* the pipeline components - of the specific pipeline class. The overwritten components are then directly passed to the pipelines From 86454b292d3ccc0c59503595719be50ad415a6e7 Mon Sep 17 00:00:00 2001 From: Steven Liu <steven.liu@huggingface.co> Date: Mon, 8 May 2023 14:11:25 -0700 Subject: [PATCH 2/3] fix typo --- src/diffusers/loaders.py | 2 +- src/diffusers/models/modeling_utils.py | 2 +- src/diffusers/pipelines/pipeline_utils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/diffusers/loaders.py b/src/diffusers/loaders.py index 79e6cd5a4a52..4b1ea89a8e80 100644 --- a/src/diffusers/loaders.py +++ b/src/diffusers/loaders.py @@ -1208,7 +1208,7 @@ def from_ckpt(cls, pretrained_model_link_or_path, **kwargs): use_safetensors (`bool`, *optional*, defaults to `None`): If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from - `safetensors` weights. If the to `False` the pipeline will *not* use `safetensors`. + `safetensors` weights. If set to `False` the pipeline will *not* use `safetensors`. extract_ema (`bool`, *optional*, defaults to `False`): Only relevant for checkpoints that have both EMA and non-EMA weights. Whether to extract the EMA weights or not. Defaults to `False`. Pass `True` to extract the EMA weights. EMA weights usually yield higher quality images for diff --git a/src/diffusers/models/modeling_utils.py b/src/diffusers/models/modeling_utils.py index 016503ba2e45..e3bb9f8664c2 100644 --- a/src/diffusers/models/modeling_utils.py +++ b/src/diffusers/models/modeling_utils.py @@ -409,7 +409,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P use_safetensors (`bool`, *optional*, defaults to `None`): If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from - `safetensors` weights. If the to `False` the pipeline will *not* use `safetensors`. + `safetensors` weights. If set to `False` the pipeline will *not* use `safetensors`. <Tip> diff --git a/src/diffusers/pipelines/pipeline_utils.py b/src/diffusers/pipelines/pipeline_utils.py index 44c3caf021c1..03307e2752cd 100644 --- a/src/diffusers/pipelines/pipeline_utils.py +++ b/src/diffusers/pipelines/pipeline_utils.py @@ -817,7 +817,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P use_safetensors (`bool`, *optional*, defaults to `None`): If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from - `safetensors` weights. If the to `False` the pipeline will *not* use `safetensors`. + `safetensors` weights. If set to `False` the pipeline will *not* use `safetensors`. kwargs (remaining dictionary of keyword arguments, *optional*): Can be used to overwrite load - and saveable variables - *i.e.* the pipeline components - of the specific pipeline class. The overwritten components are then directly passed to the pipelines From 13e85479e89ef573cb0be0e5b63f6421924cdd66 Mon Sep 17 00:00:00 2001 From: Steven Liu <steven.liu@huggingface.co> Date: Tue, 9 May 2023 12:01:24 -0700 Subject: [PATCH 3/3] apply feedback --- src/diffusers/loaders.py | 2 +- src/diffusers/models/modeling_utils.py | 6 +++--- src/diffusers/pipelines/pipeline_utils.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/diffusers/loaders.py b/src/diffusers/loaders.py index 4b1ea89a8e80..c03d72085e93 100644 --- a/src/diffusers/loaders.py +++ b/src/diffusers/loaders.py @@ -1206,7 +1206,7 @@ def from_ckpt(cls, pretrained_model_link_or_path, **kwargs): git-based system for storing models and other artifacts on huggingface.co, so `revision` can be any identifier allowed by git. use_safetensors (`bool`, *optional*, defaults to `None`): - If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the + If set to `None`, the pipeline will load the `safetensors` weights if they're available **and** if the `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from `safetensors` weights. If set to `False` the pipeline will *not* use `safetensors`. extract_ema (`bool`, *optional*, defaults to `False`): Only relevant for diff --git a/src/diffusers/models/modeling_utils.py b/src/diffusers/models/modeling_utils.py index e3bb9f8664c2..ef14ec3d09ef 100644 --- a/src/diffusers/models/modeling_utils.py +++ b/src/diffusers/models/modeling_utils.py @@ -407,9 +407,9 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P If specified load weights from `variant` filename, *e.g.* pytorch_model.<variant>.bin. `variant` is ignored when using `from_flax`. use_safetensors (`bool`, *optional*, defaults to `None`): - If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the - `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from - `safetensors` weights. If set to `False` the pipeline will *not* use `safetensors`. + If set to `None`, the `safetensors` weights will be downloaded if they're available **and** if the + `safetensors` library is installed. If set to `True`, the model will be forcibly loaded from + `safetensors` weights. If set to `False`, loading will *not* use `safetensors`. <Tip> diff --git a/src/diffusers/pipelines/pipeline_utils.py b/src/diffusers/pipelines/pipeline_utils.py index 03307e2752cd..9288248d309b 100644 --- a/src/diffusers/pipelines/pipeline_utils.py +++ b/src/diffusers/pipelines/pipeline_utils.py @@ -815,7 +815,7 @@ def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.P model. This is only supported when torch version >= 1.9.0. If you are using an older version of torch, setting this argument to `True` will raise an error. use_safetensors (`bool`, *optional*, defaults to `None`): - If set to `None`, the pipeline will load the `safetensors` weights if they're availabe **and** if the + If set to `None`, the pipeline will load the `safetensors` weights if they're available **and** if the `safetensors` library is installed. If set to `True`, the pipeline will forcibly load the models from `safetensors` weights. If set to `False` the pipeline will *not* use `safetensors`. kwargs (remaining dictionary of keyword arguments, *optional*):