|
@@ -159,7 +159,7 @@ class ToMode(VisionTransform): |
|
|
while the Neural Network might use CHW mode input tensor |
|
|
while the Neural Network might use CHW mode input tensor |
|
|
|
|
|
|
|
|
:param mode: Output mode of input. Use "CHW" mode by default. |
|
|
:param mode: Output mode of input. Use "CHW" mode by default. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, mode="CHW", *, order=None): |
|
|
def __init__(self, mode="CHW", *, order=None): |
|
@@ -185,14 +185,14 @@ class Compose(VisionTransform): |
|
|
r""" |
|
|
r""" |
|
|
Composes several transforms together. |
|
|
Composes several transforms together. |
|
|
|
|
|
|
|
|
:param transforms: List of ``VisionTransform`` to compose. |
|
|
|
|
|
|
|
|
:param transforms: List of :class:`VisionTransform` to compose. |
|
|
:param batch_compose: Whether use shuffle_indices for batch data or not. |
|
|
:param batch_compose: Whether use shuffle_indices for batch data or not. |
|
|
If True, use original input sequence. |
|
|
If True, use original input sequence. |
|
|
Otherwise, the shuffle_indices will be used for transforms. |
|
|
Otherwise, the shuffle_indices will be used for transforms. |
|
|
:param shuffle_indices: Indices used for random shuffle, start at 1. |
|
|
:param shuffle_indices: Indices used for random shuffle, start at 1. |
|
|
For example, if shuffle_indices is [(1, 3), (2, 4)], then the 1st and 3rd transform |
|
|
For example, if shuffle_indices is [(1, 3), (2, 4)], then the 1st and 3rd transform |
|
|
will be random shuffled, the 2nd and 4th transform will also be shuffled. |
|
|
will be random shuffled, the 2nd and 4th transform will also be shuffled. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
|
|
|
|
|
|
Example: |
|
|
Example: |
|
|
|
|
|
|
|
@@ -265,7 +265,7 @@ class TorchTransformCompose(VisionTransform): |
|
|
such as Normalize and ToTensor in torchvision. |
|
|
such as Normalize and ToTensor in torchvision. |
|
|
|
|
|
|
|
|
:param transforms: The same with ``Compose`` |
|
|
:param transforms: The same with ``Compose`` |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, transforms, *, order=None): |
|
|
def __init__(self, transforms, *, order=None): |
|
@@ -312,7 +312,7 @@ class Pad(VisionTransform): |
|
|
:param value: Padding value of image, could be a sequence of int or float. |
|
|
:param value: Padding value of image, could be a sequence of int or float. |
|
|
if it's float value, the dtype of image will be casted to float32 also. |
|
|
if it's float value, the dtype of image will be casted to float32 also. |
|
|
:param mask_value: Padding value of segmentation map. |
|
|
:param mask_value: Padding value of segmentation map. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, size=0, value=0, mask_value=0, *, order=None): |
|
|
def __init__(self, size=0, value=0, mask_value=0, *, order=None): |
|
@@ -358,7 +358,7 @@ class Resize(VisionTransform): |
|
|
* cv2.INTER_AREA – resampling using pixel area relation. |
|
|
* cv2.INTER_AREA – resampling using pixel area relation. |
|
|
* cv2.INTER_CUBIC – a bicubic interpolation over 4×4 pixel neighborhood. |
|
|
* cv2.INTER_CUBIC – a bicubic interpolation over 4×4 pixel neighborhood. |
|
|
* cv2.INTER_LANCZOS4 – a Lanczos interpolation over 8×8 pixel neighborhood. |
|
|
* cv2.INTER_LANCZOS4 – a Lanczos interpolation over 8×8 pixel neighborhood. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, output_size, interpolation=cv2.INTER_LINEAR, *, order=None): |
|
|
def __init__(self, output_size, interpolation=cv2.INTER_LINEAR, *, order=None): |
|
@@ -477,7 +477,7 @@ class RandomResize(VisionTransform): |
|
|
r"""Resize the input data randomly. |
|
|
r"""Resize the input data randomly. |
|
|
|
|
|
|
|
|
:param scale_range: . |
|
|
:param scale_range: . |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, scale_range, interpolation=cv2.INTER_LINEAR, *, order=None): |
|
|
def __init__(self, scale_range, interpolation=cv2.INTER_LINEAR, *, order=None): |
|
@@ -525,7 +525,7 @@ class RandomCrop(VisionTransform): |
|
|
:param output_size: Target size of output image, with (height, width) shape. |
|
|
:param output_size: Target size of output image, with (height, width) shape. |
|
|
:param padding_size: The same with `size` in ``Pad`` |
|
|
:param padding_size: The same with `size` in ``Pad`` |
|
|
:param padding_value: The same with `value` in ``Pad`` |
|
|
:param padding_value: The same with `value` in ``Pad`` |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__( |
|
|
def __init__( |
|
@@ -583,7 +583,7 @@ class RandomResizedCrop(VisionTransform): |
|
|
:param output_size: Target size of output image, with (height, width) shape. |
|
|
:param output_size: Target size of output image, with (height, width) shape. |
|
|
:param scale_range: Range of size of the origin size cropped. Default: (0.08, 1.0) |
|
|
:param scale_range: Range of size of the origin size cropped. Default: (0.08, 1.0) |
|
|
:param ratio_range: Range of aspect ratio of the origin aspect ratio cropped. Default: (0.75, 1.33) |
|
|
:param ratio_range: Range of aspect ratio of the origin aspect ratio cropped. Default: (0.75, 1.33) |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__( |
|
|
def __init__( |
|
@@ -667,7 +667,7 @@ class CenterCrop(VisionTransform): |
|
|
r"""Crops the given the input data at the center. |
|
|
r"""Crops the given the input data at the center. |
|
|
|
|
|
|
|
|
:param output_size: Target size of output image, with (height, width) shape. |
|
|
:param output_size: Target size of output image, with (height, width) shape. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, output_size, *, order=None): |
|
|
def __init__(self, output_size, *, order=None): |
|
@@ -710,7 +710,7 @@ class RandomHorizontalFlip(VisionTransform): |
|
|
r"""Horizontally flip the input data randomly with a given probability. |
|
|
r"""Horizontally flip the input data randomly with a given probability. |
|
|
|
|
|
|
|
|
:param p: probability of the input data being flipped. Default: 0.5 |
|
|
:param p: probability of the input data being flipped. Default: 0.5 |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, prob: float = 0.5, *, order=None): |
|
|
def __init__(self, prob: float = 0.5, *, order=None): |
|
@@ -742,7 +742,7 @@ class RandomVerticalFlip(VisionTransform): |
|
|
r"""Vertically flip the input data randomly with a given probability. |
|
|
r"""Vertically flip the input data randomly with a given probability. |
|
|
|
|
|
|
|
|
:param p: probability of the input data being flipped. Default: 0.5 |
|
|
:param p: probability of the input data being flipped. Default: 0.5 |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, prob: float = 0.5, *, order=None): |
|
|
def __init__(self, prob: float = 0.5, *, order=None): |
|
@@ -778,7 +778,7 @@ class Normalize(VisionTransform): |
|
|
|
|
|
|
|
|
:param mean: Sequence of means for each channel. |
|
|
:param mean: Sequence of means for each channel. |
|
|
:param std: Sequence of standard deviations for each channel. |
|
|
:param std: Sequence of standard deviations for each channel. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, mean=0.0, std=1.0, *, order=None): |
|
|
def __init__(self, mean=0.0, std=1.0, *, order=None): |
|
@@ -802,7 +802,7 @@ class GaussianNoise(VisionTransform): |
|
|
|
|
|
|
|
|
:param mean: Gaussian mean used to generate noise. |
|
|
:param mean: Gaussian mean used to generate noise. |
|
|
:param std: Gaussian standard deviation used to generate noise. |
|
|
:param std: Gaussian standard deviation used to generate noise. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, mean=0.0, std=1.0, *, order=None): |
|
|
def __init__(self, mean=0.0, std=1.0, *, order=None): |
|
@@ -828,7 +828,7 @@ class BrightnessTransform(VisionTransform): |
|
|
|
|
|
|
|
|
:param value: How much to adjust the brightness. Can be any |
|
|
:param value: How much to adjust the brightness. Can be any |
|
|
non negative number. 0 gives the original image |
|
|
non negative number. 0 gives the original image |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, value, *, order=None): |
|
|
def __init__(self, value, *, order=None): |
|
@@ -859,7 +859,7 @@ class ContrastTransform(VisionTransform): |
|
|
|
|
|
|
|
|
:param value: How much to adjust the contrast. Can be any |
|
|
:param value: How much to adjust the contrast. Can be any |
|
|
non negative number. 0 gives the original image |
|
|
non negative number. 0 gives the original image |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, value, *, order=None): |
|
|
def __init__(self, value, *, order=None): |
|
@@ -890,7 +890,7 @@ class SaturationTransform(VisionTransform): |
|
|
|
|
|
|
|
|
:param value: How much to adjust the saturation. Can be any |
|
|
:param value: How much to adjust the saturation. Can be any |
|
|
non negative number. 0 gives the original image |
|
|
non negative number. 0 gives the original image |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, value, *, order=None): |
|
|
def __init__(self, value, *, order=None): |
|
@@ -921,7 +921,7 @@ class HueTransform(VisionTransform): |
|
|
|
|
|
|
|
|
:param value: How much to adjust the hue. Can be any number |
|
|
:param value: How much to adjust the hue. Can be any number |
|
|
between 0 and 0.5, 0 gives the original image |
|
|
between 0 and 0.5, 0 gives the original image |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, value, *, order=None): |
|
|
def __init__(self, value, *, order=None): |
|
@@ -969,7 +969,7 @@ class ColorJitter(VisionTransform): |
|
|
:param hue: How much to jitter hue. |
|
|
:param hue: How much to jitter hue. |
|
|
Chosen uniformly from [-hue, hue] or the given [min, max]. |
|
|
Chosen uniformly from [-hue, hue] or the given [min, max]. |
|
|
Should have 0<= hue <= 0.5 or -0.5 <= min <= max <= 0.5. |
|
|
Should have 0<= hue <= 0.5 or -0.5 <= min <= max <= 0.5. |
|
|
:param order: The same with ``VisionTransform`` |
|
|
|
|
|
|
|
|
:param order: The same with :class:`VisionTransform` |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, brightness=0, contrast=0, saturation=0, hue=0, *, order=None): |
|
|
def __init__(self, brightness=0, contrast=0, saturation=0, hue=0, *, order=None): |
|
|