Skip to the content.

Tutorial Part II: Apply the model in Fiji using DeepImageJ plugin

In the first part we learned how to train and apply a model with the YAPiC command line tool. Besides of using YAPiC for prediction, we can export the model to a bundled model that is ready to use in ImageJ’s DeepimageJ plugin.

Preparation

Install Fiji and the DeepImageJ plugin.

Export your Model with YAPiC to a DeepImageJ BundledModel

To be able to load the model into DeepImageJ, you have to convert it with YAPiC’s deploy option. To be able to export YAPiC models to ImageJ (DeepImageJ Plugin version 1.2), you have use Tensorflow version 1.15.

yapic deploy model.h5 path/to/example_image/leaves_1.tif path/to/fiji_installation/models/my_leaves_model_1 --skip-predict

The command converts the Keras model file into a DeepImageJ bundled model with all necessary metadata, example images and conversion scripts included. The model can be directly applied in DeepImageJ. There is no need of executing DeepImageJ:Build BundledModel inside ImageJ.

There are several optional parameters to add metadata to the model (e.g. author information):

--author=AUTHOR         Name of the model's authors [default: n/a]
--url=URL               Url to model publication [default: http://]
--credit=CREDIT         [default: n/a]
--mdversion=MDVERSION   Model version [default: n/a]
--reference=REFERENCE   Publication reference of model [default: n/a]

This is of particular interest if you would like to publish the model on the model repository.

Open and Apply the Model in Fiji

  1. Open Fiji
  2. Go to Plugins>>DeepImageJ>>DeepImageJ Explore
  3. Your model with name my_leaves_model_1 is listed. For a quick test, you can apply you model to the test image, which is bundled with the model.
  4. To apply the model to another image, open your image of choice and run Plugins>>DeepImageJ>>DeepImageJ Run.
    • Select your model.
    • Set the preprocessing and postprocessing macros as shown in the screenshot. The macros are included in the bundled model (they were generated with the yapic deploy command you applied earlier).
  5. Hit OK to start prediction.