diff --git a/src/main/java/io/bioimage/modelrunner/bioimageio/bioengine/BioengineInterface.java b/src/main/java/io/bioimage/modelrunner/bioimageio/bioengine/BioengineInterface.java index b7ec5728..a2334282 100644 --- a/src/main/java/io/bioimage/modelrunner/bioimageio/bioengine/BioengineInterface.java +++ b/src/main/java/io/bioimage/modelrunner/bioimageio/bioengine/BioengineInterface.java @@ -42,6 +42,7 @@ import io.bioimage.modelrunner.bioimageio.bioengine.tensor.BioEngineOutputArray; import io.bioimage.modelrunner.bioimageio.bioengine.tensor.BioengineTensor; import io.bioimage.modelrunner.bioimageio.description.ModelDescriptor; +import io.bioimage.modelrunner.bioimageio.description.ModelDescriptorFactory; import io.bioimage.modelrunner.engine.DeepLearningEngineInterface; import io.bioimage.modelrunner.exceptions.LoadModelException; import io.bioimage.modelrunner.exceptions.RunModelException; @@ -50,6 +51,8 @@ import net.imglib2.img.Img; import net.imglib2.img.ImgFactory; import net.imglib2.img.array.ArrayImgFactory; +import net.imglib2.type.NativeType; +import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.real.FloatType; /** @@ -153,7 +156,8 @@ public class BioengineInterface implements DeepLearningEngineInterface { */ private static final String SERIALIZATION_VAL = "imjoy"; - public static void main(String[] args) throws LoadModelException, RunModelException { + public static & NativeType, R extends RealType & NativeType> + void main(String[] args) throws LoadModelException, RunModelException { BioengineInterface bi = new BioengineInterface(); String path = "C:\\Users\\angel\\OneDrive\\Documentos\\" + "pasteur\\git\\deep-icy\\models\\2D UNet Arabidopsis Ap" @@ -163,12 +167,12 @@ public static void main(String[] args) throws LoadModelException, RunModelExcept final ImgFactory< FloatType > imgFactory = new ArrayImgFactory<>( new FloatType() ); final Img< FloatType > img1 = imgFactory.create( 1, 1, 512, 512 ); Tensor inpTensor = Tensor.build("input0", "bcyx", img1); - List> inputs = new ArrayList>(); - inputs.add(inpTensor); + List> inputs = new ArrayList>(); + inputs.add((Tensor) inpTensor); final Img< FloatType > img2 = imgFactory.create( 1, 2, 512, 512 ); Tensor outTensor = Tensor.build("output0", "bcyx", img2); - List> outputs = new ArrayList>(); - outputs.add(outTensor); + List> outputs = new ArrayList>(); + outputs.add((Tensor) outTensor); bi.run(inputs, outputs); System.out.print(DECODE_JSON_VAL); } @@ -177,7 +181,8 @@ public static void main(String[] args) throws LoadModelException, RunModelExcept /** * {@inheritDoc} */ - public void run(List> inputTensors, List> outputTensors) throws RunModelException { + public & NativeType, R extends RealType & NativeType> + void run(List> inputTensors, List> outputTensors) throws RunModelException { List inputs = new ArrayList(); for (Tensor tt : inputTensors) { @@ -222,14 +227,14 @@ public void run(List> inputTensors, List> outputTensors) thr * @throws RunModelException if the number of tensors expected is not the same as * the number of tensors returned by the Bioengine */ - private void fillOutputTensors(List> outputTensors, List arrayOutputs) throws RunModelException { + private & NativeType> void fillOutputTensors(List> outputTensors, List arrayOutputs) throws RunModelException { if (outputTensors.size() != arrayOutputs.size()) { throw new RunModelException("The rdf.yaml file specifies '" + outputTensors.size() + "' tensors, but the Bioengine has " + "produced '" + arrayOutputs.size() + "' output tensors."); } int c = 0; - for (Tensor tt : outputTensors) { + for (Tensor tt : outputTensors) { tt.setData(arrayOutputs.get(c ++).getImg()); } } @@ -240,7 +245,7 @@ private void fillOutputTensors(List> outputTensors, List