-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INFRA] Reduce size of TFLEARN models for brain extraction #55
Conversation
…brain extraction model
Based on a number of discussions, it seems it is indeed challenging to save properly TFlearn models in the tensorflow SavedModel which would allow to freeze and optimize the graph. Discussions and resources
I made several attempts with no success until now (See results in https://nbviewer.jupyter.org/github/Medical-Image-Analysis-Laboratory/mialsuperresolutiontoolkit/blob/52_tflearn_model_size/notebooks/optimize_tensorflow_checkpoint.ipynb). There would one last thing to try is to freeze the graph directly after training and follows post tflearn/tflearn#964 (comment) that I quoted below. They also say it is really important to do It also seems This is an additional argument in direction to use only tensorflow to create all the layers which would give more control in producing optimized models for prediction (i.e. application). This adds to the first limitation in using tflearn the development of which has stopped and depends on tensorflow 1, which causes issues in compatibility as we found only a combination of packages that works only in a Python 3.6 environment. However, I still managed to reduce both sizes from ~90MB down to ~30MB, which allows us to create packages publiable on Pypi 🥳 By testing on the first scan, it seems that the brain masks are exactly the same. Let's see if it passes all tests! |
From tflearn/tflearn#964 (comment):
|
Seems even if checkpoints are correctly used on my local installation on MacOsX (where I regenerated the new checkpoints) I do not think it is worst to dedicate more time here and I reverted changes to use the original checkpoints. By merging this PR, it will still add the notebook that makes a full report of the study for the sake of transparency, that could help future investigations if someone wish to do so. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By merging this PR it will adds the notebooks that investigates when to reduce size of TFLEARN models.
Add name for inputs of graph in _extractBrain()
.
As it does include any major changes and pass all tests I will merge it.
It investigates ways to address #52 to optimize model size to be able to publish pymialsrtk to PyPi,
Code contained in https://nbviewer.jupyter.org/github/Medical-Image-Analysis-Laboratory/mialsuperresolutiontoolkit/blob/52_tflearn_model_size/notebooks/optimize_tensorflow_checkpoint.ipynb.
However, it seems as we rely on tflearn way it is impossible or very challenging to optimize models as we can with tensorflow models for serving prediction. I do not think it is worst to dedicate time.
For more details see report in #55 (comment)