From 8a8e4db2df084c6a86b48c1b801499fd47693b0d Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Sat, 2 Dec 2023 21:58:16 +0200 Subject: [PATCH] Experimental noise stuff --- nodes.py | 59 +++++++++++++++++++++++++++++++++++++++++-- web/js/setgetnodes.js | 2 ++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index ab1502e..c60cc79 100644 --- a/nodes.py +++ b/nodes.py @@ -2475,6 +2475,56 @@ class DummyLatentOut: return (latent,) +class NormalizeLatent: + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "latent": ("LATENT",), + } + } + + RETURN_TYPES = ("LATENT",) + FUNCTION = "normalize" + CATEGORY = "KJNodes" + OUTPUT_NODE = True + + def normalize(self, latent): + samples = latent["samples"] + samples /= samples.std() + out = latent.copy() + out["samples"] = samples + return (out,) + +class FlipSigmasAdjusted: + @classmethod + def INPUT_TYPES(s): + return {"required": + {"sigmas": ("SIGMAS", ), + } + } + RETURN_TYPES = ("SIGMAS",) + CATEGORY = "sampling/custom_sampling/sigmas" + + FUNCTION = "get_sigmas_adjusted" + + def get_sigmas_adjusted(self, sigmas): + print(sigmas) + sigmas = sigmas.flip(0) + if sigmas[0] == 0: + sigmas[0] = 0.0001 + adjusted_sigmas = sigmas.clone() # Create a copy to hold the adjusted values + + # Apply the special adjustment: use the current index except for the first element + for i in range(1, len(sigmas)): + adjusted_sigmas[i] = sigmas[i - 1] + + if adjusted_sigmas[0] == 0: + adjusted_sigmas[0] = 0.0001 # Apply the zero adjustment if necessary + print(adjusted_sigmas) + return (adjusted_sigmas,) + NODE_CLASS_MAPPINGS = { "INTConstant": INTConstant, "FloatConstant": FloatConstant, @@ -2519,7 +2569,9 @@ NODE_CLASS_MAPPINGS = { "BboxToInt": BboxToInt, "SplitBboxes": SplitBboxes, "ImageGrabPIL": ImageGrabPIL, - "DummyLatentOut": DummyLatentOut + "DummyLatentOut": DummyLatentOut, + "NormalizeLatent": NormalizeLatent, + "FlipSigmasAdjusted": FlipSigmasAdjusted } NODE_DISPLAY_NAME_MAPPINGS = { "INTConstant": "INT Constant", @@ -2564,5 +2616,8 @@ NODE_DISPLAY_NAME_MAPPINGS = { "BboxToInt": "BboxToInt", "SplitBboxes": "SplitBboxes", "ImageGrabPIL": "ImageGrabPIL", - "DummyLatentOut": "DummyLatentOut" + "DummyLatentOut": "DummyLatentOut", + "NormalizeLatent": "NormalizeLatent", + "FlipSigmasAdjusted": "FlipSigmasAdjusted" + } \ No newline at end of file diff --git a/web/js/setgetnodes.js b/web/js/setgetnodes.js index d62379d..bcdb17d 100644 --- a/web/js/setgetnodes.js +++ b/web/js/setgetnodes.js @@ -313,7 +313,9 @@ app.registerExtension({ if (setter) { const slotInfo = setter.inputs[slot]; + console.log(slotInfo) const link = this.graph.links[slotInfo.link]; + console.log(link) return link; } else { const errorMessage = "No SetNode found for " + this.widgets[0].value + "(" + this.type + ")";