Struct AugmentationPipelineBuilder

Source
pub struct AugmentationPipelineBuilder<F: Float + Debug + 'static + ScalarOperand + FromPrimitive> { /* private fields */ }
Expand description

Augmentation pipeline builder for easy configuration

Implementations§

Source§

impl<F: Float + Debug + 'static + ScalarOperand + FromPrimitive> AugmentationPipelineBuilder<F>

Source

pub fn new() -> Self

Create a new pipeline builder

Examples found in repository?
examples/neural_advanced_features.rs (line 55)
50fn demonstrate_advanced_augmentation() -> Result<()> {
51    println!("🎨 Advanced Data Augmentation Demonstration");
52    println!("==========================================\n");
53
54    // Create comprehensive augmentation pipeline
55    let mut augmentation_manager = AugmentationPipelineBuilder::<f64>::new()
56        .with_seed(42)
57        .with_strong_image_augmentations()
58        .with_mixup(1.0)
59        .with_cutmix(1.0, (0.1, 0.5))
60        .build();
61
62    // Create sample image batch (NCHW format: batch=4, channels=3, height=32, width=32)
63    let images = Array4::<f64>::from_shape_fn((4, 3, 32, 32), |(b, c, h, w)| {
64        (b + c + h + w) as f64 / 100.0
65    })
66    .into_dyn();
67
68    let labels =
69        Array2::<f64>::from_shape_fn((4, 10), |(b, c)| if c == b % 10 { 1.0 } else { 0.0 })
70            .into_dyn();
71
72    println!("Original images shape: {:?}", images.shape());
73    println!("Original labels shape: {:?}", labels.shape());
74
75    // Apply standard augmentations
76    println!("\n1. Applying image augmentations...");
77    let augmented_images = augmentation_manager.augment_images(&images)?;
78    println!("   Augmented images shape: {:?}", augmented_images.shape());
79
80    // Apply MixUp
81    println!("\n2. Applying MixUp augmentation...");
82    let (mixup_images, mixup_labels) = augmentation_manager.apply_mixup(&images, &labels, 1.0)?;
83    println!("   MixUp images shape: {:?}", mixup_images.shape());
84    println!("   MixUp labels shape: {:?}", mixup_labels.shape());
85
86    // Apply CutMix
87    println!("\n3. Applying CutMix augmentation...");
88    let (cutmix_images, cutmix_labels) =
89        augmentation_manager.apply_cutmix(&images, &labels, 1.0, (0.1, 0.5))?;
90    println!("   CutMix images shape: {:?}", cutmix_images.shape());
91    println!("   CutMix labels shape: {:?}", cutmix_labels.shape());
92
93    // Display statistics
94    let stats = augmentation_manager.get_statistics();
95    println!("\n4. Augmentation Statistics:");
96    println!("   Samples processed: {}", stats.samples_processed);
97    println!("   Processing time: {:.2}ms", stats.processing_time_ms);
98    println!("   Transform counts: {:?}", stats.transform_counts);
99
100    println!("✅ Advanced augmentation demonstration completed!\n");
101    Ok(())
102}
Source

pub fn with_seed(self, seed: u64) -> Self

Set random seed

Examples found in repository?
examples/neural_advanced_features.rs (line 56)
50fn demonstrate_advanced_augmentation() -> Result<()> {
51    println!("🎨 Advanced Data Augmentation Demonstration");
52    println!("==========================================\n");
53
54    // Create comprehensive augmentation pipeline
55    let mut augmentation_manager = AugmentationPipelineBuilder::<f64>::new()
56        .with_seed(42)
57        .with_strong_image_augmentations()
58        .with_mixup(1.0)
59        .with_cutmix(1.0, (0.1, 0.5))
60        .build();
61
62    // Create sample image batch (NCHW format: batch=4, channels=3, height=32, width=32)
63    let images = Array4::<f64>::from_shape_fn((4, 3, 32, 32), |(b, c, h, w)| {
64        (b + c + h + w) as f64 / 100.0
65    })
66    .into_dyn();
67
68    let labels =
69        Array2::<f64>::from_shape_fn((4, 10), |(b, c)| if c == b % 10 { 1.0 } else { 0.0 })
70            .into_dyn();
71
72    println!("Original images shape: {:?}", images.shape());
73    println!("Original labels shape: {:?}", labels.shape());
74
75    // Apply standard augmentations
76    println!("\n1. Applying image augmentations...");
77    let augmented_images = augmentation_manager.augment_images(&images)?;
78    println!("   Augmented images shape: {:?}", augmented_images.shape());
79
80    // Apply MixUp
81    println!("\n2. Applying MixUp augmentation...");
82    let (mixup_images, mixup_labels) = augmentation_manager.apply_mixup(&images, &labels, 1.0)?;
83    println!("   MixUp images shape: {:?}", mixup_images.shape());
84    println!("   MixUp labels shape: {:?}", mixup_labels.shape());
85
86    // Apply CutMix
87    println!("\n3. Applying CutMix augmentation...");
88    let (cutmix_images, cutmix_labels) =
89        augmentation_manager.apply_cutmix(&images, &labels, 1.0, (0.1, 0.5))?;
90    println!("   CutMix images shape: {:?}", cutmix_images.shape());
91    println!("   CutMix labels shape: {:?}", cutmix_labels.shape());
92
93    // Display statistics
94    let stats = augmentation_manager.get_statistics();
95    println!("\n4. Augmentation Statistics:");
96    println!("   Samples processed: {}", stats.samples_processed);
97    println!("   Processing time: {:.2}ms", stats.processing_time_ms);
98    println!("   Transform counts: {:?}", stats.transform_counts);
99
100    println!("✅ Advanced augmentation demonstration completed!\n");
101    Ok(())
102}
Source

pub fn with_standard_image_augmentations(self) -> Self

Add standard image augmentations

Source

pub fn with_strong_image_augmentations(self) -> Self

Add strong image augmentations

Examples found in repository?
examples/neural_advanced_features.rs (line 57)
50fn demonstrate_advanced_augmentation() -> Result<()> {
51    println!("🎨 Advanced Data Augmentation Demonstration");
52    println!("==========================================\n");
53
54    // Create comprehensive augmentation pipeline
55    let mut augmentation_manager = AugmentationPipelineBuilder::<f64>::new()
56        .with_seed(42)
57        .with_strong_image_augmentations()
58        .with_mixup(1.0)
59        .with_cutmix(1.0, (0.1, 0.5))
60        .build();
61
62    // Create sample image batch (NCHW format: batch=4, channels=3, height=32, width=32)
63    let images = Array4::<f64>::from_shape_fn((4, 3, 32, 32), |(b, c, h, w)| {
64        (b + c + h + w) as f64 / 100.0
65    })
66    .into_dyn();
67
68    let labels =
69        Array2::<f64>::from_shape_fn((4, 10), |(b, c)| if c == b % 10 { 1.0 } else { 0.0 })
70            .into_dyn();
71
72    println!("Original images shape: {:?}", images.shape());
73    println!("Original labels shape: {:?}", labels.shape());
74
75    // Apply standard augmentations
76    println!("\n1. Applying image augmentations...");
77    let augmented_images = augmentation_manager.augment_images(&images)?;
78    println!("   Augmented images shape: {:?}", augmented_images.shape());
79
80    // Apply MixUp
81    println!("\n2. Applying MixUp augmentation...");
82    let (mixup_images, mixup_labels) = augmentation_manager.apply_mixup(&images, &labels, 1.0)?;
83    println!("   MixUp images shape: {:?}", mixup_images.shape());
84    println!("   MixUp labels shape: {:?}", mixup_labels.shape());
85
86    // Apply CutMix
87    println!("\n3. Applying CutMix augmentation...");
88    let (cutmix_images, cutmix_labels) =
89        augmentation_manager.apply_cutmix(&images, &labels, 1.0, (0.1, 0.5))?;
90    println!("   CutMix images shape: {:?}", cutmix_images.shape());
91    println!("   CutMix labels shape: {:?}", cutmix_labels.shape());
92
93    // Display statistics
94    let stats = augmentation_manager.get_statistics();
95    println!("\n4. Augmentation Statistics:");
96    println!("   Samples processed: {}", stats.samples_processed);
97    println!("   Processing time: {:.2}ms", stats.processing_time_ms);
98    println!("   Transform counts: {:?}", stats.transform_counts);
99
100    println!("✅ Advanced augmentation demonstration completed!\n");
101    Ok(())
102}
Source

pub fn with_mixup(self, alpha: f64) -> Self

Add MixUp augmentation

Examples found in repository?
examples/neural_advanced_features.rs (line 58)
50fn demonstrate_advanced_augmentation() -> Result<()> {
51    println!("🎨 Advanced Data Augmentation Demonstration");
52    println!("==========================================\n");
53
54    // Create comprehensive augmentation pipeline
55    let mut augmentation_manager = AugmentationPipelineBuilder::<f64>::new()
56        .with_seed(42)
57        .with_strong_image_augmentations()
58        .with_mixup(1.0)
59        .with_cutmix(1.0, (0.1, 0.5))
60        .build();
61
62    // Create sample image batch (NCHW format: batch=4, channels=3, height=32, width=32)
63    let images = Array4::<f64>::from_shape_fn((4, 3, 32, 32), |(b, c, h, w)| {
64        (b + c + h + w) as f64 / 100.0
65    })
66    .into_dyn();
67
68    let labels =
69        Array2::<f64>::from_shape_fn((4, 10), |(b, c)| if c == b % 10 { 1.0 } else { 0.0 })
70            .into_dyn();
71
72    println!("Original images shape: {:?}", images.shape());
73    println!("Original labels shape: {:?}", labels.shape());
74
75    // Apply standard augmentations
76    println!("\n1. Applying image augmentations...");
77    let augmented_images = augmentation_manager.augment_images(&images)?;
78    println!("   Augmented images shape: {:?}", augmented_images.shape());
79
80    // Apply MixUp
81    println!("\n2. Applying MixUp augmentation...");
82    let (mixup_images, mixup_labels) = augmentation_manager.apply_mixup(&images, &labels, 1.0)?;
83    println!("   MixUp images shape: {:?}", mixup_images.shape());
84    println!("   MixUp labels shape: {:?}", mixup_labels.shape());
85
86    // Apply CutMix
87    println!("\n3. Applying CutMix augmentation...");
88    let (cutmix_images, cutmix_labels) =
89        augmentation_manager.apply_cutmix(&images, &labels, 1.0, (0.1, 0.5))?;
90    println!("   CutMix images shape: {:?}", cutmix_images.shape());
91    println!("   CutMix labels shape: {:?}", cutmix_labels.shape());
92
93    // Display statistics
94    let stats = augmentation_manager.get_statistics();
95    println!("\n4. Augmentation Statistics:");
96    println!("   Samples processed: {}", stats.samples_processed);
97    println!("   Processing time: {:.2}ms", stats.processing_time_ms);
98    println!("   Transform counts: {:?}", stats.transform_counts);
99
100    println!("✅ Advanced augmentation demonstration completed!\n");
101    Ok(())
102}
Source

pub fn with_cutmix(self, alpha: f64, cut_ratio_range: (f64, f64)) -> Self

Add CutMix augmentation

Examples found in repository?
examples/neural_advanced_features.rs (line 59)
50fn demonstrate_advanced_augmentation() -> Result<()> {
51    println!("🎨 Advanced Data Augmentation Demonstration");
52    println!("==========================================\n");
53
54    // Create comprehensive augmentation pipeline
55    let mut augmentation_manager = AugmentationPipelineBuilder::<f64>::new()
56        .with_seed(42)
57        .with_strong_image_augmentations()
58        .with_mixup(1.0)
59        .with_cutmix(1.0, (0.1, 0.5))
60        .build();
61
62    // Create sample image batch (NCHW format: batch=4, channels=3, height=32, width=32)
63    let images = Array4::<f64>::from_shape_fn((4, 3, 32, 32), |(b, c, h, w)| {
64        (b + c + h + w) as f64 / 100.0
65    })
66    .into_dyn();
67
68    let labels =
69        Array2::<f64>::from_shape_fn((4, 10), |(b, c)| if c == b % 10 { 1.0 } else { 0.0 })
70            .into_dyn();
71
72    println!("Original images shape: {:?}", images.shape());
73    println!("Original labels shape: {:?}", labels.shape());
74
75    // Apply standard augmentations
76    println!("\n1. Applying image augmentations...");
77    let augmented_images = augmentation_manager.augment_images(&images)?;
78    println!("   Augmented images shape: {:?}", augmented_images.shape());
79
80    // Apply MixUp
81    println!("\n2. Applying MixUp augmentation...");
82    let (mixup_images, mixup_labels) = augmentation_manager.apply_mixup(&images, &labels, 1.0)?;
83    println!("   MixUp images shape: {:?}", mixup_images.shape());
84    println!("   MixUp labels shape: {:?}", mixup_labels.shape());
85
86    // Apply CutMix
87    println!("\n3. Applying CutMix augmentation...");
88    let (cutmix_images, cutmix_labels) =
89        augmentation_manager.apply_cutmix(&images, &labels, 1.0, (0.1, 0.5))?;
90    println!("   CutMix images shape: {:?}", cutmix_images.shape());
91    println!("   CutMix labels shape: {:?}", cutmix_labels.shape());
92
93    // Display statistics
94    let stats = augmentation_manager.get_statistics();
95    println!("\n4. Augmentation Statistics:");
96    println!("   Samples processed: {}", stats.samples_processed);
97    println!("   Processing time: {:.2}ms", stats.processing_time_ms);
98    println!("   Transform counts: {:?}", stats.transform_counts);
99
100    println!("✅ Advanced augmentation demonstration completed!\n");
101    Ok(())
102}
Source

pub fn build(self) -> AugmentationManager<F>

Build the augmentation manager

Examples found in repository?
examples/neural_advanced_features.rs (line 60)
50fn demonstrate_advanced_augmentation() -> Result<()> {
51    println!("🎨 Advanced Data Augmentation Demonstration");
52    println!("==========================================\n");
53
54    // Create comprehensive augmentation pipeline
55    let mut augmentation_manager = AugmentationPipelineBuilder::<f64>::new()
56        .with_seed(42)
57        .with_strong_image_augmentations()
58        .with_mixup(1.0)
59        .with_cutmix(1.0, (0.1, 0.5))
60        .build();
61
62    // Create sample image batch (NCHW format: batch=4, channels=3, height=32, width=32)
63    let images = Array4::<f64>::from_shape_fn((4, 3, 32, 32), |(b, c, h, w)| {
64        (b + c + h + w) as f64 / 100.0
65    })
66    .into_dyn();
67
68    let labels =
69        Array2::<f64>::from_shape_fn((4, 10), |(b, c)| if c == b % 10 { 1.0 } else { 0.0 })
70            .into_dyn();
71
72    println!("Original images shape: {:?}", images.shape());
73    println!("Original labels shape: {:?}", labels.shape());
74
75    // Apply standard augmentations
76    println!("\n1. Applying image augmentations...");
77    let augmented_images = augmentation_manager.augment_images(&images)?;
78    println!("   Augmented images shape: {:?}", augmented_images.shape());
79
80    // Apply MixUp
81    println!("\n2. Applying MixUp augmentation...");
82    let (mixup_images, mixup_labels) = augmentation_manager.apply_mixup(&images, &labels, 1.0)?;
83    println!("   MixUp images shape: {:?}", mixup_images.shape());
84    println!("   MixUp labels shape: {:?}", mixup_labels.shape());
85
86    // Apply CutMix
87    println!("\n3. Applying CutMix augmentation...");
88    let (cutmix_images, cutmix_labels) =
89        augmentation_manager.apply_cutmix(&images, &labels, 1.0, (0.1, 0.5))?;
90    println!("   CutMix images shape: {:?}", cutmix_images.shape());
91    println!("   CutMix labels shape: {:?}", cutmix_labels.shape());
92
93    // Display statistics
94    let stats = augmentation_manager.get_statistics();
95    println!("\n4. Augmentation Statistics:");
96    println!("   Samples processed: {}", stats.samples_processed);
97    println!("   Processing time: {:.2}ms", stats.processing_time_ms);
98    println!("   Transform counts: {:?}", stats.transform_counts);
99
100    println!("✅ Advanced augmentation demonstration completed!\n");
101    Ok(())
102}

Trait Implementations§

Source§

impl<F: Float + Debug + 'static + ScalarOperand + FromPrimitive> Default for AugmentationPipelineBuilder<F>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V