From e350da28e2e0258dfc3f47bcaeea78f517abd758 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Fri, 7 Jun 2024 12:52:23 +0900 Subject: [PATCH] fix: segs_scale - crash if batch mask is given https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/628#issuecomment-2153720821 --- modules/impact/config.py | 2 +- modules/impact/core.py | 9 +++++++-- pyproject.toml | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/impact/config.py b/modules/impact/config.py index 71aa9a7..3d48191 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -2,7 +2,7 @@ import configparser import os -version_code = [5, 11, 2] +version_code = [5, 11, 3] version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') dependency_version = 20 diff --git a/modules/impact/core.py b/modules/impact/core.py index 4f71d01..32b350c 100644 --- a/modules/impact/core.py +++ b/modules/impact/core.py @@ -830,8 +830,13 @@ def segs_scale_match(segs, target_shape): if isinstance(cropped_mask, np.ndarray): cropped_mask = torch.from_numpy(cropped_mask) - cropped_mask = torch.nn.functional.interpolate(cropped_mask.unsqueeze(0).unsqueeze(0), size=(new_h, new_w), mode='bilinear', align_corners=False) - cropped_mask = cropped_mask.squeeze(0).squeeze(0).numpy() + + if isinstance(cropped_mask, torch.Tensor) and len(cropped_mask.shape) == 3: + cropped_mask = torch.nn.functional.interpolate(cropped_mask.unsqueeze(0), size=(new_h, new_w), mode='bilinear', align_corners=False) + cropped_mask = cropped_mask.squeeze(0) + else: + cropped_mask = torch.nn.functional.interpolate(cropped_mask.unsqueeze(0).unsqueeze(0), size=(new_h, new_w), mode='bilinear', align_corners=False) + cropped_mask = cropped_mask.squeeze(0).squeeze(0).numpy() if cropped_image is not None: cropped_image = tensor_resize(cropped_image if isinstance(cropped_image, torch.Tensor) else torch.from_numpy(cropped_image), new_w, new_h) diff --git a/pyproject.toml b/pyproject.toml index 4b56f07..15639fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-impact-pack" description = "This extension offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler." -version = "5.11.2" +version = "5.11.3" license = "LICENSE" dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]