8.1.2.3. blueoil.data_augmentor
¶
8.1.2.3.1. Module Contents¶
8.1.2.3.1.1. Classes¶
Gaussian blur filter. |
|
Adjust image brightness. |
|
Adjust image color. |
|
Adjust image contrast. |
|
Crop image. |
|
Flip left right. |
|
Flip top bottom. |
|
Change image hue. |
|
Add padding to images. |
|
Cut out random patches of the image. |
|
Class that performs Random Erasing in Random Erasing Data Augmentation by Zhong et al. |
|
Class that performs Random Erasing in Random Erasing Data Augmentation by Zhong et al. |
|
SSD random crop. |
|
Rotate. |
8.1.2.3.1.2. Functions¶
|
Flip left right only bounding box. |
|
Flip top bottom only bounding box. |
|
Random Erasing in a box (util func). |
|
|
|
Resize image to scale size keeping the aspect ratio and place it in center of fill color image. |
-
class
blueoil.data_augmentor.
Blur
(value=(0, 1))¶ Bases:
blueoil.data_processor.Processor
Gaussian blur filter.
- Reference:
https://pillow.readthedocs.io/en/stable/reference/ImageFilter.html#PIL.ImageFilter.GaussianBlur
- Parameters
value (int | list | tuple) – Blur radius. Default is random number from 0 to 1. References default is 2.
-
__call__
(self, image, **kwargs)¶
-
class
blueoil.data_augmentor.
Brightness
(value=(0.75, 1.25))¶ Bases:
blueoil.data_processor.Processor
Adjust image brightness.
- Parameters
value (int | list | tuple) – An enhancement factor of 0.0 gives a black image. A factor of 1.0 gives the original image.
-
__call__
(self, image, **kwargs)¶
-
class
blueoil.data_augmentor.
Color
(value=(0.75, 1.25))¶ Bases:
blueoil.data_processor.Processor
Adjust image color.
- Parameters
value (int | list | tuple) – An enhancement factor of 0.0 gives a black and white image. A factor of 1.0 gives the original image.
-
__call__
(self, image, **kwargs)¶
-
class
blueoil.data_augmentor.
Contrast
(value=(0.75, 1.25))¶ Bases:
blueoil.data_processor.Processor
Adjust image contrast.
- Parameters
value (int | list | tuple) – An enhancement factor of 0.0 gives a solid grey image. A factor of 1.0 gives the original image.
-
__call__
(self, image, **kwargs)¶
-
class
blueoil.data_augmentor.
Crop
(size, resize=None)¶ Bases:
blueoil.data_processor.Processor
Crop image.
- Parameters
size (int | list | tuple) – Crop to this size.
resize (int | list | tuple) – If there are resize param, resize and crop.
-
__call__
(self, image, mask=None, **kwargs)¶
-
blueoil.data_augmentor.
_flip_left_right_boundingbox
(image, boxes)¶ Flip left right only bounding box.
- Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
boxes (np.ndarray) – bounding boxes. shape is [num_boxes, 5(x, y, w, h, class_id)]
-
class
blueoil.data_augmentor.
FlipLeftRight
(probability=0.5)¶ Bases:
blueoil.data_processor.Processor
Flip left right.
- Parameters
probability (number) – Probability for flipping.
-
__call__
(self, image, mask=None, gt_boxes=None, **kwargs)¶
-
blueoil.data_augmentor.
_flip_top_bottom_boundingbox
(img, boxes)¶ Flip top bottom only bounding box.
- Parameters
img – np array image.
boxes (np.ndarray) – bounding boxes. shape is [num_boxes, 5(x, y, w, h, class_id)]
-
class
blueoil.data_augmentor.
FlipTopBottom
(probability=0.5)¶ Bases:
blueoil.data_processor.Processor
Flip top bottom.
- Parameters
probability (number) – Probability for flipping.
-
__call__
(self, image, mask=None, gt_boxes=None, **kwargs)¶ - Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
mask (np.ndarray) – Annotation data for segmentation. shape is [height, width] or [height, width, channel]
gt_boxes – Ground truth boxes in the image. shape is [num_boxes, 5(x, y, w, h, class)]
- Returns
Contains processed image, mask, gt_boxes and etc.
- Return type
all args (dict)
-
class
blueoil.data_augmentor.
Hue
(value=(-10, 10))¶ Bases:
blueoil.data_processor.Processor
Change image hue.
- Parameters
value (int | list | tuple) – Assume the value in -255, 255. When the value is 0, nothing to do.
-
__call__
(self, image, **kwargs)¶
-
class
blueoil.data_augmentor.
Pad
(value, fill=0)¶ Bases:
blueoil.data_processor.Processor
Add padding to images.
- Parameters
value (int or tuple) – Padding on each border. If a single int is provided this is used to pad all borders. If tuple of length 2 is provided this is the padding on left/right and top/bottom respectively. If a tuple of length 4 is provided this is the padding for the left, top, right and bottom borders respectively.
fill (int) – Pixel fill value. Default is 0.
-
__call__
(self, image, mask=None, **kwargs)¶ - Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
mask (np.ndarray) – Annotation data for segmentation. shape is [height, width] or [height, width, channel]
- Returns
Contains processed image, mask and etc.
- Return type
all args (dict)
-
class
blueoil.data_augmentor.
RandomPatchCut
(num_patch=1, max_size=10, square=True)¶ Bases:
blueoil.data_processor.Processor
Cut out random patches of the image.
- Parameters
num_patch (int) – number of random patch cut-outs to generate
max_size (int) – maximum size of the patch edge, in percentages of image size
square (bool) – force square aspect ratio for patch shape
-
__call__
(self, image, **kwargs)¶ Cut random patches.
- Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
- Returns
Contains processed image and etc.
- Return type
all args (dict)
-
class
blueoil.data_augmentor.
RandomErasing
(probability=0.5, sl=0.02, sh=0.4, r1=0.3, content_type='mean', mean=[125, 122, 114])¶ Bases:
blueoil.data_processor.Processor
Class that performs Random Erasing in Random Erasing Data Augmentation by Zhong et al. The following Args(hyper parameters) are referred to the paper.
- Parameters
probability (float) – The probability that the operation will be performed.
sl (float) – min erasing area
sh (float) – max erasing area
r1 (float) – min aspect ratio
content_type (string) – type of erasing value: {“mean”, “random”}
mean (list) – erasing value if you use “mean” mode (mean ImageNet pixel value)
-
__call__
(self, image, **kwargs)¶ Random Erasing in an entire image.
- Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
gt_boxes – Ground truth boxes in the image. shape is [num_boxes, 5(x, y, w, h, class)]
- Returns
Contains processed image and etc.
- Return type
all args (dict)
-
class
blueoil.data_augmentor.
RandomErasingForDetection
(probability=0.5, sl=0.02, sh=0.2, r1=0.3, content_type='mean', mean=[125, 122, 114], i_a=True, o_a=True)¶ Bases:
blueoil.data_processor.Processor
Class that performs Random Erasing in Random Erasing Data Augmentation by Zhong et al. The following Args(hyper parameters) are referred to the paper. This Augmentation can be used when you train object detection task.
- Parameters
probability (float) – The probability that the operation will be performed.
sl (float) – min erasing area
sh (float) – max erasing area
r1 (float) – min aspect ratio
content_type (string) – type of erasing value: {“mean”, “random”}
mean (list) – erasing value if you use “mean” mode (mean ImageNet pixel value)
i_a (bool) – image-aware, random erase an entire image.
o_a (bool) – object-aware, random erase each object bounding boxes.
-
__call__
(self, image, gt_boxes=None, **kwargs)¶ Random Erasing in boxes (and an entire image).
- Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
gt_boxes – Ground truth boxes in the image. shape is [num_boxes, 5(x, y, w, h, class)]
- Returns
Contains processed image and etc.
- Return type
all args (dict)
-
blueoil.data_augmentor.
_random_erasing_in_box
(image, box, probability, sl, sh, r1, content_type, mean)¶ Random Erasing in a box (util func).
- Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
box – Ground truth boxes in the image. shape is boxes, [5(x, y, w, h, class)]
-
class
blueoil.data_augmentor.
SSDRandomCrop
(min_crop_ratio=0.3)¶ Bases:
blueoil.data_processor.Processor
SSD random crop. :param min_crop_ratio: Minimum crop ratio for cropping the :type min_crop_ratio: number
-
__call__
(self, image, gt_boxes, **kwargs)¶ SSDRandomCrop
- Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
gt_boxes – Ground truth boxes in the image. shape is [num_boxes, 5(x, y, w, h, class)]
- Returns
Contains processed image, gt_boxes and etc.
- Return type
all args (dict)
-
-
class
blueoil.data_augmentor.
Rotate
(angle_range=(0, 90))¶ Bases:
blueoil.data_processor.Processor
Rotate.
- Parameters
angle_range (int | list | tuple) – Angle range.
-
__call__
(self, image, mask=None, **kwargs)¶ - Parameters
image (np.ndarray) – a image. shape is [height, width, channel]
mask (np.ndarray) – Annotation data for segmentation. shape is [height, width] or [height, width, channel]
- Returns
Contains processed image, mask and etc.
- Return type
all args (dict)
-
blueoil.data_augmentor.
color_filter
(img)¶
-
blueoil.data_augmentor.
affine_scale
(img, scale, fill_color='white')¶ Resize image to scale size keeping the aspect ratio and place it in center of fill color image.