1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! ImageDataSet is a simple struct that holds the path to a directory containing images. It is used to represent a dataset of images that can be used for training a model.

use crate::prelude::*;
use std::path::{Path, PathBuf};

/// A data set of images.
#[derive(Debug, Serialize, Deserialize)]
pub struct ImageDataSet(PathBuf);

impl ImageDataSet {
    /// Create a new image data set from a directory.
    pub fn from_dir<Path: AsRef<std::path::Path>>(path: Path) -> Self {
        let path = path.as_ref().to_path_buf();
        ImageDataSet(path)
    }

    /// Set the path to the image data set.
    pub fn set_path(&mut self, path: PathBuf) {
        self.0 = path;
    }

    /// Get the path to the image data set.
    pub fn path(&self) -> &Path {
        &self.0
    }
}