Exemple #1
0
def make_coco_transforms_v2(image_set):
    ### keep only one scale as 960*608
    normalize = T.Compose(
        [T.ToTensor(),
         T.Normalize([0.408, 0.459, 0.482], [1., 1., 1.])])
    print('NVdata Norm rgb: [0.408, 0.459, 0.482], [1., 1., 1.]')
    # scales = [608]
    re_size = (608, 960)
    if image_set == 'train':
        print(re_size)
        return T.Compose([
            T.RandomHorizontalFlip(),
            T.RandomSelect(
                T.RandomResize(re_size),
                T.Compose([
                    T.RandomResize([400, 500, 600]),
                    T.RandomSizeCrop(384, 600),
                    T.RandomResize(re_size),
                ])),
            normalize,
        ])

    if image_set == 'test':
        # print("608 960")
        # print("800 1333")
        return T.Compose([
            # T.RandomResize([608], max_size=980), #800 1333, 604 960, not604, should be 608*966 604*960
            T.RandomResize((604, 960)),
            # T.RandomResize([800], max_size=1333),
            normalize,
        ])

    raise ValueError(f'unknown {image_set}')
Exemple #2
0
def make_coco_transforms(image_set):

# MEANS = (104, 117, 123) as bgr 
    normalize = T.Compose([
        T.ToTensor(),
        # T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
        # mean=(104, 117, 123) ==> (0.40784313725490196 0.4588235294117647 0.4823529411764706) transpose(2,1,0) = [0.482, 0.459, 0.408]
        # T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) # coco mean and std
        T.Normalize([0.482, 0.459, 0.408], [1., 1., 1.]) # mean=(104, 117, 123) for not for rgb, bgr instead, after transpose [0.482, 0.459, 0.408]
    ])
    print('NVdata Norm: [0.482, 0.459, 0.408], [1., 1., 1.]')
    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 == 'test':
        return T.Compose([
            T.RandomResize([800], max_size=1333),
            normalize,
        ])

    raise ValueError(f'unknown {image_set}')
Exemple #3
0
def make_coco_transforms(image_set):
    # MEANS = (104, 117, 123) as bgr
    normalize = T.Compose([
        T.ToTensor(),
        # T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
        # mean=(104, 117, 123) ==> (0.40784313725490196 0.4588235294117647 0.4823529411764706) transpose(2,1,0) = [0.482, 0.459, 0.408]
        # T.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) # coco mean and std this shuold be in bgr
        ## before for 150 epochs
        # T.Normalize([0.482, 0.459, 0.408], [1., 1., 1.]) # mean=(104, 117, 123) for not for rgb, bgr instead, after transpose [0.482, 0.459, 0.408]
        # New implement from 12.11
        # This is rgb already # mean=(104, 117, 123) ==> (0.40784313725490196 0.4588235294117647 0.4823529411764706)
        T.Normalize([0.408, 0.459, 0.482], [1., 1., 1.])
    ])
    print('NVdata Norm rgb: [0.408, 0.459, 0.482], [1., 1., 1.]')
    scales = [480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800]
    # scales = [480, 512, 544, 576, 604, 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 == 'test':
        # print("604 960")
        print("608 966")
        # print("800 1333")
        return T.Compose([
            T.RandomResize(
                [608], max_size=980
            ),  #800 1333, 604 960, not604, should be 608*966 604*960
            # T.RandomResize([604], max_size=960),
            # T.RandomResize([800], max_size=1333),
            normalize,
        ])

    raise ValueError(f'unknown {image_set}')