From a311f9278dcbd787faf863bb90b6ae541c59a826 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Thu, 19 Dec 2024 23:06:49 +0900 Subject: [PATCH] fixed: sam detector - invalid position https://github.com/ltdrdata/ComfyUI-Impact-Pack/issues/853 --- js/impact-sam-editor.js | 17 +++++++++-------- modules/impact/config.py | 2 +- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/js/impact-sam-editor.js b/js/impact-sam-editor.js index cb34309..371987c 100644 --- a/js/impact-sam-editor.js +++ b/js/impact-sam-editor.js @@ -262,7 +262,7 @@ class ImpactSamEditorDialog extends ComfyDialog { const pointsCanvas = document.createElement('canvas'); imgCanvas.id = "imageCanvas"; - maskCanvas.id = "maskCanvas"; + maskCanvas.id = "samEditorMaskCanvas"; pointsCanvas.id = "pointsCanvas"; this.setlayout(imgCanvas, maskCanvas, pointsCanvas); @@ -356,13 +356,13 @@ class ImpactSamEditorDialog extends ComfyDialog { let w = (drawWidth * imgCanvas.clientWidth/imgCanvas.width) + "px"; let h = (drawHeight * imgCanvas.clientHeight/imgCanvas.height) + "px"; - pointsCanvas.width = drawWidth; - pointsCanvas.height = drawHeight; + pointsCanvas.width = drawWidth * imgCanvas.clientWidth/imgCanvas.width; + pointsCanvas.height = drawHeight * imgCanvas.clientHeight/imgCanvas.height; pointsCanvas.style.top = imgCanvas.offsetTop + "px"; pointsCanvas.style.left = imgCanvas.offsetLeft + "px"; - maskCanvas.style.width = w; - maskCanvas.style.height = h; + maskCanvas.width = pointsCanvas.width; + maskCanvas.height = pointsCanvas.height; maskCanvas.style.top = imgCanvas.offsetTop + "px"; maskCanvas.style.left = imgCanvas.offsetLeft + "px"; @@ -476,8 +476,9 @@ class ImpactSamEditorDialog extends ComfyDialog { for(const i in self.prompt_points) { const [is_positive, x, y] = self.prompt_points[i]; const point = [x,y]; - if(is_positive) + if(is_positive) { positive_points.push(point); + } else negative_points.push(point); } @@ -511,8 +512,8 @@ class ImpactSamEditorDialog extends ComfyDialog { const x = event.offsetX || event.targetTouches[0].clientX - maskRect.left; const y = event.offsetY || event.targetTouches[0].clientY - maskRect.top; - const originalX = x * self.image.width / self.pointsCanvas.width; - const originalY = y * self.image.height / self.pointsCanvas.height; + const originalX = x * self.image.width / self.pointsCanvas.clientWidth; + const originalY = y * self.image.height / self.pointsCanvas.clientHeight; var point = null; if (event.button == 0) { diff --git a/modules/impact/config.py b/modules/impact/config.py index 3f5e46b..1e58c7c 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -1,7 +1,7 @@ import configparser import os -version_code = [8, 1] +version_code = [8, 1, 1] version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') dependency_version = 24 diff --git a/pyproject.toml b/pyproject.toml index ad46d1d..daccdb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-impact-pack" description = "This node pack offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler." -version = "8.1" +version = "8.1.1" license = { file = "LICENSE.txt" } dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]