Args: crop_type (str): one of "relative_range", "relative", "absolute", "absolute_range". crop_size (tuple[float, float]): two floats, explained below. - "relative": crop a (H * crop_size[0], W * crop_size[1]) region from an input image of size (H,
(self, crop_type: str, crop_size)
| 498 | """ |
| 499 | |
| 500 | def __init__(self, crop_type: str, crop_size): |
| 501 | """ |
| 502 | Args: |
| 503 | crop_type (str): one of "relative_range", "relative", "absolute", "absolute_range". |
| 504 | crop_size (tuple[float, float]): two floats, explained below. |
| 505 | |
| 506 | - "relative": crop a (H * crop_size[0], W * crop_size[1]) region from an input image of |
| 507 | size (H, W). crop size should be in (0, 1] |
| 508 | - "relative_range": uniformly sample two values from [crop_size[0], 1] |
| 509 | and [crop_size[1]], 1], and use them as in "relative" crop type. |
| 510 | - "absolute" crop a (crop_size[0], crop_size[1]) region from input image. |
| 511 | crop_size must be smaller than the input image size. |
| 512 | - "absolute_range", for an input of size (H, W), uniformly sample H_crop in |
| 513 | [crop_size[0], min(H, crop_size[1])] and W_crop in [crop_size[0], min(W, crop_size[1])]. |
| 514 | Then crop a region (H_crop, W_crop). |
| 515 | """ |
| 516 | # TODO style of relative_range and absolute_range are not consistent: |
| 517 | # one takes (h, w) but another takes (min, max) |
| 518 | super().__init__() |
| 519 | assert crop_type in ["relative_range", "relative", "absolute", "absolute_range"] |
| 520 | self._init(locals()) |
| 521 | |
| 522 | def get_transform(self, image): |
| 523 | h, w = image.shape[:2] |