Main VoxelMorph tutorial is out of date
Hi.
It seem the main VoxelMorph tutorial is out of date and do not works on Colab anymore. Problems are:
- Voxelmorph install not working
- unet.input is now a list of a keras tensor instead of just the keras tensor
- vxm_data_generator yield a tuple of 2 lists instead of tuples
- Uses of model.fit_generator instead of model.fit
- The output of model.predict is a list instead of tuple
- In tf.keras.optimizers.Adam uses lr instead of learning_rate
I made an updated Colab notebook that works in the meantime but it's more of a patched up version than a real replacement because some changes feel unsatisfactory:
- extracting the keras tensor from the unet.input list to keep the rest as is
- converting the output of the network into tuples for visualization to keep the rest as is
As a side note, the Voxelmorph install not working using:
!pip install voxelmorph
Is a recurring issue for multiple people. I do not know if it is because they are trying to use the tutorial or it also occurs on their local installation. (e.g. #633 )
Here is the method for locally deploying VoxelMorph Tutorial on Windows, including fixing errors such as "ImportError: cannot import name 'mean_absolute_error' from 'tensorflow.keras.losses'". The solution is to modify the TensorFlow version and manually install the corresponding libraries.
Please first create a Python 3.8 virtual environment, and then install TensorFlow 2.4.0 with:
pip install tensorflow-gpu==2.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
I am running it on Windows (3090Ti*1) using VSCode, so I installed ipykernel.
Then, install VoxelMorph according to the code in "VoxelMorph Tutorial.ipynb" by running:
pip install voxelmorph
Then, install the corresponding TensorFlow 2.4.0 version libraries:
pip install numpy==1.19.5
pip install Matplotlib==3.3.3
pip install scikit-image==0.17.2
pip install nibabel==3.2.1
While it might work, this does not change the fact that a Colab notebook tutorial is designed to be simple for anyone to use and should give accurate informations on the package. Using this method also means using a nearly 3 years old version of voxelmorph with the corresponding errors I listed. While they are not major, they are still a problem for a beginner (those most likely to need a tutorial). It also means creating an environment specifically for the tutorial as most wants to use the newer and better version (same for TensorFlow as 2.4 is nearly 5 years old). They also probably don't want to crawl through the commits to find the one used by PyPI to get information on the available functions and their workings.
As such, I think updating the colab notebook is preferable. Additionally, updating PyPI package to current commit would also help a lot as a number of open issues are related to it. I might also add that non-Chinese users might want to use:
pip install tensorflow-gpu==2.4.0
Instead of the mirror:
pip install tensorflow-gpu==2.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
If they want to run it locally.