CSBDeep / CSBDeep_fiji

BSD 2-Clause "Simplified" License
11 stars 4 forks source link

Test SavedModelBundle exports #2

Closed frauzufall closed 5 years ago

frauzufall commented 6 years ago

https://www.tensorflow.org/api_docs/java/reference/org/tensorflow/SavedModelBundle

frauzufall commented 6 years ago

@HedgehogCode @uschmidt83 I am currently working on the SavedModel import with Uwes new net_project model and the standard input mapping (TIME Z Y X CHANNEL). I still get this error:

DatasetTensorBridge::setInputTensorShape: input node shape [-1, -1, -1, -1, 1]
DatasetTensorBridge::setOutputTensorShape: output node shape [-1, -1, -1, 2]
setmappingdefaults
After expand: [ 768 512 50 ]
executeInceptionGraph
java.lang.IllegalArgumentException: input and filter must have the same depth
     [[Node: conv3d_1_1/convolution = Conv3D[T=DT_FLOAT, _output_shapes=[[?,?,?,?,8]], data_format="NDHWC", padding="SAME", strides=[1, 1, 1, 1, 1], _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_input_1_1_0_0, conv3d_1_1/kernel/read)]]
    at org.tensorflow.Session.run(Native Method)
    at org.tensorflow.Session.access$100(Session.java:48)
    at org.tensorflow.Session$Runner.runHelper(Session.java:295)
    at org.tensorflow.Session$Runner.run(Session.java:245)
    at mpicbg.csbd.tensorflow.TensorFlowRunner.executeGraph(TensorFlowRunner.java:34)
    at mpicbg.csbd.commands.TiledPredictionUtil.executeGraphWithPadding(TiledPredictionUtil.java:117)
    at mpicbg.csbd.commands.TiledPredictionUtil.tiledPrediction(TiledPredictionUtil.java:81)
    at mpicbg.csbd.commands.AnyNetwork.run(AnyNetwork.java:246)
    at org.scijava.command.CommandModule.run(CommandModule.java:199)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:168)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:66)
    at org.scijava.thread.DefaultThreadService$3.call(DefaultThreadService.java:238)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

Any thoughts appreciated!

@HedgehogCode I got rid of everything supporting the Graph import since this is not the recommended strategy. The current state of the code is in https://github.com/frauzufall/CSBDeep/tree/saved-model. I am using the AnyNetwork command for testing.

uschmidt83 commented 6 years ago

Hi, vielleicht ne dumme Frage, aber sollte der output shape nicht ‘[-1, -1, -1, -1, 2]‘ (anstatt ‘[-1, -1, -1, 2]‘) sein?

HedgehogCode commented 6 years ago

@frauzufall My fault. I used the mapping from the DatasetTensorBridge wrong. This resulted in an input Tensor with a wrong shape. But now it fails when mapping it back because the output of the project model has one dimension less and we can't use the mapping directly anymore. This should be easy to fix for the special case but I am not sure how to handle this in general.

@uschmidt83 I think it's because this network reduces one dimension.

frauzufall commented 6 years ago

Cool! The dimension reduction was already implemented, I'll have a look at it, probably just have to add it to your code again. The rule from Martin was that if the output shape has one dimension less than the input shape, Z-Axis is tossed. It would be simpler in general if the shape stayed the same and the reduced dimension would just have a size of 1...