Skip to content

Commit

Permalink
Always map location to cpu when load checkpoint (#6405)
Browse files Browse the repository at this point in the history
  • Loading branch information
st9007a committed Nov 2, 2021
1 parent db256a1 commit 599fcc2
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 @@ -39,8 +39,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 599fcc2

Please sign in to comment.