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
Hello. Sometime in January 2023, this work around worked without issue. I have come back to it to convert a new Stardist model from TensorFlow2 to TensorFlow1.14, and I am running into a series of errors. I am not sure if maybe the version of Keras is incompatible. If you have any suggestions of a starting place to troubleshoot, I would greatly appreciate it. I am running pythong from an Anaconda temrinal with the environment created as noted above, specifying TF version 1.14.
The error message is:
The installed package list is below for reference: