1
+ from typing_extensions import override
1
2
import torch
2
3
import torch .nn .functional as F
3
4
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
+
5
25
@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 :
15
27
m = model .clone ()
16
28
def mahiro_normd (args ):
17
29
scale : float = args ['cond_scale' ]
@@ -30,12 +42,16 @@ def mahiro_normd(args):
30
42
wm = (simsc * cfg + (4 - simsc )* leap ) / 4
31
43
return wm
32
44
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
+ ]
34
54
35
- NODE_CLASS_MAPPINGS = {
36
- "Mahiro" : Mahiro
37
- }
38
55
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