Skip to content

Inference Model

Mohamed E. Masoud edited this page Jan 25, 2023 · 22 revisions

Default Models

For our user convenience, a MeshNet segmentation model is trained and converted to Tensorflow.js(tfjs).

While MeshNet Model has fewer number of parameters compared to the classical segmentation model U-Net, it is also can achieve a competitive DICE score.

New Models

If you need to import your own 3D segmentation model, please make sure your model layers are compatible with tfjs layers.

If you are using a layer not supported by tfjs, try to find a workaround. For example, Keras batchnorm5d will raise an issue with tfjs model because there is not a batchnorm5d layer in tfjs. One possible workaround here is to use a fusion technique with Keras layers by merging batch normalization layer with convolution layer as shown in this link.

In addition to full-volume inference option, Brainchop is designed also to accept batch input shape such that: [null, batch_D, batch_H, batch_W, 1] (e.g. [null, 38, 38, 38, 1]), the smaller the batch dimensions the better for browser resources management.

After training your model on 3D segmentation task, multiple converters to tfjs can be used from command line , or by python code such as:

                        # Python sample code
                        import tensorflowjs as tfjs
                        # Loading the saved keras model 
                        keras_model = keras.models.load_model('path/to/model/location')
                        # Convert and save keras to tfjs_target_dir
                        tfjs.converters.save_keras_model(keras_model, tfjs_target_dir)

For more information about importing a model e.g. keras into Tensorflow.js please refere this tutorial

Successful conversion to tfjs will result into two main files, the model json file and the weights file as shown here

  • The model.json file consists of model topology and weights manifest.
  • The binary weights file (i.e. *.bin) consists of the concatenated weight values.

Importing above files can easily done using model browse option from model list.

Clone this wiki locally