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

Anchors are not centered on grid cells #7951

Open
luukbalkenende opened this issue Jul 25, 2024 · 0 comments
Open

Anchors are not centered on grid cells #7951

luukbalkenende opened this issue Jul 25, 2024 · 0 comments

Comments

@luukbalkenende
Copy link

Describe the bug
Anchors should be placed ideally in the middle of a grid cell.
However, this is not the case here:

# compute anchor centers regarding to the image.
# shifts_centers is [x_center, y_center] or [x_center, y_center, z_center]
shifts_centers = [
torch.arange(0, size[axis], dtype=torch.int32, device=device) * stride[axis]
for axis in range(self.spatial_dims)
]

Expected behavior
The anchors should be placed ideally in the middle of a grid cell.

Possible fix
This could probably be fixed by simply changing these lines to:

shifts_centers = [
    torch.arange(0, size[axis], dtype=torch.int32, device=device) * stride[axis] + int(stride[axis] / 2)
    for axis in range(self.spatial_dims)
]
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