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

[Fix] Fix _flip_keypoint of RandomFlip returns the wrong result #2527

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions mmcv/transforms/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,8 @@ def _flip_bbox(self, bboxes: np.ndarray, img_shape: Tuple[int, int],
bboxes (numpy.ndarray): Bounding boxes, shape (..., 4*k)
img_shape (tuple[int]): Image shape (height, width)
direction (str): Flip direction. Options are 'horizontal',
'vertical'.
'vertical', and 'diagonal'.

Returns:
numpy.ndarray: Flipped bounding boxes.
"""
Expand Down Expand Up @@ -1239,7 +1240,8 @@ def _flip_keypoints(
keypoints (numpy.ndarray): Keypoints, shape (..., 2)
img_shape (tuple[int]): Image shape (height, width)
direction (str): Flip direction. Options are 'horizontal',
'vertical'.
'vertical', and 'diagonal'.

Returns:
numpy.ndarray: Flipped keypoints.
"""
Expand All @@ -1259,7 +1261,7 @@ def _flip_keypoints(
raise ValueError(
f"Flipping direction must be 'horizontal', 'vertical', \
or 'diagonal', but got '{direction}'")
flipped = np.concatenate([keypoints, meta_info], axis=-1)
flipped = np.concatenate([flipped, meta_info], axis=-1)
return flipped

def _flip_seg_map(self, seg_map: dict, direction: str) -> np.ndarray:
Expand Down Expand Up @@ -1357,6 +1359,7 @@ def transform(self, results: dict) -> dict:

Args:
results (dict): Result dict from loading pipeline.

Returns:
dict: Flipped results, 'img', 'gt_bboxes', 'gt_seg_map',
'gt_keypoints', 'flip', and 'flip_direction' keys are
Expand Down