use crate::core::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const MOVING_MNIST_PACK: Pack = Pack {
name: "moving_mnist",
version: "1.0.0",
license: "CC-BY-SA-3.0",
files: &[PackFile {
name: "mnist_test_seq.npy",
size: 819_200_096,
shake256: "44136c19911ddfc9a8d6353aee5bb7ba42e359e5bfb24a8ea7fe03ec6f4ca6ce",
urls: &[
"https://www.cs.toronto.edu/~nitish/unsupervised_video/mnist_test_seq.npy",
"http://www.cs.toronto.edu/~nitish/unsupervised_video/mnist_test_seq.npy",
],
}],
};
#[derive(Clone, Debug)]
pub struct MovingMnistConfig {
pub count: Option<usize>,
pub cache_dir: Option<PathBuf>,
pub normalize: bool,
}
impl Default for MovingMnistConfig {
fn default() -> Self {
Self {
count: None,
cache_dir: None,
normalize: true,
}
}
}
impl MovingMnistConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::MovingMnist {
#[inline]
pub fn load(config: &MovingMnistConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &MovingMnistConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &MovingMnistConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}