Skip to content

Commit

Permalink
efficientsam mask is 2d
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed May 31, 2024
1 parent 6d01190 commit 3da9df3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/ai/nets/samj/models/EfficientSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ protected void processMasksWithSam(SharedMemoryArray shmArr, boolean returnAll)
+ " predicted_iou = torch.take_along_dim(predicted_iou, sorted_ids, dim=2)" + System.lineSeparator()
+ " predicted_logits = torch.take_along_dim(predicted_logits, sorted_ids[..., None, None], dim=2)" + System.lineSeparator()
+ " mask_val = torch.ge(predicted_logits[0, 0, 0, :, :], 0).cpu().detach().numpy()" + System.lineSeparator()
+ (this.isIJROIManager ? "mask_val[0, 1:, 1:] += mask_val[0, :-1, :-1]" : "") + System.lineSeparator()
+ (this.isIJROIManager ? "mask_val[1:, 1:] += mask_val[:-1, :-1]" : "") + System.lineSeparator()
+ " cont_x_val,cont_y_val = get_polygons_from_binary_mask(mask_val, only_biggest=" + (!returnAll ? "True" : "False") + ")" + System.lineSeparator()
+ " cont_x += cont_x_val" + System.lineSeparator()
+ " cont_y += cont_y_val" + System.lineSeparator()
Expand Down Expand Up @@ -316,7 +316,7 @@ protected void processPointsWithSAM(int nPoints, int nNegPoints, boolean returnA
+ "task.update('end predict')" + System.lineSeparator()
+ "task.update(str(mask.shape))" + System.lineSeparator()
//+ "np.save('/temp/aa.npy', mask)" + System.lineSeparator()
+ (this.isIJROIManager ? "mask[0, 1:, 1:] += mask[0, :-1, :-1]" : "") + System.lineSeparator()
+ (this.isIJROIManager ? "mask[1:, 1:] += mask[:-1, :-1]" : "") + System.lineSeparator()
+ "contours_x,contours_y = get_polygons_from_binary_mask(mask, only_biggest=" + (!returnAll ? "True" : "False") + ")" + System.lineSeparator()
+ "task.update('all contours traced')" + System.lineSeparator()
+ "task.outputs['contours_x'] = contours_x" + System.lineSeparator()
Expand Down Expand Up @@ -347,7 +347,7 @@ protected void processBoxWithSAM(boolean returnAll) {
+ "task.update('end predict')" + System.lineSeparator()
+ "task.update(str(mask.shape))" + System.lineSeparator()
//+ "np.save('/home/carlos/git/mask.npy', mask)" + System.lineSeparator()
+ (this.isIJROIManager ? "mask[0, 1:, 1:] += mask[0, :-1, :-1]" : "") + System.lineSeparator()
+ (this.isIJROIManager ? "mask[1:, 1:] += mask[:-1, :-1]" : "") + System.lineSeparator()
+ "contours_x,contours_y = get_polygons_from_binary_mask(mask, only_biggest=" + (!returnAll ? "True" : "False") + ")" + System.lineSeparator()
+ "task.update('all contours traced')" + System.lineSeparator()
+ "task.outputs['contours_x'] = contours_x" + System.lineSeparator()
Expand Down

0 comments on commit 3da9df3

Please sign in to comment.