Ejemplo n.º 1
0
 def apply_transform(self,
                     input: Tensor,
                     params: Dict[str, Tensor],
                     transform: Optional[Tensor] = None) -> Tensor:
     thresholds = params["thresholds"]
     additions: Optional[Tensor]
     if "additions" in params:
         additions = params["additions"]
     else:
         additions = None
     return solarize(input, thresholds, additions)
Ejemplo n.º 2
0
def apply_solarize(input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
    r"""Solarize an image.

    Args:
        input (torch.Tensor): Tensor to be transformed with shape :math:`(*, C, H, W)`.
        params (Dict[str, torch.Tensor]):
            - params['thresholds_factor']: thresholds ranged from 0 ~ 1.
            - params['additions_factor']: additions to add on before solarizing.

    Returns:
        torch.Tensor: Adjusted image with shape :math:`(B, C, H, W)`.
    """
    thresholds = params['thresholds_factor']
    additions: Optional[torch.Tensor]
    if 'additions_factor' in params:
        additions = params['additions_factor']
    else:
        additions = None
    return solarize(input, thresholds, additions)
Ejemplo n.º 3
0
def apply_solarize(input: torch.Tensor, params: Dict[str, torch.Tensor]) -> torch.Tensor:
    r"""Solarize an image.

    Args:
        input (torch.Tensor): Tensor to be transformed with shape (H, W), (C, H, W), (B, C, H, W).
        params (Dict[str, torch.Tensor]):
            - params['thresholds_factor']: thresholds ranged from 0 ~ 1.
            - params['additions_factor']: additions to add on before solarizing.

    Returns:
        torch.Tensor: Adjusted image.
    """
    input = _transform_input(input)
    _validate_input_dtype(input, accepted_dtypes=[torch.float16, torch.float32, torch.float64])

    thresholds = params['thresholds_factor']
    additions: Optional[torch.Tensor]
    if 'additions_factor' in params:
        additions = params['additions_factor']
    else:
        additions = None
    return solarize(input, thresholds, additions)