aiqm / torchani

Accurate Neural Network Potential on PyTorch
https://aiqm.github.io/torchani/
MIT License
459 stars 126 forks source link

Use local model parameters #581

Closed tfisher013 closed 3 years ago

tfisher013 commented 3 years ago

Hi developers,

I originally posted this issue under ani-model-zoo, but perhaps it belongs here.

I'm looking for a way to load TorchANI model parameters locally (I downloaded the 2x model parameters from github.com/aiqm/ani-model-zoo/archive/ani-2x.zip). Specifically, is there a way that I can change the line below to load the model parameters from a local path instead of from the aiqm repo?

model = torchani.models.ANI2x(periodic_table_index=True).to(device).double()

Thanks for your help!

yueyericardo commented 3 years ago

Hi,

ani-model-zoo belongs to torchani, and it could only be used within torchani. The reason we move it to ani-model-zoo repo (100MB) is to reduce the size of TorchANI for deployment. Line39 parse_resources.py

Why you need to use it outside of torchani?

tfisher013 commented 3 years ago

Thanks for your reply.

I'm using TorchANI in a web app that's behind a firewall and that was causing some issues accessing the parameters on Github. While that issue has been resolved for now, I don't maintain the firewall settings and being able to ensure that the parameters are able to load should something change would be great.

I understand that the parameters aren't loaded each time the model is run, so this would be insurance against using a different model sometime in the future (or perhaps having to replace the current one) with firewall settings that would be causing the issue I had earlier.

yueyericardo commented 3 years ago

Hi,

Good to hear you are using torchani, what's the web app for?

Depends on how you install torchani, you can alway download the zip file from ani-model-zoo, and unzip it into torchani/torchani/resources folder, then it should work. A way to find the resources folder might be

python -c 'import os; import torchani; ani_root = torchani.__file__; ani_resource = os.path.dirname(ani_root) + "/resources"; print(ani_resource)'
/home/richard/dev/torchani/torchani/resources
tfisher013 commented 3 years ago

Thanks for your reply.

The web app is used to help determine favorable chemical reaction pathways. It's been really helpful due to its speed.

TorchANI is installed via pip on the web server. I'll give this solution a try.

IgnacioJPickering commented 3 years ago

@tfisher013 has this been solved?

tfisher013 commented 3 years ago

Sorry for the delay. Yes, I've been able to use the solution @yueyericardo shared to fix this issue. Thanks for your help!