1adrianb / face-alignment

:fire: 2D and 3D Face alignment library build using pytorch
https://www.adrianbulat.com
BSD 3-Clause "New" or "Revised" License
6.88k stars 1.33k forks source link

[Contribution suggestion] Allow explicitly passing in model_dir #283

Open thogerb opened 2 years ago

thogerb commented 2 years ago

Hi @1adrianb

Lovely package, first of all. I was testing it, and ran into (and have resolved in a fork) an issue with deploying to AWS Lambda:

Fix/enhancement (easy): Add model_dir: str = None to each of the __init__ for classes that use torch URL-loading functions. Downstream functions already support the explicit model_dir, but top-level class initialization e.g. in api.py module doesn't.

If you agree, I am happy to send you a PR on it:)

Best, Thoger.

thogerb commented 2 years ago

Ok, I notice now that the same could probably also be achieved by globally calling torch.hub.set_dir or setting the TORCH_HOME environment variable.

Docs: https://pytorch.org/docs/stable/hub.html#torch.hub.get_dir

Personally not a big fan of using the global state but it should suffice for the use case 👍 Feel free to close this opened "Issue".