1
+ from typing_extensions import override
2
+
1
3
import torch
2
4
import comfy .utils
5
+ from comfy_api .latest import ComfyExtension , io
3
6
4
- class SD_4XUpscale_Conditioning :
7
+ class SD_4XUpscale_Conditioning ( io . ComfyNode ) :
5
8
@classmethod
6
- def INPUT_TYPES (s ):
7
- return {"required" : { "images" : ("IMAGE" ,),
8
- "positive" : ("CONDITIONING" ,),
9
- "negative" : ("CONDITIONING" ,),
10
- "scale_ratio" : ("FLOAT" , {"default" : 4.0 , "min" : 0.0 , "max" : 10.0 , "step" : 0.01 }),
11
- "noise_augmentation" : ("FLOAT" , {"default" : 0.0 , "min" : 0.0 , "max" : 1.0 , "step" : 0.001 }),
12
- }}
13
- RETURN_TYPES = ("CONDITIONING" , "CONDITIONING" , "LATENT" )
14
- RETURN_NAMES = ("positive" , "negative" , "latent" )
15
-
16
- FUNCTION = "encode"
9
+ def define_schema (cls ):
10
+ return io .Schema (
11
+ node_id = "SD_4XUpscale_Conditioning" ,
12
+ category = "conditioning/upscale_diffusion" ,
13
+ inputs = [
14
+ io .Image .Input ("images" ),
15
+ io .Conditioning .Input ("positive" ),
16
+ io .Conditioning .Input ("negative" ),
17
+ io .Float .Input ("scale_ratio" , default = 4.0 , min = 0.0 , max = 10.0 , step = 0.01 ),
18
+ io .Float .Input ("noise_augmentation" , default = 0.0 , min = 0.0 , max = 1.0 , step = 0.001 ),
19
+ ],
20
+ outputs = [
21
+ io .Conditioning .Output (display_name = "positive" ),
22
+ io .Conditioning .Output (display_name = "negative" ),
23
+ io .Latent .Output (display_name = "latent" ),
24
+ ],
25
+ )
17
26
18
- CATEGORY = "conditioning/upscale_diffusion"
19
-
20
- def encode (self , images , positive , negative , scale_ratio , noise_augmentation ):
27
+ @classmethod
28
+ def execute (cls , images , positive , negative , scale_ratio , noise_augmentation ):
21
29
width = max (1 , round (images .shape [- 2 ] * scale_ratio ))
22
30
height = max (1 , round (images .shape [- 3 ] * scale_ratio ))
23
31
@@ -39,8 +47,16 @@ def encode(self, images, positive, negative, scale_ratio, noise_augmentation):
39
47
out_cn .append (n )
40
48
41
49
latent = torch .zeros ([images .shape [0 ], 4 , height // 4 , width // 4 ])
42
- return (out_cp , out_cn , {"samples" :latent })
50
+ return io .NodeOutput (out_cp , out_cn , {"samples" :latent })
51
+
52
+
53
+ class SdUpscaleExtension (ComfyExtension ):
54
+ @override
55
+ async def get_node_list (self ) -> list [type [io .ComfyNode ]]:
56
+ return [
57
+ SD_4XUpscale_Conditioning ,
58
+ ]
59
+
43
60
44
- NODE_CLASS_MAPPINGS = {
45
- "SD_4XUpscale_Conditioning" : SD_4XUpscale_Conditioning ,
46
- }
61
+ async def comfy_entrypoint () -> SdUpscaleExtension :
62
+ return SdUpscaleExtension ()
0 commit comments