diff --git a/detect.py b/detect.py index d913921060d5..211a0049ae4b 100644 --- a/detect.py +++ b/detect.py @@ -94,9 +94,10 @@ def run(weights=ROOT / 'yolov5s.pt', # model.pt path(s) imgsz = check_img_size(imgsz, s=stride) # check image size # Half + if engine and model.trt_fp16_input != half: + LOGGER.info('model ' + ('requires' if model.trt_fp16_input else 'incompatible with') + ' --half. Adjusting automatically.') + half = model.trt_fp16_input half &= (pt or jit or onnx or engine) and device.type != 'cpu' # FP16 supported on limited backends with CUDA - if engine: - assert (model.trt_fp16_input == half), 'model ' + ('requires' if model.trt_fp16_input else 'incompatible with') + ' --half' if pt or jit: model.model.half() if half else model.model.float()