Skip to content

Commit

Permalink
experimental.py Apple MPS fix
Browse files Browse the repository at this point in the history
May resolve #8102
  • Loading branch information
glenn-jocher committed Jun 6, 2022
1 parent 47233e1 commit 6817548
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions models/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ def forward(self, x, augment=False, profile=False, visualize=False):


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)
w = attempt_download(w) # download if missing
ckpt = torch.load(w, 'cpu').to(device) if device == torch.device('mps') else torch.load(w, device) # load
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

Expand Down

0 comments on commit 6817548

Please sign in to comment.