Skip to content

Commit

Permalink
finish correcting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 31, 2024
1 parent cf49a74 commit 80ef5f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public void installEverything() throws IOException, InterruptedException,
* @return the path to the EfficientSAM Small weights file
*/
public String getModelWeightsPath() {
File file = Paths.get(path, "envs", EVITSAM_ENV_NAME, EVITSAM_NAME, "weights", modelType + ".pt").toFile();
File file = Paths.get(path, "envs", EVITSAM_ENV_NAME, EVITSAM_NAME, "weights", "efficientvit_sam_" + modelType + ".pt").toFile();
if (!file.isFile()) return null;
return file.getAbsolutePath();
}
Expand All @@ -495,7 +495,7 @@ public String getModelWeigthsName() {

@Override
public String getModelWeigthPath() {
return Paths.get(this.path, "envs", EVITSAM_ENV_NAME, EVITSAM_NAME, "weights", modelType + ".pt").toAbsolutePath().toString();
return Paths.get(this.path, "envs", EVITSAM_ENV_NAME, EVITSAM_NAME, "weights", "efficientvit_sam_" + modelType + ".pt").toAbsolutePath().toString();
}

@Override
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/ai/nets/samj/models/EfficientViTSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,15 @@ protected void createEncodeImageScript() {
script += "im_shm = shared_memory.SharedMemory(name='"
+ shma.getNameForPython() + "', size=" + shma.getSize()
+ ")" + System.lineSeparator();
int size = 1;
for (long l : targetDims) {size *= l;}
int size = (int) targetDims[2];
for (int i = 0; i < targetDims.length - 1; i ++) {
size *= Math.ceil(targetDims[i] / (double) scale);
}
script += "im = np.ndarray(" + size + ", dtype='" + CommonUtils.getDataTypeFromRAI(Cast.unchecked(shma.getSharedRAI()))
+ "', buffer=im_shm.buf).reshape([";
for (long ll : targetDims)
script += ll + ", ";
script = script.substring(0, script.length() - 2);
for (int i = 0; i < targetDims.length - 1; i ++)
script += (int) Math.ceil(targetDims[i] / (double) scale) + ", ";
script += targetDims[2];
script += "])" + System.lineSeparator();
script += "im = np.transpose(im, (1, 0, 2))" + System.lineSeparator();
//code += "np.save('/home/carlos/git/aa.npy', im)" + System.lineSeparator();
Expand Down

0 comments on commit 80ef5f0

Please sign in to comment.