Skip to content

Commit

Permalink
add methods to communication layer
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Jul 17, 2024
1 parent 65ef7c4 commit 49591c9
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/main/java/ai/nets/samj/communication/model/EfficientSAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,34 @@ public String getInputImageAxes() {
public void setReturnOnlyBiggest(boolean onlyBiggest) {
this.onlyBiggest = onlyBiggest;
}

@Override
public String persistEncoding() throws IOException, InterruptedException {
try {
return efficientSamJ.persistEncoding();
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding: "+e.getMessage());
throw e;
}
}

@Override
public void selectEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.selectEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}

@Override
public void deleteEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.deleteEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to delete the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,34 @@ public String getInputImageAxes() {
public void setReturnOnlyBiggest(boolean onlyBiggest) {
this.onlyBiggest = onlyBiggest;
}

@Override
public String persistEncoding() throws IOException, InterruptedException {
try {
return efficientSamJ.persistEncoding();
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding: "+e.getMessage());
throw e;
}
}

@Override
public void selectEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.selectEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}

@Override
public void deleteEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.deleteEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to delete the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,34 @@ public String getInputImageAxes() {
public void setReturnOnlyBiggest(boolean onlyBiggest) {
this.onlyBiggest = onlyBiggest;
}

@Override
public String persistEncoding() throws IOException, InterruptedException {
try {
return efficientSamJ.persistEncoding();
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding: "+e.getMessage());
throw e;
}
}

@Override
public void selectEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.selectEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}

@Override
public void deleteEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.deleteEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to delete the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,34 @@ public String getInputImageAxes() {
public void setReturnOnlyBiggest(boolean onlyBiggest) {
this.onlyBiggest = onlyBiggest;
}

@Override
public String persistEncoding() throws IOException, InterruptedException {
try {
return efficientSamJ.persistEncoding();
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding: "+e.getMessage());
throw e;
}
}

@Override
public void selectEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.selectEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}

@Override
public void deleteEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.deleteEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to delete the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,34 @@ public String getInputImageAxes() {
public void setReturnOnlyBiggest(boolean onlyBiggest) {
this.onlyBiggest = onlyBiggest;
}

@Override
public String persistEncoding() throws IOException, InterruptedException {
try {
return efficientSamJ.persistEncoding();
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding: "+e.getMessage());
throw e;
}
}

@Override
public void selectEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.selectEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}

@Override
public void deleteEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.deleteEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to delete the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,34 @@ public String getInputImageAxes() {
public void setReturnOnlyBiggest(boolean onlyBiggest) {
this.onlyBiggest = onlyBiggest;
}

@Override
public String persistEncoding() throws IOException, InterruptedException {
try {
return efficientSamJ.persistEncoding();
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding: "+e.getMessage());
throw e;
}
}

@Override
public void selectEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.selectEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to persist the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}

@Override
public void deleteEncoding(String encodingName) throws IOException, InterruptedException {
try {
efficientSamJ.deleteEncoding(encodingName);
} catch (IOException | InterruptedException | RuntimeException e) {
log.error(FULL_NAME+", unable to delete the encoding named '" + encodingName + "': "+e.getMessage());
throw e;
}
}
}
7 changes: 7 additions & 0 deletions src/main/java/ai/nets/samj/communication/model/SAMModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ public interface SAMModel {
*/
public <T extends RealType<T> & NativeType<T>> List<Polygon> fetch2dSegmentationFromMask(RandomAccessibleInterval<T> rai) throws IOException, RuntimeException, InterruptedException;


public String persistEncoding() throws IOException, InterruptedException;

public void selectEncoding(String encodingName) throws IOException, InterruptedException;

public void deleteEncoding(String encodingName) throws IOException, InterruptedException;

/**
* Close the Python process where the model is being executed
*/
Expand Down

0 comments on commit 49591c9

Please sign in to comment.