transforms
97 memberslucid.utils.transforms`lucid.utils.transforms` — image transform library.
An Albumentations-compatible transform library (matching class names +
constructor signatures) built tensor-native on Lucid (no numpy / PIL,
per H4). Transforms consume / produce lucid.Tensor images
(C, H, W) or (B, C, H, W); image decoding (file → tensor)
lives outside this package.
Two entry points:
- Class transforms —
Composea list ofTransformobjects. Each is applied with probabilitypand moves every typed target (Image/Mask/BoundingBoxes/Keypoints) consistently. - Functional — stateless ops under
lucid.utils.transforms.functional.
Presets (ImageClassification) bundle a task's canonical
inference pipeline; pretrained weights ship preprocessing this way.
>>> import lucid.utils.transforms as T
>>> tf = T.Compose([
... T.SmallestMaxSize(256),
... T.CenterCrop(224, 224),
... T.Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)),
... ])
>>> y = tf(image)
Classes
BboxParams1 methodsBounding-box handling policy for Compose (Albumentations-style).
Compose3 methodsChain transforms into one callable (works on tensors or samples).
GeometricTransformSpatial transform — must move masks, boxes, and keypoints.
PhotometricTransformColour / intensity transform — non-image targets pass through.
Transform3 methodsAbstract base for a transform parameterized by its sample-params P.
BoundingBoxes1 methodsWraps (N, 4) bounding boxes with a format + canvas size.
Image1 methodsWraps a pixel image tensor (C, H, W) or (B, C, H, W).
Keypoints1 methodsWraps (N, D) keypoints (D >= 2; first two columns x, y).
Mask1 methodsWraps a segmentation / label mask, resampled with nearest mode.
CenterCrop2 methodsCrop a centred height x width window (Albumentations CenterCrop).
HorizontalFlip2 methodsFlip left-right with probability p (Albumentations HorizontalFlip).
LongestMaxSize1 methodsScale so the longer side equals max_size (Albumentations LongestMaxSize).
RandomCrop3 methodsCrop a random height x width window (Albumentations RandomCrop).
RandomResizedCrop3 methodsCrop a random area/aspect region then resize to height x width.
Resize2 methodsResize to an exact height x width (Albumentations Resize).
SmallestMaxSize1 methodsScale so the shorter side equals max_size (Albumentations SmallestMaxSize).
VerticalFlip2 methodsFlip top-bottom with probability p (Albumentations VerticalFlip).
Blur3 methodsBox (mean) blur with a random odd kernel size (Albumentations Blur).
Defocus3 methodsDisk-kernel (out-of-focus) blur (Albumentations Defocus).
Downscale3 methodsDownscale then upscale to lose high-frequency detail (Albumentations Downscale).
GaussianBlur3 methodsGaussian blur with random kernel size and sigma (Albumentations GaussianBlur).
GaussNoise3 methodsAdditive Gaussian noise (Albumentations GaussNoise).
ISONoise3 methodsCamera-sensor-like noise (Albumentations ISONoise, approximate).
MedianBlur3 methodsMedian filter with a random odd kernel (Albumentations MedianBlur).
MotionBlur3 methodsDirectional (linear streak) motion blur (Albumentations MotionBlur).
MultiplicativeNoise3 methodsMultiply pixel values by random noise (Albumentations MultiplicativeNoise).
ZoomBlur3 methodsRadial zoom blur via averaged centre-zoomed copies (Albumentations ZoomBlur).
OneOf3 methodsApply exactly one child, sampled by child-p weight (Albumentations OneOf).
OneOrOther3 methodsApply first with probability p else second (Albumentations OneOrOther).
ReplayCompose4 methodsCompose that records applied params for deterministic replay.
Sequential3 methodsApply all children in order, gated by p (Albumentations Sequential).
SomeOf3 methodsApply n randomly-chosen children (Albumentations SomeOf).
BBoxSafeRandomCrop3 methodsRandom crop guaranteed to contain every bounding box (Albumentations BBoxSafeRandomCrop).
Lambda2 methodsApply user callables per target type (Albumentations Lambda).
MaskDropout3 methodsDrop random mask label regions from image + mask (Albumentations MaskDropout).
RandomCropNearBBox3 methodsCrop a window around the first bounding box (Albumentations RandomCropNearBBox).
RandomSizedBBoxSafeCrop3 methodsBox-safe crop then resize to a fixed output size (Albumentations RandomSizedBBoxSafeCrop).
CLAHE2 methodsContrast-limited adaptive histogram equalization (Albumentations CLAHE).
ChannelDropout3 methodsReplace random channels with a constant fill value (Albumentations ChannelDropout).
ChannelShuffle3 methodsRandomly permute the RGB channel order (Albumentations ChannelShuffle).
Emboss3 methodsEmboss an image via a 3x3 directional gradient kernel (Albumentations Emboss).
Equalize2 methodsPer-channel histogram equalization (Albumentations Equalize).
FancyPCA3 methodsAlexNet-style PCA colour augmentation (Krizhevsky 2012, Albumentations FancyPCA).
HueSaturationValue3 methodsRandom hue / saturation / value shift (Albumentations HueSaturationValue).
InvertImg2 methodsInvert pixel intensities via 1 - img (Albumentations InvertImg).
PixelDropout3 methodsRandomly set individual pixels to a fill value (Albumentations PixelDropout).
Posterize3 methodsReduce bits per channel (Albumentations Posterize).
RandomBrightness3 methodsRandomly perturb brightness only (Albumentations RandomBrightness).
RandomBrightnessContrast3 methodsRandomly perturb brightness and contrast jointly (Albumentations RandomBrightnessContrast).
RandomContrast3 methodsRandomly perturb contrast only (Albumentations RandomContrast).
RandomGamma3 methodsRandom gamma correction (Albumentations RandomGamma).
RandomToneCurve3 methodsApply a random S-shaped tone curve around midtones (Albumentations RandomToneCurve).
RGBShift3 methodsAdd per-channel additive shifts to an RGB image (Albumentations RGBShift).
RingingOvershoot3 methodsSimulate ringing / overshoot artefacts via a high-pass kernel (Albumentations RingingOvershoot).
Sharpen3 methodsSharpen an image via a 3x3 unsharp kernel blend (Albumentations Sharpen).
Solarize3 methodsInvert pixel intensities above a threshold (Albumentations Solarize).
ToGray2 methodsConvert an RGB image to grayscale while keeping 3 channels (Albumentations ToGray).
ToSepia2 methodsApply the canonical sepia-tone colour matrix (Albumentations ToSepia).
UnsharpMask3 methodsUnsharp-mask sharpen via img + alpha*(img - blur) (Albumentations UnsharpMask).
XYMasking3 methodsMask random horizontal and vertical bands of the image (Albumentations XYMasking).
Crop2 methodsCrop a fixed region [x_min, y_min, x_max, y_max) (Albumentations Crop).
CropAndPad2 methodsCrop (negative) or pad (positive) every side by px pixels.
PadIfNeeded2 methodsPad to at least min_height x min_width (Albumentations PadIfNeeded).
RandomSizedCrop3 methodsRandom-size crop then resize (Albumentations RandomSizedCrop).
ElasticTransform3 methodsElastic deformation (Simard 2003; Albumentations ElasticTransform).
GridDistortion3 methodsGrid distortion (Albumentations GridDistortion).
GridElasticDeform3 methodsGrid-based elastic deformation (Albumentations GridElasticDeform).
OpticalDistortion3 methodsRadial (barrel / pincushion) distortion (Albumentations OpticalDistortion).
AutoAugment3 methodsAutoAugment (Cubuk et al., 2019 — arXiv:1805.09501).
RandAugment3 methodsRandAugment (Cubuk et al., 2020 — arXiv:1909.13719).
TrivialAugmentWide3 methodsTrivial Augment Wide (Müller & Hutter, 2021 — arXiv:2103.10158).
CoarseDropout3 methodsDrop several random rectangles (Albumentations CoarseDropout).
GridDropout3 methodsDrop a regular grid of squares (Albumentations GridDropout).
RandomErasing3 methodsErase a random rectangular region of the image (Zhong et al., 2017).
Interpolation1 methodsResampling mode for resize-style transforms.
ColorJitter3 methodsRandomly jitter brightness/contrast/saturation/hue.
FromFloat2 methodsScale a [0, 1] image back up by max_value (Albumentations FromFloat).
Normalize2 methodsNormalize an image (Albumentations Normalize).
ToFloat2 methodsScale an integer-range image to [0, 1] (Albumentations ToFloat).
AutoTransformsPreset2 methodsResolver mirroring Hugging Face's AutoImageProcessor.
Detection1 methodsObject-detection preset — coordinates ride with the image.
ImageClassification1 methodsStandard ImageNet classification inference preset.
ImageClassificationAugment1 methodsStandard ImageNet classification training preset (augmentation).
Pose1 methodsKeypoint / pose-estimation preset.
Segmentation1 methodsSemantic-segmentation preset — image + mask share geometry.
TransformsPreset4 methodsAbstract base for task-specific preprocessing presets.
Affine3 methodsGeneral affine: scale / translate / rotate / shear (Albumentations Affine).
D43 methodsRandom element of the dihedral group D4 (Albumentations D4).
Flip3 methodsFlip around a random axis (Albumentations Flip).
Perspective3 methodsRandom four-point perspective warp (Albumentations Perspective).
RandomGridShuffle3 methodsSplit into a grid and shuffle the cells (Albumentations RandomGridShuffle).
RandomRotate903 methodsRotate by a random multiple of 90° (Albumentations RandomRotate90).
RandomScale3 methodsResize by a random factor, aspect preserved (Albumentations RandomScale).
Rotate3 methodsRotate by a random angle in [-limit, limit] (Albumentations Rotate).
SafeRotate3 methodsRotate by a random angle, expanding the canvas to keep all content (Albumentations SafeRotate).
ShiftScaleRotate3 methodsRandom shift + scale + rotation (Albumentations ShiftScaleRotate).
Transpose2 methodsSwap the H and W axes with probability p (Albumentations Transpose).