trw.transforms.transforms_random_crop
¶
Module Contents¶
Classes¶
Add padding on a numpy array of samples and random crop to original size |
|
Add random padding & cropping on a numpy or Torch arrays. The arrays are joints and the same padding/cropping applied on all the arrays |
Functions¶
|
Add a specified padding to the image and randomly crop it so that we have the same size as the original |
- trw.transforms.transforms_random_crop._transform_random_crop(feature_name, feature_value, padding, mode='edge', constant_value=0, size=None)¶
Add a specified padding to the image and randomly crop it so that we have the same size as the original image
This support joint padding & cropping of multiple arrays (e.g., to support segmentation maps)
- Parameters
feature_name – a feature name or a list of feature names
feature_value – the value of the feature or a list of feature values
padding – the padding to add to the feature value. If None, no padding added
constant_value – a constant value, depending on the mode selected
padding – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the beginning and at the end of each dimension (except for dimension 0)
mode – numpy.pad mode. Currently supported are (‘constant’, ‘edge’, ‘symmetric’)
size – if None, the image will be cropped to the original size, else it must be a list of the size to crop for each dimension except for dimension 0
- Returns
a padded and cropped image to original size
- class trw.transforms.transforms_random_crop.TransformRandomCrop(padding, criteria_fn=None, mode='edge', constant_value=0, size=None)¶
Bases:
trw.transforms.transforms.TransformBatchWithCriteria
Add padding on a numpy array of samples and random crop to original size
- Parameters
padding – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the beginning and at the end of each dimension (except for dimension 0). If None, no padding added
criteria_fn – function applied on each feature. If satisfied, the feature will be transformed, if not the original feature is returned
mode – numpy.pad mode. Currently supported are (‘constant’, ‘edge’, ‘symmetric’)
size – the size of the cropped image. If None, same size as input image
- Returns
a randomly cropped batch
- class trw.transforms.transforms_random_crop.TransformRandomCropJoint(feature_names, padding, mode='edge', constant_value=0, size=None)¶
Bases:
trw.transforms.transforms.TransformBatchJointWithCriteria
Add random padding & cropping on a numpy or Torch arrays. The arrays are joints and the same padding/cropping applied on all the arrays
- Parameters
feature_names – these are the features that will be jointly padded and cropped
padding – a sequence of size len(array.shape)-1 indicating the width of the padding to be added at the beginning and at the end of each dimension (except for dimension 0). If None, no padding added
criteria_fn – function applied on each feature. If satisfied, the feature will be transformed, if not the original feature is returned
mode – numpy.pad mode. Currently supported are (‘constant’, ‘edge’, ‘symmetric’)
size – the size of the cropped image. If None, same size as input image
- Returns
a randomly cropped batch