`attempt_load()` deserialize fix (#8051)
Browse files- models/experimental.py +2 -2
models/experimental.py
CHANGED
@@ -77,8 +77,8 @@ def attempt_load(weights, device=None, inplace=True, fuse=True):
|
|
77 |
# Loads an ensemble of models weights=[a,b,c] or a single model weights=[a] or weights=a
|
78 |
model = Ensemble()
|
79 |
for w in weights if isinstance(weights, list) else [weights]:
|
80 |
-
ckpt = torch.load(attempt_download(w))
|
81 |
-
ckpt = (ckpt.get('ema') or ckpt['model']).
|
82 |
model.append(ckpt.fuse().eval() if fuse else ckpt.eval()) # fused or un-fused model in eval mode
|
83 |
|
84 |
# Compatibility updates
|
|
|
77 |
# Loads an ensemble of models weights=[a,b,c] or a single model weights=[a] or weights=a
|
78 |
model = Ensemble()
|
79 |
for w in weights if isinstance(weights, list) else [weights]:
|
80 |
+
ckpt = torch.load(attempt_download(w), map_location=device)
|
81 |
+
ckpt = (ckpt.get('ema') or ckpt['model']).float() # FP32 model
|
82 |
model.append(ckpt.fuse().eval() if fuse else ckpt.eval()) # fused or un-fused model in eval mode
|
83 |
|
84 |
# Compatibility updates
|