| 1853 | backend = [TransformBackends.TORCH, TransformBackends.NUMPY] |
| 1854 | |
| 1855 | def __init__(self, num_control_points: tuple[int, int] | int = 10, prob: float = 0.1) -> None: |
| 1856 | RandomizableTransform.__init__(self, prob) |
| 1857 | |
| 1858 | if isinstance(num_control_points, int): |
| 1859 | if num_control_points <= 2: |
| 1860 | raise ValueError("num_control_points should be greater than or equal to 3") |
| 1861 | self.num_control_points = (num_control_points, num_control_points) |
| 1862 | else: |
| 1863 | if len(num_control_points) != 2: |
| 1864 | raise ValueError("num_control points should be a number or a pair of numbers") |
| 1865 | if min(num_control_points) <= 2: |
| 1866 | raise ValueError("num_control_points should be greater than or equal to 3") |
| 1867 | self.num_control_points = (min(num_control_points), max(num_control_points)) |
| 1868 | self.reference_control_points: NdarrayOrTensor |
| 1869 | self.floating_control_points: NdarrayOrTensor |
| 1870 | |
| 1871 | def interp(self, x: NdarrayOrTensor, xp: NdarrayOrTensor, fp: NdarrayOrTensor) -> NdarrayOrTensor: |
| 1872 | ns = torch if isinstance(x, torch.Tensor) else np |