From 542c3c7b1bf672e520ed3be9c97ffac482ddddf0 Mon Sep 17 00:00:00 2001 From: Yusuke Niitani Date: Fri, 27 Oct 2017 15:15:31 -0700 Subject: [PATCH] fix flip_keypoint so that keypoints can be in range [0, H], [0, W] --- chainercv/transforms/keypoint/flip_keypoint.py | 4 ++-- tests/transforms_tests/keypoint_tests/test_flip_keypoint.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chainercv/transforms/keypoint/flip_keypoint.py b/chainercv/transforms/keypoint/flip_keypoint.py index 76a89befb3..d7788f2ac1 100644 --- a/chainercv/transforms/keypoint/flip_keypoint.py +++ b/chainercv/transforms/keypoint/flip_keypoint.py @@ -22,7 +22,7 @@ def flip_keypoint(keypoint, size, y_flip=False, x_flip=False): H, W = size keypoint = keypoint.copy() if y_flip: - keypoint[:, 0] = H - 1 - keypoint[:, 0] + keypoint[:, 0] = H - keypoint[:, 0] if x_flip: - keypoint[:, 1] = W - 1 - keypoint[:, 1] + keypoint[:, 1] = W - keypoint[:, 1] return keypoint diff --git a/tests/transforms_tests/keypoint_tests/test_flip_keypoint.py b/tests/transforms_tests/keypoint_tests/test_flip_keypoint.py index f059b47567..5dae2f8b6d 100644 --- a/tests/transforms_tests/keypoint_tests/test_flip_keypoint.py +++ b/tests/transforms_tests/keypoint_tests/test_flip_keypoint.py @@ -14,12 +14,12 @@ def test_flip_keypoint(self): out = flip_keypoint(keypoint, size=(34, 32), y_flip=True) keypoint_expected = keypoint.copy() - keypoint_expected[:, 0] = 33 - keypoint[:, 0] + keypoint_expected[:, 0] = 34 - keypoint[:, 0] np.testing.assert_equal(out, keypoint_expected) out = flip_keypoint(keypoint, size=(34, 32), x_flip=True) keypoint_expected = keypoint.copy() - keypoint_expected[:, 1] = 31 - keypoint[:, 1] + keypoint_expected[:, 1] = 32 - keypoint[:, 1] np.testing.assert_equal(out, keypoint_expected)