class
ImageClassification
extends
TransformsPresetImageClassification(crop_size: int, resize_size: int = 256, mean: tuple[float, ...] | None = None, std: tuple[float, ...] | None = None, interpolation: str | Interpolation = Interpolation.BILINEAR)Standard ImageNet classification inference preset.
Pipeline: shorter side to resize_size (the reference's rule: the
longer side truncated, and low-pass filtered as it shrinks) →
CenterCrop(crop_size) → Normalize(mean, std). This is the
reference_vision evaluation pipeline shipped with most pretrained
image-classification weights.
Parameters
crop_sizeintSquare center-crop side fed to the model.
resize_sizeint= 256Shorter-side length before cropping.
meantuple of float= NonePer-channel normalization stats; default ImageNet.
stdtuple of float= NonePer-channel normalization stats; default ImageNet.
Resize interpolation mode.
Notes
Input is assumed already scaled to [0, 1] (prepend
lucid.utils.transforms.ToFloat for uint8).
Examples
The evaluation pipeline every ImageNet model in the zoo expects —
resize the shortest side, centre crop, normalise:
>>> import lucid, lucid.utils.transforms as T
>>> tf = T.ImageClassification(crop_size=224)
>>> tuple(tf(T.Image(lucid.rand(3, 300, 400))).data.shape)
(3, 224, 224)Used by 1
Constructors
1dunder
__init__
→None__init__(crop_size: int, resize_size: int = 256, mean: tuple[float, ...] | None = None, std: tuple[float, ...] | None = None, interpolation: str | Interpolation = Interpolation.BILINEAR)Initialise the module and validate the supplied config.
Parameters
configModelConfigMust be an instance of the subclass's declared
config_class.Raises
TypeErrorIf
config_class has not been set on the concrete subclass,
or if config is not an instance of config_class.