Doctor-Shotgun commited on
Commit
1ab24c1
·
verified ·
1 Parent(s): 79837ff

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +54 -1
README.md CHANGED
@@ -22,4 +22,57 @@ These are provided as-is, and YMMV. The user is responsible for any outputs prod
22
 
23
  Other models involved in these merges include:
24
  - [comin/IterComp](https://huggingface.co/comin/IterComp)
25
- - [CyberRealistic XL](https://civitai.com/models/312530/cyberrealistic-xl)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  Other models involved in these merges include:
24
  - [comin/IterComp](https://huggingface.co/comin/IterComp)
25
+ - [CyberRealistic XL](https://civitai.com/models/312530/cyberrealistic-xl)
26
+
27
+
28
+ ## Methods
29
+
30
+ Perpendicular merges are done via [sd-mecha](https://github.com/ljleb/sd-mecha) using the Python API, for example:
31
+
32
+ <details><summary>1) Merge noobaiXLNAIXL_vPred10Version-cyberrealistic4-perpendicular</summary>
33
+
34
+ ```python
35
+ import sd_mecha
36
+ sd_mecha.set_log_level()
37
+
38
+
39
+ text_encoder_recipe = sd_mecha.model("noobaiXLNAIXL_vPred10Version.safetensors", "sdxl")
40
+
41
+ unet_recipe = sd_mecha.add_perpendicular(
42
+ sd_mecha.model("noobaiXLNAIXL_vPred10Version.safetensors", "sdxl"),
43
+ sd_mecha.model("cyberrealisticXL_v4.safetensors", "sdxl"),
44
+ sd_mecha.model("sd_xl_base_1.0_0.9vae.safetensors", "sdxl"),
45
+ )
46
+
47
+ recipe = sd_mecha.weighted_sum(
48
+ text_encoder_recipe,
49
+ unet_recipe,
50
+ alpha=(
51
+ sd_mecha.blocks("sdxl", "txt") |
52
+ sd_mecha.blocks("sdxl", "txt2") |
53
+ sd_mecha.default("sdxl", "unet", 1)
54
+ ),
55
+ )
56
+
57
+ merger = sd_mecha.RecipeMerger(
58
+ models_dir=r"C:\path\to\models\directory",
59
+ )
60
+
61
+ merger.merge_and_save(recipe, output="output.safetensors")
62
+ ```
63
+
64
+ </details><br>
65
+
66
+ <details><summary>2) Add v_pred and ztsnr keys to the resulting model for autodetection in Comfy/Forge</summary>
67
+
68
+ ```python
69
+ from safetensors.torch import load_file, save_file
70
+ import torch
71
+
72
+ state_dict = load_file("output.safetensors")
73
+ state_dict["v_pred"] = torch.tensor([])
74
+ state_dict["ztsnr"] = torch.tensor([])
75
+ save_file(state_dict, "noobaiXLNAIXL_vPred10Version-cyberrealistic4-perpendicular.safetensors")
76
+ ```
77
+
78
+ </details><br>