Skip to content

Anchors are not centered on grid cells #7951

Open
@luukbalkenende

Description

@luukbalkenende

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)
]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions