Documentation ¶
Index ¶
- func Crop(tensor *torch.Tensor, xmin, ymin, xmax, ymax int64) *torch.Tensor
- func FromTensor(tensor *torch.Tensor) image.Image
- func LongestMaxSize(tensor *torch.Tensor, size int64, interpolation F.InterpolateMode, ...) (*torch.Tensor, float64)
- func PadIfNeeded(tensor *torch.Tensor, min_height, min_width int64, mode F.PadMode, ...) (*torch.Tensor, []int64)
- func SafeCrop(tensor *torch.Tensor, xmin, ymin, xmax, ymax int64) *torch.Tensor
- func ToTensor(frame image.Image) (output *torch.Tensor)
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 ¶
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.
Types ¶
This section is empty.