pub enum ImageAugmentationOp {
Show 14 variants
HorizontalFlip {
probability: f32,
},
VerticalFlip {
probability: f32,
},
RandomRotate90 {
probability: f32,
},
BrightnessJitter {
max_delta: f32,
},
ContrastJitter {
max_scale_delta: f32,
},
GammaJitter {
max_gamma_delta: f32,
},
GaussianNoise {
probability: f32,
std_dev: f32,
},
BoxBlur3x3 {
probability: f32,
},
RandomResizedCrop {
probability: f32,
min_scale: f32,
max_scale: f32,
},
Cutout {
probability: f32,
max_height_fraction: f32,
max_width_fraction: f32,
fill_value: f32,
},
ChannelNormalize {
mean: Vec<f32>,
std: Vec<f32>,
},
Custom(Arc<dyn Fn(&Tensor) -> Result<Tensor, ModelError> + Send + Sync>),
RandomCrop {
height: usize,
width: usize,
},
GaussianBlur {
kernel_size: usize,
},
}Expand description
Per-sample image augmentations for rank-4 NHWC training tensors.
Variants§
HorizontalFlip
Flip image across width axis with configured probability.
VerticalFlip
Flip image across height axis with configured probability.
RandomRotate90
Rotate sample by random multiples of 90 degrees with configured probability.
For square samples, rotation is sampled from {0, 90, 180, 270} degrees. For non-square samples, rotation is sampled from {0, 180} degrees to preserve shape.
BrightnessJitter
Add random uniform brightness delta in [-max_delta, +max_delta] and clamp to [0, 1].
ContrastJitter
Scale contrast around per-sample mean by factor in [1-max_scale_delta, 1+max_scale_delta].
GammaJitter
Apply gamma correction with gamma sampled in [1-max_gamma_delta, 1+max_gamma_delta].
GaussianNoise
Add per-value Gaussian noise with configured standard deviation and clamp to [0, 1].
BoxBlur3x3
Apply 3x3 box blur with configured probability.
RandomResizedCrop
Crop a random window and resize it back to original sample size.
Cutout
Apply random rectangular erasing with configured max size fractions and fill value.
ChannelNormalize
Per-channel normalization in HWC layout: (x - mean[c]) / std[c].
Custom(Arc<dyn Fn(&Tensor) -> Result<Tensor, ModelError> + Send + Sync>)
User-provided closure for custom augmentation logic.
RandomCrop
Random crop from larger image (does not resize back; changes spatial dims).
GaussianBlur
Apply gaussian blur with the given square kernel size (must be odd and >= 1).
Implementations§
Source§impl ImageAugmentationOp
impl ImageAugmentationOp
Sourcepub fn from_transform<T: Transform + Send + Sync + 'static>(t: T) -> Self
pub fn from_transform<T: Transform + Send + Sync + 'static>(t: T) -> Self
Create an augmentation op from any Transform implementation.
Trait Implementations§
Source§impl Clone for ImageAugmentationOp
impl Clone for ImageAugmentationOp
Source§impl Debug for ImageAugmentationOp
impl Debug for ImageAugmentationOp
Source§impl PartialEq for ImageAugmentationOp
impl PartialEq for ImageAugmentationOp
Auto Trait Implementations§
impl Freeze for ImageAugmentationOp
impl !RefUnwindSafe for ImageAugmentationOp
impl Send for ImageAugmentationOp
impl Sync for ImageAugmentationOp
impl Unpin for ImageAugmentationOp
impl UnsafeUnpin for ImageAugmentationOp
impl !UnwindSafe for ImageAugmentationOp
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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