add denoise support

This commit is contained in:
cubiq
2024-09-22 11:49:02 +02:00
parent e71e4f0622
commit 293ca1ca25
3 changed files with 1121 additions and 265 deletions
+3 -2
View File
@@ -28,6 +28,7 @@ class FluxBlockPatcherSampler:
"sampler": (comfy.samplers.KSampler.SAMPLERS, ), "sampler": (comfy.samplers.KSampler.SAMPLERS, ),
"scheduler": (comfy.samplers.KSampler.SCHEDULERS, ), "scheduler": (comfy.samplers.KSampler.SCHEDULERS, ),
"guidance": ("FLOAT", {"default": 3.5, "min": -10.0, "max": 10.0, "step": 0.1}), "guidance": ("FLOAT", {"default": 3.5, "min": -10.0, "max": 10.0, "step": 0.1}),
"denoise": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.05}),
"blocks": ("STRING", {"multiline": True, "dynamicPrompts": True, "default": "double_blocks\.([0-9]+)\.(img|txt)_(mod|attn|mlp\.[02])\.(lin|qkv|proj)\.(weight|bias)=1.1\nsingle_blocks\.([0-9]+)\.(linear[12]|modulation\.lin)\.(weight|bias)=1.1"}), "blocks": ("STRING", {"multiline": True, "dynamicPrompts": True, "default": "double_blocks\.([0-9]+)\.(img|txt)_(mod|attn|mlp\.[02])\.(lin|qkv|proj)\.(weight|bias)=1.1\nsingle_blocks\.([0-9]+)\.(linear[12]|modulation\.lin)\.(weight|bias)=1.1"}),
} }
@@ -37,7 +38,7 @@ class FluxBlockPatcherSampler:
RETURN_NAMES = ("latent", "sampler_params", "patched_blocks",) RETURN_NAMES = ("latent", "sampler_params", "patched_blocks",)
FUNCTION = "apply_style" FUNCTION = "apply_style"
def apply_style(self, model, conditioning, latent_image, noise_seed, steps, sampler, scheduler, guidance, blocks): def apply_style(self, model, conditioning, latent_image, noise_seed, steps, sampler, scheduler, guidance, denoise, blocks):
# is_schnell = model.model.model_type == comfy.model_base.ModelType.FLOW # is_schnell = model.model.model_type == comfy.model_base.ModelType.FLOW
sd = model.model_state_dict() sd = model.model_state_dict()
@@ -50,7 +51,7 @@ class FluxBlockPatcherSampler:
out_latent = None out_latent = None
noise = Noise_RandomNoise(noise_seed) noise = Noise_RandomNoise(noise_seed)
sigmas = BasicScheduler().get_sigmas(model, scheduler, steps, 1.0)[0] sigmas = BasicScheduler().get_sigmas(model, scheduler, steps, denoise)[0]
cond = conditioning_set_values(conditioning, {"guidance": guidance}) cond = conditioning_set_values(conditioning, {"guidance": guidance})
sca = SamplerCustomAdvanced() sca = SamplerCustomAdvanced()
latentbatch = LatentBatch() latentbatch = LatentBatch()
+264 -263
View File
@@ -1,6 +1,6 @@
{ {
"last_node_id": 65, "last_node_id": 68,
"last_link_id": 137, "last_link_id": 146,
"nodes": [ "nodes": [
{ {
"id": 11, "id": 11,
@@ -57,7 +57,7 @@
"name": "MODEL", "name": "MODEL",
"type": "MODEL", "type": "MODEL",
"links": [ "links": [
131 140
], ],
"slot_index": 0, "slot_index": 0,
"shape": 3 "shape": 3
@@ -71,6 +71,221 @@
"fp8_e4m3fn" "fp8_e4m3fn"
] ]
}, },
{
"id": 65,
"type": "PlotBlockParams",
"pos": {
"0": 1584,
"1": 33
},
"size": {
"0": 210,
"1": 102
},
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 135
},
{
"name": "params",
"type": "SAMPLER_PARAMS",
"link": 142
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
137
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "PlotBlockParams"
},
"widgets_values": [
0,
"true"
]
},
{
"id": 26,
"type": "PreviewImage",
"pos": {
"0": 1851,
"1": 30
},
"size": {
"0": 865.0372314453125,
"1": 918.26025390625
},
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 137
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
}
},
{
"id": 8,
"type": "VAEDecode",
"pos": {
"0": 1365,
"1": 7
},
"size": {
"0": 140,
"1": 46
},
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 141
},
{
"name": "vae",
"type": "VAE",
"link": 12
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
135
],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "VAEDecode"
}
},
{
"id": 10,
"type": "VAELoader",
"pos": {
"0": 1089,
"1": 445
},
"size": {
"0": 210,
"1": 58
},
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
12
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"ae.sft"
]
},
{
"id": 66,
"type": "FluxBlockPatcherSampler",
"pos": {
"0": 899,
"1": 45
},
"size": [
393.17110285341823,
321.31410750088173
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 140
},
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 139
},
{
"name": "latent_image",
"type": "LATENT",
"link": 146
}
],
"outputs": [
{
"name": "latent",
"type": "LATENT",
"links": [
141
],
"shape": 3,
"slot_index": 0
},
{
"name": "sampler_params",
"type": "SAMPLER_PARAMS",
"links": [
142
],
"shape": 3,
"slot_index": 1
},
{
"name": "patched_blocks",
"type": "STRING",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "FluxBlockPatcherSampler"
},
"widgets_values": [
0,
"fixed",
24,
"euler",
"simple",
3.5,
0.8,
"double_blocks\\.([0-9]+)\\.(img|txt)_(mod|attn|mlp\\.[02])\\.(lin|qkv|proj)\\.(weight|bias)=1.1\nsingle_blocks\\.([0-9]+)\\.(linear[12]|modulation\\.lin)\\.(weight|bias)=1.05"
]
},
{ {
"id": 6, "id": 6,
"type": "CLIPTextEncode", "type": "CLIPTextEncode",
@@ -97,7 +312,7 @@
"name": "CONDITIONING", "name": "CONDITIONING",
"type": "CONDITIONING", "type": "CONDITIONING",
"links": [ "links": [
132 139
], ],
"slot_index": 0 "slot_index": 0
} }
@@ -121,7 +336,7 @@
"1": 106 "1": 106
}, },
"flags": {}, "flags": {},
"order": 2, "order": 3,
"mode": 0, "mode": 0,
"inputs": [], "inputs": [],
"outputs": [ "outputs": [
@@ -129,7 +344,7 @@
"name": "LATENT", "name": "LATENT",
"type": "LATENT", "type": "LATENT",
"links": [ "links": [
133 146
], ],
"slot_index": 0, "slot_index": 0,
"shape": 3 "shape": 3
@@ -143,220 +358,6 @@
1024, 1024,
1 1
] ]
},
{
"id": 8,
"type": "VAEDecode",
"pos": {
"0": 1377,
"1": -31
},
"size": {
"0": 140,
"1": 46
},
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 134
},
{
"name": "vae",
"type": "VAE",
"link": 12
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
135
],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "VAEDecode"
}
},
{
"id": 65,
"type": "PlotBlockParams",
"pos": {
"0": 1584,
"1": 33
},
"size": [
210,
102
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 135
},
{
"name": "params",
"type": "SAMPLER_PARAMS",
"link": 136
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
137
],
"shape": 3,
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "PlotBlockParams"
},
"widgets_values": [
0,
"true"
]
},
{
"id": 64,
"type": "FluxBlockPatcherSampler",
"pos": {
"0": 891,
"1": -32
},
"size": [
339.0323991530754,
299.821227993353
],
"flags": {},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 131
},
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 132
},
{
"name": "latent_image",
"type": "LATENT",
"link": 133
}
],
"outputs": [
{
"name": "latent",
"type": "LATENT",
"links": [
134
],
"shape": 3,
"slot_index": 0
},
{
"name": "sampler_params",
"type": "SAMPLER_PARAMS",
"links": [
136
],
"shape": 3,
"slot_index": 1
},
{
"name": "patched_blocks",
"type": "STRING",
"links": null,
"shape": 3
}
],
"properties": {
"Node name for S&R": "FluxBlockPatcherSampler"
},
"widgets_values": [
0,
"fixed",
24,
"deis",
"beta",
3,
"double_blocks\\.0\\.=1.1\ndouble_blocks\\.1\\.=1.1\ndouble_blocks\\.2\\.=1.1\ndouble_blocks\\.3\\.=1.1"
]
},
{
"id": 10,
"type": "VAELoader",
"pos": {
"0": 1020,
"1": 319
},
"size": {
"0": 210,
"1": 58
},
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
12
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"ae.sft"
]
},
{
"id": 26,
"type": "PreviewImage",
"pos": {
"0": 1851,
"1": 30
},
"size": [
865.0372553163784,
918.2602634191438
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 137
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
}
} }
], ],
"links": [ "links": [
@@ -376,38 +377,6 @@
1, 1,
"VAE" "VAE"
], ],
[
131,
12,
0,
64,
0,
"MODEL"
],
[
132,
6,
0,
64,
1,
"CONDITIONING"
],
[
133,
59,
0,
64,
2,
"LATENT"
],
[
134,
64,
0,
8,
0,
"LATENT"
],
[ [
135, 135,
8, 8,
@@ -416,14 +385,6 @@
0, 0,
"IMAGE" "IMAGE"
], ],
[
136,
64,
1,
65,
1,
"SAMPLER_PARAMS"
],
[ [
137, 137,
65, 65,
@@ -431,16 +392,56 @@
26, 26,
0, 0,
"IMAGE" "IMAGE"
],
[
139,
6,
0,
66,
1,
"CONDITIONING"
],
[
140,
12,
0,
66,
0,
"MODEL"
],
[
141,
66,
0,
8,
0,
"LATENT"
],
[
142,
66,
1,
65,
1,
"SAMPLER_PARAMS"
],
[
146,
59,
0,
66,
2,
"LATENT"
] ]
], ],
"groups": [], "groups": [],
"config": {}, "config": {},
"extra": { "extra": {
"ds": { "ds": {
"scale": 0.630394086312919, "scale": 0.7400249944258294,
"offset": [ "offset": [
-175.11789190414686, -136.91856411173993,
613.9746410020917 632.3313593450009
] ]
}, },
"groupNodes": { "groupNodes": {
+854
View File
@@ -0,0 +1,854 @@
{
"last_node_id": 58,
"last_link_id": 116,
"nodes": [
{
"id": 11,
"type": "DualCLIPLoader",
"pos": {
"0": 40,
"1": 70
},
"size": {
"0": 210,
"1": 106
},
"flags": {},
"order": 0,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "CLIP",
"type": "CLIP",
"links": [
10
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "DualCLIPLoader"
},
"widgets_values": [
"t5xxl_fp16.safetensors",
"clip_l.safetensors",
"flux"
]
},
{
"id": 16,
"type": "KSamplerSelect",
"pos": {
"0": 1060,
"1": 330
},
"size": {
"0": 219.2825164794922,
"1": 58
},
"flags": {},
"order": 1,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "SAMPLER",
"type": "SAMPLER",
"links": [
19
],
"shape": 3
}
],
"properties": {
"Node name for S&R": "KSamplerSelect"
},
"widgets_values": [
"euler"
]
},
{
"id": 10,
"type": "VAELoader",
"pos": {
"0": 1430,
"1": 440
},
"size": {
"0": 210,
"1": 58
},
"flags": {},
"order": 2,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "VAE",
"type": "VAE",
"links": [
12
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "VAELoader"
},
"widgets_values": [
"ae.sft"
]
},
{
"id": 8,
"type": "VAEDecode",
"pos": {
"0": 1730,
"1": 270
},
"size": {
"0": 140,
"1": 46
},
"flags": {},
"order": 13,
"mode": 0,
"inputs": [
{
"name": "samples",
"type": "LATENT",
"link": 102
},
{
"name": "vae",
"type": "VAE",
"link": 12
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"links": [
96
],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "VAEDecode"
}
},
{
"id": 22,
"type": "BasicGuider",
"pos": {
"0": 1100,
"1": 210
},
"size": {
"0": 161.1999969482422,
"1": 46
},
"flags": {},
"order": 11,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 116,
"slot_index": 0
},
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 43,
"slot_index": 1
}
],
"outputs": [
{
"name": "GUIDER",
"type": "GUIDER",
"links": [
30
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "BasicGuider"
}
},
{
"id": 13,
"type": "SamplerCustomAdvanced",
"pos": {
"0": 1410,
"1": 270
},
"size": {
"0": 236.8000030517578,
"1": 106
},
"flags": {},
"order": 12,
"mode": 0,
"inputs": [
{
"name": "noise",
"type": "NOISE",
"link": 37,
"slot_index": 0
},
{
"name": "guider",
"type": "GUIDER",
"link": 30,
"slot_index": 1
},
{
"name": "sampler",
"type": "SAMPLER",
"link": 19,
"slot_index": 2
},
{
"name": "sigmas",
"type": "SIGMAS",
"link": 83,
"slot_index": 3
},
{
"name": "latent_image",
"type": "LATENT",
"link": 101,
"slot_index": 4
}
],
"outputs": [
{
"name": "output",
"type": "LATENT",
"links": [],
"slot_index": 0,
"shape": 3
},
{
"name": "denoised_output",
"type": "LATENT",
"links": [
102
],
"slot_index": 1,
"shape": 3
}
],
"properties": {
"Node name for S&R": "SamplerCustomAdvanced"
}
},
{
"id": 29,
"type": "FluxGuidance",
"pos": {
"0": 760,
"1": 140
},
"size": {
"0": 211.60000610351562,
"1": 58
},
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "conditioning",
"type": "CONDITIONING",
"link": 42
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
43
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "FluxGuidance"
},
"widgets_values": [
3.5
]
},
{
"id": 17,
"type": "BasicScheduler",
"pos": {
"0": 1070,
"1": 450
},
"size": {
"0": 210,
"1": 106
},
"flags": {},
"order": 10,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 115,
"slot_index": 0
}
],
"outputs": [
{
"name": "SIGMAS",
"type": "SIGMAS",
"links": [
83
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "BasicScheduler"
},
"widgets_values": [
"simple",
24,
1
]
},
{
"id": 25,
"type": "RandomNoise",
"pos": {
"0": 1068,
"1": 77
},
"size": {
"0": 210,
"1": 82
},
"flags": {},
"order": 3,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "NOISE",
"type": "NOISE",
"links": [
37
],
"shape": 3
}
],
"properties": {
"Node name for S&R": "RandomNoise"
},
"widgets_values": [
10,
"fixed"
]
},
{
"id": 57,
"type": "FluxBlockShareKV",
"pos": {
"0": 568,
"1": 351
},
"size": {
"0": 367.7264709472656,
"1": 191.3585662841797
},
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "model",
"type": "MODEL",
"link": 112
}
],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
115,
116
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "FluxBlockShareKV"
},
"widgets_values": [
"double_blocks\\.([0-9]+)\nsingle_blocks\\.([0-9]+)"
]
},
{
"id": 12,
"type": "UNETLoader",
"pos": {
"0": 267,
"1": 348
},
"size": {
"0": 229.8605194091797,
"1": 82
},
"flags": {},
"order": 4,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "MODEL",
"type": "MODEL",
"links": [
112
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "UNETLoader"
},
"widgets_values": [
"flux1-dev.sft",
"fp8_e4m3fn"
]
},
{
"id": 58,
"type": "EmptySD3LatentImage",
"pos": {
"0": 608,
"1": 614
},
"size": {
"0": 315,
"1": 106
},
"flags": {},
"order": 5,
"mode": 0,
"inputs": [],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [
114
],
"slot_index": 0,
"shape": 3
}
],
"properties": {
"Node name for S&R": "EmptySD3LatentImage"
},
"widgets_values": [
1024,
1024,
4
]
},
{
"id": 6,
"type": "CLIPTextEncode",
"pos": {
"0": 320,
"1": 70
},
"size": {
"0": 366.7709045410156,
"1": 201.41677856445312
},
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": 10
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": [
42
],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "CLIPTextEncode"
},
"widgets_values": [
"black cat sniffing a succulent plant"
]
},
{
"id": 49,
"type": "Reroute",
"pos": {
"0": 1191,
"1": 618
},
"size": [
75,
26
],
"flags": {},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "",
"type": "*",
"link": 114
}
],
"outputs": [
{
"name": "",
"type": "LATENT",
"links": [
101
],
"slot_index": 0
}
],
"properties": {
"showOutputText": false,
"horizontal": false
}
},
{
"id": 26,
"type": "PreviewImage",
"pos": {
"0": 1740,
"1": 390
},
"size": [
801.4180228423943,
877.8677723619548
],
"flags": {},
"order": 14,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 96
}
],
"outputs": [],
"properties": {
"Node name for S&R": "PreviewImage"
}
}
],
"links": [
[
10,
11,
0,
6,
0,
"CLIP"
],
[
12,
10,
0,
8,
1,
"VAE"
],
[
19,
16,
0,
13,
2,
"SAMPLER"
],
[
30,
22,
0,
13,
1,
"GUIDER"
],
[
37,
25,
0,
13,
0,
"NOISE"
],
[
42,
6,
0,
29,
0,
"CONDITIONING"
],
[
43,
29,
0,
22,
1,
"CONDITIONING"
],
[
83,
17,
0,
13,
3,
"SIGMAS"
],
[
96,
8,
0,
26,
0,
"IMAGE"
],
[
101,
49,
0,
13,
4,
"LATENT"
],
[
102,
13,
1,
8,
0,
"LATENT"
],
[
112,
12,
0,
57,
0,
"MODEL"
],
[
114,
58,
0,
49,
0,
"*"
],
[
115,
57,
0,
17,
0,
"MODEL"
],
[
116,
57,
0,
22,
0,
"MODEL"
]
],
"groups": [],
"config": {},
"extra": {
"ds": {
"scale": 0.6303940863128812,
"offset": [
177.5413048093568,
462.23433427354985
]
},
"groupNodes": {
"test": {
"nodes": [
{
"type": "PrimitiveNode",
"pos": [
88,
617
],
"size": {
"0": 210,
"1": 82
},
"flags": {},
"order": 5,
"mode": 0,
"outputs": [
{
"name": "INT",
"type": "INT",
"links": [],
"widget": {
"name": "width"
}
}
],
"title": "width",
"properties": {
"Run widget replace on values": false
},
"index": 0
},
{
"type": "PrimitiveNode",
"pos": [
87,
745
],
"size": {
"0": 210,
"1": 82
},
"flags": {},
"order": 6,
"mode": 0,
"outputs": [
{
"name": "INT",
"type": "INT",
"links": [],
"widget": {
"name": "height"
}
}
],
"title": "height",
"properties": {
"Run widget replace on values": false
},
"index": 1
},
{
"type": "EmptyLatentImage",
"pos": [
402,
596
],
"size": {
"0": 315,
"1": 106
},
"flags": {},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "width",
"type": "INT",
"link": null,
"widget": {
"name": "width"
},
"slot_index": 0
},
{
"name": "height",
"type": "INT",
"link": null,
"widget": {
"name": "height"
},
"slot_index": 1
}
],
"outputs": [
{
"name": "LATENT",
"type": "LATENT",
"links": [],
"slot_index": 0
}
],
"properties": {
"Node name for S&R": "EmptyLatentImage"
},
"widgets_values": [
1024,
1024,
1
],
"index": 2
}
],
"links": [
[
0,
0,
2,
0,
32,
"INT"
],
[
1,
0,
2,
1,
33,
"INT"
]
],
"external": [
[
2,
0,
"LATENT"
]
]
}
}
},
"version": 0.4
}