updates
This commit is contained in:
parent
ab8d8cbc93
commit
5f69861958
|
@ -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():
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue