Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Padding bug #1003

Open
nnistelrooij opened this issue May 13, 2024 · 0 comments
Open

Padding bug #1003

nnistelrooij opened this issue May 13, 2024 · 0 comments

Comments

@nnistelrooij
Copy link

top_padding, _, left_padding, _ = results['pad_param']
if int(left_padding) != 0:
gt_masks = gt_masks.translate(
out_shape=results['img_shape'][:2],
offset=int(left_padding),
direction='horizontal')
if int(top_padding) != 0:
gt_masks = gt_masks.translate(
out_shape=results['img_shape'][:2],
offset=int(top_padding),
direction='vertical')

The bottom and right padding may be positive, while the top and left padding is zero, causing an incorrect translation of the polygons and an incorrect output shape.

The code below addresses the bug:

        top_padding, bottom_padding, left_padding, right_padding = results['pad_param']
        if int(left_padding) != 0:
            gt_masks = gt_masks.translate(
                out_shape=results['img_shape'][:2],
                offset=int(left_padding),
                direction='horizontal')
        elif int(right_padding) != 0:
            gt_masks = gt_masks.translate(
                out_shape=results['img_shape'][:2],
                offset=-int(right_padding),
                direction='horizontal')
            
        if int(top_padding) != 0:
            gt_masks = gt_masks.translate(
                out_shape=results['img_shape'][:2],
                offset=int(top_padding),
                direction='vertical')
        elif int(bottom_padding) != 0:
            gt_masks = gt_masks.translate(
                out_shape=results['img_shape'][:2],
                offset=-int(bottom_padding),
                direction='vertical')
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

No branches or pull requests

1 participant