[][src]Struct neuro::data::ImageDataSetBuilder

pub struct ImageDataSetBuilder { /* fields omitted */ }

Methods

impl ImageDataSetBuilder[src]

pub fn from_dir(
    path: &'static Path,
    image_size: (u32, u32)
) -> ImageDataSetBuilder
[src]

Creates a dataset builder 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.

Example

This example is not tested
let path = Path::new("dataset/pets");
let data = ImageDataSetBuilder::from_dir(&path, (32, 32))
    .one_hot_encode()
    .valid_split(0.2)
    .scale(1./255.)
    .rotate(10, 0.1)
    .build()?;

pub fn build(self) -> Result<ImageDataSet, Error>[src]

Builds an ImageDataSet from the image dataset builder.

pub fn hflip(self, prob: f64) -> ImageDataSetBuilder[src]

Flips the images horizontally with the given probability.

pub fn vflip(self, prob: f64) -> ImageDataSetBuilder[src]

Flips the images vertically with the given probability.

pub fn one_hot_encode(self) -> ImageDataSetBuilder[src]

One hot encodes the labels.

pub fn rotate(self, angle: i32, prob: f64) -> ImageDataSetBuilder[src]

Rotates the images by an angle drawn from a uniform distribution with bounds ±angle (in degrees). A rotation is applied with the given probability.

pub fn valid_split(self, valid_frac: f64) -> ImageDataSetBuilder[src]

Splits the data into a training and validation sets.

pub fn scale(self, factor: PrimitiveType) -> ImageDataSetBuilder[src]

Scales the images by multiplying each pixel by the given factor.

Auto Trait Implementations

impl RefUnwindSafe for ImageDataSetBuilder

impl Send for ImageDataSetBuilder

impl Sync for ImageDataSetBuilder

impl Unpin for ImageDataSetBuilder

impl UnwindSafe for ImageDataSetBuilder

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, 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>,