Skip to content

Commit 2e21520

Browse files
committed
patch for batchsamize big images
1 parent 016ea41 commit 2e21520

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/ai/nets/samj/models/AbstractSamJ.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,13 @@ List<Mask> processBatchOfPrompts(List<int[]> pointsList, List<Rectangle> rects,
507507
if ((pointsList == null || pointsList.size() == 0) && (rects == null || rects.size() == 0) && (rai == null))
508508
return new ArrayList<Mask>();
509509
checkPrompts(pointsList, rects, rai);
510+
511+
if ((img.dimensionsAsLongArray()[0] > 512 || img.dimensionsAsLongArray()[1] > 512)
512+
&& ((encodeCoords[0] != 0 || encodeCoords[1] != 0)
513+
||(targetDims[0] != img.dimensionsAsLongArray()[0] || targetDims[1] != img.dimensionsAsLongArray()[1]))) {
514+
this.encodeCoords = new long[] {0, 0, img.dimensionsAsLongArray()[0], img.dimensionsAsLongArray()[1]}
515+
reencodeCrop(null);
516+
}
510517

511518
// TODO adapt to reencoding for big images, ideally it should process points close together together
512519
pointsList = adaptPointPrompts(pointsList);

0 commit comments

Comments
 (0)