HobbitLong / CMC

[arXiv 2019] "Contrastive Multiview Coding", also contains implementations for MoCo and InstDis
BSD 2-Clause "Simplified" License
1.3k stars 179 forks source link

mean std value for LAB/YCbCr normalization #55

Open PhilLint opened 4 years ago

PhilLint commented 4 years ago

With regards to the mean and std values required for normalization: How do the values arise for LAB and YCbCr respectively? My assumption was, that the training images were transformed into the new color space and then statistics across channels are computed which are then used for normalization. That would explain YCbCr, but what does the formula for LAB color space mean? Is it the min and max values averaged?

`def get_train_loader(args): """get the train loader""" data_folder = os.path.join(args.data_folder, 'train')

if args.view == 'Lab':
    mean = [(0 + 100) / 2, (-86.183 + 98.233) / 2, (-107.857 + 94.478) / 2]
    std = [(100 - 0) / 2, (86.183 + 98.233) / 2, (107.857 + 94.478) / 2]
    color_transfer = RGB2Lab()
elif args.view == 'YCbCr':
    mean = [116.151, 121.080, 132.342]
    std = [109.500, 111.855, 111.964]
    color_transfer = RGB2YCbCr()`
HobbitLong commented 4 years ago

Hi @PhilLint,

You are right. For YCbCr I used the mean and std. For Lab, I just normalize the input to [-1, 1].