Commit
·
64bff7e
1
Parent(s):
189f51c
Upload 8 files
Browse files- ComfyUI_Comfyroll_CustomNodes/Comfyroll_Nodes.py +1160 -0
- ComfyUI_Comfyroll_CustomNodes/Comfyroll_Pipe_Nodes.py +271 -0
- ComfyUI_Comfyroll_CustomNodes/README.md +89 -0
- ComfyUI_Comfyroll_CustomNodes/__init__.py +48 -0
- ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image1.png +3 -0
- ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image2.jpg +3 -0
- ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image3.JPG +3 -0
- ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image4.JPG +3 -0
ComfyUI_Comfyroll_CustomNodes/Comfyroll_Nodes.py
ADDED
|
@@ -0,0 +1,1160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 2 |
+
# Comfyroll Custom Nodes by RockOfFire and Akatsuzi https://github.com/RockOfFire/ComfyUI_Comfyroll_CustomNodes #
|
| 3 |
+
# for ComfyUI https://github.com/comfyanonymous/ComfyUI #
|
| 4 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 5 |
+
|
| 6 |
+
import torch
|
| 7 |
+
import numpy as np
|
| 8 |
+
from PIL import Image, ImageEnhance
|
| 9 |
+
from PIL.PngImagePlugin import PngInfo
|
| 10 |
+
import os
|
| 11 |
+
import sys
|
| 12 |
+
import io
|
| 13 |
+
import matplotlib.pyplot as plt
|
| 14 |
+
|
| 15 |
+
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "comfy"))
|
| 16 |
+
|
| 17 |
+
import comfy.sd
|
| 18 |
+
import comfy.utils
|
| 19 |
+
import comfy.model_management
|
| 20 |
+
|
| 21 |
+
import folder_paths
|
| 22 |
+
import json
|
| 23 |
+
from nodes import MAX_RESOLUTION
|
| 24 |
+
import typing as tg
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 28 |
+
|
| 29 |
+
def tensor2pil(image):
|
| 30 |
+
return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
|
| 31 |
+
|
| 32 |
+
def pil2tensor(image):
|
| 33 |
+
return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 37 |
+
|
| 38 |
+
class ComfyRoll_InputImages:
|
| 39 |
+
def __init__(self):
|
| 40 |
+
pass
|
| 41 |
+
|
| 42 |
+
@classmethod
|
| 43 |
+
def INPUT_TYPES(cls):
|
| 44 |
+
return {
|
| 45 |
+
"required": {
|
| 46 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 2}),
|
| 47 |
+
"image1": ("IMAGE",),
|
| 48 |
+
"image2": ("IMAGE",)
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
RETURN_TYPES = ("IMAGE",)
|
| 53 |
+
OUTPUT_NODE = True
|
| 54 |
+
FUNCTION = "InputImages"
|
| 55 |
+
|
| 56 |
+
CATEGORY = "Comfyroll/Logic"
|
| 57 |
+
|
| 58 |
+
def InputImages(self, Input, image1, image2):
|
| 59 |
+
if Input == 1:
|
| 60 |
+
return (image1, )
|
| 61 |
+
else:
|
| 62 |
+
return (image2, )
|
| 63 |
+
|
| 64 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 65 |
+
|
| 66 |
+
class ComfyRoll_InputImages_4way:
|
| 67 |
+
def __init__(self):
|
| 68 |
+
pass
|
| 69 |
+
|
| 70 |
+
@classmethod
|
| 71 |
+
def INPUT_TYPES(cls):
|
| 72 |
+
return {
|
| 73 |
+
"required": {
|
| 74 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 4}),
|
| 75 |
+
"image1": ("IMAGE",),
|
| 76 |
+
},
|
| 77 |
+
"optional": {
|
| 78 |
+
"image2": ("IMAGE",),
|
| 79 |
+
"image3": ("IMAGE",),
|
| 80 |
+
"image4": ("IMAGE",),
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
RETURN_TYPES = ("IMAGE",)
|
| 85 |
+
OUTPUT_NODE = True
|
| 86 |
+
FUNCTION = "InputImages_4"
|
| 87 |
+
|
| 88 |
+
CATEGORY = "Comfyroll/Logic"
|
| 89 |
+
|
| 90 |
+
def InputImages_4(self, Input, image1, image2=None, image3=None, image4=None):
|
| 91 |
+
if Input == 1:
|
| 92 |
+
return (image1, )
|
| 93 |
+
elif Input == 2:
|
| 94 |
+
return (image2, )
|
| 95 |
+
elif Input == 3:
|
| 96 |
+
return (image3, )
|
| 97 |
+
else:
|
| 98 |
+
return (image4, )
|
| 99 |
+
|
| 100 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 101 |
+
|
| 102 |
+
class ComfyRoll_InputLatents:
|
| 103 |
+
def __init__(self):
|
| 104 |
+
pass
|
| 105 |
+
|
| 106 |
+
@classmethod
|
| 107 |
+
def INPUT_TYPES(cls):
|
| 108 |
+
return {
|
| 109 |
+
"required": {
|
| 110 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 2}),
|
| 111 |
+
"latent1": ("LATENT",),
|
| 112 |
+
"latent2": ("LATENT",)
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
RETURN_TYPES = ("LATENT",)
|
| 117 |
+
OUTPUT_NODE = True
|
| 118 |
+
FUNCTION = "InputLatents"
|
| 119 |
+
|
| 120 |
+
CATEGORY = "Comfyroll/Logic"
|
| 121 |
+
|
| 122 |
+
def InputLatents(self, Input, latent1, latent2):
|
| 123 |
+
if Input == 1:
|
| 124 |
+
return (latent1, )
|
| 125 |
+
else:
|
| 126 |
+
return (latent2, )
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 131 |
+
|
| 132 |
+
class ComfyRoll_InputConditioning:
|
| 133 |
+
def __init__(self):
|
| 134 |
+
pass
|
| 135 |
+
|
| 136 |
+
@classmethod
|
| 137 |
+
def INPUT_TYPES(cls):
|
| 138 |
+
return {
|
| 139 |
+
"required": {
|
| 140 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 2}),
|
| 141 |
+
"conditioning1": ("CONDITIONING",),
|
| 142 |
+
"conditioning2": ("CONDITIONING",)
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
RETURN_TYPES = ("CONDITIONING",)
|
| 147 |
+
OUTPUT_NODE = True
|
| 148 |
+
FUNCTION = "InputConditioning"
|
| 149 |
+
|
| 150 |
+
CATEGORY = "Comfyroll/Logic"
|
| 151 |
+
|
| 152 |
+
def InputConditioning(self, Input, conditioning1, conditioning2):
|
| 153 |
+
if Input == 1:
|
| 154 |
+
return (conditioning1, )
|
| 155 |
+
else:
|
| 156 |
+
return (conditioning2, )
|
| 157 |
+
|
| 158 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 159 |
+
|
| 160 |
+
class ComfyRoll_InputClip:
|
| 161 |
+
def __init__(self):
|
| 162 |
+
pass
|
| 163 |
+
|
| 164 |
+
@classmethod
|
| 165 |
+
def INPUT_TYPES(cls):
|
| 166 |
+
return {
|
| 167 |
+
"required": {
|
| 168 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 2}),
|
| 169 |
+
"clip1": ("CLIP",),
|
| 170 |
+
"clip2": ("CLIP",)
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
RETURN_TYPES = ("CLIP",)
|
| 175 |
+
OUTPUT_NODE = True
|
| 176 |
+
FUNCTION = "InputClip"
|
| 177 |
+
|
| 178 |
+
CATEGORY = "Comfyroll/Logic"
|
| 179 |
+
|
| 180 |
+
def InputClip(self, Input, clip1, clip2):
|
| 181 |
+
if Input == 1:
|
| 182 |
+
return (clip1, )
|
| 183 |
+
else:
|
| 184 |
+
return (clip2, )
|
| 185 |
+
|
| 186 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 187 |
+
|
| 188 |
+
class ComfyRoll_InputModel:
|
| 189 |
+
def __init__(self):
|
| 190 |
+
pass
|
| 191 |
+
|
| 192 |
+
@classmethod
|
| 193 |
+
def INPUT_TYPES(cls):
|
| 194 |
+
return {
|
| 195 |
+
"required": {
|
| 196 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 2}),
|
| 197 |
+
"model1": ("MODEL",),
|
| 198 |
+
"model2": ("MODEL",)
|
| 199 |
+
}
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
RETURN_TYPES = ("MODEL",)
|
| 203 |
+
OUTPUT_NODE = True
|
| 204 |
+
FUNCTION = "InputModel"
|
| 205 |
+
|
| 206 |
+
CATEGORY = "Comfyroll/Logic"
|
| 207 |
+
|
| 208 |
+
def InputModel(self, Input, model1, model2):
|
| 209 |
+
if Input == 1:
|
| 210 |
+
return (model1, )
|
| 211 |
+
else:
|
| 212 |
+
return (model2, )
|
| 213 |
+
|
| 214 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 215 |
+
|
| 216 |
+
class ComfyRoll_InputControlNet:
|
| 217 |
+
def __init__(self):
|
| 218 |
+
pass
|
| 219 |
+
|
| 220 |
+
@classmethod
|
| 221 |
+
def INPUT_TYPES(cls):
|
| 222 |
+
return {
|
| 223 |
+
"required": {
|
| 224 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 2}),
|
| 225 |
+
"control_net1": ("CONTROL_NET",),
|
| 226 |
+
"control_net2": ("CONTROL_NET",)
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
RETURN_TYPES = ("CONTROL_NET",)
|
| 231 |
+
OUTPUT_NODE = True
|
| 232 |
+
FUNCTION = "InputControlNet"
|
| 233 |
+
|
| 234 |
+
CATEGORY = "Comfyroll/Logic"
|
| 235 |
+
|
| 236 |
+
def InputControlNet(self, Input, control_net1, control_net2):
|
| 237 |
+
if Input == 1:
|
| 238 |
+
return (control_net1, )
|
| 239 |
+
else:
|
| 240 |
+
return (control_net2, )
|
| 241 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 242 |
+
|
| 243 |
+
class ComfyRoll_InputLatentsText:
|
| 244 |
+
def __init__(self):
|
| 245 |
+
pass
|
| 246 |
+
|
| 247 |
+
@classmethod
|
| 248 |
+
def INPUT_TYPES(cls):
|
| 249 |
+
return {
|
| 250 |
+
"required": {
|
| 251 |
+
"Input": (["txt2img", "img2img"],),
|
| 252 |
+
"txt2img": ("LATENT",),
|
| 253 |
+
"img2img": ("LATENT",)
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
RETURN_TYPES = ("LATENT",)
|
| 258 |
+
OUTPUT_NODE = True
|
| 259 |
+
FUNCTION = "InputLatentsText"
|
| 260 |
+
|
| 261 |
+
CATEGORY = "Comfyroll/Process"
|
| 262 |
+
|
| 263 |
+
def InputLatentsText(self, Input, txt2img, img2img):
|
| 264 |
+
if Input == "txt2img":
|
| 265 |
+
return (txt2img, )
|
| 266 |
+
else:
|
| 267 |
+
return (img2img, )
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 271 |
+
|
| 272 |
+
class ComfyRoll_HiResFixSwitch:
|
| 273 |
+
def __init__(self):
|
| 274 |
+
pass
|
| 275 |
+
|
| 276 |
+
@classmethod
|
| 277 |
+
def INPUT_TYPES(cls):
|
| 278 |
+
return {
|
| 279 |
+
"required": {
|
| 280 |
+
"Input": (["latent_upscale", "image_upscale"],),
|
| 281 |
+
"latent_upscale": ("LATENT",),
|
| 282 |
+
"image_upscale": ("LATENT",)
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
RETURN_TYPES = ("LATENT",)
|
| 287 |
+
OUTPUT_NODE = True
|
| 288 |
+
FUNCTION = "InputHiResText"
|
| 289 |
+
|
| 290 |
+
CATEGORY = "Comfyroll/Process"
|
| 291 |
+
|
| 292 |
+
def InputHiResText(self, Input, latent_upscale, image_upscale):
|
| 293 |
+
if Input == "latent_upscale":
|
| 294 |
+
return (latent_upscale, )
|
| 295 |
+
else:
|
| 296 |
+
return (image_upscale, )
|
| 297 |
+
|
| 298 |
+
|
| 299 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 300 |
+
|
| 301 |
+
class ComfyRoll_LoraLoader:
|
| 302 |
+
def __init__(self):
|
| 303 |
+
self.loaded_lora = None
|
| 304 |
+
|
| 305 |
+
@classmethod
|
| 306 |
+
def INPUT_TYPES(s):
|
| 307 |
+
file_list = folder_paths.get_filename_list("loras")
|
| 308 |
+
file_list.insert(0, "None")
|
| 309 |
+
return {"required": { "model": ("MODEL",),
|
| 310 |
+
"clip": ("CLIP", ),
|
| 311 |
+
"switch": ([
|
| 312 |
+
"On",
|
| 313 |
+
"Off"],),
|
| 314 |
+
"lora_name": (file_list, ),
|
| 315 |
+
"strength_model": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 316 |
+
"strength_clip": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 317 |
+
}}
|
| 318 |
+
RETURN_TYPES = ("MODEL", "CLIP")
|
| 319 |
+
FUNCTION = "load_lora"
|
| 320 |
+
|
| 321 |
+
CATEGORY = "Comfyroll/IO"
|
| 322 |
+
|
| 323 |
+
def load_lora(self, model, clip, switch, lora_name, strength_model, strength_clip):
|
| 324 |
+
if strength_model == 0 and strength_clip == 0:
|
| 325 |
+
return (model, clip)
|
| 326 |
+
|
| 327 |
+
if switch == "Off" or lora_name == "None":
|
| 328 |
+
return (model, clip)
|
| 329 |
+
|
| 330 |
+
lora_path = folder_paths.get_full_path("loras", lora_name)
|
| 331 |
+
lora = None
|
| 332 |
+
if self.loaded_lora is not None:
|
| 333 |
+
if self.loaded_lora[0] == lora_path:
|
| 334 |
+
lora = self.loaded_lora[1]
|
| 335 |
+
else:
|
| 336 |
+
del self.loaded_lora
|
| 337 |
+
|
| 338 |
+
if lora is None:
|
| 339 |
+
lora = comfy.utils.load_torch_file(lora_path, safe_load=True)
|
| 340 |
+
self.loaded_lora = (lora_path, lora)
|
| 341 |
+
|
| 342 |
+
model_lora, clip_lora = comfy.sd.load_lora_for_models(model, clip, lora, strength_model, strength_clip)
|
| 343 |
+
return (model_lora, clip_lora)
|
| 344 |
+
|
| 345 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 346 |
+
|
| 347 |
+
class ComfyRoll_ApplyControlNet:
|
| 348 |
+
@classmethod
|
| 349 |
+
def INPUT_TYPES(s):
|
| 350 |
+
return {"required": {"conditioning": ("CONDITIONING", ),
|
| 351 |
+
"control_net": ("CONTROL_NET", ),
|
| 352 |
+
"image": ("IMAGE", ),
|
| 353 |
+
"switch": ([
|
| 354 |
+
"On",
|
| 355 |
+
"Off"],),
|
| 356 |
+
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01})
|
| 357 |
+
}}
|
| 358 |
+
RETURN_TYPES = ("CONDITIONING",)
|
| 359 |
+
FUNCTION = "apply_controlnet"
|
| 360 |
+
|
| 361 |
+
CATEGORY = "Comfyroll/Conditioning"
|
| 362 |
+
|
| 363 |
+
def apply_controlnet(self, conditioning, control_net, image, switch, strength):
|
| 364 |
+
if strength == 0 or switch == "Off":
|
| 365 |
+
return (conditioning, )
|
| 366 |
+
|
| 367 |
+
c = []
|
| 368 |
+
control_hint = image.movedim(-1,1)
|
| 369 |
+
for t in conditioning:
|
| 370 |
+
n = [t[0], t[1].copy()]
|
| 371 |
+
c_net = control_net.copy().set_cond_hint(control_hint, strength)
|
| 372 |
+
if 'control' in t[1]:
|
| 373 |
+
c_net.set_previous_controlnet(t[1]['control'])
|
| 374 |
+
n[1]['control'] = c_net
|
| 375 |
+
c.append(n)
|
| 376 |
+
return (c, )
|
| 377 |
+
|
| 378 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 379 |
+
|
| 380 |
+
class ComfyRoll_ImageSize_Float:
|
| 381 |
+
def __init__(self):
|
| 382 |
+
pass
|
| 383 |
+
|
| 384 |
+
@classmethod
|
| 385 |
+
def INPUT_TYPES(s):
|
| 386 |
+
return {
|
| 387 |
+
"required": {
|
| 388 |
+
"width": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 389 |
+
"height": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 390 |
+
"upscale_factor": ("FLOAT", {"default": 1, "min": 1, "max": 2000})
|
| 391 |
+
}
|
| 392 |
+
}
|
| 393 |
+
RETURN_TYPES = ("INT", "INT", "FLOAT")
|
| 394 |
+
#RETURN_NAMES = ("Width", "Height")
|
| 395 |
+
FUNCTION = "ImageSize_Float"
|
| 396 |
+
|
| 397 |
+
CATEGORY = "Comfyroll/Image"
|
| 398 |
+
|
| 399 |
+
def ImageSize_Float(self, width, height, upscale_factor):
|
| 400 |
+
return(width, height, upscale_factor)
|
| 401 |
+
|
| 402 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 403 |
+
|
| 404 |
+
class ComfyRoll_ImageOutput:
|
| 405 |
+
def __init__(self):
|
| 406 |
+
self.output_dir = folder_paths.get_output_directory()
|
| 407 |
+
self.type = "output"
|
| 408 |
+
|
| 409 |
+
@classmethod
|
| 410 |
+
def INPUT_TYPES(s):
|
| 411 |
+
return {"required":
|
| 412 |
+
{"images": ("IMAGE", ),
|
| 413 |
+
"output_type": (["Preview", "Save"],),
|
| 414 |
+
"filename_prefix": ("STRING", {"default": "ComfyUI"})},
|
| 415 |
+
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"},
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
RETURN_TYPES = ()
|
| 419 |
+
FUNCTION = "save_images"
|
| 420 |
+
|
| 421 |
+
OUTPUT_NODE = True
|
| 422 |
+
|
| 423 |
+
CATEGORY = "Comfyroll/Legacy"
|
| 424 |
+
|
| 425 |
+
def save_images(self, images, filename_prefix="ComfyUI", output_type = "Preview", prompt=None, extra_pnginfo=None):
|
| 426 |
+
def map_filename(filename):
|
| 427 |
+
prefix_len = len(os.path.basename(filename_prefix))
|
| 428 |
+
prefix = filename[:prefix_len + 1]
|
| 429 |
+
try:
|
| 430 |
+
digits = int(filename[prefix_len + 1:].split('_')[0])
|
| 431 |
+
except:
|
| 432 |
+
digits = 0
|
| 433 |
+
return (digits, prefix)
|
| 434 |
+
|
| 435 |
+
def compute_vars(input):
|
| 436 |
+
input = input.replace("%width%", str(images[0].shape[1]))
|
| 437 |
+
input = input.replace("%height%", str(images[0].shape[0]))
|
| 438 |
+
return input
|
| 439 |
+
|
| 440 |
+
if output_type == "Save":
|
| 441 |
+
self.output_dir = folder_paths.get_output_directory()
|
| 442 |
+
self.type = "output"
|
| 443 |
+
elif output_type == "Preview":
|
| 444 |
+
self.output_dir = folder_paths.get_temp_directory()
|
| 445 |
+
self.type = "temp"
|
| 446 |
+
|
| 447 |
+
filename_prefix = compute_vars(filename_prefix)
|
| 448 |
+
|
| 449 |
+
subfolder = os.path.dirname(os.path.normpath(filename_prefix))
|
| 450 |
+
filename = os.path.basename(os.path.normpath(filename_prefix))
|
| 451 |
+
|
| 452 |
+
full_output_folder = os.path.join(self.output_dir, subfolder)
|
| 453 |
+
|
| 454 |
+
if os.path.commonpath((self.output_dir, os.path.abspath(full_output_folder))) != self.output_dir:
|
| 455 |
+
print("Saving image outside the output folder is not allowed.")
|
| 456 |
+
return {}
|
| 457 |
+
|
| 458 |
+
try:
|
| 459 |
+
counter = max(filter(lambda a: a[1][:-1] == filename and a[1][-1] == "_", map(map_filename, os.listdir(full_output_folder))))[0] + 1
|
| 460 |
+
except ValueError:
|
| 461 |
+
counter = 1
|
| 462 |
+
except FileNotFoundError:
|
| 463 |
+
os.makedirs(full_output_folder, exist_ok=True)
|
| 464 |
+
counter = 1
|
| 465 |
+
|
| 466 |
+
results = list()
|
| 467 |
+
for image in images:
|
| 468 |
+
i = 255. * image.cpu().numpy()
|
| 469 |
+
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
|
| 470 |
+
metadata = PngInfo()
|
| 471 |
+
if prompt is not None:
|
| 472 |
+
metadata.add_text("prompt", json.dumps(prompt))
|
| 473 |
+
if extra_pnginfo is not None:
|
| 474 |
+
for x in extra_pnginfo:
|
| 475 |
+
metadata.add_text(x, json.dumps(extra_pnginfo[x]))
|
| 476 |
+
|
| 477 |
+
file = f"{filename}_{counter:05}_.png"
|
| 478 |
+
img.save(os.path.join(full_output_folder, file), pnginfo=metadata, compress_level=4)
|
| 479 |
+
results.append({
|
| 480 |
+
"filename": file,
|
| 481 |
+
"subfolder": subfolder,
|
| 482 |
+
"type": self.type
|
| 483 |
+
})
|
| 484 |
+
counter += 1
|
| 485 |
+
|
| 486 |
+
return { "ui": { "images": results } }
|
| 487 |
+
|
| 488 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 489 |
+
|
| 490 |
+
class CR_Int_Multiple_Of:
|
| 491 |
+
def __init__(self):
|
| 492 |
+
pass
|
| 493 |
+
|
| 494 |
+
@classmethod
|
| 495 |
+
def INPUT_TYPES(cls):
|
| 496 |
+
return {
|
| 497 |
+
"required": {
|
| 498 |
+
"integer": ("INT", {"default": 1, "min": -18446744073709551615, "max": 18446744073709551615}),
|
| 499 |
+
"multiple": ("FLOAT", {"default": 8, "min": 1, "max": 18446744073709551615}),
|
| 500 |
+
}
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
RETURN_TYPES =("INT",)
|
| 504 |
+
FUNCTION = "int_multiple_of"
|
| 505 |
+
|
| 506 |
+
CATEGORY = "Comfyroll/Math"
|
| 507 |
+
|
| 508 |
+
def int_multiple_of(self, integer, multiple=8):
|
| 509 |
+
if multiple == 0:
|
| 510 |
+
return (int(integer), )
|
| 511 |
+
integer = integer * multiple
|
| 512 |
+
return (int(integer), )
|
| 513 |
+
|
| 514 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 515 |
+
|
| 516 |
+
class ComfyRoll_AspectRatio:
|
| 517 |
+
def __init__(self):
|
| 518 |
+
pass
|
| 519 |
+
|
| 520 |
+
@classmethod
|
| 521 |
+
def INPUT_TYPES(s):
|
| 522 |
+
return {
|
| 523 |
+
"required": {
|
| 524 |
+
"width": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 525 |
+
"height": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 526 |
+
"aspect_ratio": (["custom", "1:1 square 512x512", "1:1 square 1024x1024", "2:3 portrait 512x768", "3:4 portrait 512x682", "3:2 landscape 768x512", "4:3 landscape 682x512", "16:9 cinema 910x512", "2:1 cinema 1024x512"],),
|
| 527 |
+
"swap_dimensions": (["Off", "On"],),
|
| 528 |
+
"upscale_factor1": ("FLOAT", {"default": 1, "min": 1, "max": 2000}),
|
| 529 |
+
"upscale_factor2": ("FLOAT", {"default": 1, "min": 1, "max": 2000}),
|
| 530 |
+
"batch_size": ("INT", {"default": 1, "min": 1, "max": 64})
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
RETURN_TYPES = ("INT", "INT", "FLOAT", "FLOAT", "INT")
|
| 534 |
+
#RETURN_NAMES = ("Width", "Height")
|
| 535 |
+
FUNCTION = "Aspect_Ratio"
|
| 536 |
+
|
| 537 |
+
CATEGORY = "Comfyroll/Image"
|
| 538 |
+
|
| 539 |
+
def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_factor1, upscale_factor2, batch_size):
|
| 540 |
+
if swap_dimensions == "Off":
|
| 541 |
+
if aspect_ratio == "2:3 portrait 512x768":
|
| 542 |
+
width, height = 512, 768
|
| 543 |
+
elif aspect_ratio == "3:2 landscape 768x512":
|
| 544 |
+
width, height = 768, 512
|
| 545 |
+
elif aspect_ratio == "1:1 square 512x512":
|
| 546 |
+
width, height = 512, 512
|
| 547 |
+
elif aspect_ratio == "1:1 square 1024x1024":
|
| 548 |
+
width, height = 1024, 1024
|
| 549 |
+
elif aspect_ratio == "16:9 cinema 910x512":
|
| 550 |
+
width, height = 910, 512
|
| 551 |
+
elif aspect_ratio == "3:4 portrait 512x682":
|
| 552 |
+
width, height = 512, 682
|
| 553 |
+
elif aspect_ratio == "4:3 landscape 682x512":
|
| 554 |
+
width, height = 682, 512
|
| 555 |
+
elif aspect_ratio == "2:1 cinema 1024x512":
|
| 556 |
+
width, height = 1024, 512
|
| 557 |
+
return(width, height, upscale_factor1, upscale_factor2, batch_size)
|
| 558 |
+
elif swap_dimensions == "On":
|
| 559 |
+
if aspect_ratio == "2:3 portrait 512x768":
|
| 560 |
+
width, height = 512, 768
|
| 561 |
+
elif aspect_ratio == "3:2 landscape 768x512":
|
| 562 |
+
width, height = 768, 512
|
| 563 |
+
elif aspect_ratio == "1:1 square 512x512":
|
| 564 |
+
width, height = 512, 512
|
| 565 |
+
elif aspect_ratio == "1:1 square 1024x1024":
|
| 566 |
+
width, height = 1024, 1024
|
| 567 |
+
elif aspect_ratio == "16:9 cinema 910x512":
|
| 568 |
+
width,height = 910, 512
|
| 569 |
+
elif aspect_ratio == "3:4 portrait 512x682":
|
| 570 |
+
width, height = 512, 682
|
| 571 |
+
elif aspect_ratio == "4:3 landscape 682x512":
|
| 572 |
+
width, height = 682, 512
|
| 573 |
+
elif aspect_ratio == "2:1 cinema 1024x512":
|
| 574 |
+
width, height = 1024, 512
|
| 575 |
+
return(height, width, upscale_factor1, upscale_factor2, batch_size)
|
| 576 |
+
|
| 577 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 578 |
+
|
| 579 |
+
class ComfyRoll_AspectRatio_SDXL:
|
| 580 |
+
def __init__(self):
|
| 581 |
+
pass
|
| 582 |
+
|
| 583 |
+
@classmethod
|
| 584 |
+
def INPUT_TYPES(s):
|
| 585 |
+
return {
|
| 586 |
+
"required": {
|
| 587 |
+
"width": ("INT", {"default": 1024, "min": 64, "max": 2048}),
|
| 588 |
+
"height": ("INT", {"default": 1024, "min": 64, "max": 2048}),
|
| 589 |
+
"aspect_ratio": (["custom", "square 1024x1024", "portrait 896x1152", "portrait 832x1216", "portrait 768x1344", "portrait 640 x 1536", "landscape 1152x896", "landscape 1216x832", "landscape 1344x768", "landscape 1536x640"],),
|
| 590 |
+
"swap_dimensions": (["Off", "On"],),
|
| 591 |
+
"upscale_factor1": ("FLOAT", {"default": 1, "min": 1, "max": 2000}),
|
| 592 |
+
"upscale_factor2": ("FLOAT", {"default": 1, "min": 1, "max": 2000}),
|
| 593 |
+
"batch_size": ("INT", {"default": 1, "min": 1, "max": 64})
|
| 594 |
+
}
|
| 595 |
+
}
|
| 596 |
+
RETURN_TYPES = ("INT", "INT", "FLOAT", "FLOAT", "INT")
|
| 597 |
+
#RETURN_NAMES = ("Width", "Height")
|
| 598 |
+
FUNCTION = "Aspect_Ratio"
|
| 599 |
+
|
| 600 |
+
CATEGORY = "Comfyroll/SDXL"
|
| 601 |
+
|
| 602 |
+
def Aspect_Ratio(self, width, height, aspect_ratio, swap_dimensions, upscale_factor1, upscale_factor2, batch_size):
|
| 603 |
+
if aspect_ratio == "square 1024x1024":
|
| 604 |
+
width, height = 1024, 1024
|
| 605 |
+
elif aspect_ratio == "portrait 896x1152":
|
| 606 |
+
width, height = 896, 1152
|
| 607 |
+
elif aspect_ratio == "portrait 832x1216":
|
| 608 |
+
width, height = 822, 1216
|
| 609 |
+
elif aspect_ratio == "portrait 768x1344":
|
| 610 |
+
width, height = 768, 1344
|
| 611 |
+
elif aspect_ratio == "portrait 640 x 1536":
|
| 612 |
+
width, height = 640, 1536
|
| 613 |
+
elif aspect_ratio == "landscape 1152x896":
|
| 614 |
+
width, height = 1152, 896
|
| 615 |
+
elif aspect_ratio == "landscape 1152x896":
|
| 616 |
+
width, height = 682, 512
|
| 617 |
+
elif aspect_ratio == "landscape 1216x832":
|
| 618 |
+
width, height = 1216, 832
|
| 619 |
+
elif aspect_ratio == "landscape 1344x768":
|
| 620 |
+
width, height = 1152, 896
|
| 621 |
+
elif aspect_ratio == "landscape 1536x640":
|
| 622 |
+
width, height = 1536, 640
|
| 623 |
+
|
| 624 |
+
if swap_dimensions == "On":
|
| 625 |
+
return(height, width, upscale_factor1, upscale_factor2, batch_size,)
|
| 626 |
+
else:
|
| 627 |
+
return(width, height, upscale_factor1, upscale_factor2, batch_size,)
|
| 628 |
+
|
| 629 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 630 |
+
|
| 631 |
+
class ComfyRoll_SeedToInt:
|
| 632 |
+
def __init__(self):
|
| 633 |
+
pass
|
| 634 |
+
|
| 635 |
+
@classmethod
|
| 636 |
+
def INPUT_TYPES(cls):
|
| 637 |
+
return {
|
| 638 |
+
"required": {
|
| 639 |
+
"seed": ("SEED", ),
|
| 640 |
+
}
|
| 641 |
+
}
|
| 642 |
+
|
| 643 |
+
RETURN_TYPES = ("INT",)
|
| 644 |
+
FUNCTION = "seed_to_int"
|
| 645 |
+
|
| 646 |
+
CATEGORY = "Comfyroll/Number"
|
| 647 |
+
|
| 648 |
+
def seed_to_int(self, seed):
|
| 649 |
+
return (seed.get('seed'),)
|
| 650 |
+
|
| 651 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 652 |
+
|
| 653 |
+
class Comfyroll_Color_Tint:
|
| 654 |
+
def __init__(self):
|
| 655 |
+
pass
|
| 656 |
+
|
| 657 |
+
@classmethod
|
| 658 |
+
def INPUT_TYPES(s):
|
| 659 |
+
return {
|
| 660 |
+
"required": {
|
| 661 |
+
"image": ("IMAGE",),
|
| 662 |
+
"strength": ("FLOAT", {
|
| 663 |
+
"default": 1.0,
|
| 664 |
+
"min": 0.1,
|
| 665 |
+
"max": 1.0,
|
| 666 |
+
"step": 0.1
|
| 667 |
+
}),
|
| 668 |
+
"mode": (["white", "black", "sepia", "red", "green", "blue", "cyan", "magenta", "yellow", "purple", "orange", "warm", "cool", "lime", "navy", "vintage", "rose", "teal", "maroon", "peach", "lavender", "olive"],),
|
| 669 |
+
},
|
| 670 |
+
}
|
| 671 |
+
|
| 672 |
+
RETURN_TYPES = ("IMAGE",)
|
| 673 |
+
FUNCTION = "color_tint"
|
| 674 |
+
|
| 675 |
+
CATEGORY = "Comfyroll/Image"
|
| 676 |
+
|
| 677 |
+
def color_tint(self, image: torch.Tensor, strength: float, mode: str = "sepia"):
|
| 678 |
+
if strength == 0:
|
| 679 |
+
return (image,)
|
| 680 |
+
|
| 681 |
+
sepia_weights = torch.tensor([0.2989, 0.5870, 0.1140]).view(1, 1, 1, 3).to(image.device)
|
| 682 |
+
|
| 683 |
+
mode_filters = {
|
| 684 |
+
"white": torch.tensor([1.0, 1.0, 1.0]),
|
| 685 |
+
"black": torch.tensor([0, 0, 0]),
|
| 686 |
+
"sepia": torch.tensor([1.0, 0.8, 0.6]),
|
| 687 |
+
"red": torch.tensor([1.0, 0.6, 0.6]),
|
| 688 |
+
"green": torch.tensor([0.6, 1.0, 0.6]),
|
| 689 |
+
"blue": torch.tensor([0.6, 0.8, 1.0]),
|
| 690 |
+
"cyan": torch.tensor([0.6, 1.0, 1.0]),
|
| 691 |
+
"magenta": torch.tensor([1.0, 0.6, 1.0]),
|
| 692 |
+
"yellow": torch.tensor([1.0, 1.0, 0.6]),
|
| 693 |
+
"purple": torch.tensor([0.8, 0.6, 1.0]),
|
| 694 |
+
"orange": torch.tensor([1.0, 0.7, 0.3]),
|
| 695 |
+
"warm": torch.tensor([1.0, 0.9, 0.7]),
|
| 696 |
+
"cool": torch.tensor([0.7, 0.9, 1.0]),
|
| 697 |
+
"lime": torch.tensor([0.7, 1.0, 0.3]),
|
| 698 |
+
"navy": torch.tensor([0.3, 0.4, 0.7]),
|
| 699 |
+
"vintage": torch.tensor([0.9, 0.85, 0.7]),
|
| 700 |
+
"rose": torch.tensor([1.0, 0.8, 0.9]),
|
| 701 |
+
"teal": torch.tensor([0.3, 0.8, 0.8]),
|
| 702 |
+
"maroon": torch.tensor([0.7, 0.3, 0.5]),
|
| 703 |
+
"peach": torch.tensor([1.0, 0.8, 0.6]),
|
| 704 |
+
"lavender": torch.tensor([0.8, 0.6, 1.0]),
|
| 705 |
+
"olive": torch.tensor([0.6, 0.7, 0.4]),
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
scale_filter = mode_filters[mode].view(1, 1, 1, 3).to(image.device)
|
| 709 |
+
|
| 710 |
+
grayscale = torch.sum(image * sepia_weights, dim=-1, keepdim=True)
|
| 711 |
+
tinted = grayscale * scale_filter
|
| 712 |
+
|
| 713 |
+
result = tinted * strength + image * (1 - strength)
|
| 714 |
+
return (result,)
|
| 715 |
+
|
| 716 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 717 |
+
|
| 718 |
+
class ComfyRoll_prompt_mixer:
|
| 719 |
+
def __init__(self):
|
| 720 |
+
pass
|
| 721 |
+
|
| 722 |
+
@classmethod
|
| 723 |
+
def INPUT_TYPES(s):
|
| 724 |
+
return {
|
| 725 |
+
"required":{
|
| 726 |
+
},
|
| 727 |
+
"optional":{
|
| 728 |
+
"prompt_positive": ("STRING", {"multiline": True, "default": "BASE_POSITIVE"}),
|
| 729 |
+
"prompt_negative": ("STRING", {"multiline": True, "default": "BASE_NEGATIVE"}),
|
| 730 |
+
"style_positive": ("STRING", {"multiline": True, "default": "REFINER_POSTIVE"}),
|
| 731 |
+
"style_negative": ("STRING", {"multiline": True, "default": "REFINER_NEGATIVE"}),
|
| 732 |
+
"preset": (["preset 1", "preset 2", "preset 3", "preset 4", "preset 5"],),
|
| 733 |
+
},
|
| 734 |
+
}
|
| 735 |
+
|
| 736 |
+
RETURN_TYPES = ("STRING", "STRING", "STRING", "STRING", "STRING", "STRING", )
|
| 737 |
+
RETURN_NAMES = ("pos_g", "pos_l", "pos_r", "neg_g", "neg_l", "neg_r", )
|
| 738 |
+
FUNCTION = "mixer"
|
| 739 |
+
|
| 740 |
+
CATEGORY = "Comfyroll/SDXL"
|
| 741 |
+
|
| 742 |
+
def mixer(self, prompt_positive, prompt_negative, style_positive, style_negative, preset):
|
| 743 |
+
if preset == "preset 1":
|
| 744 |
+
pos_g = prompt_positive
|
| 745 |
+
pos_l = prompt_positive
|
| 746 |
+
pos_r = prompt_positive
|
| 747 |
+
neg_g = prompt_negative
|
| 748 |
+
neg_l = prompt_negative
|
| 749 |
+
neg_r = prompt_negative
|
| 750 |
+
elif preset == "preset 2":
|
| 751 |
+
pos_g = prompt_positive
|
| 752 |
+
pos_l = style_positive
|
| 753 |
+
pos_r = prompt_positive
|
| 754 |
+
neg_g = prompt_negative
|
| 755 |
+
neg_l = style_negative
|
| 756 |
+
neg_r = prompt_negative
|
| 757 |
+
elif preset == "preset 3":
|
| 758 |
+
pos_g = style_positive
|
| 759 |
+
pos_l = prompt_positive
|
| 760 |
+
pos_r = style_positive
|
| 761 |
+
neg_g = style_negative
|
| 762 |
+
neg_l = prompt_negative
|
| 763 |
+
neg_r = style_negative
|
| 764 |
+
elif preset == "preset 4":
|
| 765 |
+
pos_g = prompt_positive + style_positive
|
| 766 |
+
pos_l = prompt_positive + style_positive
|
| 767 |
+
pos_r = prompt_positive + style_positive
|
| 768 |
+
neg_g = prompt_negative + style_negative
|
| 769 |
+
neg_l = prompt_negative + style_negative
|
| 770 |
+
neg_r = prompt_negative + style_negative
|
| 771 |
+
elif preset == "preset 5":
|
| 772 |
+
pos_g = prompt_positive
|
| 773 |
+
pos_l = prompt_positive
|
| 774 |
+
pos_r = style_positive
|
| 775 |
+
neg_g = prompt_negative
|
| 776 |
+
neg_l = prompt_negative
|
| 777 |
+
neg_r = style_negative
|
| 778 |
+
return (pos_g, pos_l, pos_r, neg_g, neg_l, neg_r, )
|
| 779 |
+
|
| 780 |
+
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 784 |
+
|
| 785 |
+
|
| 786 |
+
class Comfyroll_SDXLStyleText:
|
| 787 |
+
@classmethod
|
| 788 |
+
def INPUT_TYPES(s):
|
| 789 |
+
return {"required": {
|
| 790 |
+
"positive_style": ("STRING", {"default": "POS_STYLE", "multiline": True}),
|
| 791 |
+
"negative_style": ("STRING", {"default": "NEG_STYLE", "multiline": True}),
|
| 792 |
+
},
|
| 793 |
+
}
|
| 794 |
+
|
| 795 |
+
RETURN_TYPES = ("STRING", "STRING", )
|
| 796 |
+
RETURN_NAMES = ("positive_prompt_text_l", "negative_prompt_text_l" )
|
| 797 |
+
FUNCTION = "get_value"
|
| 798 |
+
|
| 799 |
+
CATEGORY = "Comfyroll/SDXL"
|
| 800 |
+
|
| 801 |
+
def get_value(self, positive_style, negative_style):
|
| 802 |
+
return (positive_style, negative_style,)
|
| 803 |
+
|
| 804 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 805 |
+
|
| 806 |
+
class Comfyroll_SDXLBasePromptEncoder:
|
| 807 |
+
@classmethod
|
| 808 |
+
def INPUT_TYPES(s):
|
| 809 |
+
return {"required": {
|
| 810 |
+
"base_clip": ("CLIP", ),
|
| 811 |
+
"pos_g": ("STRING", {"multiline": True, "default": "POS_G"}),
|
| 812 |
+
"pos_l": ("STRING", {"multiline": True, "default": "POS_L"}),
|
| 813 |
+
"neg_g": ("STRING", {"multiline": True, "default": "NEG_G"}),
|
| 814 |
+
"neg_l": ("STRING", {"multiline": True, "default": "NEG_L"}),
|
| 815 |
+
"preset": (["preset A", "preset B", "preset C"],),
|
| 816 |
+
"base_width": ("INT", {"default": 4096.0, "min": 0, "max": MAX_RESOLUTION, "step": 64}),
|
| 817 |
+
"base_height": ("INT", {"default": 4096.0, "min": 0, "max": MAX_RESOLUTION, "step": 64}),
|
| 818 |
+
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 64}),
|
| 819 |
+
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 64}),
|
| 820 |
+
"target_width": ("INT", {"default": 4096.0, "min": 0, "max": MAX_RESOLUTION, "step": 64}),
|
| 821 |
+
"target_height": ("INT", {"default": 4096.0, "min": 0, "max": MAX_RESOLUTION, "step": 64}),
|
| 822 |
+
},
|
| 823 |
+
}
|
| 824 |
+
|
| 825 |
+
RETURN_TYPES = ("CONDITIONING", "CONDITIONING", )
|
| 826 |
+
RETURN_NAMES = ("base_positive", "base_negative", )
|
| 827 |
+
FUNCTION = "encode"
|
| 828 |
+
|
| 829 |
+
CATEGORY = "Comfyroll/SDXL"
|
| 830 |
+
|
| 831 |
+
def encode(self, base_clip, pos_g, pos_l, neg_g, neg_l, base_width, base_height, crop_w, crop_h, target_width, target_height, preset,):
|
| 832 |
+
empty = base_clip.tokenize("")
|
| 833 |
+
|
| 834 |
+
# positive prompt
|
| 835 |
+
tokens1 = base_clip.tokenize(pos_g)
|
| 836 |
+
tokens1["l"] = base_clip.tokenize(pos_l)["l"]
|
| 837 |
+
|
| 838 |
+
if len(tokens1["l"]) != len(tokens1["g"]):
|
| 839 |
+
while len(tokens1["l"]) < len(tokens1["g"]):
|
| 840 |
+
tokens1["l"] += empty["l"]
|
| 841 |
+
while len(tokens1["l"]) > len(tokens1["g"]):
|
| 842 |
+
tokens1["g"] += empty["g"]
|
| 843 |
+
|
| 844 |
+
cond1, pooled1 = base_clip.encode_from_tokens(tokens1, return_pooled=True)
|
| 845 |
+
res1 = [[cond1, {"pooled_output": pooled1, "width": base_width, "height": base_height, "crop_w": crop_w, "crop_h": crop_h, "target_width": target_width, "target_height": target_height}]]
|
| 846 |
+
|
| 847 |
+
# negative prompt
|
| 848 |
+
tokens2 = base_clip.tokenize(neg_g)
|
| 849 |
+
tokens2["l"] = base_clip.tokenize(neg_l)["l"]
|
| 850 |
+
|
| 851 |
+
if len(tokens2["l"]) != len(tokens2["g"]):
|
| 852 |
+
while len(tokens2["l"]) < len(tokens2["g"]):
|
| 853 |
+
tokens2["l"] += empty["l"]
|
| 854 |
+
while len(tokens2["l"]) > len(tokens2["g"]):
|
| 855 |
+
tokens2["g"] += empty["g"]
|
| 856 |
+
|
| 857 |
+
cond2, pooled2 = base_clip.encode_from_tokens(tokens2, return_pooled=True)
|
| 858 |
+
res2 = [[cond2, {"pooled_output": pooled2, "width": base_width, "height": base_height, "crop_w": crop_w, "crop_h": crop_h, "target_width": target_width, "target_height": target_height}]]
|
| 859 |
+
|
| 860 |
+
# positive style
|
| 861 |
+
tokens2 = base_clip.tokenize(pos_l)
|
| 862 |
+
tokens2["l"] = base_clip.tokenize(neg_l)["l"]
|
| 863 |
+
|
| 864 |
+
if len(tokens2["l"]) != len(tokens2["g"]):
|
| 865 |
+
while len(tokens2["l"]) < len(tokens2["g"]):
|
| 866 |
+
tokens2["l"] += empty["l"]
|
| 867 |
+
while len(tokens2["l"]) > len(tokens2["g"]):
|
| 868 |
+
tokens2["g"] += empty["g"]
|
| 869 |
+
|
| 870 |
+
cond2, pooled2 = base_clip.encode_from_tokens(tokens2, return_pooled=True)
|
| 871 |
+
res3 = [[cond2, {"pooled_output": pooled2, "width": base_width, "height": base_height, "crop_w": crop_w, "crop_h": crop_h, "target_width": target_width, "target_height": target_height}]]
|
| 872 |
+
|
| 873 |
+
# negative style
|
| 874 |
+
tokens2 = base_clip.tokenize(neg_l)
|
| 875 |
+
tokens2["l"] = base_clip.tokenize(neg_l)["l"]
|
| 876 |
+
|
| 877 |
+
if len(tokens2["l"]) != len(tokens2["g"]):
|
| 878 |
+
while len(tokens2["l"]) < len(tokens2["g"]):
|
| 879 |
+
tokens2["l"] += empty["l"]
|
| 880 |
+
while len(tokens2["l"]) > len(tokens2["g"]):
|
| 881 |
+
tokens2["g"] += empty["g"]
|
| 882 |
+
|
| 883 |
+
cond2, pooled2 = base_clip.encode_from_tokens(tokens2, return_pooled=True)
|
| 884 |
+
res4 = [[cond2, {"pooled_output": pooled2, "width": base_width, "height": base_height, "crop_w": crop_w, "crop_h": crop_h, "target_width": target_width, "target_height": target_height}]]
|
| 885 |
+
|
| 886 |
+
if preset == "preset A":
|
| 887 |
+
base_positive = res1
|
| 888 |
+
base_negative = res2
|
| 889 |
+
elif preset == "preset B":
|
| 890 |
+
base_positive = res3
|
| 891 |
+
base_negative = res4
|
| 892 |
+
elif preset == "preset C":
|
| 893 |
+
base_positive = res1 + res3
|
| 894 |
+
base_negative = res2 + res4
|
| 895 |
+
|
| 896 |
+
return (base_positive, base_negative, )
|
| 897 |
+
|
| 898 |
+
|
| 899 |
+
|
| 900 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 901 |
+
|
| 902 |
+
|
| 903 |
+
class Comfyroll_Halftone_Grid:
|
| 904 |
+
@classmethod
|
| 905 |
+
def INPUT_TYPES(s):
|
| 906 |
+
return {"required": {
|
| 907 |
+
"width": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 908 |
+
"height": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 909 |
+
"dot_style": (["Accent","afmhot","autumn","binary","Blues","bone","BrBG","brg",
|
| 910 |
+
"BuGn","BuPu","bwr","cividis","CMRmap","cool","coolwarm","copper","cubehelix","Dark2","flag",
|
| 911 |
+
"gist_earth","gist_gray","gist_heat","gist_rainbow","gist_stern","gist_yarg","GnBu","gnuplot","gnuplot2","gray","Greens",
|
| 912 |
+
"Greys","hot","hsv","inferno","jet","magma","nipy_spectral","ocean","Oranges","OrRd",
|
| 913 |
+
"Paired","Pastel1","Pastel2","pink","PiYG","plasma","PRGn","prism","PuBu","PuBuGn",
|
| 914 |
+
"PuOr","PuRd","Purples","rainbow","RdBu","RdGy","RdPu","RdYlBu","RdYlGn","Reds","seismic",
|
| 915 |
+
"Set1","Set2","Set3","Spectral","spring","summer","tab10","tab20","tab20b","tab20c","terrain",
|
| 916 |
+
"turbo","twilight","twilight_shifted","viridis","winter","Wistia","YlGn","YlGnBu","YlOrBr","YlOrRd"],),
|
| 917 |
+
"reverse_dot_style": (["No", "Yes"],),
|
| 918 |
+
"dot_frequency": ("INT", {"default": 50, "min": 1, "max":200, "step": 1}),
|
| 919 |
+
"background_color": (["custom", "white", "black", "red", "green", "blue", "cyan", "magenta", "yellow", "purple", "orange", "lime", "navy", "teal", "maroon", "lavender", "olive"],),
|
| 920 |
+
"background_R": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1}),
|
| 921 |
+
"background_G": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1}),
|
| 922 |
+
"background_B": ("INT", {"default": 255, "min": 0, "max": 255, "step": 1}),
|
| 923 |
+
"x_pos": ("FLOAT", {"default": 0.5, "min": 0, "max": 1, "step": .01}),
|
| 924 |
+
"y_pos": ("FLOAT", {"default": 0.5, "min": 0, "max": 1, "step": .01}),
|
| 925 |
+
},
|
| 926 |
+
}
|
| 927 |
+
|
| 928 |
+
RETURN_TYPES = ("IMAGE", )
|
| 929 |
+
FUNCTION = "halftone"
|
| 930 |
+
|
| 931 |
+
CATEGORY = "Comfyroll/Image"
|
| 932 |
+
|
| 933 |
+
def halftone(self, width, height, dot_style, reverse_dot_style, dot_frequency, background_color, background_R, background_G, background_B, x_pos, y_pos):
|
| 934 |
+
if background_color == "custom":
|
| 935 |
+
bgc = (background_R/255, background_G/255, background_B/255)
|
| 936 |
+
else:
|
| 937 |
+
bgc = background_color
|
| 938 |
+
|
| 939 |
+
reverse = ""
|
| 940 |
+
|
| 941 |
+
if reverse_dot_style == "Yes":
|
| 942 |
+
reverse = "_r"
|
| 943 |
+
|
| 944 |
+
#img = Image.new(mode = 'RGB', size = (300, 200), color = (red, green, blue))
|
| 945 |
+
fig, ax = plt.subplots(figsize=(width/100,height/100))
|
| 946 |
+
#fig, ax = plt.subplots(figsize=(width/20,height/20))
|
| 947 |
+
|
| 948 |
+
|
| 949 |
+
dotsx = np.linspace(0, 1, dot_frequency)
|
| 950 |
+
dotsy = np.linspace(0, 1, dot_frequency)
|
| 951 |
+
|
| 952 |
+
X, Y = np.meshgrid(dotsx, dotsy)
|
| 953 |
+
|
| 954 |
+
dist = np.sqrt((X - x_pos)**2 + (Y - y_pos)**2)
|
| 955 |
+
|
| 956 |
+
fig.patch.set_facecolor(bgc)
|
| 957 |
+
ax.scatter(X, Y, c=dist, cmap=dot_style+reverse)
|
| 958 |
+
|
| 959 |
+
plt.axis('off')
|
| 960 |
+
plt.tight_layout(pad=0, w_pad=0, h_pad=0)
|
| 961 |
+
plt.autoscale(tight=True)
|
| 962 |
+
plt.show()
|
| 963 |
+
|
| 964 |
+
img_buf = io.BytesIO()
|
| 965 |
+
plt.savefig(img_buf, format='png')
|
| 966 |
+
img = Image.open(img_buf)
|
| 967 |
+
|
| 968 |
+
return(pil2tensor(img),)
|
| 969 |
+
|
| 970 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 971 |
+
|
| 972 |
+
|
| 973 |
+
|
| 974 |
+
class Comfyroll_LatentBatchSize:
|
| 975 |
+
|
| 976 |
+
def __init__(self):
|
| 977 |
+
pass
|
| 978 |
+
|
| 979 |
+
@classmethod
|
| 980 |
+
def INPUT_TYPES(s):
|
| 981 |
+
return {
|
| 982 |
+
"required": {
|
| 983 |
+
"latent": ("LATENT", ),
|
| 984 |
+
"batch_size": ("INT", {
|
| 985 |
+
"default": 2,
|
| 986 |
+
"min": 1,
|
| 987 |
+
"max": 16,
|
| 988 |
+
"step": 1,
|
| 989 |
+
}),
|
| 990 |
+
},
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
RETURN_TYPES = ("LATENT", )
|
| 994 |
+
|
| 995 |
+
FUNCTION = "batchsize"
|
| 996 |
+
|
| 997 |
+
OUTPUT_NODE = False
|
| 998 |
+
|
| 999 |
+
CATEGORY = "Comfyroll/Latent"
|
| 1000 |
+
|
| 1001 |
+
def batchsize(self, latent: tg.Sequence[tg.Mapping[tg.Text, torch.Tensor]], batch_size: int):
|
| 1002 |
+
samples = latent['samples']
|
| 1003 |
+
shape = samples.shape
|
| 1004 |
+
|
| 1005 |
+
sample_list = [samples] + [
|
| 1006 |
+
torch.clone(samples) for _ in range(batch_size - 1)
|
| 1007 |
+
]
|
| 1008 |
+
|
| 1009 |
+
return ({
|
| 1010 |
+
'samples': torch.cat(sample_list),
|
| 1011 |
+
}, )
|
| 1012 |
+
|
| 1013 |
+
|
| 1014 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 1015 |
+
|
| 1016 |
+
class Comfyroll_ApplyLoRA_Stack:
|
| 1017 |
+
|
| 1018 |
+
@classmethod
|
| 1019 |
+
def INPUT_TYPES(cls):
|
| 1020 |
+
return {"required": {"model": ("MODEL",),
|
| 1021 |
+
"clip": ("CLIP", ),
|
| 1022 |
+
"lora_stack": ("LORA_STACK", ),
|
| 1023 |
+
}
|
| 1024 |
+
}
|
| 1025 |
+
|
| 1026 |
+
RETURN_TYPES = ("MODEL", "CLIP",)
|
| 1027 |
+
RETURN_NAMES = ("MODEL", "CLIP", )
|
| 1028 |
+
FUNCTION = "apply_lora_stack"
|
| 1029 |
+
CATEGORY = "Comfyroll/IO"
|
| 1030 |
+
|
| 1031 |
+
def apply_lora_stack(self, model, clip, lora_stack=None,):
|
| 1032 |
+
|
| 1033 |
+
# Initialise the list
|
| 1034 |
+
lora_params = list()
|
| 1035 |
+
|
| 1036 |
+
# Extend lora_params with lora-stack items
|
| 1037 |
+
if lora_stack:
|
| 1038 |
+
lora_params.extend(lora_stack)
|
| 1039 |
+
else:
|
| 1040 |
+
return (model, clip,)
|
| 1041 |
+
|
| 1042 |
+
#print(lora_params)
|
| 1043 |
+
|
| 1044 |
+
# Initialise the model and clip
|
| 1045 |
+
model_lora = model
|
| 1046 |
+
clip_lora = clip
|
| 1047 |
+
|
| 1048 |
+
# Loop through the list
|
| 1049 |
+
for tup in lora_params:
|
| 1050 |
+
lora_name, strength_model, strength_clip = tup
|
| 1051 |
+
print(lora_name, strength_model, strength_clip)
|
| 1052 |
+
|
| 1053 |
+
lora_path = folder_paths.get_full_path("loras", lora_name)
|
| 1054 |
+
lora = comfy.utils.load_torch_file(lora_path, safe_load=True)
|
| 1055 |
+
|
| 1056 |
+
model_lora, clip_lora = comfy.sd.load_lora_for_models(model_lora, clip_lora, lora, strength_model, strength_clip)
|
| 1057 |
+
|
| 1058 |
+
return (model_lora, clip_lora,)
|
| 1059 |
+
|
| 1060 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 1061 |
+
|
| 1062 |
+
# Based on Efficiency Nodes
|
| 1063 |
+
class Comfyroll_LoRA_Stack:
|
| 1064 |
+
|
| 1065 |
+
loras = ["None"] + folder_paths.get_filename_list("loras")
|
| 1066 |
+
|
| 1067 |
+
@classmethod
|
| 1068 |
+
def INPUT_TYPES(cls):
|
| 1069 |
+
return {"required": {
|
| 1070 |
+
"switch_1": ([
|
| 1071 |
+
"Off",
|
| 1072 |
+
"On"],),
|
| 1073 |
+
"lora_name_1": (cls.loras,),
|
| 1074 |
+
"model_weight_1": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 1075 |
+
"clip_weight_1": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 1076 |
+
"switch_2": ([
|
| 1077 |
+
"Off",
|
| 1078 |
+
"On"],),
|
| 1079 |
+
"lora_name_2": (cls.loras,),
|
| 1080 |
+
"model_weight_2": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 1081 |
+
"clip_weight_2": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 1082 |
+
"switch_3": ([
|
| 1083 |
+
"Off",
|
| 1084 |
+
"On"],),
|
| 1085 |
+
"lora_name_3": (cls.loras,),
|
| 1086 |
+
"model_weight_3": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 1087 |
+
"clip_weight_3": ("FLOAT", {"default": 1.0, "min": -10.0, "max": 10.0, "step": 0.01}),
|
| 1088 |
+
},
|
| 1089 |
+
"optional": {"lora_stack": ("LORA_STACK",)
|
| 1090 |
+
},
|
| 1091 |
+
}
|
| 1092 |
+
|
| 1093 |
+
RETURN_TYPES = ("LORA_STACK",)
|
| 1094 |
+
RETURN_NAMES = ("LORA_STACK",)
|
| 1095 |
+
FUNCTION = "lora_stacker"
|
| 1096 |
+
CATEGORY = "Comfyroll/IO"
|
| 1097 |
+
|
| 1098 |
+
def lora_stacker(self, lora_name_1, model_weight_1, clip_weight_1, switch_1, lora_name_2, model_weight_2, clip_weight_2, switch_2, lora_name_3, model_weight_3, clip_weight_3, switch_3, lora_stack=None):
|
| 1099 |
+
|
| 1100 |
+
# Initialise the list
|
| 1101 |
+
lora_list=list()
|
| 1102 |
+
|
| 1103 |
+
if lora_stack is not None:
|
| 1104 |
+
lora_list.extend([l for l in lora_stack if l[0] != "None"])
|
| 1105 |
+
|
| 1106 |
+
if lora_name_1 != "None" and switch_1 == "On":
|
| 1107 |
+
lora_list.extend([(lora_name_1, model_weight_1, clip_weight_1)]),
|
| 1108 |
+
|
| 1109 |
+
if lora_name_2 != "None" and switch_2 == "On":
|
| 1110 |
+
lora_list.extend([(lora_name_2, model_weight_2, clip_weight_2)]),
|
| 1111 |
+
|
| 1112 |
+
if lora_name_3 != "None" and switch_3 == "On":
|
| 1113 |
+
lora_list.extend([(lora_name_3, model_weight_3, clip_weight_3)]),
|
| 1114 |
+
|
| 1115 |
+
return (lora_list,)
|
| 1116 |
+
|
| 1117 |
+
|
| 1118 |
+
|
| 1119 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 1120 |
+
|
| 1121 |
+
|
| 1122 |
+
'''
|
| 1123 |
+
NODE_CLASS_MAPPINGS = {
|
| 1124 |
+
"CR Image Input Switch": ComfyRoll_InputImages,
|
| 1125 |
+
"CR Image Input Switch (4 way)": ComfyRoll_InputImages_4way,
|
| 1126 |
+
"CR Latent Input Switch": ComfyRoll_InputLatents,
|
| 1127 |
+
"CR Process Switch": ComfyRoll_InputLatentsText,
|
| 1128 |
+
"CR Conditioning Input Switch": ComfyRoll_InputConditioning,
|
| 1129 |
+
"CR Clip Input Switch": ComfyRoll_InputClip,
|
| 1130 |
+
"CR Model Input Switch": ComfyRoll_InputModel,
|
| 1131 |
+
"CR ControlNet Input Switch": ComfyRoll_InputControlNet,
|
| 1132 |
+
"CR Load LoRA": ComfyRoll_LoraLoader,
|
| 1133 |
+
"CR Apply ControlNet": ComfyRoll_ApplyControlNet,
|
| 1134 |
+
"CR Image Size": ComfyRoll_ImageSize_Float,
|
| 1135 |
+
"CR Image Output": ComfyRoll_ImageOutput,
|
| 1136 |
+
"CR Integer Multiple": CR_Int_Multiple_Of,
|
| 1137 |
+
"CR Aspect Ratio": ComfyRoll_AspectRatio,
|
| 1138 |
+
"CR Aspect Ratio SDXL": ComfyRoll_AspectRatio_SDXL,
|
| 1139 |
+
"CR Seed to Int": ComfyRoll_SeedToInt,
|
| 1140 |
+
"CR Color Tint": Comfyroll_Color_Tint,
|
| 1141 |
+
"CR SDXL Prompt Mixer": ComfyRoll_prompt_mixer,
|
| 1142 |
+
"CR SDXL Style Text": Comfyroll_SDXLStyleText,
|
| 1143 |
+
"CR SDXL Base Prompt Encoder": Comfyroll_SDXLBasePromptEncoder,
|
| 1144 |
+
"CR Hires Fix Process Switch": ComfyRoll_HiResFixSwitch,
|
| 1145 |
+
"CR Halftones" :Comfyroll_Halftone_Grid,
|
| 1146 |
+
"CR LoRA Stack":Comfyroll_LoRA_Stack,
|
| 1147 |
+
"CR Apply LoRA Stack":Comfyroll_ApplyLoRA_Stack,
|
| 1148 |
+
"CR Latent Batch Size":Comfyroll_LatentBatchSize
|
| 1149 |
+
}
|
| 1150 |
+
'''
|
| 1151 |
+
|
| 1152 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 1153 |
+
# Credits #
|
| 1154 |
+
# WASasquatch https://github.com/WASasquatch/was-node-suite-comfyui #
|
| 1155 |
+
# hnmr293 https://github.com/hnmr293/ComfyUI-nodes-hnmr #
|
| 1156 |
+
# SeargeDP https://github.com/SeargeDP/SeargeSDXL #
|
| 1157 |
+
# LucianoCirino https://github.com/LucianoCirino/efficiency-nodes-comfyui #
|
| 1158 |
+
# SLAPaper https://github.com/SLAPaper/ComfyUI-Image-Selector #
|
| 1159 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 1160 |
+
|
ComfyUI_Comfyroll_CustomNodes/Comfyroll_Pipe_Nodes.py
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 2 |
+
# Comfyroll Pipe Nodes by Akatsuzi https://github.com/RockOfFire/ComfyUI_Comfyroll_CustomNodes #
|
| 3 |
+
# for ComfyUI https://github.com/comfyanonymous/ComfyUI #
|
| 4 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import sys
|
| 8 |
+
import json
|
| 9 |
+
import torch
|
| 10 |
+
import comfy.sd
|
| 11 |
+
import comfy.utils
|
| 12 |
+
import numpy as np
|
| 13 |
+
|
| 14 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 15 |
+
|
| 16 |
+
class module_pipe_loader:
|
| 17 |
+
def __init__(self):
|
| 18 |
+
pass
|
| 19 |
+
|
| 20 |
+
@classmethod
|
| 21 |
+
def INPUT_TYPES(s):
|
| 22 |
+
return {
|
| 23 |
+
"required": {
|
| 24 |
+
#"model": ("MODEL",),
|
| 25 |
+
},
|
| 26 |
+
"optional": {
|
| 27 |
+
"model": ("MODEL",),
|
| 28 |
+
"pos": ("CONDITIONING",),
|
| 29 |
+
"neg": ("CONDITIONING",),
|
| 30 |
+
"latent": ("LATENT",),
|
| 31 |
+
"vae": ("VAE",),
|
| 32 |
+
"clip": ("CLIP",),
|
| 33 |
+
"controlnet": ("CONTROL_NET",),
|
| 34 |
+
"image": ("IMAGE",),
|
| 35 |
+
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff})
|
| 36 |
+
},
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
RETURN_TYPES = ("PIPE_LINE", )
|
| 40 |
+
RETURN_NAMES = ("pipe", )
|
| 41 |
+
FUNCTION = "flush"
|
| 42 |
+
|
| 43 |
+
CATEGORY = "Comfyroll/Module"
|
| 44 |
+
|
| 45 |
+
def flush(self, model=0, pos=0, neg=0, latent=0, vae=0, clip=0, controlnet=0, image=0, seed=0):
|
| 46 |
+
pipe_line = (model, pos, neg, latent, vae, clip, controlnet, image, seed)
|
| 47 |
+
return (pipe_line, )
|
| 48 |
+
|
| 49 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 50 |
+
|
| 51 |
+
class module_input:
|
| 52 |
+
def __init__(self):
|
| 53 |
+
pass
|
| 54 |
+
|
| 55 |
+
@classmethod
|
| 56 |
+
def INPUT_TYPES(s):
|
| 57 |
+
return {
|
| 58 |
+
"required": {"pipe": ("PIPE_LINE",)},
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
RETURN_TYPES = ("PIPE_LINE", "MODEL", "CONDITIONING", "CONDITIONING", "LATENT", "VAE", "CLIP", "CONTROL_NET", "IMAGE", "INT")
|
| 62 |
+
RETURN_NAMES = ("pipe", "model", "pos", "neg", "latent", "vae", "clip", "controlnet", "image", "seed")
|
| 63 |
+
FUNCTION = "flush"
|
| 64 |
+
|
| 65 |
+
CATEGORY = "Comfyroll/Module"
|
| 66 |
+
|
| 67 |
+
def flush(self, pipe):
|
| 68 |
+
model, pos, neg, latent, vae, clip, controlnet, image, seed = pipe
|
| 69 |
+
return pipe, model, pos, neg, latent, vae, clip, controlnet, image, seed
|
| 70 |
+
|
| 71 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 72 |
+
|
| 73 |
+
class module_output:
|
| 74 |
+
def __init__(self):
|
| 75 |
+
pass
|
| 76 |
+
|
| 77 |
+
@classmethod
|
| 78 |
+
def INPUT_TYPES(s):
|
| 79 |
+
return {"required": {"pipe": ("PIPE_LINE",)},
|
| 80 |
+
"optional": {
|
| 81 |
+
"model": ("MODEL",),
|
| 82 |
+
"pos": ("CONDITIONING",),
|
| 83 |
+
"neg": ("CONDITIONING",),
|
| 84 |
+
"latent": ("LATENT",),
|
| 85 |
+
"vae": ("VAE",),
|
| 86 |
+
"clip": ("CLIP",),
|
| 87 |
+
"controlnet": ("CONTROL_NET",),
|
| 88 |
+
"image": ("IMAGE",),
|
| 89 |
+
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff})
|
| 90 |
+
},
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
RETURN_TYPES = ("PIPE_LINE", )
|
| 94 |
+
RETURN_NAMES = ("pipe", )
|
| 95 |
+
FUNCTION = "flush"
|
| 96 |
+
|
| 97 |
+
CATEGORY = "Comfyroll/Module"
|
| 98 |
+
|
| 99 |
+
def flush(self, pipe, model=None, pos=None, neg=None, latent=None, vae=None, clip=None, controlnet=None, image=None, seed=None):
|
| 100 |
+
new_model, new_pos, new_neg, new_latent, new_vae, new_clip, new_controlnet, new_image, new_seed = pipe
|
| 101 |
+
|
| 102 |
+
if model is not None:
|
| 103 |
+
new_model = model
|
| 104 |
+
|
| 105 |
+
if pos is not None:
|
| 106 |
+
new_pos = pos
|
| 107 |
+
|
| 108 |
+
if neg is not None:
|
| 109 |
+
new_neg = neg
|
| 110 |
+
|
| 111 |
+
if latent is not None:
|
| 112 |
+
new_latent = latent
|
| 113 |
+
|
| 114 |
+
if vae is not None:
|
| 115 |
+
new_vae = vae
|
| 116 |
+
|
| 117 |
+
if clip is not None:
|
| 118 |
+
new_clip = clip
|
| 119 |
+
|
| 120 |
+
if controlnet is not None:
|
| 121 |
+
new_controlnet = controlnet
|
| 122 |
+
|
| 123 |
+
if image is not None:
|
| 124 |
+
new_image = image
|
| 125 |
+
|
| 126 |
+
if seed is not None:
|
| 127 |
+
new_seed = seed
|
| 128 |
+
|
| 129 |
+
pipe = new_model, new_pos, new_neg, new_latent, new_vae, new_clip, new_controlnet, new_image, new_seed
|
| 130 |
+
return (pipe, )
|
| 131 |
+
|
| 132 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 133 |
+
|
| 134 |
+
class image_pipe_in:
|
| 135 |
+
def __init__(self):
|
| 136 |
+
pass
|
| 137 |
+
|
| 138 |
+
@classmethod
|
| 139 |
+
def INPUT_TYPES(s):
|
| 140 |
+
return {
|
| 141 |
+
"required": {
|
| 142 |
+
#"model": ("MODEL",),
|
| 143 |
+
},
|
| 144 |
+
"optional": {
|
| 145 |
+
"image": ("IMAGE",),
|
| 146 |
+
"width": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 147 |
+
"height": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 148 |
+
"upscale_factor": ("FLOAT", {"default": 1, "min": 1, "max": 2000})
|
| 149 |
+
},
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
RETURN_TYPES = ("PIPE_LINE", )
|
| 153 |
+
RETURN_NAMES = ("pipe", )
|
| 154 |
+
FUNCTION = "flush"
|
| 155 |
+
|
| 156 |
+
CATEGORY = "Comfyroll/Module"
|
| 157 |
+
|
| 158 |
+
def flush(self, image=0, width=0, height=0, upscale_factor=0):
|
| 159 |
+
pipe_line = (image, width, height, upscale_factor)
|
| 160 |
+
return (pipe_line, )
|
| 161 |
+
|
| 162 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 163 |
+
|
| 164 |
+
class image_pipe_edit:
|
| 165 |
+
def __init__(self):
|
| 166 |
+
pass
|
| 167 |
+
|
| 168 |
+
@classmethod
|
| 169 |
+
def INPUT_TYPES(s):
|
| 170 |
+
return {"required": {"pipe": ("PIPE_LINE",)},
|
| 171 |
+
"optional": {
|
| 172 |
+
"image": ("IMAGE",),
|
| 173 |
+
"width": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 174 |
+
"height": ("INT", {"default": 512, "min": 64, "max": 2048}),
|
| 175 |
+
"upscale_factor": ("FLOAT", {"default": 1, "min": 1, "max": 2000})
|
| 176 |
+
},
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
RETURN_TYPES = ("PIPE_LINE", )
|
| 180 |
+
RETURN_NAMES = ("pipe", )
|
| 181 |
+
FUNCTION = "flush"
|
| 182 |
+
|
| 183 |
+
CATEGORY = "Comfyroll/Module"
|
| 184 |
+
|
| 185 |
+
def flush(self, pipe, image=None, width=None, height=None, upscale_factor=None):
|
| 186 |
+
new_image, new_width, new_height, new_upscale_factor = pipe
|
| 187 |
+
|
| 188 |
+
if image is not None:
|
| 189 |
+
new_image = image
|
| 190 |
+
|
| 191 |
+
if width is not None:
|
| 192 |
+
new_width = width
|
| 193 |
+
|
| 194 |
+
if height is not None:
|
| 195 |
+
new_height = height
|
| 196 |
+
|
| 197 |
+
if upscale_factor is not None:
|
| 198 |
+
new_upscale_factor = upscale_factor
|
| 199 |
+
|
| 200 |
+
pipe = new_image, new_width, new_height, new_upscale_factor
|
| 201 |
+
return (pipe, )
|
| 202 |
+
|
| 203 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 204 |
+
|
| 205 |
+
class image_pipe_out:
|
| 206 |
+
def __init__(self):
|
| 207 |
+
pass
|
| 208 |
+
|
| 209 |
+
@classmethod
|
| 210 |
+
def INPUT_TYPES(s):
|
| 211 |
+
return {
|
| 212 |
+
"required": {"pipe": ("PIPE_LINE",)},
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
RETURN_TYPES = ("PIPE_LINE", "IMAGE", "INT", "INT", "FLOAT",)
|
| 216 |
+
RETURN_NAMES = ("pipe", "image", "width", "height", "upscale_factor")
|
| 217 |
+
FUNCTION = "flush"
|
| 218 |
+
|
| 219 |
+
CATEGORY = "Comfyroll/Module"
|
| 220 |
+
|
| 221 |
+
def flush(self, pipe):
|
| 222 |
+
#if switch == "Off":
|
| 223 |
+
#return (pipe, )
|
| 224 |
+
#else:
|
| 225 |
+
image, width, height, upscale_factor = pipe
|
| 226 |
+
return pipe, image, width, height, upscale_factor
|
| 227 |
+
|
| 228 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 229 |
+
|
| 230 |
+
class input_switch_pipe:
|
| 231 |
+
def __init__(self):
|
| 232 |
+
pass
|
| 233 |
+
|
| 234 |
+
@classmethod
|
| 235 |
+
def INPUT_TYPES(cls):
|
| 236 |
+
return {
|
| 237 |
+
"required": {
|
| 238 |
+
"Input": ("INT", {"default": 1, "min": 1, "max": 2}),
|
| 239 |
+
"pipe1": ("PIPE_LINE",),
|
| 240 |
+
"pipe2": ("PIPE_LINE",)
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
RETURN_TYPES = ("PIPE_LINE",)
|
| 245 |
+
OUTPUT_NODE = True
|
| 246 |
+
FUNCTION = "InputSwitchPipe"
|
| 247 |
+
|
| 248 |
+
CATEGORY = "Comfyroll/Module"
|
| 249 |
+
|
| 250 |
+
def InputSwitchPipe(self, Input, pipe1, pipe2):
|
| 251 |
+
if Input == 1:
|
| 252 |
+
return (pipe1, )
|
| 253 |
+
else:
|
| 254 |
+
return (pipe2, )
|
| 255 |
+
|
| 256 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 257 |
+
'''
|
| 258 |
+
NODE_CLASS_MAPPINGS_2 = {
|
| 259 |
+
"CR Module Pipe Loader": module_pipe_loader,
|
| 260 |
+
"CR Module Input": module_input,
|
| 261 |
+
"CR Module Output": module_output,
|
| 262 |
+
"CR Image Pipe In": image_pipe_in,
|
| 263 |
+
"CR Image Pipe Edit": image_pipe_edit,
|
| 264 |
+
"CR Image Pipe Out": image_pipe_out,
|
| 265 |
+
"CR Pipe Switch": input_switch_pipe,
|
| 266 |
+
}
|
| 267 |
+
'''
|
| 268 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
| 269 |
+
# Credits
|
| 270 |
+
# TinyTerra https://github.com/TinyTerra/ComfyUI_tinyterraNodes #
|
| 271 |
+
#---------------------------------------------------------------------------------------------------------------------------------------------------#
|
ComfyUI_Comfyroll_CustomNodes/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Comfyroll Custom Nodes
|
| 2 |
+
|
| 3 |
+
These nodes were originally made for use in the Comfyroll Template Workflows.
|
| 4 |
+
|
| 5 |
+
[ComfyUI Template Workflows](https://civitai.com/models/59806/comfyroll-template-workflows)
|
| 6 |
+
|
| 7 |
+
[Comfyroll Pro Templates](https://civitai.com/models/85619/comfyroll-pro-template)
|
| 8 |
+
|
| 9 |
+
The nodes can be used in any ComfyUI workflow.
|
| 10 |
+
|
| 11 |
+
# Installation
|
| 12 |
+
|
| 13 |
+
If you have a previous version of the Comfyroll nodes from the Comfyroll Worflow Templates download, please delete this before installing these nodes.
|
| 14 |
+
|
| 15 |
+
1. cd custom_nodes
|
| 16 |
+
2. git clone https://github.com/RockOfFire/ComfyUI_Comfyroll_CustomNodes.git
|
| 17 |
+
3. Restart ComfyUI
|
| 18 |
+
|
| 19 |
+
You can also install the nodes using the following methods:
|
| 20 |
+
* install using [ComfyUI Manager](https://github.com/ltdrdata/ComfyUI-Manager)
|
| 21 |
+
* download from [CivitAI](https://civitai.com/models/87609/comfyroll-custom-nodes-for-comfyui)
|
| 22 |
+
|
| 23 |
+
# List of Custom Nodes
|
| 24 |
+
|
| 25 |
+
__Logic__
|
| 26 |
+
* CR Image Input Switch
|
| 27 |
+
* CR Image Input Switch (4 way)
|
| 28 |
+
* CR Latent Input Switch
|
| 29 |
+
* CR Conditioning Input Switch
|
| 30 |
+
* CR Clip Input Switch
|
| 31 |
+
* CR Model Input Switch
|
| 32 |
+
* CR ControlNet Input Switch
|
| 33 |
+
|
| 34 |
+
__Process__
|
| 35 |
+
* CR Img2Img Process Switch
|
| 36 |
+
* CR Hires Fix Process Switch
|
| 37 |
+
|
| 38 |
+
__IO__
|
| 39 |
+
* CR Load LoRA
|
| 40 |
+
|
| 41 |
+
__Maths__
|
| 42 |
+
* CR Integer Multiple
|
| 43 |
+
|
| 44 |
+
__Number__
|
| 45 |
+
* CR Seed to Int
|
| 46 |
+
|
| 47 |
+
__Image__
|
| 48 |
+
* CR Image Size
|
| 49 |
+
* CR Aspect Ratio
|
| 50 |
+
* CR Color Tint
|
| 51 |
+
|
| 52 |
+
__Conditioning__
|
| 53 |
+
* CR Apply ControlNet
|
| 54 |
+
|
| 55 |
+
__SDXL__
|
| 56 |
+
* CR Aspect Ratio SDXL
|
| 57 |
+
* CR SDXL Prompt Mixer
|
| 58 |
+
* CR SDXL Style Text
|
| 59 |
+
* CR SDXL Base Prompt Encoder
|
| 60 |
+
|
| 61 |
+
__Module__
|
| 62 |
+
* CR Module Pipe Loader
|
| 63 |
+
* CR Module Input
|
| 64 |
+
* CR Module Output
|
| 65 |
+
* CR Image Pipe In
|
| 66 |
+
* CR Image Pipe Edit
|
| 67 |
+
* CR Image Pipe Out
|
| 68 |
+
* CR Pipe Switch
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+

|
| 72 |
+
|
| 73 |
+

|
| 74 |
+
|
| 75 |
+

|
| 76 |
+
|
| 77 |
+

|
| 78 |
+
|
| 79 |
+
# Credits
|
| 80 |
+
|
| 81 |
+
comfyanonymous/[ComfyUI](https://github.com/comfyanonymous/ComfyUI) - A powerful and modular stable diffusion GUI.
|
| 82 |
+
|
| 83 |
+
WASasquatch/[was-node-suite-comfyui](https://github.com/WASasquatch/was-node-suite-comfyui) - A powerful custom node extensions of ComfyUI.
|
| 84 |
+
|
| 85 |
+
TinyTerra/[ComfyUI_tinyterraNodes](https://github.com/TinyTerra/ComfyUI_tinyterraNodes) - A selection of nodes for Stable Diffusion ComfyUI
|
| 86 |
+
|
| 87 |
+
hnmr293/[ComfyUI-nodes-hnmr](https://github.com/hnmr293/ComfyUI-nodes-hnmr) - ComfyUI custom nodes - merge, grid (aka xyz-plot) and others
|
| 88 |
+
|
| 89 |
+
SeargeDP/[SeargeSDXL](https://github.com/SeargeDP) - ComfyUI custom nodes - Prompt nodes and Conditioning nodes
|
ComfyUI_Comfyroll_CustomNodes/__init__.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .Comfyroll_Nodes import *
|
| 2 |
+
from .Comfyroll_Pipe_Nodes import *
|
| 3 |
+
#from .Comfyroll_Test_Nodes import *
|
| 4 |
+
|
| 5 |
+
NODE_CLASS_MAPPINGS = {
|
| 6 |
+
"CR Module Pipe Loader": module_pipe_loader,
|
| 7 |
+
"CR Module Input": module_input,
|
| 8 |
+
"CR Module Output": module_output,
|
| 9 |
+
"CR Image Pipe In": image_pipe_in,
|
| 10 |
+
"CR Image Pipe Edit": image_pipe_edit,
|
| 11 |
+
"CR Image Pipe Out": image_pipe_out,
|
| 12 |
+
"CR Pipe Switch": input_switch_pipe,
|
| 13 |
+
"CR Image Input Switch": ComfyRoll_InputImages,
|
| 14 |
+
"CR Image Input Switch (4 way)": ComfyRoll_InputImages_4way,
|
| 15 |
+
"CR Latent Input Switch": ComfyRoll_InputLatents,
|
| 16 |
+
"CR Conditioning Input Switch": ComfyRoll_InputConditioning,
|
| 17 |
+
"CR Clip Input Switch": ComfyRoll_InputClip,
|
| 18 |
+
"CR Model Input Switch": ComfyRoll_InputModel,
|
| 19 |
+
"CR ControlNet Input Switch": ComfyRoll_InputControlNet,
|
| 20 |
+
"CR Load LoRA": ComfyRoll_LoraLoader,
|
| 21 |
+
"CR Apply ControlNet": ComfyRoll_ApplyControlNet,
|
| 22 |
+
"CR Image Size": ComfyRoll_ImageSize_Float,
|
| 23 |
+
"CR Image Output": ComfyRoll_ImageOutput,
|
| 24 |
+
"CR Integer Multiple": CR_Int_Multiple_Of,
|
| 25 |
+
"CR Aspect Ratio": ComfyRoll_AspectRatio,
|
| 26 |
+
"CR Aspect Ratio SDXL": ComfyRoll_AspectRatio_SDXL,
|
| 27 |
+
"CR Seed to Int": ComfyRoll_SeedToInt,
|
| 28 |
+
"CR Color Tint": Comfyroll_Color_Tint,
|
| 29 |
+
"CR SDXL Prompt Mixer": ComfyRoll_prompt_mixer,
|
| 30 |
+
"CR SDXL Style Text": Comfyroll_SDXLStyleText,
|
| 31 |
+
"CR SDXL Base Prompt Encoder": Comfyroll_SDXLBasePromptEncoder,
|
| 32 |
+
"CR Img2Img Process Switch": ComfyRoll_InputLatentsText,
|
| 33 |
+
"CR Hires Fix Process Switch": ComfyRoll_HiResFixSwitch,
|
| 34 |
+
"CR Halftone Grid" : Comfyroll_Halftone_Grid,
|
| 35 |
+
"CR Latent Batch Size": Comfyroll_LatentBatchSize,
|
| 36 |
+
"CR LoRA Stack":Comfyroll_LoRA_Stack,
|
| 37 |
+
"CR Apply LoRA Stack":Comfyroll_ApplyLoRA_Stack,
|
| 38 |
+
### test nodes
|
| 39 |
+
#"CR Latent Upscale (Iterative)":Comfyroll_LatentUpscaleIterative,
|
| 40 |
+
#"CR KSampler (Iterative)":Comfyroll_Iterative_KSampler,
|
| 41 |
+
#"CR Load Image Sequence":Comfyroll_LoadImageSequence,
|
| 42 |
+
#"CR Switch": Comfyroll_Comfyroll_Switch_Test,
|
| 43 |
+
#"CR Halftone Image":Comfyroll_ConvertImageToHalftone,
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
__all__ = ['NODE_CLASS_MAPPINGS']
|
| 47 |
+
|
| 48 |
+
print("\033[34mComfyroll Custom Nodes: \033[92mLoaded\033[0m")
|
ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image1.png
ADDED
|
Git LFS Details
|
ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image2.jpg
ADDED
|
Git LFS Details
|
ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image3.JPG
ADDED
|
|
Git LFS Details
|
ComfyUI_Comfyroll_CustomNodes/images/custom_nodes_image4.JPG
ADDED
|
|
Git LFS Details
|