[−][src]Struct neuro::data::ImageDataSet
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]
path: &Path,
image_size: (u32, u32),
one_hot_encode: bool,
valid_frac: Option<f64>,
image_ops: ImageOps
) -> Result<ImageDataSet, Error>
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]
path: &Path,
size: (u32, u32),
image_ops: &ImageOps
) -> Result<(Vec<PrimitiveType>, u8), DataSetError>
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]
paths: &[&Path],
image_size: (u32, u32),
image_ops: &ImageOps
) -> Result<Tensor, Error>
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]
fn input_shape(&self) -> Dim4
[src]
fn output_shape(&self) -> Dim4
[src]
fn num_train_samples(&self) -> u64
[src]
fn num_valid_samples(&self) -> u64
[src]
fn classes(&self) -> Option<Vec<String>>
[src]
fn x_train(&self) -> &Tensor
[src]
fn y_train(&self) -> &Tensor
[src]
fn x_valid(&self) -> Option<&Tensor>
[src]
fn y_valid(&self) -> Option<&Tensor>
[src]
fn x_test(&self) -> Option<&Tensor>
[src]
fn y_test(&self) -> Option<&Tensor>
[src]
fn x_train_stats(&self) -> &Option<(Scaling, Tensor, Tensor)>
[src]
fn y_train_stats(&self) -> &Option<(Scaling, Tensor, Tensor)>
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,