From b56735ebae9491662c97fab376839814d1fb0a4b Mon Sep 17 00:00:00 2001 From: Zaida Zhou <58739961+zhouzaida@users.noreply.github.com> Date: Fri, 6 Jan 2023 20:21:58 +0800 Subject: [PATCH] [Fix] _flip_keypoint of RandomFlip returns a wrong result (#2527) --- mmcv/transforms/processing.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mmcv/transforms/processing.py b/mmcv/transforms/processing.py index 09098f1990..96e1bb0a1c 100644 --- a/mmcv/transforms/processing.py +++ b/mmcv/transforms/processing.py @@ -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. """ @@ -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. """ @@ -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: @@ -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