<gh_stars>1-10
# encoding: utf-8
"""
@author:  liaoxingyu
@contact: <EMAIL>
"""

import torchvision.transforms as T

from .transforms import RandomErasing
from .car_tansform import ImageErasing


def build_transforms(cfg, is_train=True):
    normalize_transform = T.Normalize(mean=cfg.INPUT.PIXEL_MEAN, std=cfg.INPUT.PIXEL_STD)
    if is_train:
        transform = T.Compose([
            T.Resize(cfg.INPUT.SIZE_TRAIN),
            T.RandomHorizontalFlip(p=cfg.INPUT.PROB),
            T.ColorJitter(brightness=1., contrast=[0.1, 1.0], saturation=[0.5, 1.0], hue=[-0.3, 0.3]),  # values based on jupyter notebook
            T.Pad(cfg.INPUT.PADDING),
            T.RandomCrop(cfg.INPUT.SIZE_TRAIN),
            T.ToTensor(),
            ImageErasing(probability=cfg.INPUT.RE_PROB, mean=cfg.INPUT.PIXEL_MEAN),
            normalize_transform
           
        ])
    else:
        transform = T.Compose([
            T.Resize(cfg.INPUT.SIZE_TEST),
            T.ToTensor(),
            normalize_transform
        ])

    return transform

# encoding: utf-8
"""
@author:  liaoxingyu
@contact: <EMAIL>
"""

import torchvision.transforms as T

from .transforms import RandomErasing
from .car_tansform import ImageErasing


def build_transforms(cfg, is_train=True):
    normalize_transform = T.Normalize(mean=cfg.INPUT.PIXEL_MEAN, std=cfg.INPUT.PIXEL_STD)
    if is_train:
        transform = T.Compose([
            T.Resize(cfg.INPUT.SIZE_TRAIN),
            T.RandomHorizontalFlip(p=cfg.INPUT.PROB),
            T.ColorJitter(brightness=1., contrast=[0.1, 1.0], saturation=[0.5, 1.0], hue=[-0.3, 0.3]),  # values based on jupyter notebook
            T.Pad(cfg.INPUT.PADDING),
            T.RandomCrop(cfg.INPUT.SIZE_TRAIN),
            T.ToTensor(),
            ImageErasing(probability=cfg.INPUT.RE_PROB, mean=cfg.INPUT.PIXEL_MEAN),
            normalize_transform
           
        ])
    else:
        transform = T.Compose([
            T.Resize(cfg.INPUT.SIZE_TEST),
            T.ToTensor(),
            normalize_transform
        ])

    return transform
# encoding: utf-8 @author:  liaoxingyu @contact: <EMAIL> # values based on jupyter notebook