pub trait ImageTensorExt {
    // Required methods
    fn to_image(&self) -> DynamicImage;
    fn from_image(image: DynamicImage) -> Self;
}
Expand description

Trait to convert between tch::Tensor and image::DynamicImage.

Required Methods§

source

fn to_image(&self) -> DynamicImage

Converts a tch::Tensor to a image::DynamicImage.

Arguments
  • self - The [C, H, W] tch::Tensor to convert to an Image. with C = 4 (RGBA), C = 3 (RGB), C = 2 (RGB) or C = 1 (RGB). we expect a non complex tensor. if every type will be converted to f32 except u8.
Returns
  • The image::DynamicImage representation of the tch::Tensor.
source

fn from_image(image: DynamicImage) -> Self

Converts a image::DynamicImage to a tch::Tensor.

Arguments
  • image - The image::DynamicImage to convert to a tch::Tensor.
Returns
  • The [C, H, W] tch::Tensor representation of the image::DynamicImage.

Implementations on Foreign Types§

source§

impl ImageTensorExt for Tensor

Implementors§