mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-10-05 06:07:03 +08:00
add it to nodes.py, add description, and make it a post_cfg function
This commit is contained in:
parent
cc06d81002
commit
708e102d65
@ -10,6 +10,7 @@ class Mahiro:
|
|||||||
RETURN_NAMES = ("patched_model",)
|
RETURN_NAMES = ("patched_model",)
|
||||||
FUNCTION = "patch"
|
FUNCTION = "patch"
|
||||||
CATEGORY = "_for_testing"
|
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):
|
def patch(self, model):
|
||||||
m = model.clone()
|
m = model.clone()
|
||||||
def mahiro_normd(args):
|
def mahiro_normd(args):
|
||||||
@ -27,8 +28,8 @@ class Mahiro:
|
|||||||
sim = F.cosine_similarity(normu, normm).mean()
|
sim = F.cosine_similarity(normu, normm).mean()
|
||||||
simsc = 2 * (sim+1)
|
simsc = 2 * (sim+1)
|
||||||
wm = (simsc*cfg + (4-simsc)*leap) / 4
|
wm = (simsc*cfg + (4-simsc)*leap) / 4
|
||||||
return args['input'] - wm
|
return wm
|
||||||
m.set_model_sampler_cfg_function(mahiro_normd)
|
m.set_model_sampler_post_cfg_function(mahiro_normd)
|
||||||
return (m, )
|
return (m, )
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user