From 258f4c64386d0e2caf73f98e45a46a7482ff4784 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 31 May 2022 10:55:14 +0200 Subject: [PATCH] `attempt_load()` deserialize fix (#8051) --- models/experimental.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/experimental.py b/models/experimental.py index 6ed528a335d2..c2d934546714 100644 --- a/models/experimental.py +++ b/models/experimental.py @@ -77,8 +77,8 @@ def attempt_load(weights, device=None, inplace=True, fuse=True): # Loads an ensemble of models weights=[a,b,c] or a single model weights=[a] or weights=a model = Ensemble() for w in weights if isinstance(weights, list) else [weights]: - ckpt = torch.load(attempt_download(w)) - ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model + ckpt = torch.load(attempt_download(w), map_location=device) + ckpt = (ckpt.get('ema') or ckpt['model']).float() # FP32 model model.append(ckpt.fuse().eval() if fuse else ckpt.eval()) # fused or un-fused model in eval mode # Compatibility updates