Skip to main content

incin_data/
lib.rs

1//! # Incin Data
2//!
3//! Provides dataset and dataloader abstractions for the Incin framework.
4//! Handles batching, shuffling, and data transformation pipelines.
5//!
6//! ## Examples
7//!
8//! Using a basic `DataLoader` with an in-memory `Dataset`:
9//!
10//! ```rust,ignore
11//! use incin_data::prelude::*;
12//! use incin_data::{Dataset, DataLoader};
13//! use incin::prelude::*;
14//!
15//! struct MyDataset {
16//!     images: Tensor<s![100, 3, 224, 224], CpuBackendImpl>,
17//!     labels: Tensor<s![100], CpuBackendImpl>,
18//! }
19//!
20//! impl Dataset for MyDataset {
21//!     type Item = (Tensor<s![3, 224, 224], CpuBackendImpl>, Tensor<s![], CpuBackendImpl>);
22//!     
23//!     fn len(&self) -> usize {
24//!         100
25//!     }
26//!     
27//!     fn get(&self, idx: usize) -> Option<Self::Item> {
28//!         if idx >= 100 { return None; }
29//!         let img = self.images.slice_dyn(vec![idx..idx+1, 0..3, 0..224, 0..224]).unwrap();
30//!         let label = self.labels.slice_dyn(vec![idx..idx+1]).unwrap();
31//!         // Return properly shaped items...
32//!         todo!()
33//!     }
34//! }
35//!
36//! fn main() {
37//!     let dataset = MyDataset {
38//!         images: Tensor::zeros(()).unwrap(),
39//!         labels: Tensor::zeros(()).unwrap(),
40//!     };
41//!     
42//!     // Create a dataloader with batch size 32, shuffling enabled
43//!     let loader = DataLoader::new(dataset).batch_size(32).shuffle(true);
44//!     
45//!     for batch in loader.iter() {
46//!         let (images, labels) = batch;
47//!         // train model...
48//!     }
49//! }
50//! ```
51
52#[macro_use]
53extern crate alloc;
54/// Dataset.
55pub mod dataset;
56/// Downloader.
57pub mod downloader;
58/// Hub.
59pub mod hub;
60/// Loader.
61pub mod loader;
62/// Transforms and data processing pipelines.
63pub mod transforms;
64/// Vision.
65pub mod vision;
66
67pub use dataset::Dataset;
68pub use downloader::Downloader;
69pub use loader::{Collate, DataLoader};
70pub use transforms::{CenterCrop, Compose, Normalize, RandomHorizontalFlip, Scale, Transform};
71
72/// Prelude.
73pub mod prelude {
74    pub use super::hub::*;
75    pub use super::loader::*;
76    pub use super::transforms::*;
77}