ANTsX / ANTsPyNet

Pre-trained models and utilities for deep learning on medical images in Python
https://antspynet.readthedocs.io
Apache License 2.0
182 stars 28 forks source link

Python Version Info Missing #97

Closed toomanycats closed 3 months ago

toomanycats commented 3 months ago

I'd like to install ANTsPyNet but I have not seen information on dependencies, perhaps I'm not looking in the correct place ?

As you know TF and Keras require specific versions of Python and since you provide a pre-trained model, I think I also need a compatible version to the one you created it with...

Hopefully I'm missing something obvious.

cookpa commented 3 months ago

For now, here's a requirements file that works for me on Linux with Python 3.11.6:

https://github.com/cookpa/ANTsXContainers/blob/master/docker/ANTsPyNet/requirements.txt

We're discussing revamping the model storage system (#94) and better requirements tracking would be good to go along with that.

ncullen93 commented 3 months ago

That’s a great idea actually... to store a requirements.txt with each trained model. The neuronets/nobrainer package uses docker for this I believe, but to me that’s a bit overkill.

ncullen93 commented 3 months ago

Coming back to this - @cookpa - the key on the dependencies is having tensorflow == 2.12 but (i think more importantly) tensorflow_probability == 0.20. I think those should be nailed down in the requirements.txt file.

Lots of issues now with later tensorflow versions due to Keras 3 and requiring newer python versions. I think the python version might have to be < 3.11 also for these to work but not 100% there.

ntustison commented 3 months ago

For what it's worth, I'm running antspynet with various versions of python 3.11 on all my linux and mac platforms.

cookpa commented 3 months ago

Same. I haven't tested every available pre-trained model though. I didn't know they had individual python requirements

ncullen93 commented 3 months ago

Right, should be fine. I'm only having an issue due to Keras 3.. so nothing to do with antspynet actually.

EDIT: but actually then if you try to install the latest tensorflow, then you will get keras 3 by default. And keras 3 breaks the tf.keras stuff due to tensorflow probability (https://github.com/tensorflow/probability/issues/1774). So I am not sure antspynet will work if you have keras 3 installed.

ntustison commented 3 months ago

One thing I should probably clarify somewhere is that most, if not all, of "pretrained models" are actually just the pretrained weights. At least all the models I've trained, I save the weights because I prefer the transparency of having the network configuration visible.

I don't know if tensorflow probability is actually required anymore. There was a network for which it was required but I commented it out because it was never used and it was giving me issues due to tensorflow probability.

toomanycats commented 3 months ago

Glad I asked. I'll try Python == 3.11.x with TF == 2.12.

TBH I hate Docker / Sing containers for things like this. If I need a container it's b/c of an OS mismatch. Trouble shooting a container is a huge PITA. For example: I ran into a hassle with ANTS b/c an ITK module used a posix thread locker that didn't play nice with NFSv4 when run inside a singularity container. I never did figure out the details but down grading to NSFv3 solved it.

ncullen93 commented 3 months ago

I totally agree... don't think docker is ever the solution ha ha.

@ntustison you should remove tf probability if you really dont think it's needed. By the way - I am semi-working on turning those weights into full networks. But eventually i may need you to power through giving me short explanations of how they were trained, etc.

ntustison commented 3 months ago

Yeah, we can remove tensorflow_probability as a requirement as it's only used for a single network that's not used for anything. I actually commented it out in the init.py file. I'll make that change.