mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-04 10:47:06 +08:00
rename, cleanup code
This commit is contained in:
parent
ac60a29e43
commit
5be653c2e5
@ -6,15 +6,15 @@ def project(v0, v1):
|
|||||||
v0_orthogonal = v0 - v0_parallel
|
v0_orthogonal = v0 - v0_parallel
|
||||||
return v0_parallel, v0_orthogonal
|
return v0_parallel, v0_orthogonal
|
||||||
|
|
||||||
class AGP:
|
class APG:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {
|
return {
|
||||||
"required": {
|
"required": {
|
||||||
"model": ("MODEL",),
|
"model": ("MODEL",),
|
||||||
"eta": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
"eta": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01, "tooltip": "Controls the scale of the parallel guidance vector. Default CFG behavior at a setting of 1."}),
|
||||||
"norm_threshold": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 50.0, "step": 0.1}),
|
"norm_threshold": ("FLOAT", {"default": 5.0, "min": 0.0, "max": 50.0, "step": 0.1, "tooltip": "Normalize guidance vector to this value, normalization disable at a setting of 0."}),
|
||||||
"momentum": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01}),
|
"momentum": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip":"Controls a running average of guidance during diffusion, disabled at a setting of 0."}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RETURN_TYPES = ("MODEL",)
|
RETURN_TYPES = ("MODEL",)
|
||||||
@ -23,20 +23,21 @@ class AGP:
|
|||||||
|
|
||||||
def patch(self, model, eta, norm_threshold, momentum):
|
def patch(self, model, eta, norm_threshold, momentum):
|
||||||
running_avg = 0
|
running_avg = 0
|
||||||
prev_shape = None
|
prev_sigma = None
|
||||||
|
|
||||||
def pre_cfg_function(args):
|
def pre_cfg_function(args):
|
||||||
nonlocal running_avg, prev_shape
|
nonlocal running_avg, prev_sigma
|
||||||
|
|
||||||
cond = args["conds_out"][0]
|
cond = args["conds_out"][0]
|
||||||
uncond = args["conds_out"][1]
|
uncond = args["conds_out"][1]
|
||||||
|
sigma = args["sigma"][0]
|
||||||
|
|
||||||
|
if prev_sigma is not None and sigma > prev_sigma:
|
||||||
|
running_avg = 0
|
||||||
|
prev_sigma = sigma
|
||||||
|
|
||||||
guidance = cond - uncond
|
guidance = cond - uncond
|
||||||
|
|
||||||
if prev_shape is not None and guidance.shape != prev_shape:
|
|
||||||
running_avg = 0
|
|
||||||
prev_shape = guidance.shape
|
|
||||||
|
|
||||||
if momentum > 0:
|
if momentum > 0:
|
||||||
if not torch.is_tensor(running_avg):
|
if not torch.is_tensor(running_avg):
|
||||||
running_avg = guidance
|
running_avg = guidance
|
||||||
@ -64,9 +65,9 @@ class AGP:
|
|||||||
return (m,)
|
return (m,)
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
"AGP": AGP,
|
"APG": APG,
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
"AGP": "Adaptive Gradient Projection",
|
"APG": "Adaptive Projected Guidance",
|
||||||
}
|
}
|
||||||
2
nodes.py
2
nodes.py
@ -2261,7 +2261,7 @@ def init_builtin_extra_nodes():
|
|||||||
"nodes_optimalsteps.py",
|
"nodes_optimalsteps.py",
|
||||||
"nodes_hidream.py",
|
"nodes_hidream.py",
|
||||||
"nodes_fresca.py",
|
"nodes_fresca.py",
|
||||||
"nodes_agp.py",
|
"nodes_apg.py",
|
||||||
"nodes_preview_any.py",
|
"nodes_preview_any.py",
|
||||||
"nodes_ace.py",
|
"nodes_ace.py",
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user