AMP check image download backup (#7936)

Resolves https://github.com/ultralytics/yolov5/discussions/7931
This commit is contained in:
Glenn Jocher 2022-05-23 15:31:54 +02:00 committed by GitHub
parent cee5959c74
commit cf3fb58522
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -511,7 +511,14 @@ def check_amp(model):
if next(model.parameters()).device.type == 'cpu': # get model device if next(model.parameters()).device.type == 'cpu': # get model device
return False return False
prefix = colorstr('AMP: ') 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 m = AutoShape(model, verbose=False) # model
a = m(im).xyxy[0] # FP32 inference a = m(im).xyxy[0] # FP32 inference
m.amp = True m.amp = True