In "rect" mode, if the original img ratio of img.shape[0]/img.shape[1] is larger than new_shape[0] / new_shape[1], the parameter of r should be
r = new_shape[0] / shape[0]
rather than
r = max(new_shape) / max(shape), which may lead to the dw or dh be negative numbers and raise errors in funciton cv2.copyMakeBorder in line 643. I think
img_ratio = shape[0] / shape[1]
if isinstance(new_shape, int):
r = float(new_shape) / max(shape) # ratio = new / old
else:
new_ratio = new_shape[0] / new_shape[1]
if img_ratio > new_ratio:
r = new_shape[0] / shape[0]
else:
r = new_shape[1] / shape[1]
# else:
# r = max(new_shape) / max(shape)
https://github.com/tanluren/yolov3-channel-and-layer-pruning/blob/621e96f0d1059b30a854f6a9e1cf308d25051e6f/utils/datasets.py#L612
In "rect" mode, if the original img ratio of
img.shape[0]/img.shape[1]
is larger thannew_shape[0] / new_shape[1]
, the parameter of r should ber = new_shape[0] / shape[0]
rather thanr = max(new_shape) / max(shape)
, which may lead to the dw or dh be negative numbers and raise errors in funciton cv2.copyMakeBorder in line 643. I thinkis a more suitable solution. Am I right?