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] Add AutoAugment and clean dataset mapper #204

Closed
wants to merge 2 commits into from

Conversation

rentainhe
Copy link
Collaborator

@rentainhe rentainhe commented Feb 10, 2023

TODO

  • Add AutoAugment as mmdet.pipeline.auto_augment
  • Clean detr_dataset_mapper for better usage and code quality
  • Verify DINO-R50 AP: 48.94AP (exp-1)

Example

  • The cleaned config: only with one augmentation args (without passing augmentation and augmentation_with_crop)
from omegaconf import OmegaConf

import detectron2.data.transforms as T
from detectron2.config import LazyCall as L
from detectron2.data import (
    build_detection_test_loader,
    build_detection_train_loader,
    get_detection_dataset_dicts,
)
from detectron2.evaluation import COCOEvaluator

from detrex.data.dataset_mappers.detr_dataset_mapper import DetrDatasetMapper
from detrex.data.transforms import AutoAugment

dataloader = OmegaConf.create()

dataloader.train = L(build_detection_train_loader)(
    dataset=L(get_detection_dataset_dicts)(names="coco_2017_train"),
    mapper=L(DetrDatasetMapper)(
        augmentation=L(AutoAugment)(
            policies=[
                [
                    L(T.RandomFlip)(),
                    L(T.ResizeShortestEdge)(
                        short_edge_length=(480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800),
                        max_size=1333,
                        sample_style="choice",
                    ),
                ],
                [
                    L(T.RandomFlip)(),
                    L(T.ResizeShortestEdge)(
                        short_edge_length=(400, 500, 600),
                        sample_style="choice",
                    ),
                    L(T.RandomCrop)(
                        crop_type="absolute_range",
                        crop_size=(384, 600),
                    ),
                    L(T.ResizeShortestEdge)(
                        short_edge_length=(480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800),
                        max_size=1333,
                        sample_style="choice",
                    ),
                ],
            ],
        ),
        is_train=True,
        mask_on=False,
        img_format="RGB",
    ),
    total_batch_size=16,
    num_workers=4,
)

dataloader.test = L(build_detection_test_loader)(
    dataset=L(get_detection_dataset_dicts)(names="coco_2017_val", filter_empty=False),
    mapper=L(DetrDatasetMapper)(
        augmentation=L(AutoAugment)(
            policies=[
                L(T.ResizeShortestEdge)(
                    short_edge_length=800,
                    max_size=1333,
                ),
            ],
        ),
        is_train=False,
        mask_on=False,
        img_format="RGB",
    ),
    num_workers=4,
)

dataloader.evaluator = L(COCOEvaluator)(
    dataset_name="${..test.dataset.names}",
)

@rentainhe rentainhe closed this Jul 5, 2023
@rentainhe rentainhe deleted the add_auto_augment branch July 5, 2023 06:42
@rentainhe rentainhe mentioned this pull request Jun 8, 2023
14 tasks
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.

None yet

1 participant