Skip to content

Commit

Permalink
correct one bug for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 9, 2024
1 parent 33a4a8f commit f0b1d32
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/main/java/ai/nets/samj/models/EfficientSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,14 @@ protected void processPromptsBatchWithSAM(SharedMemoryArray shmArr,
if (shmArr != null) {
code += ""
+ "shm_mask = shared_memory.SharedMemory(name='" + shmArr.getNameForPython() + "')" + System.lineSeparator()
+ "mask_batch = np.frombuffer(buffer=shm_mask.buf, dtype='" + shmArr.getOriginalDataType() + "').reshape([";
for (long l : shmArr.getOriginalShape())
+ "mask_batch = np.ndarray(%s, buffer=shm_mask.buf, dtype='"
+ shmArr.getOriginalDataType() + "').reshape([";
long size = 1;
for (long l : shmArr.getOriginalShape()) {
code += l + ",";
size *= l;
}
code = String.format(code, size);
code += "])" + System.lineSeparator();
code += "labeled_array, num_features = label(mask_batch)" + System.lineSeparator();
code += "num_features -= 1" + System.lineSeparator();
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/ai/nets/samj/models/EfficientViTSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,14 @@ protected void processPromptsBatchWithSAM(SharedMemoryArray shmArr,
if (shmArr != null) {
code += ""
+ "shm_mask = shared_memory.SharedMemory(name='" + shmArr.getNameForPython() + "')" + System.lineSeparator()
+ "mask_batch = np.frombuffer(buffer=shm_mask.buf, dtype='" + shmArr.getOriginalDataType() + "').reshape([";
for (long l : shmArr.getOriginalShape())
+ "mask_batch = np.ndarray(%s, buffer=shm_mask.buf, dtype='"
+ shmArr.getOriginalDataType() + "').reshape([";
long size = 1;
for (long l : shmArr.getOriginalShape()) {
code += l + ",";
size *= l;
}
code = String.format(code, size);
code += "])" + System.lineSeparator();
code += "labeled_array, num_features = label(mask_batch)" + System.lineSeparator();
code += "num_features -= 1" + System.lineSeparator();
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/ai/nets/samj/models/Sam2.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,14 @@ protected void processPromptsBatchWithSAM(SharedMemoryArray shmArr, boolean retu
if (shmArr != null) {
code += ""
+ "shm_mask = shared_memory.SharedMemory(name='" + shmArr.getNameForPython() + "')" + System.lineSeparator()
+ "mask_batch = np.frombuffer(buffer=shm_mask.buf, dtype='" + shmArr.getOriginalDataType() + "').reshape([";
for (long l : shmArr.getOriginalShape())
+ "mask_batch = np.ndarray(%s, buffer=shm_mask.buf, dtype='"
+ shmArr.getOriginalDataType() + "').reshape([";
long size = 1;
for (long l : shmArr.getOriginalShape()) {
code += l + ",";
size *= l;
}
code = String.format(code, size);
code += "])" + System.lineSeparator();
code += "labeled_array, num_features = label(mask_batch)" + System.lineSeparator();
code += "num_features -= 1" + System.lineSeparator();
Expand Down

0 comments on commit f0b1d32

Please sign in to comment.