Vignesh38 commited on
Commit
a549a3b
·
1 Parent(s): 790be00

Fix torchvision import for compatibility with newer PyTorch versions

Browse files
Files changed (1) hide show
  1. models/resnet.py +4 -1
models/resnet.py CHANGED
@@ -1,6 +1,9 @@
1
  import torch
2
  import torch.nn as nn
3
- from torchvision.models.utils import load_state_dict_from_url
 
 
 
4
 
5
 
6
  __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
 
1
  import torch
2
  import torch.nn as nn
3
+ try:
4
+ from torch.hub import load_state_dict_from_url
5
+ except ImportError:
6
+ from torchvision.models.utils import load_state_dict_from_url
7
 
8
 
9
  __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',