generated from replicate/cog-comfyui
-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathComfyUI_LayerDiffuse.py
61 lines (56 loc) · 2.37 KB
/
ComfyUI_LayerDiffuse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from custom_node_helper import CustomNodeHelper
class ComfyUI_LayerDiffuse(CustomNodeHelper):
@staticmethod
def get_config_weights(config):
config_weights_map = {
"SDXL, Attention Injection": ["layer_xl_transparent_attn.safetensors"],
"SDXL, Conv Injection": ["layer_xl_transparent_conv.safetensors"],
"SD15, Attention Injection, attn_sharing": [
"layer_sd15_transparent_attn.safetensors"
],
"SDXL, Foreground": ["layer_xl_fg2ble.safetensors"],
"SDXL, Background": ["layer_xl_bg2ble.safetensors"],
"Diff, SDXL, Foreground": ["layer_xl_fgble2bg.safetensors"],
"Diff, SDXL, Background": ["layer_xl_bgble2fg.safetensors"],
"SD15, attn_sharing, Batch size (3N)": ["layer_sd15_joint.safetensors"],
"SD15, Foreground, attn_sharing, Batch size (2N)": [
"layer_sd15_fg2bg.safetensors"
],
"SD15, Background, attn_sharing, Batch size (2N)": [
"layer_sd15_bg2fg.safetensors"
],
}
return config_weights_map.get(config, [])
@staticmethod
def get_vae_weights(config):
vae_weights_map = {
"SD15": ["layer_sd15_vae_transparent_decoder.safetensors"],
"SDXL": ["vae_transparent_decoder.safetensors"],
}
return vae_weights_map.get(config, [])
@staticmethod
def add_weights(weights_to_download, node):
if node.is_type_in(
[
"LayeredDiffusionApply",
"LayeredDiffusionJointApply",
"LayeredDiffusionCondApply",
"LayeredDiffusionCondJointApply",
]
):
config = node.input("config")
weights_to_download.extend(ComfyUI_LayerDiffuse.get_config_weights(config))
elif node.is_type(
"LayeredDiffusionDiffApply",
):
config = f"Diff, {node.input('config')}"
weights_to_download.extend(ComfyUI_LayerDiffuse.get_config_weights(config))
elif node.is_type_in(
[
"LayeredDiffusionDecode",
"LayeredDiffusionDecodeRGBA",
"LayeredDiffusionDecodeSplit",
]
):
sd_version = node.input("sd_version")
weights_to_download.extend(ComfyUI_LayerDiffuse.get_vae_weights(sd_version))