mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-11 20:40:04 +08:00
Merge branch 'comfyanonymous:master' into master
This commit is contained in:
commit
e5e8019d04
@ -47,7 +47,8 @@ class BASE:
|
|||||||
return self.unet_config["in_channels"] > 4
|
return self.unet_config["in_channels"] > 4
|
||||||
|
|
||||||
def __init__(self, unet_config):
|
def __init__(self, unet_config):
|
||||||
self.unet_config = unet_config
|
self.unet_config = unet_config.copy()
|
||||||
|
self.sampling_settings = self.sampling_settings.copy()
|
||||||
self.latent_format = self.latent_format()
|
self.latent_format = self.latent_format()
|
||||||
for x in self.unet_extra_config:
|
for x in self.unet_extra_config:
|
||||||
self.unet_config[x] = self.unet_extra_config[x]
|
self.unet_config[x] = self.unet_extra_config[x]
|
||||||
|
|||||||
@ -538,6 +538,52 @@ class SamplerCustomAdvanced:
|
|||||||
out_denoised = out
|
out_denoised = out
|
||||||
return (out, out_denoised)
|
return (out, out_denoised)
|
||||||
|
|
||||||
|
class AddNoise:
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
return {"required":
|
||||||
|
{"model": ("MODEL",),
|
||||||
|
"noise": ("NOISE", ),
|
||||||
|
"sigmas": ("SIGMAS", ),
|
||||||
|
"latent_image": ("LATENT", ),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RETURN_TYPES = ("LATENT",)
|
||||||
|
|
||||||
|
FUNCTION = "add_noise"
|
||||||
|
|
||||||
|
CATEGORY = "_for_testing/custom_sampling/noise"
|
||||||
|
|
||||||
|
def add_noise(self, model, noise, sigmas, latent_image):
|
||||||
|
if len(sigmas) == 0:
|
||||||
|
return latent_image
|
||||||
|
|
||||||
|
latent = latent_image
|
||||||
|
latent_image = latent["samples"]
|
||||||
|
|
||||||
|
noisy = noise.generate_noise(latent)
|
||||||
|
|
||||||
|
model_sampling = model.get_model_object("model_sampling")
|
||||||
|
process_latent_out = model.get_model_object("process_latent_out")
|
||||||
|
process_latent_in = model.get_model_object("process_latent_in")
|
||||||
|
|
||||||
|
if len(sigmas) > 1:
|
||||||
|
scale = torch.abs(sigmas[0] - sigmas[-1])
|
||||||
|
else:
|
||||||
|
scale = sigmas[0]
|
||||||
|
|
||||||
|
if torch.count_nonzero(latent_image) > 0: #Don't shift the empty latent image.
|
||||||
|
latent_image = process_latent_in(latent_image)
|
||||||
|
noisy = model_sampling.noise_scaling(scale, noisy, latent_image)
|
||||||
|
noisy = process_latent_out(noisy)
|
||||||
|
noisy = torch.nan_to_num(noisy, nan=0.0, posinf=0.0, neginf=0.0)
|
||||||
|
|
||||||
|
out = latent.copy()
|
||||||
|
out["samples"] = noisy
|
||||||
|
return (out,)
|
||||||
|
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"SamplerCustom": SamplerCustom,
|
"SamplerCustom": SamplerCustom,
|
||||||
"BasicScheduler": BasicScheduler,
|
"BasicScheduler": BasicScheduler,
|
||||||
@ -561,5 +607,6 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"BasicGuider": BasicGuider,
|
"BasicGuider": BasicGuider,
|
||||||
"RandomNoise": RandomNoise,
|
"RandomNoise": RandomNoise,
|
||||||
"DisableNoise": DisableNoise,
|
"DisableNoise": DisableNoise,
|
||||||
|
"AddNoise": AddNoise,
|
||||||
"SamplerCustomAdvanced": SamplerCustomAdvanced,
|
"SamplerCustomAdvanced": SamplerCustomAdvanced,
|
||||||
}
|
}
|
||||||
|
|||||||
60
comfy_extras/nodes_model_merging_model_specific.py
Normal file
60
comfy_extras/nodes_model_merging_model_specific.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import comfy_extras.nodes_model_merging
|
||||||
|
|
||||||
|
class ModelMergeSD1(comfy_extras.nodes_model_merging.ModelMergeBlocks):
|
||||||
|
CATEGORY = "advanced/model_merging/model_specific"
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
arg_dict = { "model1": ("MODEL",),
|
||||||
|
"model2": ("MODEL",)}
|
||||||
|
|
||||||
|
argument = ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01})
|
||||||
|
|
||||||
|
arg_dict["time_embed."] = argument
|
||||||
|
arg_dict["label_emb."] = argument
|
||||||
|
|
||||||
|
for i in range(12):
|
||||||
|
arg_dict["input_blocks.{}.".format(i)] = argument
|
||||||
|
|
||||||
|
for i in range(3):
|
||||||
|
arg_dict["middle_block.{}.".format(i)] = argument
|
||||||
|
|
||||||
|
for i in range(12):
|
||||||
|
arg_dict["output_blocks.{}.".format(i)] = argument
|
||||||
|
|
||||||
|
arg_dict["out."] = argument
|
||||||
|
|
||||||
|
return {"required": arg_dict}
|
||||||
|
|
||||||
|
|
||||||
|
class ModelMergeSDXL(comfy_extras.nodes_model_merging.ModelMergeBlocks):
|
||||||
|
CATEGORY = "advanced/model_merging/model_specific"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def INPUT_TYPES(s):
|
||||||
|
arg_dict = { "model1": ("MODEL",),
|
||||||
|
"model2": ("MODEL",)}
|
||||||
|
|
||||||
|
argument = ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01})
|
||||||
|
|
||||||
|
arg_dict["time_embed."] = argument
|
||||||
|
arg_dict["label_emb."] = argument
|
||||||
|
|
||||||
|
for i in range(9):
|
||||||
|
arg_dict["input_blocks.{}".format(i)] = argument
|
||||||
|
|
||||||
|
for i in range(3):
|
||||||
|
arg_dict["middle_block.{}".format(i)] = argument
|
||||||
|
|
||||||
|
for i in range(9):
|
||||||
|
arg_dict["output_blocks.{}".format(i)] = argument
|
||||||
|
|
||||||
|
arg_dict["out."] = argument
|
||||||
|
|
||||||
|
return {"required": arg_dict}
|
||||||
|
|
||||||
|
|
||||||
|
NODE_CLASS_MAPPINGS = {
|
||||||
|
"ModelMergeSD1": ModelMergeSD1,
|
||||||
|
"ModelMergeSD2": ModelMergeSD1, #SD1 and SD2 have the same blocks
|
||||||
|
"ModelMergeSDXL": ModelMergeSDXL,
|
||||||
|
}
|
||||||
1
nodes.py
1
nodes.py
@ -1946,6 +1946,7 @@ def init_custom_nodes():
|
|||||||
"nodes_stable_cascade.py",
|
"nodes_stable_cascade.py",
|
||||||
"nodes_differential_diffusion.py",
|
"nodes_differential_diffusion.py",
|
||||||
"nodes_ip2p.py",
|
"nodes_ip2p.py",
|
||||||
|
"nodes_model_merging_model_specific.py",
|
||||||
]
|
]
|
||||||
|
|
||||||
import_failed = []
|
import_failed = []
|
||||||
|
|||||||
@ -20,6 +20,10 @@ const colorPalettes = {
|
|||||||
"MODEL": "#B39DDB", // light lavender-purple
|
"MODEL": "#B39DDB", // light lavender-purple
|
||||||
"STYLE_MODEL": "#C2FFAE", // light green-yellow
|
"STYLE_MODEL": "#C2FFAE", // light green-yellow
|
||||||
"VAE": "#FF6E6E", // bright red
|
"VAE": "#FF6E6E", // bright red
|
||||||
|
"NOISE": "#B0B0B0", // gray
|
||||||
|
"GUIDER": "#66FFFF", // cyan
|
||||||
|
"SAMPLER": "#ECB4B4", // very soft red
|
||||||
|
"SIGMAS": "#CDFFCD", // soft lime green
|
||||||
"TAESD": "#DCC274", // cheesecake
|
"TAESD": "#DCC274", // cheesecake
|
||||||
},
|
},
|
||||||
"litegraph_base": {
|
"litegraph_base": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user