[][src]Struct neuro::data::ImageDataSet

pub struct ImageDataSet { /* fields omitted */ }

Structure representing a collection of images.

A builder class is provided for ease of creation: ImageDataSetBuilder.

Methods

impl ImageDataSet[src]

pub fn from_dir(
    path: &Path,
    image_size: (u32, u32),
    one_hot_encode: bool,
    valid_frac: Option<f64>,
    image_ops: ImageOps
) -> Result<ImageDataSet, Error>
[src]

Constructs an ImageDataSet from a directory tree.

The images must be in folders named after the corresponding class in a train top-level directory. Optionally, if a test directory exists, its content will be used to create a test set. For instance:

pets/
  train/
    cats/
      img1.jpg
      img2.jpg
      ...
    dogs/
      img1.jpg
      img2.jpg
      ...
  test/
    cats/
      img1.jpg
      img2.jpg
      ...
    dogs/
      img1.jpg
      img2.jpg
      ...

The images are resized to the given size using nearest-neighbor interpolation. The aspect ratio is not conserved.

Arguments

  • path - The path to the top level directory containing the images.
  • image_size - The height and width of the images.
  • one_hot_encode - Flag indicating whether the labels are one hot encoded.
  • valid_frac - The fraction of the data used for validation.
  • image_ops - The collection of operations applied on the images.

pub fn print_classes(&self)[src]

Prints the classes in the dataset.

pub fn load_image(
    path: &Path,
    size: (u32, u32),
    image_ops: &ImageOps
) -> Result<(Vec<PrimitiveType>, u8), DataSetError>
[src]

Loads a single image from a path.

Arguments

  • path - The path to the image.
  • size - The height and width of the image.
  • image_ops - The collection of operations to apply on the image.

Return value

Tuple containing a vector with the image and the number of channels.

pub fn load_image_vec(
    paths: &[&Path],
    image_size: (u32, u32),
    image_ops: &ImageOps
) -> Result<Tensor, Error>
[src]

Loads the images from the paths.

The images are scaled by the factor used to create the dataset.

Arguments

  • paths - A slice of paths to the images. Each path must point to an individual image.

pub fn image_ops(&self) -> &ImageOps[src]

Trait Implementations

impl DataSet for ImageDataSet[src]

impl Display for ImageDataSet[src]

Auto Trait Implementations

impl RefUnwindSafe for ImageDataSet

impl Send for ImageDataSet

impl Sync for ImageDataSet

impl Unpin for ImageDataSet

impl UnwindSafe for ImageDataSet

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,