A method for augmenting training data of target detection model in terahertz human body security inspection images
By cropping suspicious object areas and generating human foreground annotations in terahertz human security images, and randomly selecting augmented images for data augmentation, the problem of scarcity and imbalance of label data is solved, and the accuracy and training of the target detection model are significantly improved. efficiency.
Patent Information
- Application Number
- CN202011589752.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-29
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-12-29
AI Technical Summary
The scarcity of suspicious object label data and sample imbalance in terahertz human security images lead to poor target detection model training and low detection accuracy.
Extract the augmented data subset from the target detection data set by cropping the suspicious object labeling frame, count the number and proportion of each type of suspicious object label, use manual annotation or semantic segmentation model to mark the human body foreground area, randomly generate the coverage area and select the augmented image , regenerate data labels, and perform targeted data augmentation based on the proportion of suspicious object category labels.
It significantly improves the detection accuracy of the target detection model and can accelerate the model training convergence process under sample imbalance conditions.
Smart Images

Figure CN112633392B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of terahertz human body security inspection image processing, and in particular to a method for augmenting training data of a terahertz human body security inspection image target detection model. Background Art
[0002] Object detection can classify and locate objects of interest from images. It is a common task in computer vision, and deep learning is the main solution currently used.
[0003] Terahertz human body security inspection image suspicious object detection belongs to a specific application field. The task goal is to discover and locate suspicious objects hidden under human clothing through human body security inspection images. However, in actual model training, there are problems such as scarcity of suspicious object samples, high data acquisition cost, and very uneven overall sample distribution, which will lead to poor training effect of target detection model and low detection accuracy. The above problems need to be solved urgently. To this end, a method for training data augmentation of terahertz human body security inspection image target detection model is proposed. Summary of the invention
[0004] The technical problem to be solved by the present invention is: how to overcome the problems of insufficient label data and unbalanced samples of suspicious objects in terahertz security inspection images, and provide a method for augmenting training data of a target detection model for terahertz human body security inspection images. The method can complete directional data augmentation according to the proportion of the number of suspicious object labels in each category, thereby improving the detection accuracy of the target detection model.
[0005] The present invention solves the above technical problems through the following technical solutions, and the present invention comprises the following steps:
[0006] S1: Preparation
[0007] S11: Use the suspicious object annotation box to cut out the augmented data subset from the target detection dataset, count the number and proportion of each type of suspicious object labels, and calculate the augmented hit percentage;
[0008] S12: Marking the human foreground area of the training samples in the training data set by manual annotation or by using a semantic segmentation model to generate segmentation annotation data;
[0009] S2: Training phase
[0010] S21: Load single training image data, target detection annotation data, segmented human foreground semantic label data, and set the augmentation counter to 1;
[0011] S22: Using the human body frame annotation, calculate the coordinates of the random starting point of the covered area, and add 1 to the augmentation counter. If the number of times reaches the upper limit, give up augmentation and directly send the image data and target detection annotation data to the network training; S23: According to the proportion of the number of suspicious object category labels, randomly select an augmented coverage image from the augmented data subset;
[0012] S24: Calculate the pixel ratio μ of the covered area and the human foreground area, and the maximum value of the intersection and union ratio σ of the covered area and all suspicious object target frames. If μ and σ meet the set qualified conditions, proceed to step S25. If not, return to step S22.
[0013] S25: Use the augmented subset image to cover the original image, modify the training image annotation data, and send it to the network for training.
[0014] Furthermore, in step S11, each image has a label (x1, y1, x2, y2, c), where x1, y1 are the coordinates of the upper left corner of the target box, (x2, y2) are the coordinates of the lower right corner of the target box, and c is the target category in the box.
[0015] Furthermore, in the step S11, the cropping method is to use the suspicious object labeling box to only extract the image data within the range of [y1:y2,x1:x2] on the original image, that is, only the area of the suspicious object category items in the image is cropped; and the total number of suspicious object target box labels and the number of suspicious object labels of each category are counted, and the proportion of each category in the total is calculated: Among them C i is the number of suspicious object labels of the i-th category; calculate the corresponding reciprocal Statistical reciprocal percentage where γ i It is the probability of random expansion of each type of suspicious object. The probability of suspicious objects with fewer labels being expanded is greater, and the probability of suspicious objects with more labels being expanded is smaller.
[0016] Furthermore, in step S12, it is necessary to obtain a human body segmentation foreground area for each image containing a human body frame and generate corresponding segmentation label data, wherein the foreground pixel in the grayscale label image is 255 and the background pixel is 0.
[0017] Furthermore, in step S21, the image data refers to the image matrix data, the target detection annotation data refers to the human body frame and possible target frame data in the image, and the segmented human foreground semantic label data refers to the image label whose width and height are consistent with the image matrix. At the same time, before each picture enters the augmentation, the augmentation counter is set to 1.
[0018] Furthermore, in step S22, the human body frame is firstly marked (x p1 ,y p1 ,xp2 ,y p2 ), calculating the coordinates of the random starting point of the covered area means taking two random numbers r in the interval (0,1) using uniform distribution x , r y ; Then calculate the starting point coordinates:
[0019] x s =x p1 +r x (x p2 -x p1 )
[0020] y s =y p1 +r y (y p2 -y p1 ).
[0021] Furthermore, in step S23, the specific process of selecting the augmented cover picture is as follows:
[0022] S231: Select augmented images from the augmented data subset based on the proportion of the number of suspicious object category labels and calculate the random hit interval under the percentage of suspicious object category i;
[0023] S232: then generate a random number in the interval (0,100) to determine the category of suspicious objects that need to be expanded;
[0024] S233: Then use uniform distribution to randomly select a specific single image from the augmented subset of single-category suspicious objects.
[0025] Furthermore, in step S24, the width and height of the augmented image are set to w, h, and the coordinates of the covered area frame are set to (x s ,y s ,x s +w,y s +h), the pixel area of the covered area frame is S = wh, and the total number of pixels in the human foreground area in the statistical frame is S f , the proportion is calculated as:
[0026] Furthermore, in step S24, the qualification conditions of μ and σ are:
[0027] Furthermore, in the step S25, modifying the training image annotation data refers to adding the coordinates and categories of the covered area on the basis of the original labels.
[0028] Compared with the prior art, the present invention has the following advantages: the data augmentation method for training the terahertz human body security inspection image target detection model crops out suspicious object areas from a small number of existing images with suspicious object labels to form an augmented subset of suspicious object images, and extracts the human body foreground area of the terahertz image by using a segmentation algorithm or manual labeling method. During the training process, a coverage area is randomly generated and a suspicious object augmented image coverage is randomly selected, and data labels are regenerated. This method can accelerate the convergence process of target detection model training under sample imbalance conditions, significantly improve the detection accuracy of the model, and is worthy of being promoted and used. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is the actual security inspection picture in the second embodiment of the present invention;
[0030] Figure 2 is a schematic diagram of the data augmentation process in the second embodiment of the present invention;
[0031] Figure 3 is a flow chart of obtaining a data augmentation subset in Embodiment 2 of the present invention;
[0032] Figure 4 This is a diagram showing the data augmentation effect in the second embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following is a detailed description of an embodiment of the present invention. This embodiment is implemented on the premise of the technical solution of the present invention, and a detailed implementation method and a specific operation process are given, but the protection scope of the present invention is not limited to the following embodiment.
[0034] Embodiment 1
[0035] This embodiment provides a technical solution: a method for augmenting training data of a terahertz human body security inspection image target detection model, comprising the following steps:
[0036] S1: Preparation
[0037] S11: Use the suspicious object annotation box to cut out the augmented data subset from the target detection dataset, count the number and proportion of each type of suspicious object labels, and calculate the augmented hit percentage;
[0038] S12: Marking the human foreground area of the training samples in the training data set by manual annotation or by using a semantic segmentation model to generate segmentation annotation data;
[0039] S2: Training phase
[0040] S21: Load single training image data, target detection annotation data, segmented human foreground semantic label data, and set the augmentation counter to 1;
[0041] S22: Using the human body frame annotation, calculate the coordinates of the random starting point of the covered area, and add 1 to the augmentation counter. If the number of times reaches the upper limit, give up augmentation and directly send the image data and target detection annotation data to the network training; S23: According to the proportion of the number of suspicious object category labels, randomly select an augmented coverage image from the augmented data subset;
[0042] S24: Calculate the pixel ratio μ of the covered area and the human foreground area, and the maximum value of the intersection and union ratio σ of the covered area and all suspicious object target frames. If μ and σ meet the set qualified conditions, proceed to step S25. If not, return to step S22.
[0043] S25: Use the augmented subset image to cover the original image, modify the training image annotation data, and send it to the network for training.
[0044] In step S11, each image has a label (x1, y1, x2, y2, c), where x1, y1 are the coordinates of the upper left corner of the target box, (x2, y2) are the coordinates of the lower right corner of the target box, and c is the target category in the box.
[0045] In step S11, the cropping method is to use the suspicious object labeling box to only extract the image data within the range of [y1:y2,x1:x2] on the original image, that is, only the area of the suspicious object category items in the image is cropped; and the total number of suspicious object target box labels and the number of suspicious object labels of each category are counted, and the proportion of each category in the total is calculated: Among them C i is the number of suspicious object labels of the i-th category; calculate the corresponding reciprocal Statistical reciprocal percentage where γ i It is the probability of random expansion of each type of suspicious object. The probability of suspicious objects with fewer labels being expanded is greater, and the probability of suspicious objects with more labels being expanded is smaller.
[0046] In step S12, it is necessary to obtain the human body segmentation foreground area for each image containing a human body frame and generate corresponding segmentation label data. The foreground pixel in the grayscale label image is 255 and the background pixel is 0.
[0047] In step S21, the image data refers to the image matrix data, the target detection annotation data refers to the human body frame and possible target frame data in the image, and the segmented human foreground semantic label data refers to the image label whose width and height are consistent with the image matrix. At the same time, before each picture enters the augmentation, the augmentation counter will be set to 1.
[0048] In step S22, an upper limit of the augmentation counter is set. When the upper limit is reached and a qualified augmented image still cannot be generated, the loop is exited and training is performed directly using the original image data and target box annotations.
[0049] In step S22, the human body frame is firstly marked (x p1 ,y p1 ,x p2 ,y p2 ), calculating the coordinates of the random starting point of the covered area means using a uniform distribution to take two random numbers r in the interval (0,1) x , r y (repeatable); then calculate the starting point coordinates:
[0050] x s =x p1 +r x (x p2 -x p1 )
[0051] y s =y p1 +r y (y p2 -y p1 ).
[0052] In step S23, the specific process of selecting the augmented cover picture is as follows:
[0053] S231: Select augmented images from the augmented data subset based on the proportion of the number of suspicious object category labels and calculate the random hit interval under the percentage of suspicious object category i;
[0054] S232: then generate a random number in the interval (0,100) to determine the category of suspicious objects that need to be expanded;
[0055] S233: Then use uniform distribution to randomly select a specific single image from the augmented subset of single-category suspicious objects.
[0056] In step S24, the width and height of the augmented image are set to w, h, and the coordinates of the covered area frame are set to (x s ,y s ,x s +w,y s +h), the pixel area of the covered area frame is S = wh, and the total number of pixels in the human foreground area in the statistical frame is S f The proportion is calculated as follows:
[0057] In step S24, it is necessary to calculate the intersection-over-union ratio of the covered area and all other suspicious object labeling boxes, and take the maximum value. If there is no suspicious object label in the current image, σ is set to 0.
[0058] In step S24, the qualification conditions of μ and σ are:
[0059] In the step S25, modifying the training image annotation data refers to adding the coordinates and categories of the covered area on the basis of the original labels.
[0060] Embodiment 2
[0061] like Figure 1 As shown in the figure, most of the image samples collected by the terahertz body security inspection equipment are normal samples without any suspicious items. Only a very small number of people carry suspicious items. Specific sensitive items, such as knives, are even rarer. The scarcity of data with suspicious item labels leads to very unbalanced samples required by the target detection model. The directly trained target detection model has a low detection accuracy and cannot accurately identify suspicious items.
[0062] like Figure 2 As shown, the data augmentation method proposed in the present invention can complete random augmentation with only a small number of specific suspicious item samples, thereby improving the detection accuracy of the deep learning model.
[0063] The specific process of the data augmentation method in this embodiment is as follows:
[0064] Step S1.1: Prepare training data, such as Figure 3 As shown in the figure, the augmented subset is cropped from the original image using the suspicious object annotation box, and the number of suspicious objects of each category is counted, the proportion of each type of suspicious objects is calculated, and the augmented hit percentage of each type of suspicious objects is calculated.
[0065] For example, the current target detection model needs to detect the following categories of suspicious objects: rectangular objects (rectangle), pistols (gun), and three types of knives (knife). Use the target box annotation data of the suspicious objects to crop the corresponding object area images and rename them to rectangle_1.jpg, rectangle_2.jpg..., gun_1.jpg, gun_2.jpg..., knife_1.jpg, knife_2.jpg,...
[0066] Assume that there are 10,000 human body security inspection images in the training data set, of which the number of rectangle category boxes is 400, the number of guns is 80, and the number of knifes is 20. The proportion of each category is 0.8 (400 / 500), 0.16 (80 / 500), and 0.04 (20 / 500). The reciprocals are 1.25 (1 / 0.8), 6.25 (1 / 0.16), and 25 (1 / 0.04). The reciprocals, i.e., the augmented hit percentages, are 3.9%, 19.2%, and 76.9%. In the later stage, pictures are randomly selected from the augmented subset based on the augmented hit percentages.
[0067] Step S1.2: prepare training data and extract the human foreground area in all training samples using an image semantic segmentation model or manual annotation;
[0068] Step S2.1: Training phase, such as Figure 4 As shown, load a single training image data, target detection annotation data, segmentation human foreground semantic label data, and set the augmentation counter to 1;
[0069] Step S2.2: In the training phase, the human body frame (person) is used to annotate (x p1 ,y p1 ,x p2 ,y p2 ), calculate the coordinates of the random starting point of the covered area, and add 1 to the augmentation counter; continue to use the human body frame annotation to calculate the coordinates of the random starting point of the covered area, and add 1 to the augmentation counter. If the number of times reaches the upper limit, give up augmentation and directly send the image data and target detection annotation data to the network for training;
[0070] Generate a random starting point in the following way:
[0071] 1) Use uniform distribution to get two random numbers r in the interval (0,1) x ,r y ;
[0072] 2) Calculate the starting point coordinates:
[0073] x s =x p1 +r x (x p2 -x p1 )
[0074] y s =y p1 +r x (y p2 -y p1 )
[0075] S2.3 Training phase: Based on the proportion of suspicious object category labels, randomly select an augmented coverage image from the augmented data subset;
[0076] The specific random selection method is as follows:
[0077] 1) Use the augmented hit percentages obtained in step S1.1 to calculate the random augmented hit intervals. For example, the augmented hit percentages of rectangle, gun, and knife are 3.9%, 19.2%, and 76.9%, which can be rounded to the following corresponding intervals [0, 4), [4, 23), and [23, 100];
[0078] 2) Use a uniform distribution to select a random number in the interval [0,100], and if it falls into one of the above intervals, the augmented data is taken from the augmented images of the corresponding category. Assuming that the random number is 21, the augmented image is selected from all augmented subset images of the category gun;
[0079] 3) When augmenting a subset of images from a single category (e.g., category gun), a specific augmented image can be randomly selected using a uniform distribution method to ensure that every image can be randomly selected;
[0080] S2.4 Training stage: Calculate the pixel ratio of the covered area and the human foreground area, and the intersection and union ratio of the covered area and the suspicious object target frame. If the intersection and union ratio meets the requirements, proceed to step S2.5. If not, return to step S2.2.
[0081] The pixel intersection ratio is calculated as follows: The coordinates of the covered area box are (x n1 ,y n1 ,x n2 ,y n2 ), the pixel area of the covered area frame is: S n =(x n2 -x n1 )(y n2 -y n1 );Count the number of human foreground pixels in the covered area S f , the pixel ratio is The calculation method of the intersection over union (IOU) between the covered area and other suspicious object frames can adopt the general method in the field of target detection, which will not be repeated here. It should be noted that it is necessary to calculate the intersection over union (IOU) between the covered area and all suspicious object frames and take the maximum value σ=max(IOUs). To ensure that the covered area is within the human foreground area, μ>0.99 can be required. At the same time, to avoid covering other suspicious objects, σ<0.1 can be required. The augmentation counter in step S2.1 is set to prevent the randomly generated covered areas from always failing to meet the above requirements, and to avoid the process from falling into a local loop, which is a forced exit mechanism designed.
[0082] S2.5 Training stage: Use the augmented subset image to cover the original image, modify the training image annotation data, and send it to the network for training. After the image is covered, the label needs to be adjusted as follows. The original label is (x 11 ,y 11 ,x 12 ,y 12 ,c1),(x 21 ,y 21 ,x 22 ,y 22,c2).., after augmentation, the augmented subset item category label (x 11 ,y 11 ,x 12 ,y 12 ,c1),(x 21 ,y 21 ,x 22 ,y 22 ,c2)..(x′,y′,x′+w,y′+h,c new ), which can be expanded to produce Figure 4 The effect shown.
[0083] To summarize, the method for augmenting training data for the terahertz human body security inspection image target detection model in the above-mentioned embodiment crops out suspicious object areas from a small number of existing images with suspicious object labels to form an augmented subset of suspicious object images, and extracts the human foreground area of the terahertz image using a segmentation algorithm or manual labeling method. During the training process, a coverage area is randomly generated and a suspicious object augmented image coverage is randomly selected, and data labels are regenerated. This method can accelerate the convergence process of target detection model training under conditions of sample imbalance, significantly improve the detection accuracy of the model, and is worthy of being promoted and used.
[0084] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present invention. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present invention.
Claims
1. A method for augmenting training data of a terahertz human body security inspection image target detection model, characterized in that: The following steps are involved: S1: Preparation S11: Use the suspicious object annotation box to cut out the augmented data subset from the target detection dataset, count the number and proportion of each type of suspicious object labels, and calculate the augmented hit percentage; S12: Marking the human foreground area of the training samples in the training data set by manual annotation or by using a semantic segmentation model to generate segmentation annotation data; S2: Training phase S21: Load single training image data, target detection annotation data, segmented human foreground semantic label data, and set the augmentation counter to 1; S22: Using the human body frame annotation, the coordinates of the random starting point of the covered area are calculated, and the augmentation counter is increased by 1. If the number of times reaches the upper limit, the augmentation is abandoned, and the image data and the target detection annotation data are directly sent to the network training; S23: Randomly select an augmented coverage image from the augmented data subset based on the proportion of suspicious object category labels; S24: Calculate the pixel ratio μ of the covered area and the human foreground area, and the maximum value of the intersection and union ratio σ of the covered area and all suspicious object target frames. If μ and σ meet the set qualified conditions, proceed to step S25. If not, return to step S22. S25: Use the augmented subset image to cover the original image, modify the training image annotation data, and send it to the network for training; In step S11, each image has a label (x1, y1, x2, y2, c), where x1, y1 are the coordinates of the upper left corner of the target box, (x2, y2) are the coordinates of the lower right corner of the target box, and c is the target category in the box; The cropping method is to use the suspicious object labeling box to only extract the image data within the range of [y1:y2,x1:x2] on the original image, that is, only crop the area of the suspicious object category in the image; and count the total number of suspicious object target box labels and the number of suspicious object labels of each category, and calculate the proportion of each category in the total number: Among them C i is the number of suspicious object labels of the i-th category; calculate the corresponding reciprocal Statistical reciprocal percentage where γ i is the probability of random expansion of each type of suspicious object. Suspicious objects with fewer labels have a higher probability of being expanded, while suspicious objects with more labels have a lower probability of being expanded. In step S22, the human body frame is firstly marked (x p1 ,y p1 ,x p2 ,y p2 ), calculating the coordinates of the random starting point of the covered area means taking two random numbers r in the interval (0,1) using uniform distribution x , r y ; Then calculate the starting point coordinates: x s =x p1 +r x (x p2 -x p1 ) and s =and p1 +r y (and p2 -and p1 ); In step S23, the specific process of selecting the augmented cover picture is as follows: S231: Select augmented images from the augmented data subset based on the proportion of the number of suspicious object category labels and calculate the random hit interval under the percentage of suspicious object category i; S232: then generate a random number in the interval (0,100) to determine the category of suspicious objects that need to be expanded; S233: Then use uniform distribution to randomly select a specific single image from the augmented subset of single-category suspicious objects.
2. According to claim 1, a method for augmenting training data of a terahertz human body security inspection image target detection model, characterized in that: In step S12, it is necessary to obtain the human body segmentation foreground area for each image containing a human body frame and generate corresponding segmentation label data. The foreground pixel in the grayscale label image is 255 and the background pixel is 0.
3. The method for augmenting training data of a terahertz human body security inspection image target detection model according to claim 2, characterized in that: In step S21, the image data refers to the image matrix data, the target detection annotation data refers to the human body frame and possible target frame data in the image, and the segmented human foreground semantic label data refers to the image label whose width and height are consistent with the image matrix. At the same time, before each picture enters the augmentation, the augmentation counter is set to 1.
4. The method for augmenting training data of a terahertz human body security inspection image target detection model according to claim 3, characterized in that: In step S24, the width and height of the augmented image are set to w, h, and the coordinates of the covered area frame are set to (x s ,y s ,x s +w,y s +h), the pixel area of the covered area frame is S = wh, and the total number of pixels of the human foreground area in the statistical frame is S f , the proportion is calculated as:
5. The method for augmenting training data of a terahertz human body security inspection image target detection model according to claim 4, characterized in that: In step S24, the qualification conditions of μ and σ are:
6. The method for augmenting training data of a terahertz human body security inspection image target detection model according to claim 5, characterized in that: In the step S25, modifying the training image annotation data refers to adding the coordinates and categories of the covered area on the basis of the original labels.
