conrevo commited on
Commit
afd8b4f
1 Parent(s): 3143781

documentation

Browse files
README.md CHANGED
@@ -1 +1,62 @@
1
- This repository saves all AnimateDiff models in fp16 & safetensors format, including motion modules, motion LoRA, domain adapters and potentially more, for A1111 AnimateDiff users.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 LoRAs)
5
+ - domain adapter (v3 only, use like any other LoRAs)
6
+ - [sparse ControlNet](#sparse-controlnet) (v3 only, use like any other ControlNets)
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 LoRAs you use.
13
+
14
+ `lora_v2` contains motion LoRAs for AnimateDiff-A1111 v2.0.0. Old motion LoRAs won't work for v2.0.0 and later due to maintenance reason. `lora` will be removed after AnimateDiff-A1111 v2.0.0 is released to master branch.
15
+
16
+ I converted the original state dict via the following code. You may do so if you want to use a motion LoRA from community. Run the following script to make your own motion LoRA checkpoint compatible with AnimateDiff-A1111 v2.0.0 and later.
17
+ ```python
18
+ import os, re, torch
19
+ import safetensors.torch
20
+
21
+ def convert_mm_name_to_compvis(key):
22
+ sd_module_key, _, network_part = re.split(r'(_lora\.)', key)
23
+ sd_module_key = sd_module_key.replace("processor.", "").replace("to_out", "to_out.0")
24
+ sd_module_key = sd_module_key.replace(".", "_")
25
+ return f'{sd_module_key}.lora_{network_part}'
26
+
27
+ file_path = # replace with path to your own old motion LoRA checkpoint
28
+ save_path = # replace with path to your own new motion LoRA checkpoint
29
+ state_dict = safetensors.torch.load_file(file_path) if file_path.endswith(".safetensors") else torch.load(file_path)
30
+ modified_dict = {convert_mm_name_to_compvis(k): v for k, v in state_dict.items()}
31
+ safetensors.torch.save_file(modified_dict, save_path)
32
+ ```
33
+
34
+
35
+ ## Sparse ControlNet
36
+ Put Sparse ControlNets to `stable-diffusion-webui/models/ControlNet` and use Sparse ControlNets like any other ControlNets you use.
37
+
38
+ Like Motion LoRA, I also converted state dict keys inside sparse ControlNet. Run the following script to make your own sparse ControlNet checkpoint compatible with AnimateDiff-A1111.
39
+ ```python
40
+ import torch
41
+ import safetensors.torch
42
+ ad_cn_old = "v3_sd15_sparsectrl_scribble.ckpt" # replace with path to your own old sparse ControlNet checkpoint
43
+ ad_cn_new = "mm_sd15_v3_sparsectrl_scribble.safetensors" # replace with path to your own new sparse ControlNet checkpoint
44
+ normal_cn_path = "diffusion_pytorch_model.fp16.safetensors" # download https://huggingface.co/lllyasviel/control_v11p_sd15_openpose/resolve/main/diffusion_pytorch_model.fp16.safetensors?download=true and replace with the path to this model
45
+ ad_cn = safetensors.torch.load_file(file_path) if file_path.endswith(".safetensors") else torch.load(ad_cn_old)
46
+ normal_cn = safetensors.torch.load_file(normal_cn_path)
47
+ ad_cn_l, ad_cn_m = {}, {}
48
+ for k in ad_cn.keys():
49
+ if k.startswith("controlnet_cond_embedding"):
50
+ new_key = k.replace("controlnet_cond_embedding.", "input_hint_block.0.")
51
+ ad_cn_m[new_key] = ad_cn[k].to(torch.float16)
52
+ elif not k in normal_cn:
53
+ if "motion_modules" in k:
54
+ ad_cn_m[k] = ad_cn[k].to(torch.float16)
55
+ else:
56
+ raise Exception(f"{k} not in normal_cn")
57
+ else:
58
+ ad_cn_l[k] = ad_cn[k].to(torch.float16)
59
+ ad_cn_l = convert_from_diffuser_state_dict(ad_cn_l)
60
+ ad_cn_l.update(ad_cn_m)
61
+ safetensors.torch.save_file(ad_cn_l, ad_cn_new)
62
+ ```
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