package torch

  1. Overview
  2. Docs
PyTorch bindings for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

0.11.tar.gz
md5=45ccaed01b4aea5d1f9ae0c89c85f78b
sha512=c3d02319adb88f641c0eaf312c4a15525a28f1ee8ef46be10111aafbefb40b29fc1746733be49f6a2049a5a17ccc203a8c0481a18f70eed05b9cf4a34830a2c2

doc/torch.vision/Torch_vision/Image/index.html

Module Torch_vision.ImageSource

load_image ?resize filename returns a tensor containing the pixels for the image in filename. Supported image formats are JPEG and PNG. The resulting tensor has dimensions NCHW (with N = 1) with values between 0 and 255. When resize is set, the image is first resized preserving its original ratio then a center crop is taken.

Sourceval load_images : ?resize:(Base.int * Base.int) -> Base.string -> Torch.Tensor.t

load_images ?resize dir_name is similar to applying load_image to all the images in dir_name. The resulting tensor has dimensions NCHW where N is the number of images.

Sourceval load_dataset : dir:Base.string -> classes:Base.string Base.list -> with_cache:Base.string Base.option -> resize:(Base.int * Base.int) -> Torch.Dataset_helper.t

load_dataset ~dir ~classes ~with_cache ~resize loads the images contained in directories dir/class where class ranges over classes. The class is used to determine the labels in the resulting dataset. resize should be used if the images don't have all the same size.

Sourceval write_image : Torch.Tensor.t -> filename:Base.string -> Base.unit

write_image tensor ~filename writes tensor as an image to the disk. The format is determined by filename's extension, defaulting to png. Supported formats are jpg, tga, bmp, and png. The tensor values should be between 0 and 255, the shape of the tensor can be 1; channels; height; width or channels; height; width where channels is either 1 or 3.

Sourcemodule Loader : sig ... end
Sourceval resize : Torch.Tensor.t -> height:Base.int -> width:Base.int -> Torch.Tensor.t

resize t ~height ~width resizes the given tensor to height and width. This does not preserve the aspect ratio. t can have dimensions NCHW with C set to 1 or 3, the returned tensor will have dimensions NCH'W' with H' = height and W' = width. The input and output tensors have values between 0 and 255.

OCaml

Innovation. Community. Security.