How does torch.hub.load_state_dict_from_url work

Hi

I am quite new to Pytorch, and hence this might be a silly question.

I am using Google Colab, and trying to load the pretrained weights of vit_small_patch16_384 from timm module. But I am facing some issues, as its .npz format.

!pip install timm==0.4.12 (timm version I used)

checkpoint = torch.hub.load_state_dict_from_url( ‘https://storage.googleapis.com/vit_models/augreg/S_16-i21k-300ep-lr_0.001-aug_light1-wd_0.03-do_0.0-sd_0.0--imagenet2012-steps_20k-lr_0.03-res_384.npz’, map_location=‘cpu’, check_hash=True)

I get the following error:

RuntimeError: Expected hasRecord(“version”) to be true, but got false. (Could this error message be improved? If so, please report an enhancement request to PyTorch.)

What am I doing wrong?
Can anyone please help me to resolve this.
Thanks in advance

1 Like

Hi there, I have met the same error, have you fixed it now?

Where did you get the url from? https://storage.googleapis.com/vit_models/augreg/S_16-i21k-300ep-lr_0.001-aug_light1-wd_0.03-do_0.0-sd_0.0--imagenet2012-steps_20k-lr_0.03-res_384.npz

That’s a numpy file format and you’re trying to load a numpy checkpoint and not a torch one, fwiw the error message can be improved