-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Description
Describe the bug
Anchors should be placed ideally in the middle of a grid cell.
However, this is not the case here:
MONAI/monai/apps/detection/utils/anchor_utils.py
Lines 253 to 258 in 12d00ce
# 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)
]