use crate::core::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const SMALLNORB_PACK: Pack = Pack {
name: "smallnorb",
version: "1.0.0",
license: "CC BY-SA 3.0 (attribution, NYU)",
files: &[
PackFile {
name: "training-dat.gz",
size: 131_896_188,
shake256: "737be6afab2463d95611421444cf7707d34f72bc8f0cec8d9ebd4ce0f050fe16",
urls: &[
"https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/smallnorb-5x46789x9x18x6x2x96x96-training-dat.mat.gz",
],
},
PackFile {
name: "training-cat.gz",
size: 348,
shake256: "3f1e94930ea384b2ecef08cca9b43af1e7e9757526bf0b10b6ee0f7a91b503d3",
urls: &[
"https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/smallnorb-5x46789x9x18x6x2x96x96-training-cat.mat.gz",
],
},
PackFile {
name: "training-info.gz",
size: 71_052,
shake256: "f95711c2fb6381f566c771d1cf7f69580f7b81aca31c7513de9dcdb47c947bb1",
urls: &[
"https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/smallnorb-5x46789x9x18x6x2x96x96-training-info.mat.gz",
],
},
PackFile {
name: "testing-dat.gz",
size: 130_799_817,
shake256: "5cac160c412103ae38a810c92729ea2423428db36cf48e0f9498a37285d016f3",
urls: &[
"https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/smallnorb-5x01235x9x18x6x2x96x96-testing-dat.mat.gz",
],
},
PackFile {
name: "testing-cat.gz",
size: 347,
shake256: "2b71364067b90bac7cc5604f6093e294698bb17cbce6300d37734f73f9606077",
urls: &[
"https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/smallnorb-5x01235x9x18x6x2x96x96-testing-cat.mat.gz",
],
},
PackFile {
name: "testing-info.gz",
size: 10_428,
shake256: "1e1d0aaa0a3bcf1fc871e8aeb518da679c76b3e130ca43dd02497426cfd75257",
urls: &[
"https://cs.nyu.edu/~ylclab/data/norb-v1.0-small/smallnorb-5x01235x9x18x6x2x96x96-testing-info.mat.gz",
],
},
],
};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum SmallnorbSplit {
#[default]
Train,
Test,
}
#[derive(Clone, Debug)]
pub struct SmallnorbConfig {
pub split: SmallnorbSplit,
pub normalize: bool,
pub cache_dir: Option<PathBuf>,
}
impl Default for SmallnorbConfig {
fn default() -> Self {
Self {
split: SmallnorbSplit::Train,
normalize: true,
cache_dir: None,
}
}
}
impl SmallnorbConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::Smallnorb {
#[inline]
pub fn load(config: &SmallnorbConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &SmallnorbConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &SmallnorbConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}