How to Download timm models to specified location.

Hi everyone,
I’m trying to download a timm model to a user-specified location on my local machine using the following code:
model = timm.create_model(model_name, pretrained=True)

The code above downloads the model to the default location: C:\Users\17swa\.cache\torch\hub\checkpoints, which I don’t want. I want the model to be stored in my user specified location.

However, I couldn’t find a way to specify the download location. Is it possible to do this? If yes, could someone please guide me on how to achieve it?

From the docs:

The locations are used in the order of

    * Calling hub.set_dir(<PATH_TO_HUB_DIR>)

    * $TORCH_HOME/hub, if environment variable TORCH_HOME is set.

    * $XDG_CACHE_HOME/torch/hub, if environment variable XDG_CACHE_HOME is set.

    * ~/.cache/torch/hub

so you could change it via the Python calls or the mentioned env variables.