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] Add swap_labe_pairs in RandomFlip #2332

Merged
merged 9 commits into from
Oct 17, 2022

Conversation

MeowZheng
Copy link
Collaborator

@MeowZheng MeowZheng commented Oct 14, 2022

Motivation

To handle datasets with left/right annotations when flip the seg map horizontally.

Modification

Add swap_label_pairs in RandomFlip init, and swap the labels of a seg map when swap_label_pairs is defined.

BC-breaking (Optional)

No

Use cases (Optional)

LIP dataset data augmentation

Checklist

Before PR:

  • I have read and followed the workflow indicated in the CONTRIBUTING.md to create this PR.
  • Pre-commit or linting tools indicated in CONTRIBUTING.md are used to fix the potential lint issues.
  • Bug fixes are covered by unit tests, the case that causes the bug should be added in the unit tests.
  • New functionalities are covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, including docstring or example tutorials.

After PR:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with some of those projects, like MMDet or MMCls.
  • CLA has been signed and all committers have signed the CLA in this PR.

@zhouzaida zhouzaida added the 2.x label Oct 16, 2022
@zhouzaida zhouzaida added this to the 2.0.0rc2 milestone Oct 16, 2022
Comment on lines 1102 to 1104
def _flip_keypoints(self, keypoints: np.ndarray, img_shape: Tuple[int,
int],
direction: str) -> np.ndarray:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _flip_keypoints(self, keypoints: np.ndarray, img_shape: Tuple[int,
int],
direction: str) -> np.ndarray:
def _flip_keypoints(
self,
keypoints: np.ndarray,
img_shape: Tuple[int, int],
direction: str,) -> np.ndarray:

Comment on lines 1036 to 1038
swap_label_pairs (list, optional): The label pair need to be swapped
for ground truth, like 'left arm' and 'right arm' need to be
swapped after horizontal flipping.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the swap_label_paris only affect seg maps? How about key points?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And better to provide the detailed usage of the argument. How to specify the left arm and right arm pair?

Comment on lines 1036 to 1038
swap_seg_labels (list, optional): The label pair need to be swapped
for ground truth, like 'left arm' and 'right arm' need to be
swapped after horizontal flipping.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to add an example here, like

Suggested change
swap_seg_labels (list, optional): The label pair need to be swapped
for ground truth, like 'left arm' and 'right arm' need to be
swapped after horizontal flipping.
swap_seg_labels (list, optional): The label pair need to be swapped
for ground truth, like 'left arm' and 'right arm' need to be
swapped after horizontal flipping. For example, ``[(1, 5)]``,
where 1/5 is the label of the left/right arm. Defaults to None.

@zhouzaida zhouzaida merged commit bf48ca0 into open-mmlab:2.x Oct 17, 2022
@MeowZheng MeowZheng deleted the flip-seg-fix branch October 19, 2022 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants