|
--- |
|
license: other |
|
license_name: fair-ai-public-license-1.0-sd |
|
license_link: https://freedevproject.org/faipl-1.0-sd/ |
|
language: |
|
- en |
|
pipeline_tag: text-to-image |
|
tags: |
|
- safetensors |
|
- diffusers |
|
- stable-diffusion |
|
- stable-diffusion-xl |
|
- art |
|
library_name: diffusers |
|
--- |
|
|
|
# NoobAI-XL-Merges |
|
|
|
Various merges built on [Laxhar Lab's](https://huggingface.co/Laxhar) Illustrious-xl-based text to image model, uploaded for testing purposes. |
|
|
|
These are provided as-is, and YMMV. The user is responsible for any outputs produced using these checkpoints. |
|
|
|
Other models involved in these merges include: |
|
- [comin/IterComp](https://huggingface.co/comin/IterComp) |
|
- [CyberRealistic XL](https://civitai.com/models/312530/cyberrealistic-xl) |
|
|
|
|
|
## Methods |
|
|
|
Perpendicular merges are done via [sd-mecha](https://github.com/ljleb/sd-mecha) using the Python API, for example: |
|
|
|
<details><summary>1) Merge noobaiXLNAIXL_vPred10Version-cyberrealistic4-perpendicular</summary> |
|
|
|
```python |
|
import sd_mecha |
|
sd_mecha.set_log_level() |
|
|
|
|
|
text_encoder_recipe = sd_mecha.model("noobaiXLNAIXL_vPred10Version.safetensors", "sdxl") |
|
|
|
unet_recipe = sd_mecha.add_perpendicular( |
|
sd_mecha.model("noobaiXLNAIXL_vPred10Version.safetensors", "sdxl"), |
|
sd_mecha.model("cyberrealisticXL_v4.safetensors", "sdxl"), |
|
sd_mecha.model("sd_xl_base_1.0_0.9vae.safetensors", "sdxl"), |
|
) |
|
|
|
recipe = sd_mecha.weighted_sum( |
|
text_encoder_recipe, |
|
unet_recipe, |
|
alpha=( |
|
sd_mecha.blocks("sdxl", "txt") | |
|
sd_mecha.blocks("sdxl", "txt2") | |
|
sd_mecha.default("sdxl", "unet", 1) |
|
), |
|
) |
|
|
|
merger = sd_mecha.RecipeMerger( |
|
models_dir=r"C:\path\to\models\directory", |
|
) |
|
|
|
merger.merge_and_save(recipe, output="output.safetensors") |
|
``` |
|
|
|
</details><br> |
|
|
|
<details><summary>2) Add v_pred and ztsnr keys to the resulting model for autodetection in Comfy/Forge</summary> |
|
|
|
```python |
|
from safetensors.torch import load_file, save_file |
|
import torch |
|
|
|
state_dict = load_file("output.safetensors") |
|
state_dict["v_pred"] = torch.tensor([]) |
|
state_dict["ztsnr"] = torch.tensor([]) |
|
save_file(state_dict, "noobaiXLNAIXL_vPred10Version-cyberrealistic4-perpendicular.safetensors") |
|
``` |
|
|
|
</details><br> |