diff --git a/nodes/deep_bump.py b/nodes/deep_bump.py index 639aaa9..8be4836 100644 --- a/nodes/deep_bump.py +++ b/nodes/deep_bump.py @@ -264,7 +264,7 @@ class DeepBump: "LARGEST", ], ), - "normals_to_height_seamless": (["TRUE", "FALSE"],), + "normals_to_height_seamless": ("BOOL", {"default": False}), }, } @@ -279,7 +279,7 @@ class DeepBump: mode="Color to Normals", color_to_normals_overlap="SMALL", normals_to_curvature_blur_radius="SMALL", - normals_to_height_seamless="TRUE", + normals_to_height_seamless=True, ): image = utils_inference.tensor2pil(image) @@ -295,9 +295,7 @@ class DeepBump: in_img, normals_to_curvature_blur_radius, None ) if mode == "Normals to Height": - out_img = normals_to_height( - in_img, normals_to_height_seamless == "TRUE", None - ) + out_img = normals_to_height(in_img, normals_to_height_seamless, None) out_img = (np.transpose(out_img, (1, 2, 0)) * 255).astype(np.uint8) diff --git a/nodes/faceenhance.py b/nodes/faceenhance.py index e2317af..45d4fde 100644 --- a/nodes/faceenhance.py +++ b/nodes/faceenhance.py @@ -136,12 +136,12 @@ class RestoreFace: "image": ("IMAGE",), "model": ("FACEENHANCE_MODEL",), # Input are aligned faces - "aligned": (["true", "false"], {"default": "false"}), + "aligned": ("BOOL", {"default": False}), # Only restore the center face - "only_center_face": (["true", "false"], {"default": "false"}), + "only_center_face": ("BOOL", {"default": False}), # Adjustable weights "weight": ("FLOAT", {"default": 0.5}), - "save_tmp_steps": (["true", "false"], {"default": "true"}), + "save_tmp_steps": ("BOOL", {"default": True}), } } @@ -183,15 +183,11 @@ class RestoreFace: self, image: torch.Tensor, model: GFPGANer, - aligned="false", - only_center_face="false", + aligned=False, + only_center_face=False, weight=0.5, - save_tmp_steps="true", + save_tmp_steps=True, ) -> Tuple[torch.Tensor]: - save_tmp_steps = save_tmp_steps == "true" - aligned = aligned == "true" - only_center_face = only_center_face == "true" - out = [ self.do_restore( image[i], model, aligned, only_center_face, weight, save_tmp_steps diff --git a/nodes/faceswap.py b/nodes/faceswap.py index aa1fc25..c7d8f70 100644 --- a/nodes/faceswap.py +++ b/nodes/faceswap.py @@ -82,8 +82,9 @@ class FaceSwap: "reference": ("IMAGE",), "faces_index": ("STRING", {"default": "0"}), "faceswap_model": ("FACESWAP_MODEL", {"default": "None"}), + "debug": ("BOOL", {"default": False}), }, - "optional": {"debug": (["true", "false"], {"default": "false"})}, + "optional": {}, } RETURN_TYPES = ("IMAGE",) @@ -96,7 +97,7 @@ class FaceSwap: reference: torch.Tensor, faces_index: str, faceswap_model, - debug="false", + debug=False, ): def do_swap(img): model_management.throw_exception_if_processing_interrupted() diff --git a/nodes/fun.py b/nodes/fun.py index 5661686..d63cce2 100644 --- a/nodes/fun.py +++ b/nodes/fun.py @@ -72,7 +72,7 @@ class QrCode: "error_correct": (("L", "M", "Q", "H"), {"default": "L"}), "box_size": ("INT", {"default": 10, "max": 8096, "min": 0, "step": 1}), "border": ("INT", {"default": 4, "max": 8096, "min": 0, "step": 1}), - "invert": (("True", "False"), {"default": "False"}), + "invert": (("BOOL",), {"default": False}), } } @@ -99,8 +99,8 @@ class QrCode: qr.add_data(url) qr.make(fit=True) - back_color = (255, 255, 255) if invert == "True" else (0, 0, 0) - fill_color = (0, 0, 0) if invert == "True" else (255, 255, 255) + back_color = (255, 255, 255) if invert else (0, 0, 0) + fill_color = (0, 0, 0) if invert else (255, 255, 255) code = img = qr.make_image(back_color=back_color, fill_color=fill_color) diff --git a/nodes/image_processing.py b/nodes/image_processing.py index ad302be..acbb3c0 100644 --- a/nodes/image_processing.py +++ b/nodes/image_processing.py @@ -392,7 +392,7 @@ class ImagePremultiply: "required": { "image": ("IMAGE",), "mask": ("MASK",), - "invert": (["True", "False"], {"default": "False"}), + "invert": ("BOOL", {"default": False}), } } @@ -401,8 +401,6 @@ class ImagePremultiply: FUNCTION = "premultiply" def premultiply(self, image, mask, invert): - invert = invert == "True" - images = tensor2pil(image) if invert: masks = tensor2pil(mask) # .convert("L") @@ -445,7 +443,7 @@ class ImageResizeFactor: "FLOAT", {"default": 2, "min": 0.01, "max": 16.0, "step": 0.01}, ), - "supersample": (["true", "false"], {"default": "true"}), + "supersample": ("BOOL", {"default": True}), "resampling": ( ["lanczos", "nearest", "bilinear", "bicubic"], {"default": "lanczos"}, @@ -510,7 +508,7 @@ class ImageResizeFactor: resample_filters = {"nearest": 0, "bilinear": 2, "bicubic": 3, "lanczos": 1} # Apply supersample - if supersample == "true": + if supersample: super_size = (new_width * 8, new_height * 8) log.debug(f"Applying supersample: {super_size}") img = img.resize( @@ -529,12 +527,12 @@ class ImageResizeFactor: self, image: torch.Tensor, factor: float, - supersample: str, + supersample: bool, resampling: str, mask=None, ): log.debug(f"Resizing image with factor {factor} and resampling {resampling}") - supersample = supersample == "true" + batch_count = image.size(0) log.debug(f"Batch count: {batch_count}") if batch_count == 1: @@ -566,7 +564,7 @@ class SaveImageGrid: "required": { "images": ("IMAGE",), "filename_prefix": ("STRING", {"default": "ComfyUI"}), - "save_intermediate": (["true", "false"], {"default": "false"}), + "save_intermediate": ("BOOL", {"default": False}), }, "hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO"}, } @@ -607,11 +605,10 @@ class SaveImageGrid: self, images, filename_prefix="Grid", - save_intermediate="false", + save_intermediate=False, prompt=None, extra_pnginfo=None, ): - save_intermediate = save_intermediate == "true" ( full_output_folder, filename, diff --git a/nodes/mask.py b/nodes/mask.py index 6745dfe..56af63f 100644 --- a/nodes/mask.py +++ b/nodes/mask.py @@ -16,8 +16,8 @@ class ImageRemoveBackgroundRembg: "required": { "image": ("IMAGE",), "alpha_matting": ( - ["True", "False"], - {"default": "False"}, + "BOOL", + {"default": False}, ), "alpha_matting_foreground_threshold": ( "INT", @@ -32,8 +32,8 @@ class ImageRemoveBackgroundRembg: {"default": 10, "min": 0, "max": 255}, ), "post_process_mask": ( - ["True", "False"], - {"default": "False"}, + "BOOL", + {"default": False}, ), "bgcolor": ( "COLOR", @@ -76,13 +76,13 @@ class ImageRemoveBackgroundRembg: for img in images: img_rm = remove( data=img, - alpha_matting=alpha_matting == "True", + alpha_matting=alpha_matting, alpha_matting_foreground_threshold=alpha_matting_foreground_threshold, alpha_matting_background_threshold=alpha_matting_background_threshold, alpha_matting_erode_size=alpha_matting_erode_size, session=None, only_mask=False, - post_process_mask=post_process_mask == "True", + post_process_mask=post_process_mask, bgcolor=None, )