huggingface / pytorch-image-models

The largest collection of PyTorch image encoders / backbones. Including train, eval, inference, export scripts, and pretrained weights -- ResNet, ResNeXT, EfficientNet, NFNet, Vision Transformer (ViT), MobileNetV4, MobileNet-V3 & V2, RegNet, DPN, CSPNet, Swin Transformer, MaxViT, CoAtNet, ConvNeXt, and more
https://huggingface.co/docs/timm
Apache License 2.0
32.44k stars 4.77k forks source link

[BUG] [efficientnetv2_rw_t] Pretrained weight file corrupted. #1301

Closed thohemp closed 2 years ago

thohemp commented 2 years ago

Loading pretrained weights for the model efficientnetv2_rw_t throws following error:

model  = timm.create_model('efficientnetv2_rw_t', pretrained=True, num_classes=0)
File ".../python3.6/site-packages/timm/models/helpers.py", line 189, in load_pretrained
    state_dict = load_state_dict_from_url(pretrained_url, progress=progress, map_location='cpu')
  File ".../python3.6/site-packages/torch/hub.py", line 528, in load_state_dict_from_url
    return torch.load(cached_file, map_location=map_location)
  File ".../python3.6/site-packages/torch/serialization.py", line 593, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File ".../python3.6/site-packages/torch/serialization.py", line 779, in _legacy_load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
 RuntimeError: unexpected EOF, expected 660309 more bytes. The file might be corrupted.
rwightman commented 2 years ago

@thohemp I did a manual download of the checkpoint to bypass my cached copy, it's fine and sha matches. so any corruption is due to your internet connection or local storage,

> wget https://github.com/rwightman/pytorch-image-models/releases/download/v0.1-weights/efficientnetv2_t_agc-3620981a.pth
>> 2022-06-13 08:51:04 (12.6 MB/s) - ‘efficientnetv2_t_agc-3620981a.pth’ saved [55190269/55190269]

> sha256sum efficientnetv2_t_agc-3620981a.pth 
>> 3620981a6fd48fd305a50bc0f8e1bee2e3c1545a7d530f3d6f9fbb2030cf67fb  efficientnetv2_t_agc-3620981a.pth

> python validate.py /imagenet/validation/ --model efficientnetv2_rw_t --amp  --checkpoint efficientnetv2_t_agc-3620981a.pth 
>>  * Acc@1 82.346 (17.654) Acc@5 96.188 (3.812)
--result
{
    "model": "efficientnetv2_rw_t",
    "top1": 82.346,
    "top1_err": 17.654,
    "top5": 96.188,
    "top5_err": 3.812,
    "param_count": 13.65,
    "img_size": 288,
    "crop_pct": 1.0,
    "interpolation": "bicubic"
}