Skip to content

Commit

Permalink
AMP check image download backup (ultralytics#7936)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher authored and Clay Januhowski committed Sep 8, 2022
1 parent 30be08e commit 97d4484
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,14 @@ def check_amp(model):
if next(model.parameters()).device.type == 'cpu': # get model device
return False
prefix = colorstr('AMP: ')
im = cv2.imread(ROOT / 'data' / 'images' / 'bus.jpg')[..., ::-1] # OpenCV image (BGR to RGB)
file = ROOT / 'data' / 'images' / 'bus.jpg' # image to test
if file.exists():
im = cv2.imread(file)[..., ::-1] # OpenCV image (BGR to RGB)
elif check_online():
im = 'https://ultralytics.com/images/bus.jpg'
else:
LOGGER.warning(emojis(f'{prefix}checks skipped ⚠️, not online.'))
return True
m = AutoShape(model, verbose=False) # model
a = m(im).xyxy[0] # FP32 inference
m.amp = True
Expand Down

0 comments on commit 97d4484

Please sign in to comment.