This note shows how to make a new Python environment containing TensorFlow 1.x, load a model based on CSBDeep, and then export via export_TF()
. Please see this on why you might want to do this.
As an example, we load a StarDist model and export it from the new environment. But the same should also work accordingly with all CSBDeep model types.
Assuming that you use conda
to manage your environments (if not, e.g. read this), do the following:
- Create a new Python environment and install TensorFlow 1.x, CSBDeep and other necessary packages (e.g. StarDist):
conda create -y --name tf1_model_export python=3.7
conda activate tf1_model_export
# note: gpu support is not necessary for tensorflow
pip install "tensorflow<2"
pip install "csbdeep[tf1]"
# also install stardist in this example
pip install "stardist[tf1]"
- Make a new Python script to export the model:
from stardist.models import StarDist2D
model = StarDist2D(None, name='my_model', basedir='.')
model.export_TF()
- Run the script to export the model
Hi, I tried to import my model using:
from stardist.models import StarDist2D model = StarDist2D(None, name='spine_3D', basedir='c:\\ImageModels\\myModels') model.export_TF()
but I have the follow:
AttributeError: Not allowed to add new parameters (means, stds, unet_residual, unet_kern_size, unet_n_first, unet_input_shape, train_loss, batch_norm, n2v_perc_pix, n2v_patch_shape, n2v_manipulator, n2v_neighborhood_radius, single_net_per_channel, blurpool, skip_skipone, structN2Vmask, probabilistic)
any idea of how could I fix it?