Skip to content

Commit

Permalink
remove last errors, even though not finished
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Sep 30, 2024
1 parent eab97db commit afbeb3c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
16 changes: 10 additions & 6 deletions src/main/java/io/bioimage/modelrunner/model/Stardist2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package io.bioimage.modelrunner.model;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
Expand All @@ -41,6 +42,7 @@
import io.bioimage.modelrunner.apposed.appose.MambaInstallException;
import io.bioimage.modelrunner.bioimageio.BioimageioRepo;
import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor;
import io.bioimage.modelrunner.bioimageio.description.ModelDescriptorFactory;
import io.bioimage.modelrunner.bioimageio.description.exceptions.ModelSpecsException;
import io.bioimage.modelrunner.engine.installation.EngineInstall;
import io.bioimage.modelrunner.exceptions.LoadEngineException;
Expand Down Expand Up @@ -111,9 +113,11 @@ private Stardist2D(ModelDescriptor descriptor) {
* path to the Bioimage.io model
* @return an instance of a Stardist2D model ready to be used
* @throws ModelSpecsException if there is any error in the configuration of the specs rdf.yaml file of the Bioimage.io
* @throws IOException
* @throws FileNotFoundException
*/
public static Stardist2D fromBioimageioModel(String modelPath) throws ModelSpecsException {
ModelDescriptor descriptor = ModelDescriptor.readFromLocalFile(modelPath + File.separator + Constants.RDF_FNAME, false);
public static Stardist2D fromBioimageioModel(String modelPath) throws ModelSpecsException, FileNotFoundException, IOException {
ModelDescriptor descriptor = ModelDescriptorFactory.readFromLocalFile(modelPath + File.separator + Constants.RDF_FNAME);
return new Stardist2D(descriptor);
}

Expand Down Expand Up @@ -152,7 +156,7 @@ public static Stardist2D fromPretained(String pretrainedModel, String installDir
ModelSpecsException {
if ((pretrainedModel.equals("StarDist H&E Nuclei Segmentation")
|| pretrainedModel.equals("2D_versatile_he")) && !forceInstall) {
ModelDescriptor md = ModelDescriptor.getModelsAtLocalRepo().stream()
ModelDescriptor md = ModelDescriptorFactory.getModelsAtLocalRepo().stream()
.filter(mm ->mm.getName().equals("StarDist H&E Nuclei Segmentation")).findFirst().orElse(null);
if (md != null) return new Stardist2D(md);
String path = BioimageioRepo.connect().downloadByName("StarDist H&E Nuclei Segmentation", installDir);
Expand All @@ -163,7 +167,7 @@ public static Stardist2D fromPretained(String pretrainedModel, String installDir
return Stardist2D.fromBioimageioModel(path);
} else if ((pretrainedModel.equals("StarDist Fluorescence Nuclei Segmentation")
|| pretrainedModel.equals("2D_versatile_fluo")) && !forceInstall) {
ModelDescriptor md = ModelDescriptor.getModelsAtLocalRepo().stream()
ModelDescriptor md = ModelDescriptorFactory.getModelsAtLocalRepo().stream()
.filter(mm ->mm.getName().equals("StarDist Fluorescence Nuclei Segmentation")).findFirst().orElse(null);
if (md != null) return new Stardist2D(md);
String path = BioimageioRepo.connect().downloadByName("StarDist Fluorescence Nuclei Segmentation", installDir);
Expand Down Expand Up @@ -215,8 +219,8 @@ RandomAccessibleInterval<T> predict(RandomAccessibleInterval<T> image) throws Mo
Tensor<T> inputTensor = Tensor.build("input", "byxc", image);
Tensor<T> outputTensor = Tensor.buildEmptyTensor("output", "byxc");

List<Tensor<?>> inputList = new ArrayList<Tensor<?>>();
List<Tensor<?>> outputList = new ArrayList<Tensor<?>>();
List<Tensor<T>> inputList = new ArrayList<Tensor<T>>();
List<Tensor<T>> outputList = new ArrayList<Tensor<T>>();
inputList.add(inputTensor);
outputList.add(outputTensor);

Expand Down
14 changes: 9 additions & 5 deletions src/main/java/io/bioimage/modelrunner/model/Stardist3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package io.bioimage.modelrunner.model;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
Expand All @@ -41,6 +42,7 @@
import io.bioimage.modelrunner.apposed.appose.MambaInstallException;
import io.bioimage.modelrunner.bioimageio.BioimageioRepo;
import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor;
import io.bioimage.modelrunner.bioimageio.description.ModelDescriptorFactory;
import io.bioimage.modelrunner.bioimageio.description.exceptions.ModelSpecsException;
import io.bioimage.modelrunner.engine.installation.EngineInstall;
import io.bioimage.modelrunner.exceptions.LoadEngineException;
Expand Down Expand Up @@ -111,9 +113,11 @@ private Stardist3D(ModelDescriptor descriptor) {
* path to the Bioimage.io model
* @return an instance of a Stardist3D model ready to be used
* @throws ModelSpecsException if there is any error in the configuration of the specs rdf.yaml file of the Bioimage.io
* @throws IOException
* @throws FileNotFoundException
*/
public static Stardist3D fromBioimageioModel(String modelPath) throws ModelSpecsException {
ModelDescriptor descriptor = ModelDescriptor.readFromLocalFile(modelPath + File.separator + Constants.RDF_FNAME, false);
public static Stardist3D fromBioimageioModel(String modelPath) throws ModelSpecsException, FileNotFoundException, IOException {
ModelDescriptor descriptor = ModelDescriptorFactory.readFromLocalFile(modelPath + File.separator + Constants.RDF_FNAME);
return new Stardist3D(descriptor);
}

Expand Down Expand Up @@ -150,7 +154,7 @@ public static Stardist3D fromPretained(String pretrainedModel, String installDir
InterruptedException,
ModelSpecsException {
if (pretrainedModel.equals("StarDist Plant Nuclei 3D ResNet") && !forceInstall) {
ModelDescriptor md = ModelDescriptor.getModelsAtLocalRepo().stream()
ModelDescriptor md = ModelDescriptorFactory.getModelsAtLocalRepo().stream()
.filter(mm ->mm.getName().equals(pretrainedModel)).findFirst().orElse(null);
if (md != null) return new Stardist3D(md);
String path = BioimageioRepo.connect().downloadByName("StarDist Plant Nuclei 3D ResNet", installDir);
Expand Down Expand Up @@ -207,8 +211,8 @@ RandomAccessibleInterval<T> predict(RandomAccessibleInterval<T> image) throws Mo
Tensor<T> inputTensor = Tensor.build("input", "bzyxc", image);
Tensor<T> outputTensor = Tensor.buildEmptyTensor("output", "bzyxc");

List<Tensor<?>> inputList = new ArrayList<Tensor<?>>();
List<Tensor<?>> outputList = new ArrayList<Tensor<?>>();
List<Tensor<T>> inputList = new ArrayList<Tensor<T>>();
List<Tensor<T>> outputList = new ArrayList<Tensor<T>>();
inputList.add(inputTensor);
outputList.add(outputTensor);

Expand Down

0 comments on commit afbeb3c

Please sign in to comment.