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
To convert for QuPath create Conda env as above.
Extra:
pip install tf2onnx