Transposes the input image based on the given `indices` dimension ordering.
| 569 | |
| 570 | |
| 571 | class Transpose(Transform): |
| 572 | """ |
| 573 | Transposes the input image based on the given `indices` dimension ordering. |
| 574 | """ |
| 575 | |
| 576 | backend = [TransformBackends.TORCH] |
| 577 | |
| 578 | def __init__(self, indices: Sequence[int] | None) -> None: |
| 579 | self.indices = None if indices is None else tuple(indices) |
| 580 | |
| 581 | def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: |
| 582 | """ |
| 583 | Apply the transform to `img`. |
| 584 | """ |
| 585 | img = convert_to_tensor(img, track_meta=get_track_meta()) |
| 586 | return img.permute(self.indices or tuple(range(img.ndim)[::-1])) # type: ignore |
| 587 | |
| 588 | |
| 589 | class SqueezeDim(Transform): |
no outgoing calls
searching dependent graphs…