def apply_augmentation(inputs, mean, std, angle=((- 5), 5), scale=(1, 1.2), crop_size=None, train=True):
    (img, label) = inputs
    img = img.copy()
    img = img.transpose(1, 2, 0)
    if train:
        (img, _) = augmentation.gamma_correction(img)
    img -= mean[None, None, :]
    img /= std[None, None, :]
    if train:
        (img, _) = augmentation.random_rotate(img, angle=angle)
        if (np.random.rand() < 0.5):
            (img, _) = augmentation.mirror(img)
        if (np.random.rand() < 0.5):
            (img, _) = augmentation.flip(img)
        (img, _) = augmentation.random_resize(img, scale=scale)
    if (crop_size is not None):
        rnd1 = np.random.randint((img.shape[0] - crop_size))
        rnd2 = np.random.randint((img.shape[1] - crop_size))
        img = img[rnd1:(rnd1 + crop_size), rnd2:(rnd2 + crop_size), :]
    img = img.transpose(2, 0, 1)
    return (img, label)
def apply_augmentation(inputs, mean, std, angle=((- 5), 5), scale=(1, 1.2), crop_size=None, train=True):
    (img, label) = inputs
    img = img.copy()
    img = img.transpose(1, 2, 0)
    if train:
        (img, _) = augmentation.gamma_correction(img)
    img -= mean[None, None, :]
    img /= std[None, None, :]
    if train:
        (img, _) = augmentation.random_rotate(img, angle=angle)
        if (np.random.rand() < 0.5):
            (img, _) = augmentation.mirror(img)
        if (np.random.rand() < 0.5):
            (img, _) = augmentation.flip(img)
        (img, _) = augmentation.random_resize(img, scale=scale)
    if (crop_size is not None):
        rnd1 = np.random.randint((img.shape[0] - crop_size))
        rnd2 = np.random.randint((img.shape[1] - crop_size))
        img = img[rnd1:(rnd1 + crop_size), rnd2:(rnd2 + crop_size), :]
    img = img.transpose(2, 0, 1)
    return (img, label)