add it to nodes.py, add description, and make it a post_cfg function

This commit is contained in:
yoinked 2024-12-09 15:20:10 +00:00
parent cc06d81002
commit 708e102d65
2 changed files with 4 additions and 2 deletions

View File

@ -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 = {

View File

@ -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",
]