Files

63 lines
2.5 KiB
Python

"""SEEDS-3 sampler node with exposed stochasticity controls.
ComfyUI ships a node for the order-2 SEEDS solver (SamplerSEEDS2) but NOT for the
order-3 solver `seeds_3`, which means `seeds_3` can only ever run at its hard-coded
defaults (eta=1, s_noise=1) via the KSampler dropdown. That full-strength stochastic
term is what injects grain.
This node wraps the public `comfy.samplers.ksampler("seeds_3", ...)` API and exposes
eta / s_noise / r_1 / r_2 so you can run seeds_3 deterministically. At eta=0 the
stochastic noise injection is fully disabled (see comfy/k_diffusion/sampling.py:
`inject_noise = eta > 0 and s_noise > 0`), turning seeds_3 into a clean 3rd-order
exponential ODE solver: it keeps seeds_3's high-denoise structure/text preservation
while removing the grain.
"""
import comfy.samplers
class SamplerSEEDS3:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"eta": ("FLOAT", {
"default": 0.0, "min": 0.0, "max": 100.0, "step": 0.01, "round": False,
"tooltip": "Stochastic strength. 0.0 = fully deterministic (no injected grain). "
"Raise for more stochastic texture/variety at the cost of grain.",
}),
"s_noise": ("FLOAT", {
"default": 1.0, "min": 0.0, "max": 100.0, "step": 0.01, "round": False,
"tooltip": "SDE noise multiplier. Only has an effect when eta > 0.",
}),
"r_1": ("FLOAT", {
"default": 1.0 / 3.0, "min": 0.01, "max": 0.99, "step": 0.01, "round": False,
"tooltip": "First intermediate stage position (default 1/3).",
}),
"r_2": ("FLOAT", {
"default": 2.0 / 3.0, "min": 0.01, "max": 0.99, "step": 0.01, "round": False,
"tooltip": "Second intermediate stage position (default 2/3).",
}),
}
}
RETURN_TYPES = ("SAMPLER",)
CATEGORY = "sampling/custom_sampling/samplers"
FUNCTION = "get_sampler"
def get_sampler(self, eta=0.0, s_noise=1.0, r_1=1.0 / 3.0, r_2=2.0 / 3.0):
sampler = comfy.samplers.ksampler(
"seeds_3",
{"eta": eta, "s_noise": s_noise, "r_1": r_1, "r_2": r_2},
)
return (sampler,)
NODE_CLASS_MAPPINGS = {
"SamplerSEEDS3": SamplerSEEDS3,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"SamplerSEEDS3": "SEEDS-3 Sampler (eta control)",
}