Skip to content

Commit

Permalink
correct small bug
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 11, 2024
1 parent ff0352b commit caa62bd
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 11 deletions.
19 changes: 18 additions & 1 deletion src/main/java/ai/nets/samj/communication/model/EfficientSAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class EfficientSAM implements SAMModel {

private EfficientSamJ efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class EfficientViTSAML0 implements SAMModel {

private EfficientViTSamJ efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class EfficientViTSAML1 implements SAMModel {

private EfficientViTSamJ efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class EfficientViTSAML2 implements SAMModel {

private EfficientViTSamJ efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class EfficientViTSAMXL0 implements SAMModel {

private EfficientViTSamJ efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class EfficientViTSAMXL1 implements SAMModel {

private EfficientViTSamJ efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;

Expand Down
19 changes: 18 additions & 1 deletion src/main/java/ai/nets/samj/communication/model/SAM2Large.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class SAM2Large implements SAMModel {

private Sam2 efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/ai/nets/samj/communication/model/SAM2Small.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,24 @@ public class SAM2Small implements SAMModel {

private Sam2 efficientSamJ;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down
24 changes: 22 additions & 2 deletions src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.awt.Rectangle;
import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import ai.nets.samj.models.AbstractSamJ;
Expand All @@ -47,7 +48,24 @@ public class SAM2Tiny implements SAMModel {

private Sam2 samj;
private final SamEnvManagerAbstract manager;
private SAMJLogger log;
private SAMJLogger log = new SAMJLogger() {

@Override
public void info(String text) {
System.out.println(text);
}

@Override
public void warn(String text) {
System.err.println("[WARNING] -- " + text);
}

@Override
public void error(String text) {
System.err.println(text);
}

};
private Boolean installed = false;
private boolean onlyBiggest = false;
/**
Expand Down Expand Up @@ -109,7 +127,9 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
this.log = useThisLoggerForIt;
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
AbstractSamJ.DebugTextPrinter filteringLogger = text -> {
int idx = text.indexOf("contours_x");
if (idx > 0) this.log.info( text.substring(0,idx) );
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/nets/samj/models/Sam2.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class Sam2 extends AbstractSamJ {
+ "from sam2.sam2_image_predictor import SAM2ImagePredictor" + System.lineSeparator()
+ "from sam2.utils.misc import variant_to_config_mapping" + System.lineSeparator()
+ "task.update('imported')" + System.lineSeparator()
+ "model = build_sam2(variant_to_config_mapping['%s'],'%s')" + System.lineSeparator()
+ "model = build_sam2(variant_to_config_mapping['%s'],r'%s')" + System.lineSeparator()
+ "predictor = SAM2ImagePredictor(model)" + System.lineSeparator()
+ "task.update('created predictor')" + System.lineSeparator()
+ "encodings_map = {}" + System.lineSeparator()
Expand Down

0 comments on commit caa62bd

Please sign in to comment.