experimental.py Apple MPS device fix (#8121)
* experimental.py Apple MPS fix May resolve https://github.com/ultralytics/yolov5/issues/8102 * Update experimental.py * Update experimental.py
This commit is contained in:
parent
47233e1698
commit
18674e2f03
|
|
@ -72,13 +72,13 @@ class Ensemble(nn.ModuleList):
|
|||
|
||||
|
||||
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
|
||||
from models.yolo import Detect, Model
|
||||
|
||||
# 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), map_location=device)
|
||||
ckpt = (ckpt.get('ema') or ckpt['model']).float() # FP32 model
|
||||
ckpt = torch.load(attempt_download(w), map_location='cpu') # load
|
||||
ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model
|
||||
model.append(ckpt.fuse().eval() if fuse else ckpt.eval()) # fused or un-fused model in eval mode
|
||||
|
||||
# Compatibility updates
|
||||
|
|
|
|||
Loading…
Reference in New Issue