Transforms¶
Eztorch supports transforms from Torchaug and from Torchvision.
On top of that, several video transforms have been defined.
Video transforms¶
Apply key¶
- class eztorch.transforms.ApplyTransformToKey(key, transform)[source]¶
Applies transform to key of dictionary input.
- Parameters:
key (
str
) – The dictionary key the transform is applied to.transform (
Module
) – The transform that is applied.
- class eztorch.transforms.ApplyTransformToKeyOnList(key, transform)[source]¶
Applies transform to key of dictionary input where input is a list :type key:
str
:param key: the dictionary key the transform is applied to. :type transform:Module
:param transform: the transform that is applied.- Example::
>>> transforms.ApplyTransformToKeyOnList( >>> key='input', >>> transform=UniformTemporalSubsample(num_video_samples), >>> )
- class eztorch.transforms.ApplySameTransformInputKeyOnList(transform, dim=1)[source]¶
Apply same transform to the input list key.
- Parameters:
transform (
Module
) – The transform to apply.dim (
int
, optional) – The dimension to retrieve the various elements of the list.Default:1
- class eztorch.transforms.ApplySameTransformToKeyOnList(key, transform, dim=1)[source]¶
Applies the same transform to key of dictionary input where input is a list.
- Parameters:
key (
str
) – the dictionary key the transform is applied to.transform (
Module
) – the transform that is applied.dim (
int
, optional) – The dimension to retrieve the various elements of the list.Default:1
- class eztorch.transforms.ApplyTransformAudioKey(transform)[source]¶
Apply Transform to the audio key.
- Parameters:
transform (
Module
) – The transform to apply.
- class eztorch.transforms.ApplyTransformAudioKeyOnList(transform)[source]¶
Apply Transform to the audio key.
- Parameters:
transform (
Module
) – The transform to apply.
- class eztorch.transforms.ApplyTransformInputKey(transform)[source]¶
Apply Transform to the input key.
- Parameters:
transform (
Module
) – The transform to apply.
- class eztorch.transforms.ApplyTransformInputKeyOnList(transform)[source]¶
Apply Transform to the input key.
- Parameters:
transform (
Module
) – The transform to apply.
- class eztorch.transforms.ApplyTransformOnDict(transform)[source]¶
Apply Transform to the audio key.
- Parameters:
transform (
Module
) – The transform to apply.
Apply transform on list¶
- class eztorch.transforms.ApplyTransformOnList(transform, list_len=2)[source]¶
Apply transform to a list of input.
- Parameters:
transform (
Module
) – A transform for the list of input.list_len (
int
, optional) – len of the input.Default:2
- class eztorch.transforms.ApplyTransformsOnList(transforms)[source]¶
Apply transform to a list of input.
- Parameters:
transform – A transform for the list of input.
list_len – len of the input.
Dict keep keys¶
- class eztorch.transforms.DictKeepKeys(keys)[source]¶
Keep specified keys in dict.
References
- Parameters:
keys (
List
[str
]) – The list of keys to keep.
Div 255¶
Multi-crop¶
- class eztorch.transforms.MultiCropTransform(set_transforms)[source]¶
Define multi crop transform that apply several sets of transform to the inputs.
- Parameters:
set_transforms (
List
[Any
]) – List of Dictionary of sets of transforms specifying transforms and number of views per set.
Example:
set_transforms = [ {'transform': [...], 'num_views': ...}, {'transform': [...], 'num_views': ...}, ... ] transform = MultiCropTransform( set_transforms )
Only input transform¶
- class eztorch.transforms.OnlyInputTransform(transform)[source]¶
Apply Transform to only the key
'input'
in a sample dictionary.- Parameters:
transform (
Callable
) – The transform to apply.
- class eztorch.transforms.OnlyInputListTransform(transform)[source]¶
Apply Transform to only the key
'input'
in a list of sample dictionary.- Parameters:
transform (
Callable
) – The transform to apply.
- class eztorch.transforms.OnlyInputListSameTransform(transform)[source]¶
Apply the same transform to only the key
'input'
in a list of sample dictionary.- Parameters:
transform (
Callable
) – The transform to apply.
- class eztorch.transforms.OnlyInputTransformWithDictTransform(transform, dict_transform, first_dict=False)[source]¶
Apply Transform to only the key
'input'
in a sample dictionary with a transformation on the dictionary afterwards.- Parameters:
transform (
Callable
) – The transform to apply to the input.dict_transform (
Callable
) – The transform to apply to the dictionary.first_dict (
bool
, optional) – IfTrue
, first apply the transformation on the dict, else, first apply the transformation on the input.Default:False
- class eztorch.transforms.OnlyInputListTransformWithDictTransform(transform, dict_transform, first_dict=False)[source]¶
Apply Transform to only the key
'input'
in a list of sample dictionary with a transformation on the dictionary afterwards.- Parameters:
transform (
Callable
) – The transform to apply to the input.dict_transform (
Callable
) – The transform to apply to the dictionary.first_dict (
bool
, optional) – IfTrue
, first apply the transformation on the dict, else, first apply the transformation on the input.