From 65e8b094ab11fd8a886940fb666581f6cb0ea87a Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 23 Apr 2024 22:02:25 +0200 Subject: [PATCH] correct small bugs --- .../ai/nets/samj/communication/model/EfficientSAM.java | 2 +- src/main/java/ai/nets/samj/models/AbstractSamJ.java | 8 ++++---- src/main/java/ai/nets/samj/models/EfficientViTSamJ.java | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java index 908691b..2d6d9bf 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java @@ -55,7 +55,7 @@ public class EfficientSAM implements SAMModel { /** * Axes order required for the input image by the model */ - public static final String INPUT_IMAGE_AXES = "yxc"; + public static final String INPUT_IMAGE_AXES = "xyc"; private static final String HTML_DESCRIPTION = "EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment Anything
" + "Weights size: 105.7 MB
" diff --git a/src/main/java/ai/nets/samj/models/AbstractSamJ.java b/src/main/java/ai/nets/samj/models/AbstractSamJ.java index a55ea33..1132a19 100644 --- a/src/main/java/ai/nets/samj/models/AbstractSamJ.java +++ b/src/main/java/ai/nets/samj/models/AbstractSamJ.java @@ -745,10 +745,10 @@ private Rectangle getApproximateAreaNeeded(List pointsList, List p * @return whether the bounding box is within the encoded area or not */ public boolean isAreaEncoded(int[] boundingBox) { - boolean upperLeftVertex = (boundingBox[0] > this.encodeCoords[0]) && (boundingBox[0] < this.encodeCoords[2]); - boolean upperRightVertex = (boundingBox[2] > this.encodeCoords[0]) && (boundingBox[2] < this.encodeCoords[2]); - boolean downLeftVertex = (boundingBox[1] > this.encodeCoords[1]) && (boundingBox[1] < this.encodeCoords[3]); - boolean downRightVertex = (boundingBox[3] > this.encodeCoords[1]) && (boundingBox[3] < this.encodeCoords[3]); + boolean upperLeftVertex = (boundingBox[0] > encodeCoords[0]) && (boundingBox[0] < encodeCoords[0] + targetDims[0]); + boolean upperRightVertex = (boundingBox[2] > encodeCoords[0]) && (boundingBox[2] < encodeCoords[0] + targetDims[0]); + boolean downLeftVertex = (boundingBox[1] > encodeCoords[1]) && (boundingBox[1] < encodeCoords[1] + targetDims[1]); + boolean downRightVertex = (boundingBox[3] > encodeCoords[1]) && (boundingBox[3] < encodeCoords[1] + targetDims[1]); if (upperLeftVertex && upperRightVertex && downLeftVertex && downRightVertex) return true; diff --git a/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java b/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java index 4bf8783..08446bc 100644 --- a/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java +++ b/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java @@ -318,7 +318,6 @@ protected void createEncodeImageScript() { script += ll + ", "; script = script.substring(0, script.length() - 2); script += "])" + System.lineSeparator(); - script += "im = np.transpose(im, (1, 0, 2))" + System.lineSeparator(); //code += "np.save('/home/carlos/git/aa.npy', im)" + System.lineSeparator(); script += "im_shm.unlink()" + System.lineSeparator(); //code += "box_shm.close()" + System.lineSeparator();