glenn-jocher commited on
Commit
4f6c0cf
·
unverified ·
1 Parent(s): 0dec8ff

Update hubconf.py

Browse files
Files changed (1) hide show
  1. hubconf.py +2 -2
hubconf.py CHANGED
@@ -27,12 +27,12 @@ def create(name, pretrained, channels, classes):
27
  Returns:
28
  pytorch model
29
  """
30
- config = os.path.join(os.path.dirname(__file__), 'models', '%s.yaml' % name)
31
  model = Model(config, channels, classes)
32
  if pretrained:
33
  ckpt = '%s.pt' % name # checkpoint filename
34
  google_utils.attempt_download(ckpt) # download if not found locally
35
- state_dict = torch.load(ckpt)['model'].state_dict()
36
  state_dict = {k: v for k, v in state_dict.items() if model.state_dict()[k].numel() == v.numel()} # filter
37
  model.load_state_dict(state_dict, strict=False) # load
38
  return model
 
27
  Returns:
28
  pytorch model
29
  """
30
+ config = os.path.join(os.path.dirname(__file__), 'models', '%s.yaml' % name) # model.yaml path
31
  model = Model(config, channels, classes)
32
  if pretrained:
33
  ckpt = '%s.pt' % name # checkpoint filename
34
  google_utils.attempt_download(ckpt) # download if not found locally
35
+ state_dict = torch.load(ckpt, map_location=torch.device('cpu'))['model'].state_dict()
36
  state_dict = {k: v for k, v in state_dict.items() if model.state_dict()[k].numel() == v.numel()} # filter
37
  model.load_state_dict(state_dict, strict=False) # load
38
  return model