Skip to content

Inference Model

Mohamed E. Masoud edited this page Dec 6, 2021 · 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.

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

Clone this wiki locally