Skip to content

Commit

Permalink
Always map location to cpu when load checkpoint (open-mmlab#6405)
Browse files Browse the repository at this point in the history
  • Loading branch information
st9007a authored and ZwwWayne committed Jul 18, 2022
1 parent e8e04d2 commit e0c15dd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mmdet/apis/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def init_detector(config, checkpoint=None, device='cuda:0', cfg_options=None):
config.model.train_cfg = None
model = build_detector(config.model, test_cfg=config.get('test_cfg'))
if checkpoint is not None:
map_loc = 'cpu' if device == 'cpu' else None
checkpoint = load_checkpoint(model, checkpoint, map_location=map_loc)
checkpoint = load_checkpoint(model, checkpoint, map_location='cpu')
if 'CLASSES' in checkpoint.get('meta', {}):
model.CLASSES = checkpoint['meta']['CLASSES']
else:
Expand Down

0 comments on commit e0c15dd

Please sign in to comment.