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

[Feature] Support CopyPaste when mask is not available #10509

Merged
merged 7 commits into from
Jun 19, 2023

Conversation

nijkah
Copy link
Contributor

@nijkah nijkah commented Jun 14, 2023

Motivation

closes #9686
There is a same feature in 2.x #8905

Some examples
image

image

Modification

Add new method to BaseBox

BC-breaking (Optional)

Does the modification introduce changes that break the backward-compatibility of the downstream repos?
If so, please describe how it breaks the compatibility and how the downstream projects should modify their code to keep compatibility with this PR.

Use cases (Optional)

load_pipeline = [
    dict(type='LoadImageFromFile', backend_args=backend_args),
    dict(type='LoadAnnotations', with_bbox=True),
    dict(
        type='RandomResize',
        scale=image_size,
        ratio_range=(0.8, 1.25),
        keep_ratio=True),
    dict(
        type='RandomCrop',
        crop_type='absolute_range',
        crop_size=image_size,
        recompute_bbox=True,
        allow_negative_crop=True),
    dict(type='FilterAnnotations', min_gt_bbox_wh=(1e-2, 1e-2)),
    dict(type='RandomFlip', prob=0.5),
    dict(type='Pad', size=image_size),
]
train_pipeline = [
    dict(type='CopyPaste', max_num_pasted=100, paste_by_box=True),
    dict(type='PackDetInputs')
]

train_dataloader = dict(
    dataset=dict(
        _delete_=True,
        type='MultiImageMixDataset',
        dataset=dict(
            type=dataset_type,
            data_root=data_root,
            ann_file='annotations/instances_train2017.json',
            data_prefix=dict(img='train2017/'),
            filter_cfg=dict(filter_empty_gt=True, min_size=32),
            pipeline=load_pipeline,
            backend_args=backend_args),
        pipeline=train_pipeline))

@jamiechoi1995
Copy link
Contributor

Hi, after adapted your code, I got an error when running mmrotate 1.x

  File "/home/jovyan/work/mmdetection-3.0.0/mmdet/datasets/transforms/loading.py", line 396, in transform                                                       
    self._load_bboxes(results)                                                                                                                                           
  File "/home/jovyan/work/mmdetection-3.0.0/mmdet/datasets/transforms/loading.py", line 278, in _load_bboxes                                                    
    results['gt_bboxes'] = box_type_cls(gt_bboxes, dtype=torch.float32)                                                                                                  
TypeError: Can't instantiate abstract class QuadriBoxes with abstract methods create_masks 

@nijkah
Copy link
Contributor Author

nijkah commented Jun 14, 2023

Hi, after adapted your code, I got an error when running mmrotate 1.x

  File "/home/jovyan/work/mmdetection-3.0.0/mmdet/datasets/transforms/loading.py", line 396, in transform                                                       
    self._load_bboxes(results)                                                                                                                                           
  File "/home/jovyan/work/mmdetection-3.0.0/mmdet/datasets/transforms/loading.py", line 278, in _load_bboxes                                                    
    results['gt_bboxes'] = box_type_cls(gt_bboxes, dtype=torch.float32)                                                                                                  
TypeError: Can't instantiate abstract class QuadriBoxes with abstract methods create_masks 

Hi, @jamiechoi1995. Because this transform depends on the box_type, every new box_type should define create_masks method. I will create a PR on MMRotate after merging this PR.

@jamiechoi1995
Copy link
Contributor

Hi, after adapted your code, I got an error when running mmrotate 1.x

  File "/home/jovyan/work/mmdetection-3.0.0/mmdet/datasets/transforms/loading.py", line 396, in transform                                                       
    self._load_bboxes(results)                                                                                                                                           
  File "/home/jovyan/work/mmdetection-3.0.0/mmdet/datasets/transforms/loading.py", line 278, in _load_bboxes                                                    
    results['gt_bboxes'] = box_type_cls(gt_bboxes, dtype=torch.float32)                                                                                                  
TypeError: Can't instantiate abstract class QuadriBoxes with abstract methods create_masks 

Hi, @jamiechoi1995. Because this transform depends on the box_type, every new box_type should define create_masks method. I will create a PR on MMRotate after merging this PR.

Got it, thanks

@hhaAndroid
Copy link
Collaborator

@nijkah Please fix the CI

@nijkah
Copy link
Contributor Author

nijkah commented Jun 15, 2023

@nijkah Please fix the CI

Hi, @hhaAndroid . I think the CI failed temporarily. I cannot see the error in the log.
Can I ask you to rerun it?

@nijkah
Copy link
Contributor Author

nijkah commented Jun 16, 2023

Hi @hhaAndroid. I almost finished this PR. One thing left to consider.
What would be desirable when the config sets paste_by_box=True and results already contain gt_masks?

  1. Throws warning or error message
  2. Just use gt_masks as in the current code

@hhaAndroid
Copy link
Collaborator

hhaAndroid commented Jun 16, 2023

Hi @hhaAndroid. I almost finished this PR. One thing left to consider. What would be desirable when the config sets paste_by_box=True and results already contain gt_masks?

  1. Throws warning or error message
  2. Just use gt_masks as in the current code

throws warning is ok and use gt_masks

@hhaAndroid hhaAndroid merged commit f5228ff into open-mmlab:dev-3.x Jun 19, 2023
@nijkah nijkah deleted the copypaste_bbox branch August 17, 2023 02:38
yumion pushed a commit to yumion/mmdetection that referenced this pull request Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants