From 5f6986195890baa87cac18e340d1a256b18f92df Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 22 Apr 2019 16:52:14 +0200 Subject: [PATCH] updates --- detect.py | 2 +- utils/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/detect.py b/detect.py index 3a8c6f14..86682329 100644 --- a/detect.py +++ b/detect.py @@ -72,7 +72,7 @@ def detect( if det is not None and len(det) > 0: # Rescale boxes from 416 to true image size - det[:, :4] = scale_coords(img.shape, det[:, :4], im0.shape).round() + det[:, :4] = scale_coords(img.shape[2:], det[:, :4], im0.shape).round() # Print results to screen for c in det[:, -1].unique(): diff --git a/utils/utils.py b/utils/utils.py index f1c0ea8d..d5917dc6 100755 --- a/utils/utils.py +++ b/utils/utils.py @@ -103,8 +103,8 @@ def xywh2xyxy(x): def scale_coords(img1_shape, coords, img0_shape): # Rescale coords1 (xyxy) from img1_shape to img0_shape gain = max(img1_shape) / max(img0_shape) # gain = old / new - coords[:, [0, 2]] -= (img1_shape[3] - img0_shape[1] * gain) / 2 # x padding - coords[:, [1, 3]] -= (img1_shape[2] - img0_shape[0] * gain) / 2 # y padding + coords[:, [0, 2]] -= (img1_shape[1] - img0_shape[1] * gain) / 2 # x padding + coords[:, [1, 3]] -= (img1_shape[0] - img0_shape[0] * gain) / 2 # y padding coords[:, :4] /= gain coords[:, :4] = coords[:, :4].clamp(min=0) return coords