def normalize(img, norm_min, norm_max):
    """ Normalize numpy array or torch tensor from RGB range
    to given norm range [norm_min, norm_max]. """
    assert norm_max > norm_min
    norm_range = norm_max - norm_min
    return img/255.0*norm_range + norm_min