Skip to content

Commit

Permalink
Mapping loaded, pretrained model to actual device. Required for CPU o…
Browse files Browse the repository at this point in the history
…nly inference.
  • Loading branch information
akarazniewicz committed Nov 11, 2019
1 parent 603d463 commit be128d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def demo(opt):

# load model
print('loading pretrained model from %s' % opt.saved_model)
model.load_state_dict(torch.load(opt.saved_model))
model.load_state_dict(torch.load(opt.saved_model, map_location=device))

# prepare data. two demo images from https://github.com/bgshih/crnn#run-demo
AlignCollate_demo = AlignCollate(imgH=opt.imgH, imgW=opt.imgW, keep_ratio_with_pad=opt.PAD)
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test(opt):

# load model
print('loading pretrained model from %s' % opt.saved_model)
model.load_state_dict(torch.load(opt.saved_model))
model.load_state_dict(torch.load(opt.saved_model, map_location=device))
opt.experiment_name = '_'.join(opt.saved_model.split('/')[1:])
# print(model)

Expand Down

0 comments on commit be128d4

Please sign in to comment.