Skip to content

Commit

Permalink
Fixed model load on CPU-only machines
Browse files Browse the repository at this point in the history
  • Loading branch information
lovaslin committed Jun 17, 2024
1 parent 534cc44 commit 5021795
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/defect_detection/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def deepAE_load(path, use_only=True, loss_fn=None, opt=None, opt_param=None):
ae = AE_cls(param, use_only, loss_fn, opt, opt_param)

# Load trained parameters
ae.load_state_dict(torch.load(path + "AE_state.save"))
if torch.cuda.is_available():
ae.load_state_dict(torch.load(path + "AE_state.save"))
else:
ae.load_state_dict(torch.load(path + "AE_state.save", map_location='cpu'))

return ae

0 comments on commit 5021795

Please sign in to comment.