Add UNet weights in diffusers format
#2
by
dn6
HF staff
- opened
- README.md +26 -0
- unet_1_step_x0/config.json +73 -0
- unet_1_step_x0/diffusion_pytorch_model.safetensors +3 -0
- unet_2_step/config.json +73 -0
- unet_2_step/diffusion_pytorch_model.safetensors +3 -0
- unet_4_step/config.json +73 -0
- unet_4_step/diffusion_pytorch_model.safetensors +3 -0
- unet_8_step/config.json +73 -0
- unet_8_step/diffusion_pytorch_model.safetensors +3 -0
README.md
CHANGED
@@ -90,6 +90,32 @@ pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, times
|
|
90 |
pipe("A girl smiling", num_inference_steps=1, guidance_scale=0).images[0].save("output.png")
|
91 |
```
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
## ComfyUI Usage
|
95 |
|
|
|
90 |
pipe("A girl smiling", num_inference_steps=1, guidance_scale=0).images[0].save("output.png")
|
91 |
```
|
92 |
|
93 |
+
## Loading weights into the Diffusers `UNet2DConditionModel`
|
94 |
+
|
95 |
+
It is also possible to directly load the weights into the `UNet2DConditionModel`. This is useful if you want to avoid downloading the original SDXL UNet or preload different UNets in RAM and then hot-swap them in VRAM.
|
96 |
+
|
97 |
+
```python
|
98 |
+
import torch
|
99 |
+
from diffusers import (
|
100 |
+
EulerDiscreteScheduler,
|
101 |
+
StableDiffusionXLPipeline,
|
102 |
+
UNet2DConditionModel,
|
103 |
+
)
|
104 |
+
|
105 |
+
base = "stabilityai/stable-diffusion-xl-base-1.0"
|
106 |
+
repo_id = "ByteDance/SDXL-Lightning"
|
107 |
+
|
108 |
+
# Load model.
|
109 |
+
unet = UNet2DConditionModel.from_pretrained(repo_id, subfolder="unet_4_step", torch_dtype=torch.float16)
|
110 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16")
|
111 |
+
|
112 |
+
# Ensure sampler uses "trailing" timesteps and "sample" prediction type.
|
113 |
+
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|
114 |
+
pipe.enable_model_cpu_offload()
|
115 |
+
|
116 |
+
# Ensure using the same inference steps as the loaded model and CFG set to 0.
|
117 |
+
pipe("A girl smiling", num_inference_steps=4, guidance_scale=0).images[0].save("output.png")
|
118 |
+
```
|
119 |
|
120 |
## ComfyUI Usage
|
121 |
|
unet_1_step_x0/config.json
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "UNet2DConditionModel",
|
3 |
+
"_diffusers_version": "0.27.0.dev0",
|
4 |
+
"_name_or_path": "/home/dhruv_huggingface_co/.cache/huggingface/hub/models--stabilityai--stable-diffusion-xl-base-1.0/snapshots/462165984030d82259a11f4367a4eed129e94a7b/unet",
|
5 |
+
"act_fn": "silu",
|
6 |
+
"addition_embed_type": "text_time",
|
7 |
+
"addition_embed_type_num_heads": 64,
|
8 |
+
"addition_time_embed_dim": 256,
|
9 |
+
"attention_head_dim": [
|
10 |
+
5,
|
11 |
+
10,
|
12 |
+
20
|
13 |
+
],
|
14 |
+
"attention_type": "default",
|
15 |
+
"block_out_channels": [
|
16 |
+
320,
|
17 |
+
640,
|
18 |
+
1280
|
19 |
+
],
|
20 |
+
"center_input_sample": false,
|
21 |
+
"class_embed_type": null,
|
22 |
+
"class_embeddings_concat": false,
|
23 |
+
"conv_in_kernel": 3,
|
24 |
+
"conv_out_kernel": 3,
|
25 |
+
"cross_attention_dim": 2048,
|
26 |
+
"cross_attention_norm": null,
|
27 |
+
"down_block_types": [
|
28 |
+
"DownBlock2D",
|
29 |
+
"CrossAttnDownBlock2D",
|
30 |
+
"CrossAttnDownBlock2D"
|
31 |
+
],
|
32 |
+
"downsample_padding": 1,
|
33 |
+
"dropout": 0.0,
|
34 |
+
"dual_cross_attention": false,
|
35 |
+
"encoder_hid_dim": null,
|
36 |
+
"encoder_hid_dim_type": null,
|
37 |
+
"flip_sin_to_cos": true,
|
38 |
+
"freq_shift": 0,
|
39 |
+
"in_channels": 4,
|
40 |
+
"layers_per_block": 2,
|
41 |
+
"mid_block_only_cross_attention": null,
|
42 |
+
"mid_block_scale_factor": 1,
|
43 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
44 |
+
"norm_eps": 1e-05,
|
45 |
+
"norm_num_groups": 32,
|
46 |
+
"num_attention_heads": null,
|
47 |
+
"num_class_embeds": null,
|
48 |
+
"only_cross_attention": false,
|
49 |
+
"out_channels": 4,
|
50 |
+
"projection_class_embeddings_input_dim": 2816,
|
51 |
+
"resnet_out_scale_factor": 1.0,
|
52 |
+
"resnet_skip_time_act": false,
|
53 |
+
"resnet_time_scale_shift": "default",
|
54 |
+
"reverse_transformer_layers_per_block": null,
|
55 |
+
"sample_size": 128,
|
56 |
+
"time_cond_proj_dim": null,
|
57 |
+
"time_embedding_act_fn": null,
|
58 |
+
"time_embedding_dim": null,
|
59 |
+
"time_embedding_type": "positional",
|
60 |
+
"timestep_post_act": null,
|
61 |
+
"transformer_layers_per_block": [
|
62 |
+
1,
|
63 |
+
2,
|
64 |
+
10
|
65 |
+
],
|
66 |
+
"up_block_types": [
|
67 |
+
"CrossAttnUpBlock2D",
|
68 |
+
"CrossAttnUpBlock2D",
|
69 |
+
"UpBlock2D"
|
70 |
+
],
|
71 |
+
"upcast_attention": null,
|
72 |
+
"use_linear_projection": true
|
73 |
+
}
|
unet_1_step_x0/diffusion_pytorch_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dfc0c9a9b0240983e8296f2280757e3c03e0e5c12283d05a4d011619992b9861
|
3 |
+
size 5135149760
|
unet_2_step/config.json
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "UNet2DConditionModel",
|
3 |
+
"_diffusers_version": "0.27.0.dev0",
|
4 |
+
"_name_or_path": "/home/dhruv_huggingface_co/.cache/huggingface/hub/models--stabilityai--stable-diffusion-xl-base-1.0/snapshots/462165984030d82259a11f4367a4eed129e94a7b/unet",
|
5 |
+
"act_fn": "silu",
|
6 |
+
"addition_embed_type": "text_time",
|
7 |
+
"addition_embed_type_num_heads": 64,
|
8 |
+
"addition_time_embed_dim": 256,
|
9 |
+
"attention_head_dim": [
|
10 |
+
5,
|
11 |
+
10,
|
12 |
+
20
|
13 |
+
],
|
14 |
+
"attention_type": "default",
|
15 |
+
"block_out_channels": [
|
16 |
+
320,
|
17 |
+
640,
|
18 |
+
1280
|
19 |
+
],
|
20 |
+
"center_input_sample": false,
|
21 |
+
"class_embed_type": null,
|
22 |
+
"class_embeddings_concat": false,
|
23 |
+
"conv_in_kernel": 3,
|
24 |
+
"conv_out_kernel": 3,
|
25 |
+
"cross_attention_dim": 2048,
|
26 |
+
"cross_attention_norm": null,
|
27 |
+
"down_block_types": [
|
28 |
+
"DownBlock2D",
|
29 |
+
"CrossAttnDownBlock2D",
|
30 |
+
"CrossAttnDownBlock2D"
|
31 |
+
],
|
32 |
+
"downsample_padding": 1,
|
33 |
+
"dropout": 0.0,
|
34 |
+
"dual_cross_attention": false,
|
35 |
+
"encoder_hid_dim": null,
|
36 |
+
"encoder_hid_dim_type": null,
|
37 |
+
"flip_sin_to_cos": true,
|
38 |
+
"freq_shift": 0,
|
39 |
+
"in_channels": 4,
|
40 |
+
"layers_per_block": 2,
|
41 |
+
"mid_block_only_cross_attention": null,
|
42 |
+
"mid_block_scale_factor": 1,
|
43 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
44 |
+
"norm_eps": 1e-05,
|
45 |
+
"norm_num_groups": 32,
|
46 |
+
"num_attention_heads": null,
|
47 |
+
"num_class_embeds": null,
|
48 |
+
"only_cross_attention": false,
|
49 |
+
"out_channels": 4,
|
50 |
+
"projection_class_embeddings_input_dim": 2816,
|
51 |
+
"resnet_out_scale_factor": 1.0,
|
52 |
+
"resnet_skip_time_act": false,
|
53 |
+
"resnet_time_scale_shift": "default",
|
54 |
+
"reverse_transformer_layers_per_block": null,
|
55 |
+
"sample_size": 128,
|
56 |
+
"time_cond_proj_dim": null,
|
57 |
+
"time_embedding_act_fn": null,
|
58 |
+
"time_embedding_dim": null,
|
59 |
+
"time_embedding_type": "positional",
|
60 |
+
"timestep_post_act": null,
|
61 |
+
"transformer_layers_per_block": [
|
62 |
+
1,
|
63 |
+
2,
|
64 |
+
10
|
65 |
+
],
|
66 |
+
"up_block_types": [
|
67 |
+
"CrossAttnUpBlock2D",
|
68 |
+
"CrossAttnUpBlock2D",
|
69 |
+
"UpBlock2D"
|
70 |
+
],
|
71 |
+
"upcast_attention": null,
|
72 |
+
"use_linear_projection": true
|
73 |
+
}
|
unet_2_step/diffusion_pytorch_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9a7dce8c3b431268f83be043d8c2e126e148f3ee30391aaf6f53dca541dea55e
|
3 |
+
size 5135149760
|
unet_4_step/config.json
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "UNet2DConditionModel",
|
3 |
+
"_diffusers_version": "0.27.0.dev0",
|
4 |
+
"_name_or_path": "/home/dhruv_huggingface_co/.cache/huggingface/hub/models--stabilityai--stable-diffusion-xl-base-1.0/snapshots/462165984030d82259a11f4367a4eed129e94a7b/unet",
|
5 |
+
"act_fn": "silu",
|
6 |
+
"addition_embed_type": "text_time",
|
7 |
+
"addition_embed_type_num_heads": 64,
|
8 |
+
"addition_time_embed_dim": 256,
|
9 |
+
"attention_head_dim": [
|
10 |
+
5,
|
11 |
+
10,
|
12 |
+
20
|
13 |
+
],
|
14 |
+
"attention_type": "default",
|
15 |
+
"block_out_channels": [
|
16 |
+
320,
|
17 |
+
640,
|
18 |
+
1280
|
19 |
+
],
|
20 |
+
"center_input_sample": false,
|
21 |
+
"class_embed_type": null,
|
22 |
+
"class_embeddings_concat": false,
|
23 |
+
"conv_in_kernel": 3,
|
24 |
+
"conv_out_kernel": 3,
|
25 |
+
"cross_attention_dim": 2048,
|
26 |
+
"cross_attention_norm": null,
|
27 |
+
"down_block_types": [
|
28 |
+
"DownBlock2D",
|
29 |
+
"CrossAttnDownBlock2D",
|
30 |
+
"CrossAttnDownBlock2D"
|
31 |
+
],
|
32 |
+
"downsample_padding": 1,
|
33 |
+
"dropout": 0.0,
|
34 |
+
"dual_cross_attention": false,
|
35 |
+
"encoder_hid_dim": null,
|
36 |
+
"encoder_hid_dim_type": null,
|
37 |
+
"flip_sin_to_cos": true,
|
38 |
+
"freq_shift": 0,
|
39 |
+
"in_channels": 4,
|
40 |
+
"layers_per_block": 2,
|
41 |
+
"mid_block_only_cross_attention": null,
|
42 |
+
"mid_block_scale_factor": 1,
|
43 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
44 |
+
"norm_eps": 1e-05,
|
45 |
+
"norm_num_groups": 32,
|
46 |
+
"num_attention_heads": null,
|
47 |
+
"num_class_embeds": null,
|
48 |
+
"only_cross_attention": false,
|
49 |
+
"out_channels": 4,
|
50 |
+
"projection_class_embeddings_input_dim": 2816,
|
51 |
+
"resnet_out_scale_factor": 1.0,
|
52 |
+
"resnet_skip_time_act": false,
|
53 |
+
"resnet_time_scale_shift": "default",
|
54 |
+
"reverse_transformer_layers_per_block": null,
|
55 |
+
"sample_size": 128,
|
56 |
+
"time_cond_proj_dim": null,
|
57 |
+
"time_embedding_act_fn": null,
|
58 |
+
"time_embedding_dim": null,
|
59 |
+
"time_embedding_type": "positional",
|
60 |
+
"timestep_post_act": null,
|
61 |
+
"transformer_layers_per_block": [
|
62 |
+
1,
|
63 |
+
2,
|
64 |
+
10
|
65 |
+
],
|
66 |
+
"up_block_types": [
|
67 |
+
"CrossAttnUpBlock2D",
|
68 |
+
"CrossAttnUpBlock2D",
|
69 |
+
"UpBlock2D"
|
70 |
+
],
|
71 |
+
"upcast_attention": null,
|
72 |
+
"use_linear_projection": true
|
73 |
+
}
|
unet_4_step/diffusion_pytorch_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6fbf9e77c74fd7b38f33269f2f1630538ddd094a661b037aa18f53520d50984e
|
3 |
+
size 5135149760
|
unet_8_step/config.json
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_class_name": "UNet2DConditionModel",
|
3 |
+
"_diffusers_version": "0.27.0.dev0",
|
4 |
+
"_name_or_path": "/home/dhruv_huggingface_co/.cache/huggingface/hub/models--stabilityai--stable-diffusion-xl-base-1.0/snapshots/462165984030d82259a11f4367a4eed129e94a7b/unet",
|
5 |
+
"act_fn": "silu",
|
6 |
+
"addition_embed_type": "text_time",
|
7 |
+
"addition_embed_type_num_heads": 64,
|
8 |
+
"addition_time_embed_dim": 256,
|
9 |
+
"attention_head_dim": [
|
10 |
+
5,
|
11 |
+
10,
|
12 |
+
20
|
13 |
+
],
|
14 |
+
"attention_type": "default",
|
15 |
+
"block_out_channels": [
|
16 |
+
320,
|
17 |
+
640,
|
18 |
+
1280
|
19 |
+
],
|
20 |
+
"center_input_sample": false,
|
21 |
+
"class_embed_type": null,
|
22 |
+
"class_embeddings_concat": false,
|
23 |
+
"conv_in_kernel": 3,
|
24 |
+
"conv_out_kernel": 3,
|
25 |
+
"cross_attention_dim": 2048,
|
26 |
+
"cross_attention_norm": null,
|
27 |
+
"down_block_types": [
|
28 |
+
"DownBlock2D",
|
29 |
+
"CrossAttnDownBlock2D",
|
30 |
+
"CrossAttnDownBlock2D"
|
31 |
+
],
|
32 |
+
"downsample_padding": 1,
|
33 |
+
"dropout": 0.0,
|
34 |
+
"dual_cross_attention": false,
|
35 |
+
"encoder_hid_dim": null,
|
36 |
+
"encoder_hid_dim_type": null,
|
37 |
+
"flip_sin_to_cos": true,
|
38 |
+
"freq_shift": 0,
|
39 |
+
"in_channels": 4,
|
40 |
+
"layers_per_block": 2,
|
41 |
+
"mid_block_only_cross_attention": null,
|
42 |
+
"mid_block_scale_factor": 1,
|
43 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
44 |
+
"norm_eps": 1e-05,
|
45 |
+
"norm_num_groups": 32,
|
46 |
+
"num_attention_heads": null,
|
47 |
+
"num_class_embeds": null,
|
48 |
+
"only_cross_attention": false,
|
49 |
+
"out_channels": 4,
|
50 |
+
"projection_class_embeddings_input_dim": 2816,
|
51 |
+
"resnet_out_scale_factor": 1.0,
|
52 |
+
"resnet_skip_time_act": false,
|
53 |
+
"resnet_time_scale_shift": "default",
|
54 |
+
"reverse_transformer_layers_per_block": null,
|
55 |
+
"sample_size": 128,
|
56 |
+
"time_cond_proj_dim": null,
|
57 |
+
"time_embedding_act_fn": null,
|
58 |
+
"time_embedding_dim": null,
|
59 |
+
"time_embedding_type": "positional",
|
60 |
+
"timestep_post_act": null,
|
61 |
+
"transformer_layers_per_block": [
|
62 |
+
1,
|
63 |
+
2,
|
64 |
+
10
|
65 |
+
],
|
66 |
+
"up_block_types": [
|
67 |
+
"CrossAttnUpBlock2D",
|
68 |
+
"CrossAttnUpBlock2D",
|
69 |
+
"UpBlock2D"
|
70 |
+
],
|
71 |
+
"upcast_attention": null,
|
72 |
+
"use_linear_projection": true
|
73 |
+
}
|
unet_8_step/diffusion_pytorch_model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1ad9c1bc10073648ee4bf43c9c44cdbd23afaffdec4f8ee8642d601371a3f9c1
|
3 |
+
size 5135149760
|