From 3000929df25e030e80d4e8bbfd32e598c2c95f85 Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Sat, 30 Nov 2024 18:34:47 +0100 Subject: [PATCH] REMOVE TODOs --- .../ai/nets/samj/models/AbstractSamJ.java | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/src/main/java/ai/nets/samj/models/AbstractSamJ.java b/src/main/java/ai/nets/samj/models/AbstractSamJ.java index 2420792..6dcbe58 100644 --- a/src/main/java/ai/nets/samj/models/AbstractSamJ.java +++ b/src/main/java/ai/nets/samj/models/AbstractSamJ.java @@ -405,6 +405,31 @@ else if (task.outputs.get("rle") == null) return masks; } + public List processBatchOfPoints(List points) { + return processBatchOfPoints(points, true); + } + + public List processBatchOfPoints(List pointsList, boolean returnAll) + throws IOException, RuntimeException, InterruptedException { + if (pointsList == null || pointsList.size() == 0) + return new ArrayList(); + // TODO add logic to reeencode + // TODO the idea is that the + + pointsList = adaptPointPrompts(pointsList); + pointsNegList = adaptPointPrompts(pointsNegList); + this.script = ""; + processPointsWithSAM(pointsList.size(), pointsNegList.size(), returnAll); + HashMap inputs = new HashMap(); + inputs.put("input_points", pointsList); + inputs.put("input_neg_points", pointsNegList); + printScript(script, "Points and negative points inference"); + List polys = processAndRetrieveContours(inputs); + recalculatePolys(polys, encodeCoords); + debugPrinter.printText("processPoints() obtained " + polys.size() + " polygons"); + return polys; + } + /** * Method used that runs EfficientSAM using a list of points as the prompt. This method runs * the prompt encoder and the EfficientSAM decoder only, the image encoder was run when the model @@ -723,27 +748,10 @@ private ArrayList getPointsNotInRect(List pointsList, List } public Rectangle getCurrentlyEncodedArea() { - // TODO remove int xMargin = (int) (targetDims[0] * 0.1); - // TODO remove int yMargin = (int) (targetDims[1] * 0.1); Rectangle alreadyEncoded; alreadyEncoded = new Rectangle((int) encodeCoords[0], (int) encodeCoords[1], (int) targetDims[0], (int) targetDims[1]); return alreadyEncoded; - /** - * TODO - * TODO - * TODO - * TODO - if (encodeCoords[0] != 0 || encodeCoords[1] != 0 || targetDims[1] != this.img.dimensionsAsLongArray()[1] - || targetDims[0] != this.img.dimensionsAsLongArray()[0]) { - alreadyEncoded = new Rectangle((int) encodeCoords[0] + xMargin / 2, (int) encodeCoords[1] + yMargin / 2, - (int) targetDims[0] - xMargin, (int) targetDims[1] - yMargin); - } else { - alreadyEncoded = new Rectangle((int) encodeCoords[0], (int) encodeCoords[1], - (int) targetDims[0], (int) targetDims[1]); - } - return alreadyEncoded; - */ } /**