Skip to content

Commit

Permalink
experimental.py Apple MPS device fix (#8121)
Browse files Browse the repository at this point in the history
* experimental.py Apple MPS fix

May resolve #8102

* Update experimental.py

* Update experimental.py
  • Loading branch information
glenn-jocher committed Jun 6, 2022
1 parent 47233e1 commit 18674e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions models/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +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)
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
Expand Down

0 comments on commit 18674e2

Please sign in to comment.