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

Ignoring annotations outside of an image #1269

Closed
AldusLorde opened this issue Feb 10, 2020 · 7 comments
Closed

Ignoring annotations outside of an image #1269

AldusLorde opened this issue Feb 10, 2020 · 7 comments
Labels
stale Issues with no activity for a long time

Comments

@AldusLorde
Copy link

Hi! What is the purpose of doing so? You are trying to ignore anchors whose centres are outside of an image, but according to your code, generated anchors just can't be outside of the image. It's mentioned in the Faster R-CNN paper that cross-bounding anchors are ignored (but FPN doesn't ignore them). Another strange thing there is that you compare x coordinate with the height, not width.
Also, I checked your code and it seems that you doesn't shift width and height of anchors by 1 (pixel ranges are inclusive from both sides and so on, compute_overlap.pyx contains a good example of such shifting)

Screenshot from 2020-02-10 14-58-55

@hgaiser
Copy link
Contributor

hgaiser commented Feb 10, 2020

There's multiple questions there, I'll try to split them up:

Hi! What is the purpose of doing so? You are trying to ignore anchors whose centres are outside of an image, but according to your code, generated anchors just can't be outside of the image.

Generated anchors can't be outside the image batch, but the image batch can have caused a margin around some images. If you have images of different ratios, e.g. an image of shape (500, 500) and an image of shape (500, 400), then the latter image will get padded with zeros to match the shape of the former.

Another strange thing there is that you compare x coordinate with the height, not width.

We encode our boxes as (x1, y1, x2, y2), but batches are shaped (B, H, W, C). Perhaps anchors_center should be ordered (x, y) to make it comparable to anchors, but currently it is (y, x) because of the image batch.

Also, I checked your code and it seems that you doesn't shift width and height of anchors by 1 (pixel ranges are inclusive from both sides and so on, compute_overlap.pyx contains a good example of such shifting)

Hmm interesting point. I worked out the code treating the x2 and y2 as exclusive, but it seems indeed that compute_overlap.pyx treats them inclusive (this code is borrowed from py-faster-rcnn). Do you see any harm in changing compute_overlap.pyx to be exclusive?

@AldusLorde
Copy link
Author

AldusLorde commented Feb 10, 2020

I see, thank you)

Hmm interesting point. I worked out the code treating the x2 and y2 as exclusive, but it seems indeed that compute_overlap.pyx treats them inclusive (this code is borrowed from py-faster-rcnn). Do you see any harm in changing compute_overlap.pyx to be exclusive?

A tough question. Unfortunately I'm not that skilled to give a correct answer. I came across this information while searching for a solution https://stackoverflow.com/a/57247833

@AldusLorde
Copy link
Author

Generated anchors can't be outside the image batch, but the image batch can have caused a margin around some images. If you have images of different ratios, e.g. an image of shape (500, 500) and an image of shape (500, 400), then the latter image will get padded with zeros to match the shape of the former.

Have you considered the Darknet approach?
AlexeyAB/darknet#232 (comment)

It uses single size images and there are lots of ways to resize image (with keeping the aspect ratio or not) in this framework.

@hgaiser
Copy link
Contributor

hgaiser commented Feb 13, 2020

Hmm our approach is basically the same as their second approach, with the exception that they center the image. I'm not sure what the effects of that would be, I would image it doesn't matter much.

@AldusLorde
Copy link
Author

Hmm our approach is basically the same as their second approach, with the exception that they center the image. I'm not sure what the effects of that would be, I would image it doesn't matter much.

They use a fixed-size network so all images have equal spatial dimensions,

@cl2227619761
Copy link

what about just clamp the size within the image, instead of ignoring them

@stale
Copy link

stale bot commented May 9, 2020

This issue has been automatically marked as stale due to the lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Issues with no activity for a long time label May 9, 2020
@stale stale bot closed this as completed May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issues with no activity for a long time
Projects
None yet
Development

No branches or pull requests

3 participants