updates
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user