Args: boxes: source bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode`` src_spatial_size: original image spatial size before resizing. Raises: ValueError: When ``self.spatial_size`` length is less th
(self, boxes: NdarrayOrTensor, src_spatial_size: Sequence[int] | int)
| 291 | self.spatial_size = spatial_size |
| 292 | |
| 293 | def __call__(self, boxes: NdarrayOrTensor, src_spatial_size: Sequence[int] | int) -> NdarrayOrTensor: # type: ignore[override] |
| 294 | """ |
| 295 | Args: |
| 296 | boxes: source bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode`` |
| 297 | src_spatial_size: original image spatial size before resizing. |
| 298 | |
| 299 | Raises: |
| 300 | ValueError: When ``self.spatial_size`` length is less than ``boxes`` spatial dimensions. |
| 301 | """ |
| 302 | input_ndim = get_spatial_dims(boxes=boxes) # spatial ndim |
| 303 | src_spatial_size_ = ensure_tuple_rep(src_spatial_size, input_ndim) |
| 304 | |
| 305 | if self.size_mode == "all": |
| 306 | # spatial_size must be a Sequence if size_mode is 'all' |
| 307 | output_ndim = len(ensure_tuple(self.spatial_size)) |
| 308 | if output_ndim != input_ndim: |
| 309 | raise ValueError( |
| 310 | "len(spatial_size) must be greater or equal to img spatial dimensions, " |
| 311 | f"got spatial_size={output_ndim} img={input_ndim}." |
| 312 | ) |
| 313 | spatial_size_ = fall_back_tuple(self.spatial_size, src_spatial_size_) |
| 314 | else: # for the "longest" mode |
| 315 | if not isinstance(self.spatial_size, int): |
| 316 | raise ValueError("spatial_size must be an int number if size_mode is 'longest'.") |
| 317 | scale = self.spatial_size / max(src_spatial_size_) |
| 318 | spatial_size_ = tuple(int(round(s * scale)) for s in src_spatial_size_) |
| 319 | |
| 320 | return resize_boxes(boxes, src_spatial_size_, spatial_size_) |
| 321 | |
| 322 | |
| 323 | class FlipBox(Transform): |
nothing calls this directly
no test coverage detected