mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2025-12-09 05:54:24 +08:00
convert nodes_pag.py to V3 schema (#10080)
This commit is contained in:
parent
3af1881455
commit
11bab7be76
@ -3,25 +3,30 @@
|
|||||||
|
|
||||||
#My modified one here is more basic but has less chances of breaking with ComfyUI updates.
|
#My modified one here is more basic but has less chances of breaking with ComfyUI updates.
|
||||||
|
|
||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
import comfy.model_patcher
|
import comfy.model_patcher
|
||||||
import comfy.samplers
|
import comfy.samplers
|
||||||
|
from comfy_api.latest import ComfyExtension, io
|
||||||
|
|
||||||
class PerturbedAttentionGuidance:
|
|
||||||
|
class PerturbedAttentionGuidance(io.ComfyNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def define_schema(cls):
|
||||||
return {
|
return io.Schema(
|
||||||
"required": {
|
node_id="PerturbedAttentionGuidance",
|
||||||
"model": ("MODEL",),
|
category="model_patches/unet",
|
||||||
"scale": ("FLOAT", {"default": 3.0, "min": 0.0, "max": 100.0, "step": 0.01, "round": 0.01}),
|
inputs=[
|
||||||
}
|
io.Model.Input("model"),
|
||||||
}
|
io.Float.Input("scale", default=3.0, min=0.0, max=100.0, step=0.01, round=0.01),
|
||||||
|
],
|
||||||
|
outputs=[
|
||||||
|
io.Model.Output(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
RETURN_TYPES = ("MODEL",)
|
@classmethod
|
||||||
FUNCTION = "patch"
|
def execute(cls, model, scale) -> io.NodeOutput:
|
||||||
|
|
||||||
CATEGORY = "model_patches/unet"
|
|
||||||
|
|
||||||
def patch(self, model, scale):
|
|
||||||
unet_block = "middle"
|
unet_block = "middle"
|
||||||
unet_block_id = 0
|
unet_block_id = 0
|
||||||
m = model.clone()
|
m = model.clone()
|
||||||
@ -49,8 +54,16 @@ class PerturbedAttentionGuidance:
|
|||||||
|
|
||||||
m.set_model_sampler_post_cfg_function(post_cfg_function)
|
m.set_model_sampler_post_cfg_function(post_cfg_function)
|
||||||
|
|
||||||
return (m,)
|
return io.NodeOutput(m)
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
|
||||||
"PerturbedAttentionGuidance": PerturbedAttentionGuidance,
|
class PAGExtension(ComfyExtension):
|
||||||
}
|
@override
|
||||||
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||||
|
return [
|
||||||
|
PerturbedAttentionGuidance,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def comfy_entrypoint() -> PAGExtension:
|
||||||
|
return PAGExtension()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user