

_base_ = [
    '../_base_/models/mask-rcnn_r50_fpn.py',
    '../_base_/datasets/coco_instance.py',
    '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]

# load_from = 'work_dirs/mask-rcnn_r50_fpn_1x_coco/fine1-mamba1111/epoch_19.pth'  # 官方预训练模型

tta_model = dict(
    type='DetTTAModel',
    tta_cfg=dict(nms=dict(
        type='nms',
        iou_threshold=0.5),
        max_per_img=100))


tta_pipeline_aggressive = [
    dict(type='LoadImageFromFile',
         backend_args=None),
    dict(
        type='TestTimeAug',
        transforms=[
            # 更多尺度变换
            [
                dict(type='Resize', scale=(800, 480), keep_ratio=True),     # 更小尺度
                dict(type='Resize', scale=(1000, 600), keep_ratio=True),
                dict(type='Resize', scale=(1333, 800), keep_ratio=True),    # 原始
                dict(type='Resize', scale=(1666, 1000), keep_ratio=True),
                dict(type='Resize', scale=(2000, 1200), keep_ratio=True),   # 更大尺度
                dict(type='Resize', scale=(600, 1000), keep_ratio=True),    # 竖直方向
                dict(type='Resize', scale=(800, 1333), keep_ratio=True),
            ],
            # 翻转变换
            [
                dict(type='RandomFlip', prob=0.),
                dict(type='RandomFlip', prob=1.),
            ],
            # 旋转变换（小角度）
            [
                dict(type='Rotate', angle=0),
                dict(type='Rotate', angle=90),
                dict(type='Rotate', angle=180),
                dict(type='Rotate', angle=270),
            ],
            # 更丰富的颜色变换
            [
                dict(type='ColorTransform', transforms=[]),  # 原始
                dict(type='ColorTransform',
                     transforms=[dict(type='AutoContrast')]),
                dict(type='ColorTransform',
                     transforms=[dict(type='Equalize')]),
                dict(type='ColorTransform',
                     transforms=[dict(type='Brightness', magnitude=0.15)]),
                dict(type='ColorTransform',
                     transforms=[dict(type='Contrast', magnitude=0.15)]),
                dict(type='ColorTransform',
                     transforms=[dict(type='Sharpness', magnitude=0.1)]),
            ],
            [
                dict(
                    type='PackDetInputs',
                    meta_keys=('img_id', 'img_path', 'ori_shape',
                               'img_shape', 'scale_factor', 'flip',
                               'flip_direction', 'rotate'))
            ]
        ])]

# tta_pipeline = [
#     dict(type='LoadImageFromFile',
#          backend_args=None),
#     dict(
#         type='TestTimeAug',
#         transforms=[[
#             dict(type='Resize', scale=(1333, 800), keep_ratio=True)
#         ], [ # It uses 2 flipping transformations (flipping and not flipping).
#             dict(type='RandomFlip', prob=1.),
#             dict(type='RandomFlip', prob=0.)
#         ], [
#             dict(
#                 type='PackDetInputs',
#                 meta_keys=('img_id', 'img_path', 'ori_shape',
#                            'img_shape', 'scale_factor', 'flip',
#                            'flip_direction'))
#         ]])]

