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.
Attributes
preset_typeClassVar[str]Short identifier (e.g.
"ImageClassification") used as the
preprocessor_type key in to_dict / from_dict.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.