abstract
TransformsPreset
extends
_NoParamsTransform[Empty]ABCTransformsPreset(p: float = 1.0)Abstract base for task-specific preprocessing presets.
A preset is a thin wrapper over an internal Compose
pipeline (assembled in __init__ from the preset's task-
specific defaults) plus a serialisation contract. Subclasses
must:
- Set the
preset_typeclass variable to a unique short string used inconfig.json. - Declare the constructor's typed kwargs (no
**kwargs— enforces the schema explicitly). - Build
self._pipeline(aCompose) inside__init__. - Implement
_init_kwargsreturning the dict of constructor arguments needed to reconstruct an identical instance.
Parameters
pfloat= 1.0Probability of applying the transform; otherwise the input
passes through unchanged.
Attributes
preset_typeClassVar[str]Short identifier (e.g.
"ImageClassification") used as the
preprocessor_type key in to_dict / from_dict.Examples
The base of the ready-made pipelines — ImageClassification,
ImageClassificationAugment, Detection,
Segmentation, Pose. Each is the preprocessing its
task expects, so a caller reaches for one rather than assembling
resize, crop and normalise by hand:
>>> import lucid.utils.transforms as T
>>> sorted(c.__name__ for c in T.TransformsPreset.__subclasses__())
['Detection', 'ImageClassification', 'ImageClassificationAugment', 'Pose', 'Segmentation']Used by 1
Constructors
1Class methods
1from_dict(cfg: dict[str, object])Reconstruct a preset instance from a to_dict payload.
When called on the base TransformsPreset, dispatches
to the registered subclass named by cfg["preprocessor_type"];
when called on a concrete subclass, verifies the key matches
and constructs that subclass directly.
Parameters
cfgdict{"preprocessor_type": ..., "init_kwargs": {...}}.Returns
TransformsPresetNew instance of the named subclass.
Raises
KeyErrorIf
preprocessor_type is not in the registry.ValueErrorIf
cfg is missing required keys or preprocessor_type
disagrees with the class from_dict was called on.