Exemplo n.º 1
0
def make_coco_transforms(image_set):

    normalize = T.Compose([
        T.ToTensor(),
        T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ])

    #original_scales = [480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800]
    #scales = [int(s * 0.5) for s in original_scales]
    scales = list(range(640 // 5, 640, 32))

    if image_set == 'train':
        return T.Compose([
            T.RandomHorizontalFlip(),
            T.RandomSelect(
                T.RandomResize(scales, max_size=640),  # Originally: 1333.
                T.Compose([
                    T.RandomResize([400, 500,
                                    600]),  # Originally: [400, 500, 600].
                    T.RandomSizeCrop(384, 600),  # Originally: 384, 600.
                    T.RandomResize(scales, max_size=640),  # Originally: 1333.
                ])),
            normalize,
        ])

    if image_set == 'val':
        return T.Compose([
            T.RandomResize([640], max_size=640),  # Originally: [800], 1333.
            normalize,
        ])

    raise ValueError(f'unknown {image_set}')
Exemplo n.º 2
0
def make_coco_transforms(image_set):

    normalize = T.Compose([
        T.ToTensor(),
        T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ])

    scales = [480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800]

    if image_set == 'train':
        return T.Compose([
            T.RandomHorizontalFlip(),
            T.RandomSelect(
                T.RandomResize(scales, max_size=1333),
                T.Compose([
                    T.RandomResize([400, 500, 600]),
                    T.RandomSizeCrop(384, 600),
                    T.RandomResize(scales, max_size=1333),
                ])
            ),
            normalize,
        ])

    if image_set == 'val':
        return T.Compose([
            T.RandomResize([800], max_size=1333),
            normalize,
        ])

    raise ValueError(f'unknown {image_set}')