kylielee505 commited on
Commit
a01e463
·
verified ·
1 Parent(s): 28df445

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AnimateDiff Model Checkpoints for A1111 SD WebUI
2
+ This repository saves all AnimateDiff models in fp16 & safetensors format for A1111 AnimateDiff users, including
3
+ - motion module (v1-v3)
4
+ - [motion LoRA](#motion-lora) (v2 only, use like any other LoRA)
5
+ - domain adapter (v3 only, use like any other LoRA)
6
+ - [sparse ControlNet](#sparse-controlnet) (v3 only, use like any other ControlNet)
7
+
8
+ Unless specified below, you are fine to use models from the [official model repository](https://huggingface.co/guoyww/animatediff/tree/main). I will only convert state dict keys if absolutely necessary.
9
+
10
+
11
+ ## Motion LoRA
12
+ Put Motion LoRAs to `stable-diffusion-webui/models/Lora` and use Motion LoRAs like any other LoRA you use.
13
+
14
+ [lora_v2](https://huggingface.co/conrevo/AnimateDiff-A1111/tree/main/lora_v2) contains motion LoRAs for AnimateDiff-A1111 v2.0.0 and later. I converted state dict keys inside motion LoRAs. Originlal motion LoRAs won't work for AnimateDiff-A1111 v2.0.0 and later due to maintenance reason.
15
+
16
+ Use [convert.py](convert.py) in the following way if you want to convert a third-party motion LoRA to be compatible with A1111:
17
+ - Activate your A1111 Python environment first.
18
+ - Command: `python script.py lora [file_path] [save_path]`
19
+ - Replace `[file_path]` with the path to your old LoRA checkpoint.
20
+ - Replace `[save_path]` with the path where you want to save the new LoRA checkpoint.
21
+
22
+
23
+ ## Sparse ControlNet
24
+ Put Sparse ControlNets to `stable-diffusion-webui/models/ControlNet` and use Sparse ControlNets like any other ControlNet you use.
25
+
26
+ Like Motion LoRA, I converted state dict keys inside sparse ControlNet. Original sparse ControlNets won't work for A1111 due to maintenance reason.
27
+
28
+ Use [convert.py](convert.py) in the following way if you want to convert a third-party sparse ControlNet to be compatible with A1111:
29
+ - Activate your A1111 Python environment first.
30
+ - Command: `python script.py controlnet [ad_cn_old] [ad_cn_new] [normal_cn_path]`
31
+ - Replace `[ad_cn_old]` with the path to your old sparse ControlNet checkpoint.
32
+ - Replace `[ad_cn_new]` with the path where you want to save the new sparse ControlNet checkpoint.
33
+ - Replace `[normal_cn_path]` with the path to the normal ControlNet model. Download normal ControlNet from [here](https://huggingface.co/lllyasviel/control_v11p_sd15_openpose/resolve/main/diffusion_pytorch_model.fp16.safetensors?download=true).
34
+
35
+
36
+ ## HotShotXL
37
+ You need to use HotShotXL in this repository if you want to use it for AnimateDiff-A1111 v2.0.0 and later. Like Motion LoRA, I converted state dict keys inside HotShotXL. Original HotShotXL won't work for AnimateDiff-A1111 v2.0.0 and later due to maintenance reason.
control/mm_sd15_v3_sparsectrl_rgb.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d07d75bd0395fd419477395305b34d4cd23b5d3e7ad5896d73b7fdfe49594d2
3
+ size 993974272
control/mm_sd15_v3_sparsectrl_scribble.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8e6451a0f0d1430684e6b895ba13adf147946e553ad568038a4621dfaca1d52b
3
+ size 996119576
convert.py ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import re
3
+ import torch
4
+ import safetensors.torch
5
+
6
+
7
+ def convert_mm_name_to_compvis(key):
8
+ sd_module_key, _, network_part = re.split(r'(_lora\.)', key)
9
+ sd_module_key = sd_module_key.replace("processor.", "").replace("to_out", "to_out.0")
10
+ sd_module_key = sd_module_key.replace(".", "_")
11
+ return f'{sd_module_key}.lora_{network_part}'
12
+
13
+ def convert_from_diffuser_state_dict(ad_cn_l):
14
+ unet_conversion_map = [
15
+ # (stable-diffusion, HF Diffusers)
16
+ ("time_embed.0.weight", "time_embedding.linear_1.weight"),
17
+ ("time_embed.0.bias", "time_embedding.linear_1.bias"),
18
+ ("time_embed.2.weight", "time_embedding.linear_2.weight"),
19
+ ("time_embed.2.bias", "time_embedding.linear_2.bias"),
20
+ ("label_emb.0.0.weight", "add_embedding.linear_1.weight"),
21
+ ("label_emb.0.0.bias", "add_embedding.linear_1.bias"),
22
+ ("label_emb.0.2.weight", "add_embedding.linear_2.weight"),
23
+ ("label_emb.0.2.bias", "add_embedding.linear_2.bias"),
24
+ ("input_blocks.0.0.weight", "conv_in.weight"),
25
+ ("input_blocks.0.0.bias", "conv_in.bias"),
26
+ ("middle_block_out.0.weight", "controlnet_mid_block.weight"),
27
+ ("middle_block_out.0.bias", "controlnet_mid_block.bias"),
28
+ ]
29
+
30
+ unet_conversion_map_resnet = [
31
+ # (stable-diffusion, HF Diffusers)
32
+ ("in_layers.0", "norm1"),
33
+ ("in_layers.2", "conv1"),
34
+ ("out_layers.0", "norm2"),
35
+ ("out_layers.3", "conv2"),
36
+ ("emb_layers.1", "time_emb_proj"),
37
+ ("skip_connection", "conv_shortcut"),
38
+ ]
39
+
40
+ unet_conversion_map_layer = []
41
+ # hardcoded number of downblocks and resnets/attentions...
42
+ # would need smarter logic for other networks.
43
+ for i in range(4):
44
+ # loop over downblocks/upblocks
45
+
46
+ for j in range(10):
47
+ # loop over resnets/attentions for downblocks
48
+ hf_down_res_prefix = f"down_blocks.{i}.resnets.{j}."
49
+ sd_down_res_prefix = f"input_blocks.{3*i + j + 1}.0."
50
+ unet_conversion_map_layer.append((sd_down_res_prefix, hf_down_res_prefix))
51
+
52
+ hf_down_atn_prefix = f"down_blocks.{i}.attentions.{j}."
53
+ sd_down_atn_prefix = f"input_blocks.{3 * i + j + 1}.1."
54
+ unet_conversion_map_layer.append((sd_down_atn_prefix, hf_down_atn_prefix))
55
+
56
+ hf_downsample_prefix = f"down_blocks.{i}.downsamplers.0.conv."
57
+ sd_downsample_prefix = f"input_blocks.{3 * (i + 1)}.0.op."
58
+ unet_conversion_map_layer.append((sd_downsample_prefix, hf_downsample_prefix))
59
+
60
+
61
+ hf_mid_atn_prefix = "mid_block.attentions.0."
62
+ sd_mid_atn_prefix = "middle_block.1."
63
+ unet_conversion_map_layer.append((sd_mid_atn_prefix, hf_mid_atn_prefix))
64
+
65
+ for j in range(2):
66
+ hf_mid_res_prefix = f"mid_block.resnets.{j}."
67
+ sd_mid_res_prefix = f"middle_block.{2*j}."
68
+ unet_conversion_map_layer.append((sd_mid_res_prefix, hf_mid_res_prefix))
69
+
70
+ # controlnet specific
71
+
72
+ controlnet_cond_embedding_names = ['conv_in'] + [f'blocks.{i}' for i in range(6)] + ['conv_out']
73
+ for i, hf_prefix in enumerate(controlnet_cond_embedding_names):
74
+ hf_prefix = f"controlnet_cond_embedding.{hf_prefix}."
75
+ sd_prefix = f"input_hint_block.{i*2}."
76
+ unet_conversion_map_layer.append((sd_prefix, hf_prefix))
77
+
78
+ for i in range(12):
79
+ hf_prefix = f"controlnet_down_blocks.{i}."
80
+ sd_prefix = f"zero_convs.{i}.0."
81
+ unet_conversion_map_layer.append((sd_prefix, hf_prefix))
82
+
83
+
84
+ def _convert_from_diffuser_state_dict(unet_state_dict):
85
+ mapping = {k: k for k in unet_state_dict.keys()}
86
+ for sd_name, hf_name in unet_conversion_map:
87
+ mapping[hf_name] = sd_name
88
+ for k, v in mapping.items():
89
+ if "resnets" in k:
90
+ for sd_part, hf_part in unet_conversion_map_resnet:
91
+ v = v.replace(hf_part, sd_part)
92
+ mapping[k] = v
93
+ for k, v in mapping.items():
94
+ for sd_part, hf_part in unet_conversion_map_layer:
95
+ v = v.replace(hf_part, sd_part)
96
+ mapping[k] = v
97
+ new_state_dict = {v: unet_state_dict[k] for k, v in mapping.items() if k in unet_state_dict}
98
+ return new_state_dict
99
+
100
+ return _convert_from_diffuser_state_dict(ad_cn_l)
101
+
102
+
103
+ def lora_conversion(file_path, save_path):
104
+ state_dict = safetensors.torch.load_file(file_path) if file_path.endswith(".safetensors") else torch.load(file_path)
105
+ modified_dict = {convert_mm_name_to_compvis(k): v for k, v in state_dict.items()}
106
+ safetensors.torch.save_file(modified_dict, save_path)
107
+ print(f"LoRA conversion completed: {save_path}")
108
+
109
+
110
+ def controlnet_conversion(ad_cn_old, ad_cn_new, normal_cn_path):
111
+ ad_cn = safetensors.torch.load_file(ad_cn_old) if ad_cn_old.endswith(".safetensors") else torch.load(ad_cn_old)
112
+ normal_cn = safetensors.torch.load_file(normal_cn_path)
113
+ ad_cn_l, ad_cn_m = {}, {}
114
+
115
+ for k in ad_cn.keys():
116
+ if k.startswith("controlnet_cond_embedding"):
117
+ new_key = k.replace("controlnet_cond_embedding.", "input_hint_block.0.")
118
+ ad_cn_m[new_key] = ad_cn[k].to(torch.float16)
119
+ elif not k in normal_cn:
120
+ if "motion_modules" in k:
121
+ ad_cn_m[k] = ad_cn[k].to(torch.float16)
122
+ else:
123
+ raise Exception(f"{k} not in normal_cn")
124
+ else:
125
+ ad_cn_l[k] = ad_cn[k].to(torch.float16)
126
+
127
+ ad_cn_l = convert_from_diffuser_state_dict(ad_cn_l)
128
+ ad_cn_l.update(ad_cn_m)
129
+ safetensors.torch.save_file(ad_cn_l, ad_cn_new)
130
+ print(f"ControlNet conversion completed: {ad_cn_new}")
131
+
132
+
133
+ def main():
134
+ parser = argparse.ArgumentParser(description="Script to convert LoRA and ControlNet models.")
135
+ subparsers = parser.add_subparsers(dest='command')
136
+
137
+ # LoRA conversion parser
138
+ lora_parser = subparsers.add_parser('lora', help='LoRA conversion')
139
+ lora_parser.add_argument('file_path', type=str, help='Path to the old LoRA checkpoint')
140
+ lora_parser.add_argument('save_path', type=str, help='Path to save the new LoRA checkpoint')
141
+
142
+ # ControlNet conversion parser
143
+ cn_parser = subparsers.add_parser('controlnet', help='ControlNet conversion')
144
+ cn_parser.add_argument('ad_cn_old', type=str, help='Path to the old sparse ControlNet checkpoint')
145
+ cn_parser.add_argument('ad_cn_new', type=str, help='Path to save the new sparse ControlNet checkpoint')
146
+ cn_parser.add_argument('normal_cn_path', type=str, help='Path to the normal ControlNet model')
147
+
148
+ args = parser.parse_args()
149
+
150
+ if args.command == 'lora':
151
+ lora_conversion(args.file_path, args.save_path)
152
+ elif args.command == 'controlnet':
153
+ controlnet_conversion(args.ad_cn_old, args.ad_cn_new, args.normal_cn_path)
154
+ else:
155
+ parser.print_help()
156
+
157
+ if __name__ == "__main__":
158
+ main()
lora/mm_sd15_v2_lora_PanLeft.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6276d00d0398241f5d03862a95fb4002fa251c7238e9c8a284399ee48445d65
3
+ size 38730736
lora/mm_sd15_v2_lora_PanRight.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86e04ae653fbbe2e8287cca41961301c343941c60a2e24ef39ea71da765891cb
3
+ size 38730736
lora/mm_sd15_v2_lora_RollingAnticlockwise.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:edf299118571342807d57e4e4c1840c86be26c57b8682b3a7a3a35f7d2a134ee
3
+ size 38730736
lora/mm_sd15_v2_lora_RollingClockwise.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bfb12b055b650b859f95dea0cd66b104aed19ddaf65d119346b529d2ab162a02
3
+ size 38730736
lora/mm_sd15_v2_lora_TiltDown.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb0d712627d48906b012f9d9ee41d5963fdb82929f7ac842b8ea29a3fb3b6183
3
+ size 38730736
lora/mm_sd15_v2_lora_TiltUp.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d474baad5434ea5f5eb2125d7b031c642cfab46c2d8643921bbf4e22dcb8d056
3
+ size 38730736
lora/mm_sd15_v2_lora_ZoomIn.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b62ba0b02f7904772002e736c808894026295ed6087a20a2410b340cbb9b444
3
+ size 38730736
lora/mm_sd15_v2_lora_ZoomOut.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3a2726d7e464e8bc17e64618f3b5a90845b0202c00fdc4346be1582ba08fd8a0
3
+ size 38730736
lora/mm_sd15_v3_adapter.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78b7fd991066c10ffb24d6e7c89e01438be2c702568a2b5c5bf3a0371b1c854b
3
+ size 51059544
lora_v2/mm_sd15_v2_lora_PanLeft.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c21abede9d32778826d1f26976baed1acf79ae90a3cbfcf35c987ef7c862e77
3
+ size 38727544
lora_v2/mm_sd15_v2_lora_PanRight.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f70336a72ac316f8667cd88d986fd01081ca8fc4b940fd6155df700f9389f897
3
+ size 38727544
lora_v2/mm_sd15_v2_lora_RollingAnticlockwise.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2148bd92f4102dcc05dfeb4b3d4c6e2c9e099d2f7583481cea17041167589f1
3
+ size 38727544
lora_v2/mm_sd15_v2_lora_RollingClockwise.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e855537b7e33438362f156b59693030db437960e12d269e6f89f33d23a05ed45
3
+ size 38727544
lora_v2/mm_sd15_v2_lora_TiltDown.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38f2a7f96ffa612f8a397dda465a267b994379e91f67b0584875200608c6bc13
3
+ size 38727544
lora_v2/mm_sd15_v2_lora_TiltUp.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54f0cb3900af167360b1af934e101a88e00541dee297a5fa629415e834a4bf0f
3
+ size 38727544
lora_v2/mm_sd15_v2_lora_ZoomIn.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6cc1467ab86de38073c877b1b1798c96de0dc945dc91df04031313bb20670ef5
3
+ size 38727544
lora_v2/mm_sd15_v2_lora_ZoomOut.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce4ebb8f003ac988bf69db17fe5ef655d72b8512dabb18f07e4355d3b6b8f1ec
3
+ size 38727544
lora_v2/mm_sd15_v3_adapter.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78b7fd991066c10ffb24d6e7c89e01438be2c702568a2b5c5bf3a0371b1c854b
3
+ size 51059544
motion_module/mm_sd14_v1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc16214feab8b0d8b9e7b05f5a4d9c5e2648601e9c807c51b1b0dc7478879535
3
+ size 836054808
motion_module/mm_sd15_AnimateLCM.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f3c5eb97c65d35362e713416e402d54174ccaa0f531f45ad80006e48199bc77d
3
+ size 906505488
motion_module/mm_sd15_v1.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb1858cebf3b0d83e056c7413fc9c43702f24f78c295a4cde1a8ba97f299f7df
3
+ size 836054808
motion_module/mm_sd15_v2.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d3976a7dcd11d4f5202d5360c6f1996fc669d6114c530afb3dca4769cc6dd2b2
3
+ size 908929664
motion_module/mm_sd15_v3.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8ca0eadb18c6ad6652bca344a458f31780901a87f765bf95a81ef9c5be55f29
3
+ size 836618008
motion_module/mm_sdxl_hs.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a8345a99396e5be93e0f90ace4a78ec0bd85d2d7cf63e2aae747fe64288aab7b
3
+ size 474700904
motion_module/mm_sdxl_v10_beta.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:deda6b381d44c3e60d410432fb5be4d7147460948e0edb55a7d5997804e5f6c3
3
+ size 475059304