Skip to content

Commit

Permalink
improve robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 11, 2024
1 parent caa62bd commit eff7ac5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
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 Down Expand Up @@ -127,10 +128,12 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
if (this.efficientSamJ == null)
efficientSamJ = EfficientSamJ.initializeSam(manager);
try {
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
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 Down Expand Up @@ -116,10 +117,12 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
if (this.efficientSamJ == null)
this.efficientSamJ = EfficientViTSamJ.initializeSam("l0", manager);
try {
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
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.install.EfficientViTSamEnvManager;
Expand Down Expand Up @@ -116,10 +117,12 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
if (this.efficientSamJ == null)
this.efficientSamJ = EfficientViTSamJ.initializeSam("l1", manager);
try {
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
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 Down Expand Up @@ -115,10 +116,12 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
if (this.efficientSamJ == null)
this.efficientSamJ = EfficientViTSamJ.initializeSam("l2", manager);
try {
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
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 Down Expand Up @@ -115,10 +116,12 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
if (this.efficientSamJ == null)
this.efficientSamJ = EfficientViTSamJ.initializeSam("xl0", manager);
try {
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
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 Down Expand Up @@ -117,10 +118,12 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
if (this.efficientSamJ == null)
this.efficientSamJ = EfficientViTSamJ.initializeSam("xl1", manager);
try {
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
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 Down Expand Up @@ -127,7 +128,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
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 Down Expand Up @@ -127,10 +128,12 @@ public boolean isInstalled() {
*/
public void setImage(final RandomAccessibleInterval<?> image, final SAMJLogger useThisLoggerForIt)
throws IOException, InterruptedException, RuntimeException {
Objects.requireNonNull(image, "The image cannot be null.");
if (useThisLoggerForIt != null)
this.log = useThisLoggerForIt;
if (this.efficientSamJ == null)
efficientSamJ = Sam2.initializeSam("small", manager);
try {
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

0 comments on commit eff7ac5

Please sign in to comment.