glenn-jocher
commited on
Commit
•
2d45de6
1
Parent(s):
c13d4ce
Model `ema` key backward compatibility fix (#6972)
Browse filesFix for older model loading issue in https://github.com/ultralytics/yolov5/commit/d3d9cbce221b2ced46dde374f24fde72c8e71c37#commitcomment-68622388
- models/experimental.py +1 -1
models/experimental.py
CHANGED
@@ -94,7 +94,7 @@ def attempt_load(weights, map_location=None, inplace=True, fuse=True):
|
|
94 |
model = Ensemble()
|
95 |
for w in weights if isinstance(weights, list) else [weights]:
|
96 |
ckpt = torch.load(attempt_download(w), map_location=map_location) # load
|
97 |
-
ckpt = (ckpt
|
98 |
model.append(ckpt.fuse().eval() if fuse else ckpt.eval()) # fused or un-fused model in eval mode
|
99 |
|
100 |
# Compatibility updates
|
|
|
94 |
model = Ensemble()
|
95 |
for w in weights if isinstance(weights, list) else [weights]:
|
96 |
ckpt = torch.load(attempt_download(w), map_location=map_location) # load
|
97 |
+
ckpt = (ckpt.get('ema') or ckpt['model']).float() # FP32 model
|
98 |
model.append(ckpt.fuse().eval() if fuse else ckpt.eval()) # fused or un-fused model in eval mode
|
99 |
|
100 |
# Compatibility updates
|