Expects a numpy array of length 2 in the final dimension. Requires the original image size in (H, W) format.
(self, coords: np.ndarray, original_size: Tuple[int, ...])
| 31 | return np.array(resize(to_pil_image(image), target_size)) |
| 32 | |
| 33 | def apply_coords(self, coords: np.ndarray, original_size: Tuple[int, ...]) -> np.ndarray: |
| 34 | """ |
| 35 | Expects a numpy array of length 2 in the final dimension. Requires the |
| 36 | original image size in (H, W) format. |
| 37 | """ |
| 38 | old_h, old_w = original_size |
| 39 | new_h, new_w = self.get_preprocess_shape( |
| 40 | original_size[0], original_size[1], self.target_length |
| 41 | ) |
| 42 | coords = deepcopy(coords).astype(float) |
| 43 | coords[..., 0] = coords[..., 0] * (new_w / old_w) |
| 44 | coords[..., 1] = coords[..., 1] * (new_h / old_h) |
| 45 | return coords |
| 46 | |
| 47 | def apply_boxes(self, boxes: np.ndarray, original_size: Tuple[int, ...]) -> np.ndarray: |
| 48 | """ |
no test coverage detected