예제 #1
0
    def __init__(
        self,
        size: Union[int, Sequence[int]],
        scale: Tuple[float, float] = (0.08, 1.0),
        ratio: Tuple[float, float] = (3.0 / 4.0, 4.0 / 3.0),
        interpolation: InterpolationMode = InterpolationMode.BILINEAR,
        antialias: Optional[bool] = None,
    ) -> None:
        super().__init__()
        self.size = _setup_size(
            size,
            error_msg="Please provide only two dimensions (h, w) for size.")

        if not isinstance(scale, Sequence):
            raise TypeError("Scale should be a sequence")
        scale = cast(Tuple[float, float], scale)
        if not isinstance(ratio, Sequence):
            raise TypeError("Ratio should be a sequence")
        ratio = cast(Tuple[float, float], ratio)
        if (scale[0] > scale[1]) or (ratio[0] > ratio[1]):
            warnings.warn("Scale and ratio should be of kind (min, max)")

        self.size = size
        self.scale = scale
        self.ratio = ratio
        self.interpolation = interpolation
        self.antialias = antialias
예제 #2
0
    def __init__(
        self,
        size: Union[int, Sequence[int]],
        scale: Tuple[float, float] = (0.08, 1.0),
        ratio: Tuple[float, float] = (3.0 / 4.0, 4.0 / 3.0),
        interpolation: InterpolationMode = InterpolationMode.BILINEAR,
    ) -> None:
        super().__init__()
        self.size = _setup_size(
            size,
            error_msg="Please provide only two dimensions (h, w) for size.")

        if not isinstance(scale, Sequence):
            raise TypeError("Scale should be a sequence")
        scale = cast(Tuple[float, float], scale)
        if not isinstance(ratio, Sequence):
            raise TypeError("Ratio should be a sequence")
        ratio = cast(Tuple[float, float], ratio)
        if (scale[0] > scale[1]) or (ratio[0] > ratio[1]):
            warnings.warn("Scale and ratio should be of kind (min, max)")

        # Backward compatibility with integer value
        if isinstance(interpolation, int):
            warnings.warn(
                "Argument interpolation should be of type InterpolationMode instead of int. "
                "Please, use InterpolationMode enum.")
            interpolation = _interpolation_modes_from_int(interpolation)

        self.size = size
        self.scale = scale
        self.ratio = ratio
        self.interpolation = interpolation
예제 #3
0
 def __init__(self,
              size: Union[int, Sequence[int]],
              vertical_flip: bool = False) -> None:
     super().__init__()
     self.size = _setup_size(
         size,
         error_msg="Please provide only two dimensions (h, w) for size.")
     self.vertical_flip = vertical_flip
예제 #4
0
 def __init__(self,
              size,
              scale=(0.08, 1.0),
              ratio=(3. / 4., 4. / 3.),
              target_type=None):
     super().__init__(target_type=target_type)
     self.size = VT._setup_size(size, "Invalid value for size (h, w)")
     self.scale = scale
     self.ratio = ratio
예제 #5
0
파일: transforms.py 프로젝트: pmeier/vision
 def __init__(self, size, fill=0, padding_mode="constant"):
     super().__init__()
     size = tuple(
         T._setup_size(
             size,
             error_msg="Please provide only two dimensions (h, w) for size."
         ))
     self.crop_height = size[0]
     self.crop_width = size[1]
     self.fill = fill  # TODO: Fill is currently respected only on PIL. Apply tensor patch.
     self.padding_mode = padding_mode
예제 #6
0
 def __init__(self,
              size,
              padding=None,
              pad_if_needed=False,
              fill=0,
              padding_mode="constant",
              mask_fill=255,
              target_type: Optional[TargetType] = None):
     super().__init__(target_type)
     self.size = VT._setup_size(size, "Invalid value for size (h, w)")
     self.padding = padding
     self.pad_if_needed = pad_if_needed
     self.padding_mode = padding_mode
     self.fill = fill
     self.mask_fill = mask_fill
     if self.padding is not None and self.target_type is not None:
         # when reflection padding is applied, what are the expected mask or bbox?
         raise RuntimeError(
             "padding is unexpected for non-classification tasks")
     if self.target_type == "detection":
         warnings.warn(
             f"{self.__class__.__name__} expects coordinate origin is at left top. "
             f"Inconsistency with this may cause unexpected results.",
             HomuraTransformWarning)
예제 #7
0
 def __init__(self, size: Union[int, Sequence[int]]) -> None:
     super().__init__()
     self.size = _setup_size(
         size,
         error_msg="Please provide only two dimensions (h, w) for size.")
예제 #8
0
 def __init__(self, size, target_type=None):
     super().__init__(target_type)
     self.size = VT._setup_size(size, "Invalid size for (h, w) for size")
예제 #9
0
 def __init__(self, size):
     self.size = tuple(
         _setup_size(
             size,
             error_msg="Please provide only two dimensions (h, w) for size."
         ))
예제 #10
0
 def active_size(self, size):
     self._active_size = _setup_size(
         int(size / self.ratio),
         error_msg="Please provide only two dimensions (h, w) for size.")