Skip to content
class

ImageClassificationAugment

extendsTransformsPreset
ImageClassificationAugment(crop_size: int, scale: tuple[float, float] = (0.08, 1.0), ratio: tuple[float, float] = (0.75, 1.3333333333333333), color_jitter: float = 0.4, hflip_prob: float = 0.5, auto_augment: str | None = None, random_erasing: float = 0.0, mean: tuple[float, ...] | None = None, std: tuple[float, ...] | None = None, interpolation: str | Interpolation = Interpolation.BILINEAR)

Standard ImageNet classification training preset (augmentation).

Pipeline (stages 4–7 conditional, all share the same Normalize stats):

1. RandomResizedCrop(crop_size, scale, ratio)
2. HorizontalFlip(p=hflip_prob)            — skipped if hflip_prob = 0
3. AutoAugment / RandAugment / TAW         — skipped if auto_augment = None
4. ColorJitter(brightness=contrast=...)    — skipped if color_jitter = 0
5. Normalize(mean, std, max_pixel_value=1)
6. RandomErasing(p=random_erasing)         — skipped if random_erasing = 0

Mirrors the reference-framework training recipe shipped with most classification models. Setting auto_augment and/or random_erasing reaches the strong-augmentation recipe used by timm / reference_vision references.

Parameters

crop_sizeint
Square crop fed to the model.
scaletuple of float= (0.08, 1.0)
RandomResizedCrop scale range.
ratiotuple of float= (0.75, 1.3333)
RandomResizedCrop aspect-ratio range.
color_jitterfloat= 0.4
Brightness / contrast / saturation jitter strength. Zero disables ColorJitter entirely.
hflip_probfloat= 0.5
Horizontal-flip probability. Zero disables the flip.
auto_augmentstr or None= None
AutoAugment-family policy. See _parse_auto_augment for accepted spec strings. None disables this stage — recommended unless you already have a tuned recipe.
random_erasingfloat= 0.0
lucid.utils.transforms.RandomErasing probability applied after Normalize (mirrors reference ordering). 0.0 disables the stage.
meantuple of float= None
Per-channel normalization stats; default ImageNet.
stdtuple of float= None
Per-channel normalization stats; default ImageNet.
interpolationstr or Interpolation= "bilinear"
No description.

Examples

The training counterpart of ImageClassification — a random
resized crop and a horizontal flip instead of a centre crop:
>>> import lucid, lucid.utils.transforms as T
>>> tf = T.ImageClassificationAugment(crop_size=224)
>>> tuple(tf(T.Image(lucid.rand(3, 300, 400))).data.shape)
(3, 224, 224)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(crop_size: int, scale: tuple[float, float] = (0.08, 1.0), ratio: tuple[float, float] = (0.75, 1.3333333333333333), color_jitter: float = 0.4, hflip_prob: float = 0.5, auto_augment: str | None = None, random_erasing: float = 0.0, mean: tuple[float, ...] | None = None, std: tuple[float, ...] | None = None, interpolation: str | Interpolation = Interpolation.BILINEAR)