Skip to content

Commit

Permalink
[Fix] _flip_keypoint of RandomFlip returns a wrong result (#2527)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouzaida authored Jan 6, 2023
1 parent 4ae327f commit fadd915
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit fadd915

Please sign in to comment.