Update nodes.py

Naming convention updates
This commit is contained in:
WAS 2023-03-27 01:35:04 -07:00 committed by GitHub
parent 526f163ad0
commit 5db28f1c54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

140
nodes.py
View File

@ -40,7 +40,7 @@ class CLIPTextEncode:
RETURN_TYPES = ("CONDITIONING",) RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode" FUNCTION = "encode"
CATEGORY = "conditioning" CATEGORY = "Conditioning"
def encode(self, clip, text): def encode(self, clip, text):
return ([[clip.encode(text), {}]], ) return ([[clip.encode(text), {}]], )
@ -52,7 +52,7 @@ class ConditioningCombine:
RETURN_TYPES = ("CONDITIONING",) RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "combine" FUNCTION = "combine"
CATEGORY = "conditioning" CATEGORY = "Conditioning"
def combine(self, conditioning_1, conditioning_2): def combine(self, conditioning_1, conditioning_2):
return (conditioning_1 + conditioning_2, ) return (conditioning_1 + conditioning_2, )
@ -70,7 +70,7 @@ class ConditioningSetArea:
RETURN_TYPES = ("CONDITIONING",) RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "append" FUNCTION = "append"
CATEGORY = "conditioning" CATEGORY = "Conditioning"
def append(self, conditioning, width, height, x, y, strength, min_sigma=0.0, max_sigma=99.0): def append(self, conditioning, width, height, x, y, strength, min_sigma=0.0, max_sigma=99.0):
c = [] c = []
@ -93,7 +93,7 @@ class VAEDecode:
RETURN_TYPES = ("IMAGE",) RETURN_TYPES = ("IMAGE",)
FUNCTION = "decode" FUNCTION = "decode"
CATEGORY = "latent" CATEGORY = "Latent"
def decode(self, vae, samples): def decode(self, vae, samples):
return (vae.decode(samples["samples"]), ) return (vae.decode(samples["samples"]), )
@ -123,7 +123,7 @@ class VAEEncode:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "encode" FUNCTION = "encode"
CATEGORY = "latent" CATEGORY = "Latent"
def encode(self, vae, pixels): def encode(self, vae, pixels):
x = (pixels.shape[1] // 64) * 64 x = (pixels.shape[1] // 64) * 64
@ -165,7 +165,7 @@ class VAEEncodeForInpaint:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "encode" FUNCTION = "encode"
CATEGORY = "latent/inpaint" CATEGORY = "Latent/Inpaint"
def encode(self, vae, pixels, mask): def encode(self, vae, pixels, mask):
x = (pixels.shape[1] // 64) * 64 x = (pixels.shape[1] // 64) * 64
@ -197,7 +197,7 @@ class CheckpointLoader:
RETURN_TYPES = ("MODEL", "CLIP", "VAE") RETURN_TYPES = ("MODEL", "CLIP", "VAE")
FUNCTION = "load_checkpoint" FUNCTION = "load_checkpoint"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_checkpoint(self, config_name, ckpt_name, output_vae=True, output_clip=True): def load_checkpoint(self, config_name, ckpt_name, output_vae=True, output_clip=True):
config_path = folder_paths.get_full_path("configs", config_name) config_path = folder_paths.get_full_path("configs", config_name)
@ -212,7 +212,7 @@ class CheckpointLoaderSimple:
RETURN_TYPES = ("MODEL", "CLIP", "VAE") RETURN_TYPES = ("MODEL", "CLIP", "VAE")
FUNCTION = "load_checkpoint" FUNCTION = "load_checkpoint"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True): def load_checkpoint(self, ckpt_name, output_vae=True, output_clip=True):
ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name) ckpt_path = folder_paths.get_full_path("checkpoints", ckpt_name)
@ -228,7 +228,7 @@ class CLIPSetLastLayer:
RETURN_TYPES = ("CLIP",) RETURN_TYPES = ("CLIP",)
FUNCTION = "set_last_layer" FUNCTION = "set_last_layer"
CATEGORY = "conditioning" CATEGORY = "Conditioning"
def set_last_layer(self, clip, stop_at_clip_layer): def set_last_layer(self, clip, stop_at_clip_layer):
clip = clip.clone() clip = clip.clone()
@ -247,7 +247,7 @@ class LoraLoader:
RETURN_TYPES = ("MODEL", "CLIP") RETURN_TYPES = ("MODEL", "CLIP")
FUNCTION = "load_lora" FUNCTION = "load_lora"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_lora(self, model, clip, lora_name, strength_model, strength_clip): def load_lora(self, model, clip, lora_name, strength_model, strength_clip):
lora_path = folder_paths.get_full_path("loras", lora_name) lora_path = folder_paths.get_full_path("loras", lora_name)
@ -261,7 +261,7 @@ class VAELoader:
RETURN_TYPES = ("VAE",) RETURN_TYPES = ("VAE",)
FUNCTION = "load_vae" FUNCTION = "load_vae"
CATEGORY = "loaders" CATEGORY = "Loaders"
#TODO: scale factor? #TODO: scale factor?
def load_vae(self, vae_name): def load_vae(self, vae_name):
@ -277,7 +277,7 @@ class ControlNetLoader:
RETURN_TYPES = ("CONTROL_NET",) RETURN_TYPES = ("CONTROL_NET",)
FUNCTION = "load_controlnet" FUNCTION = "load_controlnet"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_controlnet(self, control_net_name): def load_controlnet(self, control_net_name):
controlnet_path = folder_paths.get_full_path("controlnet", control_net_name) controlnet_path = folder_paths.get_full_path("controlnet", control_net_name)
@ -293,7 +293,7 @@ class DiffControlNetLoader:
RETURN_TYPES = ("CONTROL_NET",) RETURN_TYPES = ("CONTROL_NET",)
FUNCTION = "load_controlnet" FUNCTION = "load_controlnet"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_controlnet(self, model, control_net_name): def load_controlnet(self, model, control_net_name):
controlnet_path = folder_paths.get_full_path("controlnet", control_net_name) controlnet_path = folder_paths.get_full_path("controlnet", control_net_name)
@ -312,7 +312,7 @@ class ControlNetApply:
RETURN_TYPES = ("CONDITIONING",) RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "apply_controlnet" FUNCTION = "apply_controlnet"
CATEGORY = "conditioning" CATEGORY = "Conditioning"
def apply_controlnet(self, conditioning, control_net, image, strength): def apply_controlnet(self, conditioning, control_net, image, strength):
c = [] c = []
@ -335,7 +335,7 @@ class CLIPLoader:
RETURN_TYPES = ("CLIP",) RETURN_TYPES = ("CLIP",)
FUNCTION = "load_clip" FUNCTION = "load_clip"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_clip(self, clip_name): def load_clip(self, clip_name):
clip_path = folder_paths.get_full_path("clip", clip_name) clip_path = folder_paths.get_full_path("clip", clip_name)
@ -350,7 +350,7 @@ class CLIPVisionLoader:
RETURN_TYPES = ("CLIP_VISION",) RETURN_TYPES = ("CLIP_VISION",)
FUNCTION = "load_clip" FUNCTION = "load_clip"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_clip(self, clip_name): def load_clip(self, clip_name):
clip_path = folder_paths.get_full_path("clip_vision", clip_name) clip_path = folder_paths.get_full_path("clip_vision", clip_name)
@ -366,7 +366,7 @@ class CLIPVisionEncode:
RETURN_TYPES = ("CLIP_VISION_OUTPUT",) RETURN_TYPES = ("CLIP_VISION_OUTPUT",)
FUNCTION = "encode" FUNCTION = "encode"
CATEGORY = "conditioning/style_model" CATEGORY = "Conditioning/Style Model"
def encode(self, clip_vision, image): def encode(self, clip_vision, image):
output = clip_vision.encode_image(image) output = clip_vision.encode_image(image)
@ -380,7 +380,7 @@ class StyleModelLoader:
RETURN_TYPES = ("STYLE_MODEL",) RETURN_TYPES = ("STYLE_MODEL",)
FUNCTION = "load_style_model" FUNCTION = "load_style_model"
CATEGORY = "loaders" CATEGORY = "Loaders"
def load_style_model(self, style_model_name): def load_style_model(self, style_model_name):
style_model_path = folder_paths.get_full_path("style_models", style_model_name) style_model_path = folder_paths.get_full_path("style_models", style_model_name)
@ -398,7 +398,7 @@ class StyleModelApply:
RETURN_TYPES = ("CONDITIONING",) RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "apply_stylemodel" FUNCTION = "apply_stylemodel"
CATEGORY = "conditioning/style_model" CATEGORY = "Conditioning/Style Model"
def apply_stylemodel(self, clip_vision_output, style_model, conditioning): def apply_stylemodel(self, clip_vision_output, style_model, conditioning):
cond = style_model.get_cond(clip_vision_output) cond = style_model.get_cond(clip_vision_output)
@ -420,7 +420,7 @@ class EmptyLatentImage:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "generate" FUNCTION = "generate"
CATEGORY = "latent" CATEGORY = "Latent"
def generate(self, width, height, batch_size=1): def generate(self, width, height, batch_size=1):
latent = torch.zeros([batch_size, 4, height // 8, width // 8]) latent = torch.zeros([batch_size, 4, height // 8, width // 8])
@ -441,7 +441,7 @@ class LatentUpscale:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "upscale" FUNCTION = "upscale"
CATEGORY = "latent" CATEGORY = "Latent"
def upscale(self, samples, upscale_method, width, height, crop): def upscale(self, samples, upscale_method, width, height, crop):
s = samples.copy() s = samples.copy()
@ -457,7 +457,7 @@ class LatentRotate:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "rotate" FUNCTION = "rotate"
CATEGORY = "latent/transform" CATEGORY = "Latent/Transform"
def rotate(self, samples, rotation): def rotate(self, samples, rotation):
s = samples.copy() s = samples.copy()
@ -481,7 +481,7 @@ class LatentFlip:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "flip" FUNCTION = "flip"
CATEGORY = "latent/transform" CATEGORY = "Latent/Transform"
def flip(self, samples, flip_method): def flip(self, samples, flip_method):
s = samples.copy() s = samples.copy()
@ -504,7 +504,7 @@ class LatentComposite:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "composite" FUNCTION = "composite"
CATEGORY = "latent" CATEGORY = "Latent"
def composite(self, samples_to, samples_from, x, y, composite_method="normal", feather=0): def composite(self, samples_to, samples_from, x, y, composite_method="normal", feather=0):
x = x // 8 x = x // 8
@ -546,7 +546,7 @@ class LatentCrop:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "crop" FUNCTION = "crop"
CATEGORY = "latent/transform" CATEGORY = "Latent/Transform"
def crop(self, samples, width, height, x, y): def crop(self, samples, width, height, x, y):
s = samples.copy() s = samples.copy()
@ -586,7 +586,7 @@ class SetLatentNoiseMask:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "set_mask" FUNCTION = "set_mask"
CATEGORY = "latent/inpaint" CATEGORY = "Latent/Inpaint"
def set_mask(self, samples, mask): def set_mask(self, samples, mask):
s = samples.copy() s = samples.copy()
@ -679,7 +679,7 @@ class KSampler:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "sample" FUNCTION = "sample"
CATEGORY = "sampling" CATEGORY = "Sampling"
def sample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=1.0): def sample(self, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=1.0):
return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise) return common_ksampler(model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=denoise)
@ -706,7 +706,7 @@ class KSamplerAdvanced:
RETURN_TYPES = ("LATENT",) RETURN_TYPES = ("LATENT",)
FUNCTION = "sample" FUNCTION = "sample"
CATEGORY = "sampling" CATEGORY = "Sampling"
def sample(self, model, add_noise, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, start_at_step, end_at_step, return_with_leftover_noise, denoise=1.0): def sample(self, model, add_noise, noise_seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, start_at_step, end_at_step, return_with_leftover_noise, denoise=1.0):
force_full_denoise = True force_full_denoise = True
@ -735,7 +735,7 @@ class SaveImage:
OUTPUT_NODE = True OUTPUT_NODE = True
CATEGORY = "image" CATEGORY = "Image"
def save_images(self, images, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None): def save_images(self, images, filename_prefix="ComfyUI", prompt=None, extra_pnginfo=None):
def map_filename(filename): def map_filename(filename):
@ -818,7 +818,7 @@ class LoadImage:
{"image": (sorted(os.listdir(s.input_dir)), )}, {"image": (sorted(os.listdir(s.input_dir)), )},
} }
CATEGORY = "image" CATEGORY = "Image"
RETURN_TYPES = ("IMAGE", "MASK") RETURN_TYPES = ("IMAGE", "MASK")
FUNCTION = "load_image" FUNCTION = "load_image"
@ -852,7 +852,7 @@ class LoadImageMask:
"channel": (["alpha", "red", "green", "blue"], ),} "channel": (["alpha", "red", "green", "blue"], ),}
} }
CATEGORY = "image" CATEGORY = "Image"
RETURN_TYPES = ("MASK",) RETURN_TYPES = ("MASK",)
FUNCTION = "load_image" FUNCTION = "load_image"
@ -891,7 +891,7 @@ class ImageScale:
RETURN_TYPES = ("IMAGE",) RETURN_TYPES = ("IMAGE",)
FUNCTION = "upscale" FUNCTION = "upscale"
CATEGORY = "image/upscaling" CATEGORY = "Image/Upscaling"
def upscale(self, image, upscale_method, width, height, crop): def upscale(self, image, upscale_method, width, height, crop):
samples = image.movedim(-1,1) samples = image.movedim(-1,1)
@ -908,7 +908,7 @@ class ImageInvert:
RETURN_TYPES = ("IMAGE",) RETURN_TYPES = ("IMAGE",)
FUNCTION = "invert" FUNCTION = "invert"
CATEGORY = "image" CATEGORY = "Image"
def invert(self, image): def invert(self, image):
s = 1.0 - image s = 1.0 - image
@ -933,7 +933,7 @@ class ImagePadForOutpaint:
RETURN_TYPES = ("IMAGE", "MASK") RETURN_TYPES = ("IMAGE", "MASK")
FUNCTION = "expand_image" FUNCTION = "expand_image"
CATEGORY = "image" CATEGORY = "Image"
def expand_image(self, image, left, top, right, bottom, feathering): def expand_image(self, image, left, top, right, bottom, feathering):
d1, d2, d3, d4 = image.size() d1, d2, d3, d4 = image.size()
@ -979,43 +979,43 @@ class ImagePadForOutpaint:
NODE_CLASS_MAPPINGS = { NODE_CLASS_MAPPINGS = {
"CLIP Loader": CLIPLoader,
"CLIP Set Last Layer": CLIPSetLastLayer,
"CLIP Text Encode": CLIPTextEncode,
"CLIP Vision Encode": CLIPVisionEncode,
"CLIP Vision Loader": CLIPVisionLoader,
"Checkpoint Loader": CheckpointLoader,
"Checkpoint Loader (Simple)": CheckpointLoaderSimple,
"Conditioning Combine": ConditioningCombine,
"Conditioning Set Area": ConditioningSetArea,
"ControlNet Apply": ControlNetApply,
"ControlNet Loader": ControlNetLoader,
"Diff ControlNet Loader": DiffControlNetLoader,
"Empty Latent Image": EmptyLatentImage,
"Image Invert": ImageInvert,
"Image Padding (Outpaint)": ImagePadForOutpaint,
"Image Scale": ImageScale,
"KSampler": KSampler, "KSampler": KSampler,
"CheckpointLoader": CheckpointLoader, "KSampler (Advanced)": KSamplerAdvanced,
"CheckpointLoaderSimple": CheckpointLoaderSimple, "Latent Composite": LatentComposite,
"CLIPTextEncode": CLIPTextEncode, "Latent Crop": LatentCrop,
"CLIPSetLastLayer": CLIPSetLastLayer, "Latent Flip": LatentFlip,
"VAEDecode": VAEDecode, "Latent Rotate": LatentRotate,
"VAEEncode": VAEEncode, "Latent Upscale": LatentUpscale,
"VAEEncodeForInpaint": VAEEncodeForInpaint, "Load Image": LoadImage,
"VAELoader": VAELoader, "Load Image Mask": LoadImageMask,
"EmptyLatentImage": EmptyLatentImage, "Lora Loader": LoraLoader,
"LatentUpscale": LatentUpscale, "Preview Image": PreviewImage,
"SaveImage": SaveImage, "Save Image": SaveImage,
"PreviewImage": PreviewImage, "Mask Latent Noise": SetLatentNoiseMask,
"LoadImage": LoadImage, "Style Model Apply": StyleModelApply,
"LoadImageMask": LoadImageMask, "Style Model Loader": StyleModelLoader,
"ImageScale": ImageScale, "VAE Decode": VAEDecode,
"ImageInvert": ImageInvert, "VAE Decode (Tiled)": VAEDecodeTiled,
"ImagePadForOutpaint": ImagePadForOutpaint, "VAE Encode": VAEEncode,
"ConditioningCombine": ConditioningCombine, "VAE Encode (Inpaint)": VAEEncodeForInpaint,
"ConditioningSetArea": ConditioningSetArea, "VAE Encode (Tiled)": VAEEncodeTiled,
"KSamplerAdvanced": KSamplerAdvanced, "VAE Loader": VAELoader,
"SetLatentNoiseMask": SetLatentNoiseMask,
"LatentComposite": LatentComposite,
"LatentRotate": LatentRotate,
"LatentFlip": LatentFlip,
"LatentCrop": LatentCrop,
"LoraLoader": LoraLoader,
"CLIPLoader": CLIPLoader,
"CLIPVisionEncode": CLIPVisionEncode,
"StyleModelApply": StyleModelApply,
"ControlNetApply": ControlNetApply,
"ControlNetLoader": ControlNetLoader,
"DiffControlNetLoader": DiffControlNetLoader,
"StyleModelLoader": StyleModelLoader,
"CLIPVisionLoader": CLIPVisionLoader,
"VAEDecodeTiled": VAEDecodeTiled,
"VAEEncodeTiled": VAEEncodeTiled,
} }
def load_custom_node(module_path): def load_custom_node(module_path):