A nested cover data augmentation method
Patent Information
- Application Number
- CN202410988381.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2044-07-23
AI Technical Summary
[0004]本发明要解决的技术问题是:提供一种嵌套遮盖数据增强方法,解决了现有数据增强算法在缓解过拟合问题时存在完全遮挡目标等问题,提高模型泛化能力,有效提升包含小目标的分类准确率
[0008] The beneficial effects of this invention are that it solves the defects existing in the background technology, adds a random nested structure to the existing data augmentation method, and releases a part of the occluded area through random anti-masking operation; using this invention, image data of different classifications can be preprocessed, improving the generalization ability and classification accuracy of the classification model without affecting the model training and inference efficiency; at the same time, this invention retains the randomness of the cutout algorithm and the structural persistence of GridMask and FenceMask, avoiding the extra feature map calculation time caused by KeepAugment, and generally improving the classification accuracy and model generalization ability on the dataset.
Smart Images

Figure CN119006887B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual inspection technology, and in particular to a method for nested occlusion data augmentation. Background Technology
[0002] In existing technologies, data augmentation methods include the following: 1. Cutout (proposed in 2017): The Cutout algorithm randomly extracts a fixed-size square mask region from the image and assigns it a fixed value (usually black). 2. Random Erasing (proposed in 2017): Random Erasing is similar to the Cutout algorithm, but the difference is that the length and width of the mask region randomly selected by the Random Erasing algorithm are not fixed, and the replacement value of the mask region is also not fixed. 3. Hide-and-Seek (proposed in 2018): The HaS algorithm divides the original image into small blocks, and each block becomes a masked region with a certain probability; 4. GridMask (proposed in 2020): The GridMask algorithm uses a grid method for equidistant masking, so that the target area is not completely covered by the mask area; 5. FenceMask (proposed in 2020): Similar to GridMask, FenceMask replaces GridMask's equidistant grid with a tilted equidistant grid. 6. KeepAugment (proposed in 2020): The KeepAugment algorithm uses feature maps to locate mask regions, thereby preventing the target region from being covered by the mask.
[0003] However, the above-mentioned existing technologies have the following drawbacks: 1. Masks used in Cutout (proposed in 2017), Random Erasing (proposed in 2017), and Hide-and-Seek (proposed in 2018) tend to destroy the feature structure of the original image. 2. GridMask (proposed in 2020), FenceMask (proposed in 2020): The equidistant problem of GridMask makes the occlusion lack random flexibility; 3. KeepAugment (proposed in 2020): Training time caused by feature map computation. Summary of the Invention
[0004] The technical problem to be solved by this invention is to provide a nested occlusion data augmentation method, which solves the problem of complete target occlusion in existing data augmentation algorithms when alleviating overfitting, improves the generalization ability of the model, and effectively improves the classification accuracy of small targets.
[0005] The technical solution adopted by this invention to solve its technical problem is: a nested masking data augmentation method, comprising the following steps, S1. Obtain an image and set initial parameters; initial parameters include initial occlusion side length, nesting ratio, and nesting number; S2. Randomly cover the image according to the set initial covering side length to obtain the covering area; S3. Calculate the nesting side length of the un-covered area in the covered area according to the preset nesting ratio and perform random un-covering. S4. Calculate the nesting side length of the next occlusion area based on the preset nesting ratio in the random anti-occlusion area and perform random occlusion. S5. Alternately repeat steps S3 and S4; S6. Repeat until the preset number of nestings is met.
[0006] Furthermore, in step S5 of the present invention, if the previous operation was a masking operation, then the next operation is a reverse masking operation; if the previous operation was a reverse masking operation, then the next operation is a masking operation.
[0007] Furthermore, the method for calculating the nesting side length for each nesting in this invention is as follows: c n = c*r n Where c is the initial occlusion side length, r is the nesting ratio, and n is the number of nestings.
[0008] The beneficial effects of this invention are that it solves the defects existing in the background technology, adds a random nested structure to the existing data augmentation method, and releases a part of the occluded area through random anti-masking operation; using this invention, image data of different classifications can be preprocessed, improving the generalization ability and classification accuracy of the classification model without affecting the model training and inference efficiency; at the same time, this invention retains the randomness of the cutout algorithm and the structural persistence of GridMask and FenceMask, avoiding the extra feature map calculation time caused by KeepAugment, and generally improving the classification accuracy and model generalization ability on the dataset. Attached Figure Description
[0009] Figure 1 This is a schematic diagram of the method flow of the present invention; Figure 2 This is a schematic diagram illustrating the effect of the present invention. Detailed Implementation
[0010] The present invention will now be described in further detail with reference to the accompanying drawings and preferred embodiments. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0011] like Figure 1 The method shown is a nested masking data augmentation method for enhancing image data. It involves randomly selecting a small square region M1 in region M0 for demasking, and then randomly selecting an even smaller square region M2 in region M1 for masking. This process is repeated, with the masking and demasking processes nested and looped several times. Specifically, it includes the following steps: Obtain an image m. Based on a pre-set initial occlusion side length c, randomly occlude the image m. Then, within the occluded area, calculate the side length c1 of the unoccluded area according to a preset nesting ratio r, and randomly unocclude it. Subsequently, within the randomly unoccluded area, calculate the side length c2 of the occluded area according to the preset nesting ratio r, and randomly occlude it. If the previous operation was occlusion, the next operation will be unocclusion; if the previous operation was unocclusion, the next operation will be occlusion. Repeat this process until a preset nesting number n is met. Specifically, when n is 0, the algorithm evolves into the Cutout algorithm.
[0012] like Figure 2 As shown, a 16*16 area is randomly selected from a 128*128 image for masking, and then an 8*8 area is randomly selected from the 16*16 area for reverse masking, and this process is repeated. The calculation method is as follows: 1. Set the initial occlusion side length c, the nesting number n, and the nesting ratio r: (1) The initial masking side length c is the side length of the outermost mask; (2) When n = 0, nestcutout degenerates into cutout; (3) r is the nesting side length of each layer, and the formula for calculating the side length of the nth nesting layer is c. n = c*r n ; 2. Alternate between masking and unmasking; When n>0, occlusion and de-occlusion alternate; for example, n = 0 is occlusion, n = 1 is de-occlusion, n = 2 is occlusion, and so on. The calculation formula is as follows: M n = (n+2)%2 M is obtained by performing a modulo operation on each layer n. n As fill value for the mask region; 3. Obtain the final NestCutout image; Multiply the synthesized M with the original image to obtain the final NestCutout image.
[0013] The above description is only a specific embodiment of the present invention. Various examples and illustrations do not constitute a limitation on the substantive content of the present invention. Those skilled in the art can make modifications or variations to the above-described specific embodiments after reading the specification without departing from the substance and scope of the invention.
Claims
1. A nested masking data augmentation method, characterized in that: Includes the following steps, S1. Obtain an image and set initial parameters; initial parameters include initial occlusion side length, nesting ratio, and nesting number; S2. Randomly cover the image according to the set initial covering side length to obtain the covering area; S3. Calculate the nesting side length of the un-covered area in the covered area according to the preset nesting ratio and perform random un-covering. S4. Calculate the nesting side length of the next occlusion area based on the preset nesting ratio in the random anti-occlusion area and perform random occlusion. S5. Alternately repeat steps S3 and S4; S6. Repeat until the preset number of nestings is met.
2. The nested masking data augmentation method as described in claim 1, characterized in that: In step S5, if the previous operation was a masking operation, then the next operation will be a demasking operation; if the previous operation was a demasking operation, then the next operation will be a masking operation.
3. The nested masking data augmentation method as described in claim 1, characterized in that: The nesting edge length for each nested instance is calculated as follows: c n = c*r n Where c is the initial occlusion side length, r is the nesting ratio, and n is the number of nestings.
Citation Information
Patent Citations
Method and device for generating occlusion image, computer equipment and storage medium
CN112001983A
Shielded tunnel surface crack identification method
CN116883831A