This commit is contained in:
Glenn Jocher 2019-07-15 16:07:25 +02:00
parent e8c205b412
commit e73e247442
1 changed files with 2 additions and 1 deletions

View File

@ -130,7 +130,8 @@ def scale_coords(img1_shape, coords, img0_shape):
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)
coords[:, [0, 2]] = coords[:, [0, 2]].clamp(min=0, max=img0_shape[1]) # clip x
coords[:, [1, 3]] = coords[:, [1, 3]].clamp(min=0, max=img0_shape[0]) # clip y
return coords