def apply_adjust_saturation(input: torch.Tensor, params: Dict[str, torch.Tensor], return_transform: bool = False): """Wrapper for adjust_saturation for Torchvision-like param settings. Args: input (torch.Tensor): Image/Tensor to be adjusted in the shape of (*, N). saturation_factor (float): How much to adjust the saturation. 0 will give a black and white image, 1 will give the original image while 2 will enhance the saturation by a factor of 2. Returns: torch.Tensor: Adjusted image. """ input = _transform_input(input) _validate_input_dtype( input, accepted_dtypes=[torch.float16, torch.float32, torch.float64]) transformed = adjust_saturation( input, params['saturation_factor'].to(input.dtype)) if return_transform: identity: torch.Tensor = torch.eye(3, device=input.device, dtype=input.dtype).repeat( input.shape[0], 1, 1) return transformed, identity return transformed
def apply_adjust_saturation(input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor: """Wrapper for adjust_saturation for Torchvision-like param settings. Args: input (torch.Tensor): Image/Tensor to be adjusted in the shape of (*, N). params (Dict[str, torch.Tensor]): - params['saturation_factor']: How much to adjust the saturation. 0 will give a black and white image, 1 will give the original image while 2 will enhance the saturation by a factor of 2. Returns: torch.Tensor: Adjusted image. """ input = _transform_input(input) _validate_input_dtype(input, accepted_dtypes=[torch.float16, torch.float32, torch.float64]) transformed = adjust_saturation(input, params['saturation_factor'].to(input.dtype)) return transformed