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

Confused about the Equation 6. in paper #5

Open
Jordan-5i opened this issue May 27, 2020 · 1 comment
Open

Confused about the Equation 6. in paper #5

Jordan-5i opened this issue May 27, 2020 · 1 comment

Comments

@Jordan-5i
Copy link

hey, i am confused about the x_m-x_n and y_m-y_n when they are equal to zero under special condition using faster rcnn object detector, because center coordinates may be same and results to log(0). How do solve this problem?

@simaoh
Copy link
Collaborator

simaoh commented Jan 7, 2021

@Jordan-5i You are absolutely right, about the corner case of two bounding boxes with the same center coordinates.

To cover that explicitly in equation 6, one should replace |x_m-x_n| by min(|x_m-x_n|, eps) for some small constant eps>0.
In our code we do that with eps=0.001*w, and analogous computation for the y coordinates.

Here is the part of the code where we address this with torch.clamp (and also provide for the degenerate case of w=0, or h=0).

w = (x_max - x_min) + 1.
h = (y_max - y_min) + 1.
#cx.view(1,-1) transposes the vector cx, and so dim(delta_x) = (dim(cx), dim(cx))
delta_x = cx - cx.view(batch_size, 1, -1)
delta_x = torch.clamp(torch.abs(delta_x / w), min=1e-3)
delta_x = torch.log(delta_x)
delta_y = cy - cy.view(batch_size, 1, -1)
delta_y = torch.clamp(torch.abs(delta_y / h), min=1e-3)
delta_y = torch.log(delta_y)

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

2 participants