Skip to content

Commit aa865de

Browse files
committed
properly close model
1 parent 6f6f465 commit aa865de

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/main/java/ai/nets/samj/ij/SAMJ_Annotator.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,8 @@ List<Mask> samJReturnContours(SAMModel model, RandomAccessibleInterval<T> rai, L
341341
throw new IllegalArgumentException("Please provide at least one point prompt or rectangular prompt.");
342342
if (MACRO_CONSUMER == null)
343343
MACRO_CONSUMER = new Consumer();
344-
SAMModel selected = MainGUI.DEFAULT_MODEL_LIST.stream()
345-
.filter(mm -> mm.getName().equals(model.getName())).findFirst().orElse(null);
346-
if (selected == null)
347-
throw new IllegalArgumentException("Specified model does not exist. Please, for more info visit: "
348-
+ MACRO_INFO);
349-
selected.setImage(rai, null);
350-
selected.setReturnOnlyBiggest(true);
344+
model.setImage(rai, null);
345+
model.setReturnOnlyBiggest(true);
351346
RandomAccessibleInterval<T> maskRai = null;
352347
List<Mask> callbackedContours = new ArrayList<Mask>();
353348
BatchCallback callback = new BatchCallback() {
@@ -365,7 +360,7 @@ public void deletePointPrompt(List<int[]> promptList) {}
365360
public void deleteRectPrompt(List<int[]> promptList) {}
366361

367362
};
368-
List<Mask> contours = selected.processBatchOfPrompts(pointPrompts, rectPrompts, maskRai, callback);
363+
List<Mask> contours = model.processBatchOfPrompts(pointPrompts, rectPrompts, maskRai, callback);
369364
callbackedContours.addAll(contours);
370365

371366

0 commit comments

Comments
 (0)