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>
impl<F: Float + Debug + 'static + ScalarOperand + FromPrimitive> AugmentationPipelineBuilder<F>
Sourcepub fn new() -> Self
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}
Sourcepub fn with_seed(self, seed: u64) -> Self
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}
Sourcepub fn with_standard_image_augmentations(self) -> Self
pub fn with_standard_image_augmentations(self) -> Self
Add standard image augmentations
Sourcepub fn with_strong_image_augmentations(self) -> Self
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}
Sourcepub fn with_mixup(self, alpha: f64) -> Self
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}
Sourcepub fn with_cutmix(self, alpha: f64, cut_ratio_range: (f64, f64)) -> Self
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}
Sourcepub fn build(self) -> AugmentationManager<F>
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>
impl<F: Float + Debug + 'static + ScalarOperand + FromPrimitive> Default for AugmentationPipelineBuilder<F>
Auto Trait Implementations§
impl<F> Freeze for AugmentationPipelineBuilder<F>where
F: Freeze,
impl<F> RefUnwindSafe for AugmentationPipelineBuilder<F>where
F: RefUnwindSafe,
impl<F> Send for AugmentationPipelineBuilder<F>where
F: Send,
impl<F> Sync for AugmentationPipelineBuilder<F>where
F: Sync,
impl<F> Unpin for AugmentationPipelineBuilder<F>where
F: Unpin,
impl<F> UnwindSafe for AugmentationPipelineBuilder<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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