Skip to content

Commit

Permalink
remove unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 4, 2024
1 parent b1643b4 commit 03f4369
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/main/java/ai/nets/samj/models/AbstractSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.bioimage.modelrunner.apposed.appose.Service;
import io.bioimage.modelrunner.apposed.appose.Service.Task;
import io.bioimage.modelrunner.apposed.appose.Service.TaskStatus;
import io.bioimage.modelrunner.system.PlatformDetection;
import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray;
import net.imglib2.RandomAccessibleInterval;
import net.imglib2.type.NativeType;
Expand Down Expand Up @@ -205,7 +206,8 @@ public interface DebugTextPrinter { void printText(String text); }
* Close the Python process and clean the memory
*/
public void close() {
if (python != null) python.close();
if (python != null)
python.close();
}

/**
Expand Down Expand Up @@ -426,12 +428,7 @@ else if (task.outputs.get("rle") == null)
throw new RuntimeException();
callback.updateProgress(Integer.parseInt((String) task.outputs.get("n")));
results = task.outputs;
} catch (IOException | InterruptedException | RuntimeException e) {
try {
this.shma.close();
} catch (IOException e1) {
throw new IOException(e.toString() + System.lineSeparator() + e1.toString());
}
} catch (InterruptedException | RuntimeException e) {
throw e;
}
List<Mask> polys = defineMask((List<List<Number>>)results.get("contours_x"),
Expand Down Expand Up @@ -478,12 +475,7 @@ else if (task.outputs.get("contours_y") == null)
else if (task.outputs.get("rle") == null)
throw new RuntimeException();
results = task.outputs;
} catch (IOException | InterruptedException | RuntimeException e) {
try {
this.shma.close();
} catch (IOException e1) {
throw new IOException(e.toString() + System.lineSeparator() + e1.toString());
}
} catch (InterruptedException | RuntimeException e) {
throw e;
}

Expand Down Expand Up @@ -534,6 +526,7 @@ List<Mask> processBatchOfPrompts(List<int[]> pointsList, List<Rectangle> rects,
processPromptsBatchWithSAM(maskShma, returnAll);
printScript(script, "Batch of prompts inference");
List<Mask> polys = processAndRetrieveContours(inputs, callback);
if (PlatformDetection.isWindows() && maskShma != null) maskShma.close();
return polys;
} catch (IOException | RuntimeException | InterruptedException ex) {
if (maskShma != null)
Expand Down Expand Up @@ -575,6 +568,7 @@ List<Mask> processBatchOfPrompts(List<int[]> pointsList, List<Rectangle> rects,
printScript(script, "Batch of prompts inference");
List<Mask> polys = processAndRetrieveContours(inputs);
recalculatePolys(polys, encodeCoords);
if (PlatformDetection.isWindows() && maskShma != null) maskShma.close();
return polys;
} catch (IOException | RuntimeException | InterruptedException ex) {
if (maskShma != null)
Expand Down

0 comments on commit 03f4369

Please sign in to comment.