Skip to content

Bug after fix data leakage #23

Description

@zhouzq-thu

Calling softdetect with normalized_coordinates=False,

rdd/src/RDD.py

Line 89 in cacd40e

keypoints, kptscores, scoredispersitys = self.softdetect(K1, normalized_coordinates=False)

rdd/src/RDD.py

Line 158 in cacd40e

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions