Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

convert nodes_mahiro.py to V3 schema (#10070)

Alexander Piskun8accf5090809
diff --git a/comfy_extras/nodes_mahiro.py b/comfy_extras/nodes_mahiro.py
index 8fcdfba75..07b3353f4 100644
--- a/comfy_extras/nodes_mahiro.py
+++ b/comfy_extras/nodes_mahiro.py
@@ -1,17 +1,29 @@
+from typing_extensions import override
import torch
import torch.nn.functional as F
-class Mahiro:
+from comfy_api.latest import ComfyExtension, io
+
+
+class Mahiro(io.ComfyNode):
+ @classmethod
+ def define_schema(cls):
+ return io.Schema(
+ node_id="Mahiro",
+ display_name="Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)",
+ 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.",
+ inputs=[
+ io.Model.Input("model"),
+ ],
+ outputs=[
+ io.Model.Output(display_name="patched_model"),
+ ],
+ is_experimental=True,
+ )
+
@classmethod
- def INPUT_TYPES(s):
- return {"required": {"model": ("MODEL",),
- }}
- RETURN_TYPES = ("MODEL",)
- 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):
+ def execute(cls, model) -> io.NodeOutput:
m = model.clone()
def mahiro_normd(args):
scale: float = args['cond_scale']
@@ -30,12 +42,16 @@ class Mahiro:
wm = (simsc*cfg + (4-simsc)*leap) / 4
return wm
m.set_model_sampler_post_cfg_function(mahiro_normd)
- return (m, )
+ return io.NodeOutput(m)
+
+
+class MahiroExtension(ComfyExtension):
+ @override
+ async def get_node_list(self) -> list[type[io.ComfyNode]]:
+ return [
+ Mahiro,
+ ]
-NODE_CLASS_MAPPINGS = {
- "Mahiro": Mahiro
-}
-NODE_DISPLAY_NAME_MAPPINGS = {
- "Mahiro": "Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)",
-}
+async def comfy_entrypoint() -> MahiroExtension:
+ return MahiroExtension()