trw.transforms.transforms_random_crop_resize

Module Contents

Classes

TransformRandomCropResize

Randomly crop a tensor and resize to its original shape.

Functions

_transform_random_crop_resize(features_names, batch, crop_size, resize_mode)

trw.transforms.transforms_random_crop_resize._transform_random_crop_resize(features_names, batch, crop_size, resize_mode)
class trw.transforms.transforms_random_crop_resize.TransformRandomCropResize(crop_size: trw.basic_typing.ShapeX, criteria_fn: Optional[trw.transforms.transforms.CriteriaFn] = None, resize_mode: typing_extensions.Literal[nearest, linear, none] = 'linear')

Bases: trw.transforms.transforms.TransformBatchWithCriteria

Randomly crop a tensor and resize to its original shape.

Parameters
  • crop_size – a sequence of size len(array.shape)-2 indicating the width of crop, excluding the N and C components

  • criteria_fn – function applied on each feature. If satisfied, the feature will be transformed, if not the original feature is returned

  • resize_mode – string among (‘nearest’, ‘linear’, ‘none’) specifying the resampling method

Returns

a transformed batch