Skip to content
class

VideoClassification

extendsTransformsPreset
VideoClassification(crop_size: int, resize_size: int | None = None, mean: tuple[float, ...] | None = None, std: tuple[float, ...] | None = None, interpolation: str | Interpolation = Interpolation.BILINEAR)

Inference preset for a decoded video clip.

The released video encoders preprocess a clip by running the ordinary ImageNet evaluation pipeline on every frame — shortest side to crop_size * 256 / 224, centre crop, rescale, ImageNet normalise, bilinear throughout. Nothing is done across time: no temporal resampling, no frame selection. Which frames reach this is the caller's decision, because it is the decoder's.

Decoding is not done here and cannot be: reading a container is an external dependency, and Lucid's compute path takes none (H4). The input is an already-decoded clip.

Parameters

crop_sizeint
Square centre crop, per frame. The released encoders use 256, or 384 for the high-resolution ViT-g.
resize_sizeint or None= None
Shortest side before the crop. Defaults to the released rule, int(crop_size * 256 / 224) — 292 for a 256 crop; it truncates, where rounding would give 293.
meantuple of float= None
Channel statistics; ImageNet's by default.
stdtuple of float= None
Channel statistics; ImageNet's by default.
interpolationstr or Interpolation= Interpolation.BILINEAR
Resampling filter, bilinear by default as the release uses.

Examples

A clip in, a clip out — (T, C, H, W) both sides:
>>> import lucid, lucid.utils.transforms as T
>>> preset = T.VideoClassification(crop_size=64)
>>> tuple(preset(T.Image(lucid.rand(4, 3, 90, 120))).data.shape)
(4, 3, 64, 64)

Used by 1

Constructors

1
dunder

__init__

→None
__init__(crop_size: int, resize_size: int | None = None, mean: tuple[float, ...] | None = None, std: tuple[float, ...] | None = None, interpolation: str | Interpolation = Interpolation.BILINEAR)