diff --git a/IDENode/ide_node.py b/IDENode/ide_node.py index 1a36494..67576bd 100644 --- a/IDENode/ide_node.py +++ b/IDENode/ide_node.py @@ -113,13 +113,13 @@ result = runCode()""" outputs = {} - - for node in extra_pnginfo['workflow']['nodes']: - if node['id'] == int(unique_id): - outputs_valid = [ouput for ouput in node.get('outputs', []) if ouput.get('name','') != '' and ouput.get('type','') != ''] - outputs = {ouput['name']: None for ouput in outputs_valid} - self.RETURN_TYPES = ByPassTypeTuple(out["type"] for out in outputs_valid) - self.RETURN_NAMES = tuple(name for name in outputs.keys()) + if extra_pnginfo and 'workflow' in extra_pnginfo and extra_pnginfo['workflow']: + for node in extra_pnginfo['workflow']['nodes']: + if node['id'] == int(unique_id): + outputs_valid = [ouput for ouput in node.get('outputs', []) if ouput.get('name','') != '' and ouput.get('type','') != ''] + outputs = {ouput['name']: None for ouput in outputs_valid} + self.RETURN_TYPES = ByPassTypeTuple(out["type"] for out in outputs_valid) + self.RETURN_NAMES = tuple(name for name in outputs.keys()) my_namespace = types.SimpleNamespace() my_namespace.__dict__.update(outputs) diff --git a/PoseNode/js/pose_node.js b/PoseNode/js/pose_node.js index cc1b7b5..7e8e740 100644 --- a/PoseNode/js/pose_node.js +++ b/PoseNode/js/pose_node.js @@ -435,15 +435,18 @@ class OpenPose { if (await comfyuiDesktopConfirm("Reset canvas size?")) { this.setCanvasSize(512, 512); - - const backgroundImg = this.canvas.backgroundImage; - this.canvas.clear(); - this.canvas.backgroundColor = "#000000"; - this.addPose(); - - this.setBackground(backgroundImg); - this.uploadPoseFile(this.node.name); } + + const backgroundImg = this.canvas.backgroundImage; + this.canvas.clear(); + this.canvas.backgroundColor = "#000000"; + + if (await comfyuiDesktopConfirm("Add default pose?")) { + this.addPose(); + } + + this.setBackground(backgroundImg); + this.uploadPoseFile(this.node.name); } } diff --git a/PoseNode/pose_node.py b/PoseNode/pose_node.py index 8de1f24..405bfc5 100644 --- a/PoseNode/pose_node.py +++ b/PoseNode/pose_node.py @@ -34,15 +34,18 @@ class PoseNode(object): i = Image.open(image_path) i = ImageOps.exif_transpose(i) - image = i.convert("RGBA") + + if i.mode == 'RGBA': + mask = np.array(i.getchannel("A")).astype(np.float32) / 255.0 + mask = 1.0 - torch.from_numpy(mask) + image = i.convert("RGB") + else: + mask = torch.zeros((i.height, i.width), dtype=torch.float32, device="cpu") + image = i.convert("RGB") + image = np.array(image).astype(np.float32) / 255.0 image = torch.from_numpy(image)[None,] - if "A" in i.getbands(): - mask = np.array(i.getchannel("A")).astype(np.float32) / 255.0 - mask = 1.0 - torch.from_numpy(mask) - else: - mask = torch.zeros((64, 64), dtype=torch.float32, device="cpu") return (image, mask.unsqueeze(0)) @classmethod diff --git a/pyproject.toml b/pyproject.toml index 45bf81c..306f299 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_custom_nodes_alekpet" description = "Nodes: PoseNode, PainterNode, TranslateTextNode, TranslateCLIPTextEncodeNode, DeepTranslatorTextNode, DeepTranslatorCLIPTextEncodeNode, ArgosTranslateTextNode, ArgosTranslateCLIPTextEncodeNode, ChatGLM4TranslateCLIPTextEncodeNode, ChatGLM4TranslateTextNode, ChatGLM4InstructNode, ChatGLM4InstructMediaNode, PreviewTextNode, HexToHueNode, ColorsCorrectNode, IDENode." -version = "1.0.81" +version = "1.0.82" license = { file = "LICENSE" } [project.urls]