mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-12-16 17:42:58 +08:00
convert nodes_mahiro.py to V3 schema (#10070)
This commit is contained in:
parent
ed0f4a609b
commit
8accf50908
@ -1,17 +1,29 @@
|
|||||||
|
from typing_extensions import override
|
||||||
import torch
|
import torch
|
||||||
import torch.nn.functional as F
|
import torch.nn.functional as F
|
||||||
|
|
||||||
class Mahiro:
|
from comfy_api.latest import ComfyExtension, io
|
||||||
|
|
||||||
|
|
||||||
|
class Mahiro(io.ComfyNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def define_schema(cls):
|
||||||
return {"required": {"model": ("MODEL",),
|
return io.Schema(
|
||||||
}}
|
node_id="Mahiro",
|
||||||
RETURN_TYPES = ("MODEL",)
|
display_name="Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)",
|
||||||
RETURN_NAMES = ("patched_model",)
|
category="_for_testing",
|
||||||
FUNCTION = "patch"
|
description="Modify the guidance to scale more on the 'direction' of the positive prompt rather than the difference between the negative prompt.",
|
||||||
CATEGORY = "_for_testing"
|
inputs=[
|
||||||
DESCRIPTION = "Modify the guidance to scale more on the 'direction' of the positive prompt rather than the difference between the negative prompt."
|
io.Model.Input("model"),
|
||||||
def patch(self, model):
|
],
|
||||||
|
outputs=[
|
||||||
|
io.Model.Output(display_name="patched_model"),
|
||||||
|
],
|
||||||
|
is_experimental=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def execute(cls, model) -> io.NodeOutput:
|
||||||
m = model.clone()
|
m = model.clone()
|
||||||
def mahiro_normd(args):
|
def mahiro_normd(args):
|
||||||
scale: float = args['cond_scale']
|
scale: float = args['cond_scale']
|
||||||
@ -30,12 +42,16 @@ class Mahiro:
|
|||||||
wm = (simsc*cfg + (4-simsc)*leap) / 4
|
wm = (simsc*cfg + (4-simsc)*leap) / 4
|
||||||
return wm
|
return wm
|
||||||
m.set_model_sampler_post_cfg_function(mahiro_normd)
|
m.set_model_sampler_post_cfg_function(mahiro_normd)
|
||||||
return (m, )
|
return io.NodeOutput(m)
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
|
||||||
"Mahiro": Mahiro
|
|
||||||
}
|
|
||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
class MahiroExtension(ComfyExtension):
|
||||||
"Mahiro": "Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)",
|
@override
|
||||||
}
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||||
|
return [
|
||||||
|
Mahiro,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def comfy_entrypoint() -> MahiroExtension:
|
||||||
|
return MahiroExtension()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user