mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2025-12-11 06:54:26 +08:00
convert nodes_sdupscale.py to V3 schema (#9943)
This commit is contained in:
parent
7ea173c187
commit
80718908a9
@ -1,23 +1,31 @@
|
|||||||
|
from typing_extensions import override
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
from comfy_api.latest import ComfyExtension, io
|
||||||
|
|
||||||
class SD_4XUpscale_Conditioning:
|
class SD_4XUpscale_Conditioning(io.ComfyNode):
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def define_schema(cls):
|
||||||
return {"required": { "images": ("IMAGE",),
|
return io.Schema(
|
||||||
"positive": ("CONDITIONING",),
|
node_id="SD_4XUpscale_Conditioning",
|
||||||
"negative": ("CONDITIONING",),
|
category="conditioning/upscale_diffusion",
|
||||||
"scale_ratio": ("FLOAT", {"default": 4.0, "min": 0.0, "max": 10.0, "step": 0.01}),
|
inputs=[
|
||||||
"noise_augmentation": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}),
|
io.Image.Input("images"),
|
||||||
}}
|
io.Conditioning.Input("positive"),
|
||||||
RETURN_TYPES = ("CONDITIONING", "CONDITIONING", "LATENT")
|
io.Conditioning.Input("negative"),
|
||||||
RETURN_NAMES = ("positive", "negative", "latent")
|
io.Float.Input("scale_ratio", default=4.0, min=0.0, max=10.0, step=0.01),
|
||||||
|
io.Float.Input("noise_augmentation", default=0.0, min=0.0, max=1.0, step=0.001),
|
||||||
|
],
|
||||||
|
outputs=[
|
||||||
|
io.Conditioning.Output(display_name="positive"),
|
||||||
|
io.Conditioning.Output(display_name="negative"),
|
||||||
|
io.Latent.Output(display_name="latent"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
FUNCTION = "encode"
|
@classmethod
|
||||||
|
def execute(cls, images, positive, negative, scale_ratio, noise_augmentation):
|
||||||
CATEGORY = "conditioning/upscale_diffusion"
|
|
||||||
|
|
||||||
def encode(self, images, positive, negative, scale_ratio, noise_augmentation):
|
|
||||||
width = max(1, round(images.shape[-2] * scale_ratio))
|
width = max(1, round(images.shape[-2] * scale_ratio))
|
||||||
height = max(1, round(images.shape[-3] * scale_ratio))
|
height = max(1, round(images.shape[-3] * scale_ratio))
|
||||||
|
|
||||||
@ -39,8 +47,16 @@ class SD_4XUpscale_Conditioning:
|
|||||||
out_cn.append(n)
|
out_cn.append(n)
|
||||||
|
|
||||||
latent = torch.zeros([images.shape[0], 4, height // 4, width // 4])
|
latent = torch.zeros([images.shape[0], 4, height // 4, width // 4])
|
||||||
return (out_cp, out_cn, {"samples":latent})
|
return io.NodeOutput(out_cp, out_cn, {"samples":latent})
|
||||||
|
|
||||||
NODE_CLASS_MAPPINGS = {
|
|
||||||
"SD_4XUpscale_Conditioning": SD_4XUpscale_Conditioning,
|
class SdUpscaleExtension(ComfyExtension):
|
||||||
}
|
@override
|
||||||
|
async def get_node_list(self) -> list[type[io.ComfyNode]]:
|
||||||
|
return [
|
||||||
|
SD_4XUpscale_Conditioning,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
async def comfy_entrypoint() -> SdUpscaleExtension:
|
||||||
|
return SdUpscaleExtension()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user