use crate::core::IdxSplit;
use crate::core::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const FASHION_MNIST_PACK: Pack = Pack {
name: "fashion_mnist",
version: "1.0.0",
license: "MIT",
files: &[
PackFile {
name: "train-images-idx3-ubyte.gz",
size: 26_421_880,
shake256: "287217197fbade1cabc218dbc30a6ba2da0e6a3af5b4aa4185f3fd24f94ddabf",
urls: &[
"http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz",
"https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-images-idx3-ubyte.gz",
],
},
PackFile {
name: "train-labels-idx1-ubyte.gz",
size: 29_515,
shake256: "8acdf6a86fbee77624e8f5746b475a5bf3f387f76370df41cd7d6b63cea2fa21",
urls: &[
"http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz",
"https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz",
],
},
PackFile {
name: "t10k-images-idx3-ubyte.gz",
size: 4_422_102,
shake256: "897f33e93438e9eb054bd6103c0396f009a7d1035be8c726ef28ca3bd8dfabed",
urls: &[
"http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz",
"https://storage.googleapis.com/tensorflow/tf-keras-datasets/t10k-images-idx3-ubyte.gz",
],
},
PackFile {
name: "t10k-labels-idx1-ubyte.gz",
size: 5_148,
shake256: "16a6ca6f5f7f62ce4ba3d742a4fa9444a73b82bd5e5df971edd4ea468f6d77cf",
urls: &[
"http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-labels-idx1-ubyte.gz",
"https://storage.googleapis.com/tensorflow/tf-keras-datasets/t10k-labels-idx1-ubyte.gz",
],
},
],
};
pub type FashionMnistSplit = IdxSplit;
#[derive(Clone, Debug)]
pub struct FashionMnistConfig {
pub split: FashionMnistSplit,
pub cache_dir: Option<PathBuf>,
pub normalize: bool,
}
impl Default for FashionMnistConfig {
fn default() -> Self {
Self {
split: FashionMnistSplit::Train,
cache_dir: None,
normalize: true,
}
}
}
impl FashionMnistConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::FashionMnist {
#[inline]
pub fn load(config: &FashionMnistConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &FashionMnistConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &FashionMnistConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}