Usage of torch.utils.model_zoo.load_url

When loading the pre-trained model, use the model_zoo method that comes with pytorch to load the model in the url address. The specific API is as follows:

torch.utils.model_zoo.load_url(url, model_dir=None)

Role: Load the torch serialized object on the given URL.
Specifically, the specified .pth file is downloaded through the url address of the provided .pth file.
Parameters:
url (string) - URL to download the object
model_dir (string, optional) - directory to save the object
If the object already exists in model_dir, it will be deserialized and returned. [That is to say later - the case that the model has been downloaded]
Detailed description:
If the object already exists in model_dir, it will be deserialized and returned. The filename portion of the URL should follow the naming convention filename-.ext, where are the first eight or more digits of the SHA256 hash of the file's contents. Hashes are used to ensure unique names and to verify the contents of files. The default value of model_dir is TORCHHOME/models, where TORCH_HOME/models, whereTORCHHOME / m o d e l s , where TORCH_HOME defaults to ~/.torch. The default directory can be overridden using the $TORCH_MODEL_ZOO environment variable.

Guess you like

Origin blog.csdn.net/q4326rgeqaadfd/article/details/129132975