Skip to content

Commit

Permalink
correct weird bug, if a script ends with an open command that returns
Browse files Browse the repository at this point in the history
something, that will try to be sent as a message
  • Loading branch information
carlosuc3m committed Sep 7, 2024
1 parent 9374f43 commit 3f8d412
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/ai/nets/samj/models/EfficientSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ protected void createEncodeImageScript() {
code += "im_shm = shared_memory.SharedMemory(name='"
+ shma.getNameForPython() + "', size=" + shma.getSize()
+ ")" + System.lineSeparator();
code += "task.update('here')" + System.lineSeparator();
int size = 1;
for (long l : targetDims) {size *= l;}
code += "im = np.ndarray(" + size + ", dtype='" + CommonUtils.getDataTypeFromRAI(Cast.unchecked(shma.getSharedRAI()))
Expand All @@ -216,20 +217,22 @@ protected void createEncodeImageScript() {
code += ll + ", ";
code = code.substring(0, code.length() - 2);
code += "])" + System.lineSeparator();
code += "task.update('here')" + System.lineSeparator();
//code += "np.save('/home/carlos/git/crop.npy', im)" + System.lineSeparator();
code += "input_h = im.shape[1]" + System.lineSeparator();
code += "input_w = im.shape[0]" + System.lineSeparator();
code += "globals()['input_h'] = input_h" + System.lineSeparator();
code += "globals()['input_w'] = input_w" + System.lineSeparator();
code += "task.update(str(im.shape))" + System.lineSeparator();
code += "task.update('here')" + System.lineSeparator();
//code += "task.update(str(im.shape))" + System.lineSeparator();
code += "im = torch.from_numpy(np.transpose(im, (2, 1, 0)))" + System.lineSeparator();
code += "task.update('after ' + str(im.shape))" + System.lineSeparator();
code += "task.update('here')" + System.lineSeparator();
//code += "task.update('after ' + str(im.shape))" + System.lineSeparator();
code += "im_shm.unlink()" + System.lineSeparator();
//code += "box_shm.close()" + System.lineSeparator();
code += "task.update('here')" + System.lineSeparator();
this.script += code;
this.script += ""
+ "task.update(str(im.shape))" + System.lineSeparator()
+ "predictor.get_image_embeddings(im[None, ...])";
+ "_ = predictor.get_image_embeddings(im[None, ...])" + System.lineSeparator();
}

@Override
Expand Down

0 comments on commit 3f8d412

Please sign in to comment.