Update README.md
Browse files
README.md
CHANGED
|
@@ -10,3 +10,92 @@ tags:
|
|
| 10 |
- comfyui
|
| 11 |
- diffusion-single-file
|
| 12 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
- comfyui
|
| 11 |
- diffusion-single-file
|
| 12 |
---
|
| 13 |
+
For more information (including how to compress models yourself), check out https://huggingface.co/DFloat11 and https://github.com/LeanModels/DFloat11
|
| 14 |
+
|
| 15 |
+
Feel free to request for other models for compression as well, although compressing models that do not use the Flux architecture might be slightly tricky for me.
|
| 16 |
+
|
| 17 |
+
### How to Use
|
| 18 |
+
|
| 19 |
+
#### ComfyUI
|
| 20 |
+
Install my own fork of the DF11 ComfyUI custom node: https://github.com/mingyi456/ComfyUI-DFloat11-Extended. After installing the DF11 custom node, use the provided workflow [json](flux1-schnell-DF11-workflow.json), or simply replace the "Load Diffusion Model" node of an existing Flux workflow with the "DFloat11 Model Loader" node. If you run into any issues, feel free to leave a comment. The workflow is also embedded in the below [png](flux1-schnell-DF11-workflow.png) image.
|
| 21 |
+
|
| 22 |
+

|
| 23 |
+
|
| 24 |
+
Alternatively, the official DF11 custom node can be used instead, but it will not work out of the box with this model, due to ComfyUI differentiating between Dev and Schnell versions of Flux. The code within the dfloat11_model_loader.py file needs to be patched, by explicitly adding an entry for `"FluxSchnell"` in the `MODEL_TO_PATTERN_DICT` dictionary. The patched code should be as follows:
|
| 25 |
+
|
| 26 |
+
```python
|
| 27 |
+
class DFloat11ModelLoader:
|
| 28 |
+
"""
|
| 29 |
+
A custom node to load a DFloat11 diffusion model from the `diffusion_models` directory.
|
| 30 |
+
DFloat11 models are >30% smaller than their float16 counterparts, yet produce bit-for-bit identical outputs.
|
| 31 |
+
"""
|
| 32 |
+
MODEL_TO_PATTERN_DICT = {
|
| 33 |
+
"Flux": {
|
| 34 |
+
"double_blocks\.\d+": (
|
| 35 |
+
"img_mod.lin",
|
| 36 |
+
"img_attn.qkv",
|
| 37 |
+
"img_attn.proj",
|
| 38 |
+
"img_mlp.0",
|
| 39 |
+
"img_mlp.2",
|
| 40 |
+
"txt_mod.lin",
|
| 41 |
+
"txt_attn.qkv",
|
| 42 |
+
"txt_attn.proj",
|
| 43 |
+
"txt_mlp.0",
|
| 44 |
+
"txt_mlp.2",
|
| 45 |
+
),
|
| 46 |
+
"single_blocks\.\d+": (
|
| 47 |
+
"linear1",
|
| 48 |
+
"linear2",
|
| 49 |
+
"modulation.lin",
|
| 50 |
+
),
|
| 51 |
+
},
|
| 52 |
+
"FluxSchnell": {
|
| 53 |
+
"double_blocks\.\d+": (
|
| 54 |
+
"img_mod.lin",
|
| 55 |
+
"img_attn.qkv",
|
| 56 |
+
"img_attn.proj",
|
| 57 |
+
"img_mlp.0",
|
| 58 |
+
"img_mlp.2",
|
| 59 |
+
"txt_mod.lin",
|
| 60 |
+
"txt_attn.qkv",
|
| 61 |
+
"txt_attn.proj",
|
| 62 |
+
"txt_mlp.0",
|
| 63 |
+
"txt_mlp.2",
|
| 64 |
+
),
|
| 65 |
+
"single_blocks\.\d+": (
|
| 66 |
+
"linear1",
|
| 67 |
+
"linear2",
|
| 68 |
+
"modulation.lin",
|
| 69 |
+
),
|
| 70 |
+
},
|
| 71 |
+
}
|
| 72 |
+
```
|
| 73 |
+
|
| 74 |
+
#### `diffusers`
|
| 75 |
+
Refer to this [model](https://huggingface.co/DFloat11/FLUX.1-schnell-DF11) instead.
|
| 76 |
+
|
| 77 |
+
### Compression Details
|
| 78 |
+
|
| 79 |
+
This is the `pattern_dict` for compressing Flux-based models in ComfyUI:
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
pattern_dict_comfyui = {
|
| 83 |
+
"double_blocks\.\d+": (
|
| 84 |
+
"img_mod.lin",
|
| 85 |
+
"img_attn.qkv",
|
| 86 |
+
"img_attn.proj",
|
| 87 |
+
"img_mlp.0",
|
| 88 |
+
"img_mlp.2",
|
| 89 |
+
"txt_mod.lin",
|
| 90 |
+
"txt_attn.qkv",
|
| 91 |
+
"txt_attn.proj",
|
| 92 |
+
"txt_mlp.0",
|
| 93 |
+
"txt_mlp.2",
|
| 94 |
+
),
|
| 95 |
+
"single_blocks\.\d+": (
|
| 96 |
+
"linear1",
|
| 97 |
+
"linear2",
|
| 98 |
+
"modulation.lin",
|
| 99 |
+
),
|
| 100 |
+
}
|
| 101 |
+
```
|