You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/using-diffusers/other-formats.md
+37-45Lines changed: 37 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ specific language governing permissions and limitations under the License.
17
17
Diffusion models are typically stored in the Diffusers format or single-file format. Model files can be stored in various file types such as safetensors, dduf, or ckpt.
18
18
19
19
> [!TIP]
20
-
> Format refers to the directory structure and file refers to the file type.
20
+
> Format refers to whether the weights are stored in a directory structure and file refers to the file type.
21
21
22
22
This guide will show you how to load pipelines and models from these formats and files.
23
23
@@ -41,59 +41,53 @@ Use [`~loaders.FromSingleFileMixin.from_single_file`] to load a single file.
Models have a `config.json` file in their repositories with important attributes such as the number of layers and attention heads. The [`~loaders.FromSingleFileMixin.from_single_file`] method automatically determines the appropriate config to use from `config.json`.
70
+
Diffusers format models have a `config.json` file in their repositories with important attributes such as the number of layers and attention heads. The [`~loaders.FromSingleFileMixin.from_single_file`] method automatically determines the appropriate config to use from `config.json`. This may fail in a few rare instances though, in which case, you should use the `config` argument.
71
71
72
-
But if the models in a pipeline are different from the original implementation or if it doesn't have to necessary metadata to determine the correct config, then you need to use the `config` argument.
72
+
You should also use the `config` argument if the models in a pipeline are different from the original implementation or if it doesn't have the necessary metadata to determine the correct config.
Diffusers attempts to infer the pipeline components based on the signature types of the pipeline class when using `original_config` with `local_files_only=True`. It won't download the config files from a Hub repository to avoid backward breaking changes when you can't connect to the internet. This method isn't as reliable as providing a path to a local model with the `config` argument and may lead to errors. You should run the pipeline with `local_files_only=False` to download the config files to the local cache to avoid errors.
@@ -124,19 +118,19 @@ If you're working with local files, download the config files with the [`~huggin
124
118
125
119
```py
126
120
from huggingface_hub import hf_hub_download, snapshot_download
@@ -182,7 +175,7 @@ Models can be stored in several file types. Safetensors is the most common file
182
175
183
176
[Safetensors](https://hf.co/docs/safetensors) is a safe and fast file type for securely storing and loading tensors. It restricts the header size to limit certain types of attacks, supports lazy loading (useful for distributed setups), and generally loads faster.
184
177
185
-
Diffusers loads safetensors file by default if they are available and the Safetensors library is installed.
178
+
Diffusers loads safetensors file by default (a required dependency) if they are available and the Safetensors library is installed.
186
179
187
180
Use [`~DiffusionPipeline.from_pretrained`] or [`~loaders.FromSingleFileMixin.from_single_file`] to load safetensor files.
If you're using a checkpoint trained with a Diffusers training script, metadata such as the LoRA configuration, is automatically saved. When the file is loaded, the metadata is parsed to correctly configure the LoRA and avoid missing or incorrect LoRA configs. Inspect the metadata of a safetensors file by clicking on the <imgsrc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/safetensors/logo.png"alt="safetensors logo"height="15em"style="vertical-align: middle;"> logo next to the file on the Hub.
198
+
If you're using a checkpoint trained with a Diffusers training script, metadata such as the LoRA configuration, is automatically saved. When the file is loaded, the metadata is parsed to correctly configure the LoRA and avoid missing or incorrect LoRA configs. Inspect the metadata of a safetensors file by clicking on the <imgsrc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/safetensors/logo.png"alt="safetensors logo"style="vertical-align: middle; display: inline-block; max-height: 0.8em; max-width: 0.8em; margin: 0; padding: 0; line-height: 1;"> logo next to the file on the Hub.
207
199
208
-
Save the metadata for LoRAs that aren't trained with Diffusers with the`transformer_lora_adapter_metadata`and `text_encoder_lora_adapter_metadata` arguments in [`~loaders.FluxLoraLoaderMixin.save_lora_weights`]. This is only supported for safetensors files.
200
+
Save the metadata for LoRAs that aren't trained with Diffusers with either`transformer_lora_adapter_metadata`or `unet_lora_adapter_metadata` depending on your model. For the text encoder, use the `text_encoder_lora_adapter_metadata` and `text_encoder_2_lora_adapter_metadata` arguments in [`~loaders.FluxLoraLoaderMixin.save_lora_weights`]. This is only supported for safetensors files.
0 commit comments