MCPcopy
hub / github.com/pytorch/vision / perspective

Function perspective

torchvision/transforms/v2/functional/_geometry.py:1910–1939  ·  view source on GitHub ↗

See :class:`~torchvision.transforms.v2.RandomPerspective` for details.

(
    inpt: torch.Tensor,
    startpoints: Optional[list[list[int]]],
    endpoints: Optional[list[list[int]]],
    interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR,
    fill: _FillTypeJIT = None,
    coefficients: Optional[list[float]] = None,
)

Source from the content-addressed store, hash-verified

1908
1909
1910def perspective(
1911 inpt: torch.Tensor,
1912 startpoints: Optional[list[list[int]]],
1913 endpoints: Optional[list[list[int]]],
1914 interpolation: Union[InterpolationMode, int] = InterpolationMode.BILINEAR,
1915 fill: _FillTypeJIT = None,
1916 coefficients: Optional[list[float]] = None,
1917) -> torch.Tensor:
1918 """See :class:`~torchvision.transforms.v2.RandomPerspective` for details."""
1919 if torch.jit.is_scripting():
1920 return perspective_image(
1921 inpt,
1922 startpoints=startpoints,
1923 endpoints=endpoints,
1924 interpolation=interpolation,
1925 fill=fill,
1926 coefficients=coefficients,
1927 )
1928
1929 _log_api_usage_once(perspective)
1930
1931 kernel = _get_kernel(perspective, type(inpt))
1932 return kernel(
1933 inpt,
1934 startpoints=startpoints,
1935 endpoints=endpoints,
1936 interpolation=interpolation,
1937 fill=fill,
1938 coefficients=coefficients,
1939 )
1940
1941
1942def _perspective_grid(coeffs: list[float], ow: int, oh: int, dtype: torch.dtype, device: torch.device) -> torch.Tensor:

Callers

nothing calls this directly

Calls 3

_log_api_usage_onceFunction · 0.90
perspective_imageFunction · 0.85
_get_kernelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…