diff --git a/js/LayerEditor.js b/js/LayerEditor.js index c1f2e87..56cc300 100644 --- a/js/LayerEditor.js +++ b/js/LayerEditor.js @@ -256,12 +256,22 @@ export async function autoSegment() { }); const poseLandmarks = poseLandmarker.detect(image).landmarks[0]; - const breathX = + const positiveBreathX = ((poseLandmarks[11].x + poseLandmarks[12].x) / 2) * imageSize.val.width; - const breathY = + const positiveBreathY = ((poseLandmarks[11].y + poseLandmarks[12].y) / 2) * imageSize.val.height; + const negativeBreathX1 = poseLandmarks[0].x * imageSize.val.width; + const negativeBreathY1 = poseLandmarks[0].y * imageSize.val.height; + const negativeBreathX2 = poseLandmarks[9].x * imageSize.val.width; + const negativeBreathY2 = poseLandmarks[9].y * imageSize.val.height; + const negativeBreathX3 = poseLandmarks[10].x * imageSize.val.width; + const negativeBreathY3 = poseLandmarks[10].y * imageSize.val.height; + imagePromptsMulti.val["breath"] = [ - { x: breathX, y: breathY, label: 1, isAuto: true }, + { x: positiveBreathX, y: positiveBreathY, label: 1, isAuto: true }, + { x: negativeBreathX1, y: negativeBreathY1, label: 0, isAuto: true }, + { x: negativeBreathX2, y: negativeBreathY2, label: 0, isAuto: true }, + { x: negativeBreathX3, y: negativeBreathY3, label: 0, isAuto: true }, ]; imagePrompts.val = imagePromptsMulti.val[selectedLayer.val]; segmented.val = true; diff --git a/sam/sam_multilayer.py b/sam/sam_multilayer.py index 2108542..ea5eae5 100644 --- a/sam/sam_multilayer.py +++ b/sam/sam_multilayer.py @@ -241,9 +241,24 @@ class SAMMultiLayer: boxesMulti[key] = box if pose_landmarks is not None: - breathX = ((pose_landmarks[11].x + pose_landmarks[12].x) / 2) * W - breathY = ((pose_landmarks[11].y + pose_landmarks[12].y) / 2) * H - imagePromptsMulti["breath"] = [{"x": breathX, "y": breathY, "label": 1}] + positiveBreathX = ( + (pose_landmarks[11].x + pose_landmarks[12].x) / 2 + ) * W + positiveBreathY = ( + (pose_landmarks[11].y + pose_landmarks[12].y) / 2 + ) * H + negativeBreathX1 = pose_landmarks[0].x * W + negativeBreathY1 = pose_landmarks[0].y * H + negativeBreathX2 = pose_landmarks[9].x * W + negativeBreathY2 = pose_landmarks[9].y * H + negativeBreathX3 = pose_landmarks[10].x * W + negativeBreathY3 = pose_landmarks[10].y * H + imagePromptsMulti["breath"] = [ + {"x": positiveBreathX, "y": positiveBreathY, "label": 1}, + {"x": negativeBreathX1, "y": negativeBreathY1, "label": 0}, + {"x": negativeBreathX2, "y": negativeBreathY2, "label": 0}, + {"x": negativeBreathX3, "y": negativeBreathY3, "label": 0}, + ] return imagePromptsMulti, boxesMulti