vision_transforms_functional

package
v1.11.0-0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2023 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Crop

func Crop(tensor *torch.Tensor, xmin, ymin, xmax, ymax int64) *torch.Tensor

Crop a slice from a tensor with shape (..., H, W). Crop the given image at specified location and output size. The input is a Tensor with expected shape of (..., H, W). If image size is smaller than output size along any edge, image is padded with 0 and then cropped.

func FromTensor

func FromTensor(tensor *torch.Tensor) image.Image

Convert a torch tensor to an image.Image.

func LongestMaxSize

func LongestMaxSize(
	tensor *torch.Tensor,
	size int64,
	interpolation F.InterpolateMode,
	alignCorners, antialias bool,
) (*torch.Tensor, float64)

Resize a tensor to have the longest size equal to `size`. If interpolation is required, e.g., if the tensor has max size less than or equal to `size`, use the given mode, corner alignment setting, and optional anti-aliasing. Returns the resized tensor and the scale factor used to resize the tensor.

func PadIfNeeded

func PadIfNeeded(
	tensor *torch.Tensor,
	min_height, min_width int64,
	mode F.PadMode,
	value ...float64,
) (*torch.Tensor, []int64)

Pad the input tensor to the given minimum height and width. If padding is necessary, use the given padding mode. When the padding mode is constant, use the given constant padding value. Returns the padded tensor and the padding that was applied in [left, right, top, bottom] format.

func SafeCrop

func SafeCrop(tensor *torch.Tensor, xmin, ymin, xmax, ymax int64) *torch.Tensor

Crop a slice from a tensor with shape (..., H, W).

Bounding boxes are in (xmin,ymin,xmax,ymax) format.

The python syntax for this function would be: ```python tensor[..., ymin:ymax, xmin:ymax] ```

Note that the semantics of this function are (xmin,ymax,xmax,ymax), whereas the semantics for PyTorch torchvision is actually (ymin,xmin,height,width.) The semantics for edge cases are to clip to the bounds whereas in PyTorch the conventions are allow shifts past the window and larger bounds via zero padding.

func ToTensor

func ToTensor(frame image.Image) (output *torch.Tensor)

Convert an image.Image to a torch Tensor.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL