From d8dabea8babee7e1bea8f56d1ca1096ddfe7a5d3 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 11 Jan 2022 10:01:41 -1000 Subject: [PATCH 1/2] Enable ONNX ``--half` FP16 inference --- detect.py | 2 +- val.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/detect.py b/detect.py index 2d1963ad6f86..41c364c05d00 100644 --- a/detect.py +++ b/detect.py @@ -94,7 +94,7 @@ def run(weights=ROOT / 'yolov5s.pt', # model.pt path(s) imgsz = check_img_size(imgsz, s=stride) # check image size # Half - half &= (pt or jit or engine) and device.type != 'cpu' # half precision only supported by PyTorch on CUDA + half &= (pt or jit or onnx or engine) and device.type != 'cpu' # FP16 supported on limited backends with CUDA if pt or jit: model.model.half() if half else model.model.float() diff --git a/val.py b/val.py index 4709f67511bb..843943b5ff7e 100644 --- a/val.py +++ b/val.py @@ -137,9 +137,9 @@ def run(data, # Load model model = DetectMultiBackend(weights, device=device, dnn=dnn, data=data) - stride, pt, jit, engine = model.stride, model.pt, model.jit, model.engine + stride, pt, jit, onnx, engine = model.stride, model.pt, model.jit, model.onnx, model.engine imgsz = check_img_size(imgsz, s=stride) # check image size - half &= (pt or jit or engine) and device.type != 'cpu' # half precision only supported by PyTorch on CUDA + half &= (pt or jit or onnx or engine) and device.type != 'cpu' # FP16 supported on limited backends with CUDA if pt or jit: model.model.half() if half else model.model.float() elif engine: From 03e5beb8c7de7be061dd3ffa50b8149daae6d94d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:04:34 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tutorial.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorial.ipynb b/tutorial.ipynb index 97f9074f9fd0..251c18d97815 100644 --- a/tutorial.ipynb +++ b/tutorial.ipynb @@ -1099,4 +1099,4 @@ "outputs": [] } ] -} \ No newline at end of file +}