From 708e102d6514f723bc72d96d22ba5e4266f0906e Mon Sep 17 00:00:00 2001 From: yoinked Date: Mon, 9 Dec 2024 15:20:10 +0000 Subject: [PATCH] add it to nodes.py, add description, and make it a post_cfg function --- comfy_extras/nodes_mahiro.py | 5 +++-- nodes.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/comfy_extras/nodes_mahiro.py b/comfy_extras/nodes_mahiro.py index 5c882acea..7972401c0 100644 --- a/comfy_extras/nodes_mahiro.py +++ b/comfy_extras/nodes_mahiro.py @@ -10,6 +10,7 @@ class Mahiro: RETURN_NAMES = ("patched_model",) FUNCTION = "patch" CATEGORY = "_for_testing" + DESCRIPTION = "Modify the guidance to scale more on the 'direction' of the positive prompt rather than the difference between the negative prompt." def patch(self, model): m = model.clone() def mahiro_normd(args): @@ -27,8 +28,8 @@ class Mahiro: sim = F.cosine_similarity(normu, normm).mean() simsc = 2 * (sim+1) wm = (simsc*cfg + (4-simsc)*leap) / 4 - return args['input'] - wm - m.set_model_sampler_cfg_function(mahiro_normd) + return wm + m.set_model_sampler_post_cfg_function(mahiro_normd) return (m, ) NODE_CLASS_MAPPINGS = { diff --git a/nodes.py b/nodes.py index b6e2465f6..df4124544 100644 --- a/nodes.py +++ b/nodes.py @@ -2147,6 +2147,7 @@ def init_builtin_extra_nodes(): "nodes_torch_compile.py", "nodes_mochi.py", "nodes_slg.py", + "nodes_mahiro.py", "nodes_lt.py", "nodes_hooks.py", ]