Skip to content

Conversation

@zhuofanx
Copy link

This PR fixes the padding logic.

The original function breaks in one of my datasets where images are of shape (H_ori, W_ori) = (1190, 1596). This is because target_aspect_ratio is within the expected range, but int(H_ori * target_aspect_ratio) = 1595 so W_new = 1595 and (pad_left, pad_right, pad_top, pad_bottom) = (-1, 0, 0, 0). Negative padding will result in erroneous behavior in "tensor[..., pad1_t : shapes[0] - pad1_b, pad1_l : shapes[1] - pad1_r]" in _postprocess function.

The new code will ensure the padded sizes are not smaller than original, hence making padding sizes non-negative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant