1+ from typing_extensions import override
12import torch
23import torch .nn .functional as F
34
4- class Mahiro :
5+ from comfy_api .latest import ComfyExtension , io
6+
7+
8+ class Mahiro (io .ComfyNode ):
9+ @classmethod
10+ def define_schema (cls ):
11+ return io .Schema (
12+ node_id = "Mahiro" ,
13+ display_name = "Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)" ,
14+ category = "_for_testing" ,
15+ description = "Modify the guidance to scale more on the 'direction' of the positive prompt rather than the difference between the negative prompt." ,
16+ inputs = [
17+ io .Model .Input ("model" ),
18+ ],
19+ outputs = [
20+ io .Model .Output (display_name = "patched_model" ),
21+ ],
22+ is_experimental = True ,
23+ )
24+
525 @classmethod
6- def INPUT_TYPES (s ):
7- return {"required" : {"model" : ("MODEL" ,),
8- }}
9- RETURN_TYPES = ("MODEL" ,)
10- RETURN_NAMES = ("patched_model" ,)
11- FUNCTION = "patch"
12- CATEGORY = "_for_testing"
13- DESCRIPTION = "Modify the guidance to scale more on the 'direction' of the positive prompt rather than the difference between the negative prompt."
14- def patch (self , model ):
26+ def execute (cls , model ) -> io .NodeOutput :
1527 m = model .clone ()
1628 def mahiro_normd (args ):
1729 scale : float = args ['cond_scale' ]
@@ -30,12 +42,16 @@ def mahiro_normd(args):
3042 wm = (simsc * cfg + (4 - simsc )* leap ) / 4
3143 return wm
3244 m .set_model_sampler_post_cfg_function (mahiro_normd )
33- return (m , )
45+ return io .NodeOutput (m )
46+
47+
48+ class MahiroExtension (ComfyExtension ):
49+ @override
50+ async def get_node_list (self ) -> list [type [io .ComfyNode ]]:
51+ return [
52+ Mahiro ,
53+ ]
3454
35- NODE_CLASS_MAPPINGS = {
36- "Mahiro" : Mahiro
37- }
3855
39- NODE_DISPLAY_NAME_MAPPINGS = {
40- "Mahiro" : "Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)" ,
41- }
56+ async def comfy_entrypoint () -> MahiroExtension :
57+ return MahiroExtension ()
0 commit comments