affine
Affine
¶
Bases: MultiVariateAlbumentation
Perform affine transformations on an image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rotate
|
Union[None, Number, Tuple[Number, Number]]
|
How much to rotate an image (in degrees). If a single value is given then images will be rotated by a value sampled from the range [-n, n]. If a tuple (a, b) is given then each image will be rotated by a value sampled from the range [a, b]. |
None
|
scale
|
Union[None, float, Tuple[float, float]]
|
How much to scale an image (in percentage). If a single value is given then all images will be scaled by a value drawn from the range [1.0, n]. If a tuple (a,b) is given then each image will be scaled based on a value drawn from the range [a,b]. |
None
|
shear
|
Union[None, Number, Tuple[Number, Number]]
|
How much to shear an image (in degrees). If a single value is given then all images will be sheared on X and Y by two values sampled from the range [-n, n]. If a tuple (a, b) is given then images will be sheared on X and Y by two values randomly sampled from the range [a, b]. |
None
|
translate
|
Union[None, Number, Tuple[Number, Number]]
|
How much to translate an image. If a single value is given then the translation extent will be sampled from the range [0,n]. If a tuple (a,b) is given then the extent will be sampled from the range [a,b]. If integers are given then the translation will be in pixels. If a float then it will be as a fraction of the image size. |
None
|
border_handling
|
Union[str, List[str]]
|
What to do in order to fill newly created pixels. Options are 'constant', 'edge', 'symmetric', 'reflect', and 'wrap'. If a list is given, then the method will be randomly selected from the options in the list. |
'constant'
|
fill_value
|
Number
|
What pixel value to insert for image when border_handling is 'constant'. |
0
|
fill_value_mask
|
Union[None, Number]
|
Same as fill_value but only for masks. |
None
|
interpolation
|
str
|
What interpolation method to use for image. Options (from fast to slow) are 'nearest_neighbor', 'bilinear', 'bicubic', 'biquartic', and 'biquintic'. |
'bilinear'
|
mask_interpolation
|
str
|
Same as interpolation for mask. 'nearest_neighbor' is recommended by Albumentation. |
'nearest_neighbor'
|
fit_output
|
bool
|
If True, the image plane size and position will be adjusted to tightly capture the whole image after affine transformation (translate_percent and translate_px are ignored). Otherwise (False), parts of the transformed image may end up outside the image plane. Fitting the output shape can be useful to avoid corners of the image being outside the image plane after applying rotations. |
False
|
keep_ratio
|
bool
|
When True, the original aspect ratio will be kept when the random scale is applied. |
False
|
rotate_method
|
str
|
rotation method used for the bounding boxes. Should be one of "largest_box" or "ellipse". |
'largest_box'
|
mode
|
Union[None, str, Iterable[str]]
|
What mode(s) to execute this Op in. For example, "train", "eval", "test", or "infer". To execute regardless of mode, pass None. To execute in all modes except for a particular one, you can pass an argument like "!infer" or "!train". |
None
|
ds_id
|
Union[None, str, Iterable[str]]
|
What dataset id(s) to execute this Op in. To execute regardless of ds_id, pass None. To execute in all ds_ids except for a particular one, you can pass an argument like "!ds1". |
None
|
image_in
|
Optional[str]
|
The key of an image to be modified. |
None
|
mask_in
|
Optional[str]
|
The key of a mask to be modified (with the same random factors as the image). |
None
|
masks_in
|
Optional[Iterable[str]]
|
The list of mask keys to be modified (with the same random factors as the image). |
None
|
bbox_in
|
Optional[str]
|
The key of a bounding box(es) to be modified (with the same random factors as the image). |
None
|
keypoints_in
|
Optional[str]
|
The key of keypoints to be modified (with the same random factors as the image). |
None
|
image_out
|
Optional[str]
|
The key to write the modified image (defaults to |
None
|
mask_out
|
Optional[str]
|
The key to write the modified mask (defaults to |
None
|
masks_out
|
Optional[Iterable[str]]
|
The list of keys to write the modified masks (defaults to |
None
|
bbox_out
|
Optional[str]
|
The key to write the modified bounding box(es) (defaults to |
None
|
keypoints_out
|
Optional[str]
|
The key to write the modified keypoints (defaults to |
None
|
bbox_params
|
Union[BboxParams, str, None]
|
Parameters defining the type of bounding box ('coco', 'pascal_voc', 'albumentations' or 'yolo'). |
None
|
keypoint_params
|
Union[KeypointParams, str, None]
|
Parameters defining the type of keypoints ('xy', 'yx', 'xya', 'xys', 'xyas', 'xysa'). |
None
|
Image types
uint8, float32
Source code in fastestimator/fastestimator/op/numpyop/multivariate/affine.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|