Data Augmentation
Overview of Data Augmentation Operators
Data augmentation is mainly used in scenarios where training data is insufficient or simulation is required. You can transform a labeled dataset to increase the number of images for training and generate corresponding labels. In the deep learning field, augmentation is of great significance. It can improve model generalization and enhance anti-disturbance. Original data is not changed during data augmentation. A newly augmented image or XML file is saved in the specified output path.
ModelArts provides the following data augmentation operators:
Operator |
Description |
Advanced |
---|---|---|
AddNoise |
Adds noises to simulate the noises that may be generated when common capture devices capture images. |
|
Blur |
Uses filters to filter images and sometimes to simulate imaging of imaging devices. |
|
Crop |
Randomly crops a part of an image to generate a new image. |
|
CutOut |
Random erase, which is a common method used in deep learning to simulate an object that is blocked by an obstacle. |
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
Flip |
Flips along the horizontal or vertical axis of an image, which is a very common augmentation method. |
|
Grayscale |
Changes a three-channel color image to a three-channel grayscale image. |
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
HistogramEqual |
Indicates the histogram equalization, which is mainly used to improve the visual effect of images. It is used in some scenarios. |
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
LightArithmetic |
Implements linear enhancement on luminance space. |
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
LightContrast |
Enhances luminance contrast. A certain non-linear function is used to change the luminance value of the luminance space. |
func: The default value is gamma.
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
MotionBlur |
Indicates the motion blur generated when an object moves. |
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
Padding |
Pads an image with black edges. |
|
Resize |
Resizes an image. |
|
Rotate |
Rotates an image around the center point. After the operation is complete, the original shape of the image remains unchanged, and the blank part is filled with black. |
|
Saturation |
Enhances chrominance and saturation. The H and S spaces in the HSV of an image are changed linearly to change the chrominance and saturation of the image. |
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
Scale |
Zooms in or out an image. The length or width of an image is randomly zoomed in or out. |
|
Sharpen |
Indicates image sharpening, which is used to sharpen the edges of objects. |
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
Shear |
Indicates image shearing, which is used for geometric transformation of images. Pixels are mapped using linear functions. |
|
Translate |
Moves an image along the x-axis or y-axis, discards the part that exceeds the original image, and fills the blank part with black. |
|
Weather |
Adds weather information to simulate the weather effect. |
weather_mode: weather mode. The default value is Rain.
do_validation: indicates whether to validate data before data augmentation. The default value is True. |
Operator Input Requirements
The following two types of operator input are available:
- Datasets: Select a dataset and its version created on the ModelArts console from the drop-down list. Ensure that the dataset type be the same as the scenario type selected in this task.
- OBS Catalog: The storage structure supports Images and labels.
Images and labels: The structure varies depending on the scenario type.
The following shows the directory structure in the image classification scenario. The following directory structure supports only single-label scenarios.
input_path/ --label1/ ----1.jpg --label2/ ----2.jpg --../
The following shows the directory structure in the object detection scenario. Images in JPG, JPEG, PNG, and BMP formats are supported. XML files are standard PACAL VOC files.
input_path/ --1.jpg --1.xml --2.jpg --2.xml ...
Output Description
Some data will be discarded due to some algorithm operations. Therefore, the output folder may not contain the full dataset. For example, Rotate will discard the images whose bounding boxes exceed the image boundaries.
The following shows the output directory structure. In this structure, the Data folder stores newly generated images and labeling information. The manifest file stores the structure of images in the folder and can be directly imported to the dataset in Data Management.
|----data_url |----Data |----xxx.jpg |----xxx.xml(xxx.txt) |----output.manifest
A manifest file example is as follows:
{ "id": "xss", "source": "obs://home/fc8e2688015d4a1784dcbda44d840307_14.jpg", "usage": "train", "annotation": [ { "name": "Cat", "type": "modelarts/image_classification" } ] }
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.