Problem loading Stardist model into Fiji Plugin

Hi everybody,

i’m trying to use a stardist model trained on one of our workstation at my own laptop with the Fiji plugin. But i get a bunch of errors.
The pre-trained models are working so i guess it has something to do with my model.
The workstation uses newest Tensorflow version if that matters?!?
I hope someone has an idea what is causing the problems.

Thanks in advance!

Best,
Jan

The errors i get are:

[INFO] Using native TensorFlow version: TF 1.14.0 CPU
[INFO] Loading TensorFlow model GenericNetwork_10ee94b49d5e3993569c855b27dadb84 from source file file:/W:/scratch/gfriedri/ForAll/StartDist/ground_truth/PooledBoNeRuByJan/SomeData80percOnlyLateMiddleStage/models/stardist/TF_SavedModel.zip
java.lang.IllegalArgumentException: NodeDef mentions attr ‘allowed_devices’ not in Op<name=VarHandleOp; signature= → resource:resource; attr=container:string,default=""; attr=shared_name:string,default=""; attr=dtype:type; attr=shape:shape; is_stateful=true>; NodeDef: {{node down_level_0_no_0/kernel}}. (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.).
[[down_level_0_no_0/kernel]]
at org.tensorflow.SavedModelBundle.load(Native Method)
at org.tensorflow.SavedModelBundle.access$000(SavedModelBundle.java:27)
at org.tensorflow.SavedModelBundle$Loader.load(SavedModelBundle.java:32)
at org.tensorflow.SavedModelBundle.load(SavedModelBundle.java:95)
at net.imagej.tensorflow.CachedModelBundle.(CachedModelBundle.java:44)
at net.imagej.tensorflow.DefaultTensorFlowService.loadCachedModel(DefaultTensorFlowService.java:135)
at de.csbdresden.csbdeep.network.model.tensorflow.TensorFlowNetwork.loadModel(TensorFlowNetwork.java:163)
at de.csbdresden.csbdeep.network.model.DefaultNetwork.loadModel(DefaultNetwork.java:76)
at de.csbdresden.csbdeep.network.DefaultModelLoader.loadNetwork(DefaultModelLoader.java:69)
at de.csbdresden.csbdeep.network.DefaultModelLoader.run(DefaultModelLoader.java:48)
at de.csbdresden.csbdeep.commands.GenericCoreNetwork.tryToPrepareInputAndNetwork(GenericCoreNetwork.java:524)
at de.csbdresden.csbdeep.commands.GenericCoreNetwork.initiateModelIfNeeded(GenericCoreNetwork.java:303)
at de.csbdresden.csbdeep.commands.GenericCoreNetwork.mainThread(GenericCoreNetwork.java:445)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
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)
[INFO] CSBDeep plugin exit (took 145 milliseconds)
[ERROR] Module threw exception
java.lang.NullPointerException
at de.csbdresden.stardist.StarDist2D.splitPrediction(StarDist2D.java:338)
at de.csbdresden.stardist.StarDist2D.run(StarDist2D.java:307)
at org.scijava.command.CommandModule.run(CommandModule.java:196)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
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)

Hi @Eggord,

The tensorflow version in python (from which you export from) should not be newer then the one used in Fiji (e.g. if you trained in python with tf 2.3 it wont work in Fiji with tf 1.14). Have a look here:

https://stardist.net/docs/faq.html#after-training-in-python-how-do-i-export-a-model-to-be-used-in-fiji-do-i-have-to-be-careful-with-the-version-of-tensorflow

If you have a model trained with a newer tf version than the Fiji one, you could

  1. create a python environment with tf 1.14 (or whatever version you have in Fiji) e.g via conda

  2. load the model from its folder (the python stardist lib is compatible with both tf1 and tf2)

model = StarDist2D(None, name="folder_path")
  1. re-export it from there
model.export_TF(...)

Hope that helps,
M

1 Like

Hi @mweigert,

thanks for the quick answer.
Yes i was expecting something like this (why i mentioned tf :slight_smile: )
Thanks for the workaround. I will try this later this or next week and write if it worked or not.

Best,
Jan

2 Likes