AMP check image download backup (#7936)
Browse filesResolves https://github.com/ultralytics/yolov5/discussions/7931
- utils/general.py +8 -1
utils/general.py
CHANGED
@@ -511,7 +511,14 @@ def check_amp(model):
|
|
511 |
if next(model.parameters()).device.type == 'cpu': # get model device
|
512 |
return False
|
513 |
prefix = colorstr('AMP: ')
|
514 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
m = AutoShape(model, verbose=False) # model
|
516 |
a = m(im).xyxy[0] # FP32 inference
|
517 |
m.amp = True
|
|
|
511 |
if next(model.parameters()).device.type == 'cpu': # get model device
|
512 |
return False
|
513 |
prefix = colorstr('AMP: ')
|
514 |
+
file = ROOT / 'data' / 'images' / 'bus.jpg' # image to test
|
515 |
+
if file.exists():
|
516 |
+
im = cv2.imread(file)[..., ::-1] # OpenCV image (BGR to RGB)
|
517 |
+
elif check_online():
|
518 |
+
im = 'https://ultralytics.com/images/bus.jpg'
|
519 |
+
else:
|
520 |
+
LOGGER.warning(emojis(f'{prefix}checks skipped ⚠️, not online.'))
|
521 |
+
return True
|
522 |
m = AutoShape(model, verbose=False) # model
|
523 |
a = m(im).xyxy[0] # FP32 inference
|
524 |
m.amp = True
|