Skip to content
class

Compose

extends_NoParamsTransform[Empty]
Compose(transforms: list[TransformLike], bbox_params: BboxParams | None = None)

Chain transforms into one callable (works on tensors or samples).

Parameters

transformslist of Transform
Applied left-to-right; each transform's output feeds the next.
bbox_paramsBboxParams= None
When given, bounding boxes are filtered after the pipeline by min_area / min_visibility (degenerate boxes that left the frame are dropped, along with their labels).

Examples

>>> import lucid
>>> from lucid.utils.transforms import (
...     Compose, Resize, CenterCrop, Normalize, Image,
... )
>>> tf = Compose([
...     Resize(256, 256),
...     CenterCrop(224, 224),
...     Normalize(mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225),
...               max_pixel_value=1.0),
... ])
>>> tuple(tf(Image(lucid.rand(3, 300, 400))).data.shape)
(3, 224, 224)

Used by 2

Constructors

2
dunder

__init__

→None
__init__(transforms: list[TransformLike], bbox_params: BboxParams | None = None)
dunder

__call__

→object
__call__(inputs: object)

Instance methods

1
fn

make_params

→Emptyfrom _NoParams
make_params(img: Tensor)

Dunder methods

1