Calling softdetect with normalized_coordinates=False,
|
keypoints, kptscores, scoredispersitys = self.softdetect(K1, normalized_coordinates=False) |
|
keypoints, kptscores, scoredispersitys = self.softdetect(K1, normalized_coordinates=False) |
leads the grid is not normalized in grid_sample.
|
if normalized_coordinates: |
|
keypoints_xy = keypoints_xy / keypoints_xy.new_tensor([w - 1, h - 1]) * 2 - 1 # (w,h) -> (-1~1,-1~1) |
|
|
|
kptscore = torch.nn.functional.grid_sample(scores_map[b_idx].unsqueeze(0), keypoints_xy.view(1, 1, -1, 2), |
|
mode='bilinear', align_corners=True)[0, 0, 0, :] # CxN |
Possible Fix
# compute result keypoints
keypoints_xy_nms = torch.stack([indices_kpt % w, indices_kpt // w], dim=1) # Mx2
keypoints_xy = keypoints_xy_nms + xy_residual
keypoints_xy_norm = keypoints_xy / keypoints_xy.new_tensor([w - 1, h - 1]) * 2 - 1 # (w,h) -> (-1~1,-1~1)
kptscore = torch.nn.functional.grid_sample(scores_map[b_idx].unsqueeze(0), keypoints_xy_norm.view(1, 1, -1, 2),
mode='bilinear', align_corners=True)[0, 0, 0, :] # CxN
keypoints.append(keypoints_xy_norm if normalized_coordinates else keypoints_xy)
scoredispersitys.append(scoredispersity)
kptscores.append(kptscore)
Calling
softdetectwithnormalized_coordinates=False,rdd/src/RDD.py
Line 89 in cacd40e
rdd/src/RDD.py
Line 158 in cacd40e
leads the grid is not normalized in grid_sample.
rdd/src/models/soft_detect.py
Lines 126 to 130 in cacd40e
Possible Fix