Skip to content

Commit

Permalink
small changes to keep improving the abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Apr 23, 2024
1 parent a364ec4 commit b78afd5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 303 deletions.
301 changes: 0 additions & 301 deletions src/main/java/ai/nets/samj/AbstractSamJ_old.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/ai/nets/samj/models/AbstractSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void sendImgLib2AsNp() {
+ ")" + System.lineSeparator();
int size = 1;
for (long l : targetDims) {size *= l;}
code += "im = np.ndarray(" + size + ", dtype='" + CommonUtils.getDataType((RandomAccessibleInterval<T>) img)
code += "im = np.ndarray(" + size + ", dtype='" + CommonUtils.getDataType(Util.getTypeFromInterval(shma.getSharedRAI()))
+ "', buffer=im_shm.buf).reshape([";
for (long ll : targetDims)
code += ll + ", ";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/nets/samj/models/EfficientViTSamJ.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ protected <T extends RealType<T> & NativeType<T>> void setImageOfInterest(Random

@Override
protected void createEncodeImageScript() {
this.script = ""
this.script += ""
+ "task.update(str(im.shape))" + System.lineSeparator()
+ "predictor.set_image(im)";
}
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/ai/nets/samj/models/ImgLib2Utils.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*-
* #%L
* Library to call models of the family of SAM (Segment Anything Model) from Java
* %%
* Copyright (C) 2024 SAMJ developers.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package ai.nets.samj.models;

import ai.nets.samj.models.AbstractSamJ.DebugTextPrinter;
Expand All @@ -14,6 +33,11 @@
import net.imglib2.util.Util;
import net.imglib2.view.Views;

/**
* Methods used to feed images in the correct form to SAM models
*
* @author Carlos Garcia
*/
public class ImgLib2Utils {

/**
Expand Down

0 comments on commit b78afd5

Please sign in to comment.