# How to use single-file diffuser checkpoints

**URL:** <https://discuss.huggingface.co/t/how-to-use-single-file-diffuser-checkpoints/133073>\
**Category:** Beginners\
**Created:** [December 26, 2024, 8:25am UTC](https://discuss.huggingface.co/t/how-to-use-single-file-diffuser-checkpoints/133073 "2024-12-26T08:25:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kex3](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kex3](https://discuss.huggingface.co/u/kex3)\
**Post date:** [December 26, 2024, 8:25am UTC](https://discuss.huggingface.co/t/how-to-use-single-file-diffuser-checkpoints/133073/1 "2024-12-26T08:25:07Z")

</div>

I can’t figure out how to load a diffusion model from single files, like `flux1-dev.safetensors` for FLUX.1 ([black-forest-labs/FLUX.1-dev at main](https://huggingface.co/black-forest-labs/FLUX.1-dev/tree/main))

It works fine when using `FluxPipeline.from_pretrained()` which uses the multi-file format, but when I try `FluxPipeline.from_single_file()` on the above file I get:

```auto
diffusers.loaders.single_file_utils.SingleFileComponentError: Failed to load CLIPTextModel. Weights for this component appear to be missing in the checkpoint.
Please load the component before passing it in as an argument to `from_single_file`.

text_encoder = CLIPTextModel.from_pretrained('...')
pipe = FluxPipeline.from_single_file(<checkpoint path>, text_encoder=text_encoder)

```

So I was wondering, if the file only contains the transformer, which might be converted and inserted into the multi-file tree. Looking inside, though, I found that the number of tensors per layer is different and the dimensions are not quite the same, either.

There must be some way to use that file through diffusers, right?

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [December 26, 2024, 8:56am UTC](https://discuss.huggingface.co/t/how-to-use-single-file-diffuser-checkpoints/133073/2 "2024-12-26T08:56:18Z")

</div>

Hi,

The single file is meant to be used with [ComfyUI](https://github.com/comfyanonymous/ComfyUI).

---

<div class="post-metadata">

**Author:** ![kex3](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@kex3](https://discuss.huggingface.co/u/kex3)\
**Post date:** [December 26, 2024, 9:55am UTC](https://discuss.huggingface.co/t/how-to-use-single-file-diffuser-checkpoints/133073/3 "2024-12-26T09:55:51Z")

</div>

I see. Is there are reasonably easy way to still use it with diffusers? Some finetunes only provide it in that format.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [December 26, 2024, 4:26pm UTC](https://discuss.huggingface.co/t/how-to-use-single-file-diffuser-checkpoints/133073/4 "2024-12-26T16:26:56Z")

</div>

Files for ComfyUI can often be loaded using the following method. Please specify an appropriate repo for the missing parts other than DiT.

```py
from diffusers import FluxPipeline, FluxTransformer2DModel

HF_TOKEN = "hf_***"
flux_repo = "multimodalart/FLUX.1-dev2pro-full"
ckpt_path = "https://huggingface.co/Comfy-Org/flux1-dev/blob/main/flux1-dev-fp8.safetensors"
transformer = FluxTransformer2DModel.from_single_file(ckpt_path, subfolder="transformer", torch_dtype=torch.bfloat16, token=HF_TOKEN)
pipe = FluxPipeline.from_pretrained(flux_repo, transformer=transformer, torch_dtype=torch.bfloat16, token=HF_TOKEN)

```

> **[GGUF](https://huggingface.co/docs/diffusers/main/en/quantization/gguf)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [January 2, 2025, 8:42am UTC](https://discuss.huggingface.co/t/how-to-use-single-file-diffuser-checkpoints/133073/5 "2025-01-02T08:42:52Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
