Clothing safety detection method, device, storage medium and computer equipment
Through the combination of the two-stage two-stream convolutional neural network model, the feature pyramid, and the category attention mechanism, the detection deviation problems caused by distance, complicated clothing, and light changes in industrial site safety clothing detection are solved, and the detection accuracy and robustness are significantly improved. .
Patent Information
- Application Number
- CN202011641398.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-31
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-12-31
AI Technical Summary
In the safety clothing detection at industrial production and construction sites, the existing technology cannot perform accurate and robust detection of clothing safety, and the detection results are prone to deviations, which affects the accuracy of target detection, mainly due to changes in the distance of the person to be detected, complicated clothing and Changes in feature information caused by changes in light.
Using a two-stage dual-stream convolutional neural network model, the trained neural network model is obtained through iterative training, and the feature pyramid and category attention mechanism are used to extract multi-level depth feature maps and category attention feature maps, combined with weighted summation to determine the final detection results, improving detection accuracy and robustness.
The accuracy and robustness of safety clothing detection are significantly improved. It can accurately identify specific targets while ensuring detection speed, reduce the impact of non-target and background areas, and improve the detection accuracy for specific categories.
Smart Images

Figure CN112651371B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of target detection technology, and in particular to a clothing safety detection method, device, storage medium and computer equipment. Background Art
[0002] In the process of industrial production and construction, work clothes and safety helmets play a pivotal role in preventing safety accidents. According to a large amount of statistics, many safety accidents in production are often caused by human factors. Therefore, wearing work clothes and safety helmets in accordance with regulations is a necessary measure for safe production. Work clothes with unified colors and logos not only ensure the safety of workers and facilitate management, but also play a role in quickly identifying the identities of on-site personnel, and to a certain extent can prevent intrusion by outsiders.
[0003] At present, some scholars at home and abroad have conducted research on safety clothing detection under computer vision, and realized safety behavior detection in industrial production and construction sites through target detection technology. However, the current mainstream target detection technology has the following main shortcomings: (1) Due to the change in the distance between the person to be detected and the surveillance camera, the human target scale changes greatly, and it is impossible to accurately and robustly detect safety clothing; (2) When there are many construction workers in the substation, the clothing of the people to be detected may be more complicated, and there may be mutual occlusion between people, which makes the results of safety clothing detection have a large deviation; (3) As the weather changes, the light will change, resulting in changes in the extracted feature information, which in turn affects the accuracy of target detection. Summary of the invention
[0004] The purpose of the present invention is to solve at least one of the above-mentioned technical defects, especially the technical defects that the existing technology cannot accurately and robustly detect the safety of clothing when detecting safety behaviors in industrial production and construction sites, and the safety clothing detection results are prone to large deviations, thereby affecting the target detection accuracy.
[0005] The present invention provides a clothing safety detection method, comprising:
[0006] Iteratively training the neural network model using the acquired training data set until an iteration stop condition is met, thereby obtaining a trained neural network model, wherein the neural network model is a two-stage two-stream convolutional neural network;
[0007] Acquire an image to be detected, input the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, use a feature pyramid to fuse the deep feature maps of each level, perform feature enhancement layer by layer, and extract regions of interest;
[0008] The fused single-layer deep feature map is selected and input into another branch of the two-stream convolutional neural network, and the category attention feature map is extracted using the category attention mechanism. The final detection result is determined after weighted summation of the category attention feature map and the extracted region of interest, and the safety of the clothing is determined based on the detection result.
[0009] Optionally, the step of iteratively training the neural network model using the acquired training data set until an iteration stop condition is met to obtain a trained neural network model includes:
[0010] Acquire a training image, determine the corresponding object position and object category after annotating the training image, and obtain a training data set based on the training image, object position and object category;
[0011] Inputting the training images in the training data set into the neural network model, taking the corresponding object positions and object categories as outputs of the neural network model, and training the neural network model;
[0012] The parameters in the neural network model are adjusted according to the overall loss function obtained after training, and the neural network model is continuously trained using the adjusted parameters until the overall loss function reaches a target value, thereby obtaining a trained neural network model.
[0013] Optionally, the overall loss function includes a classification loss function corresponding to one branch in the neural network model and a category attention loss function corresponding to another branch.
[0014] Optionally, the step of inputting the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, fusing the deep feature maps of each level using a feature pyramid, and performing feature enhancement and extracting RoIs layer by layer includes:
[0015] Input the image to be detected into one branch of the two-stream convolutional neural network, use ResNeXt in the branch to extract a deep feature map, and use the FPN feature pyramid to fuse the deep feature maps of at least two levels in ResNeX from top to bottom;
[0016] The Gaussian non-local attention mechanism is used to enhance the fused deep features layer by layer, and the RPN is used to extract the region of interest in the deep feature map after feature enhancement layer by layer. The features of the region of interest are further extracted to obtain a region of interest with multiple features.
[0017] Optionally, the step of extracting the region of interest in the feature-enhanced deep feature map layer by layer using RPN, and further extracting features of the region of interest to obtain a region of interest with multiple features includes:
[0018] Use RPN to extract the regions of interest in the deep feature map after feature enhancement layer by layer to obtain regions of interest at different scales;
[0019] A single-scale region of interest is sent to a convolutional layer with a channel attention mechanism, and the feature maps of the region of interest are spliced using multiple channels in the convolutional layer to obtain a region of interest with multiple features.
[0020] Optionally, the feature pyramid is an FPN feature pyramid;
[0021] The step of selecting the fused single-layer depth feature map and inputting it into another branch of the two-stream convolutional neural network, and extracting the category attention feature map using the category attention mechanism, comprises:
[0022] Selecting the fused P2-level deep feature map and inputting it into another branch of the two-stream convolutional neural network, and using the category-focused convolutional layer in the branch to extract response maps of different categories in the P2-level deep feature map;
[0023] The response map is input into the global pooling layer for global pooling to obtain the corresponding confidence. After sorting the confidences corresponding to the response maps of different categories, the response map with the highest confidence is selected as the category attention feature map of the target object.
[0024] Optionally, the step of performing weighted summation of the category attention feature map and the extracted region of interest to determine the final detection result includes:
[0025] The extracted region of interest is mapped to the category attention feature map to obtain the interest attention feature map, the target position and target category are determined according to the interest attention feature map, and the target position and target category are used as the final detection result.
[0026] The present invention also provides a clothing safety detection device, comprising:
[0027] A model training unit, used to iteratively train the neural network model using the acquired training data set until an iteration stop condition is met, thereby obtaining a trained neural network model, wherein the neural network model is a two-stage two-stream convolutional neural network;
[0028] The target detection unit is used to obtain an image to be detected, input the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, use a feature pyramid to fuse the deep feature maps of each level, perform feature enhancement layer by layer, and extract the region of interest;
[0029] The clothing safety detection unit is used to select the fused single-layer deep feature map and input it into another branch of the two-stream convolutional neural network, and use the category attention mechanism to extract the category attention feature map, and determine the final detection result after weighted summation of the category attention feature map and the extracted area of interest, and determine the clothing safety situation according to the detection result.
[0030] The present invention also provides a storage medium, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the clothing safety detection method as described in any of the above embodiments.
[0031] The present invention also provides a computer device, in which computer-readable instructions are stored. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the clothing safety detection method as described in any of the above embodiments.
[0032] It can be seen from the above technical solutions that the embodiments of the present invention have the following advantages:
[0033] The clothing safety detection method, device, storage medium and computer equipment provided by the present invention include: using the acquired training data set to iteratively train the neural network model until the iteration stop condition is met, so as to obtain a trained neural network model, wherein the neural network model is a two-stage two-stream convolutional neural network; acquiring an image to be detected, inputting the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, using a feature pyramid to fuse the deep feature maps of each level, and then performing feature enhancement and extracting regions of interest layer by layer; selecting the fused single-layer deep feature map and inputting it into another branch of the two-stream convolutional neural network, and using a category attention mechanism to extract a category attention feature map, performing weighted summation on the category attention feature map and the extracted region of interest to determine the final detection result, and determining the clothing safety situation according to the detection result.
[0034] Compared with the prior art, in the first branch of the neural network model of the present invention, after the image to be detected is extracted and fused, each level of the fused feature pyramid is individually enhanced, which can not only refine the target features, but also suppress non-target and background areas; in addition, the feature map in each level of the feature pyramid is used to extract the region of interest, so as to achieve more accurate detection of specific targets, and significantly improve the accuracy and robustness of safety clothing detection while ensuring the detection speed; in the other branch, through end-to-end training, it is possible to focus on the attention feature map of a specific category, and finally the region of interest of the first branch is weightedly summed with the category attention feature map of the second branch, so as to obtain a detection result focused on a specific category, effectively improving the target detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0036] Figure 1 A schematic diagram of a flow chart of a clothing safety detection method provided by an embodiment of the present invention;
[0037] Figure 2 A flow chart of a safe clothing detection algorithm implemented by two-stage two-stream convolution of attention features and depth features provided in an embodiment of the present invention;
[0038] Figure 3 A schematic structural diagram of a clothing safety detection device provided by an embodiment of the present invention;
[0039] Figure 4 A schematic diagram of the internal structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0041] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0042] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as the general understanding of those skilled in the art to which this application belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and will not be interpreted with an idealized or overly formal meaning unless specifically defined as in the embodiments of this application.
[0043] In industrial production and construction, safety has always been an eternal theme, and work clothes and safety helmets play a pivotal role in preventing safety accidents. According to a large amount of statistics, many production safety accidents are often caused by human factors. Therefore, wearing work clothes and safety helmets in accordance with regulations is a necessary measure for safe production. Work clothes with unified colors and logos not only ensure the safety of workers and facilitate management, but also play a role in quickly identifying the identities of on-site personnel, and to a certain extent, can prevent intrusion by outsiders.
[0044] At present, safety behavior detection in industrial production and construction sites usually uses cameras to collect video data, and then uses manual supervision to judge the unsafe behavior and status of people or objects. However, manual supervision has many disadvantages: first, the use of manual supervision will inevitably increase a lot of manpower costs; second, if the time of manual supervision is too long, fatigue will occur, which can easily lead to misjudgment of supervision, or even negligence and omissions; in addition, the process of manual supervision will be affected by the monitor's mood, state, work experience, personality and living conditions, which makes safety judgment highly subjective and lacks objectivity.
[0045] At present, some scholars at home and abroad have conducted research on safety clothing detection under computer vision, which can be roughly divided into target detection based on traditional methods and target detection based on deep learning. The traditional methods of safety clothing detection include the following: the first is a detection method that combines target detection and color features. After determining the complete human target, this method selects a specific area of the human body for color feature detection; the second is a detection method that combines features and classifiers to extract the target features of the human body wearing safety clothing correctly, and then trains a classifier (Adaboost or SVM, etc.) for classification; the third is a method based on the relationship between color area and target position. The premise of this method is that the color of the safety clothing is known, and then the target area of the person is extracted to obtain the recognition result; the fourth is an edge detection method based on safety clothing, which realizes safety clothing detection through segmentation.
[0046] The popular deep learning algorithms in recent years can autonomously learn target features, have high detection accuracy and strong robustness, and have been widely used in various fields of computer vision. CNN-based target detection algorithms can be divided into single-stage and two-stage target detection. Single-stage detection algorithms include SSD series, YOLO series, RetinaNet, etc., which can quickly detect the target position; two-stage target detection algorithms include Fast R-CNN, Faster R-CNN, SDS-RCNN, R-FCN, Mask R-CNN, etc., although the detection speed is slower, the detection accuracy and robustness are generally better than single-stage target detection algorithms.
[0047] However, the current mainstream target detection technology has the following shortcomings: (1) Due to the change in the distance between the person to be detected and the surveillance camera, the human target scale changes significantly, making it impossible to accurately and robustly detect safety clothing; (2) When there are many construction workers in the substation, the clothing of the people to be detected may be more complicated, and there may be mutual occlusion between people, resulting in a large deviation in the results of safety clothing detection; (3) As the weather changes, the light will change accordingly, causing the extracted feature information to change, which in turn affects the target detection accuracy.
[0048] Therefore, the present invention aims to solve the technical problems that in the prior art, when detecting safety behaviors in industrial production and construction sites, it is impossible to accurately and robustly detect safety clothing, and the safety clothing detection results are prone to large deviations, thereby affecting the accuracy of target detection. The specific technical solutions are as follows:
[0049] Schematically, see Figure 1 , Figure 1 The present invention provides a flow chart of a clothing safety detection method provided in an embodiment of the present invention. The present invention provides a clothing safety detection method, which specifically includes the following steps:
[0050] S110: Iteratively train the neural network model using the acquired training data set until an iteration stop condition is met, thereby obtaining a trained neural network model, wherein the neural network model is a two-stage two-stream convolutional neural network.
[0051] In this step, before using the neural network model to detect the clothing of the person to be detected, it is necessary to train the pre-established neural network model with a large amount of training data so that the neural network model can be used for clothing safety detection later.
[0052] Specifically, the training data set includes the acquired training images, and the annotated object positions and object categories corresponding to the training images; wherein the acquired training images include but are not limited to images of multiple categories such as personnel at the construction site wearing safety clothes, not wearing safety clothes, wearing safety helmets, and not wearing safety helmets, and each category contains approximately more than 2,000 images; the training images should meet the requirements of targets with different scales (i.e., area sizes), and the light should include multiple types such as sunny days, cloudy days, and rainy days, so as to enrich the feature information of the training samples and effectively enhance the accuracy and robustness of the deep learning model.
[0053] Furthermore, the object position here refers to the human target area appearing in the training image, including the head area and the body area; the object category here refers to the categories of wearing a safety helmet and not wearing a safety helmet based on the head area, and wearing safety clothes and not wearing safety clothes based on the body area; the process of obtaining the object position and object category here includes but is not limited to manual calibration of the acquired training images. During the manual labeling process, the correctness of the label and the accuracy of the calibration box should be guaranteed, thereby forming a training data set for the deep learning algorithm.
[0054] After obtaining the training data set, the neural network model is iteratively trained using the training data set until the iteration stop condition is met, thereby obtaining a trained neural network model. The neural network model in the present application is a two-stage two-stream convolutional neural network. The two-stream convolutional neural network is used to detect the clothing of the person to be detected, which can effectively improve the detection accuracy and robustness.
[0055] S120: Acquire an image to be detected, input the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, use a feature pyramid to fuse the deep feature maps of each level, and then perform feature enhancement and extract the region of interest layer by layer.
[0056] In this step, after the two-stream convolutional neural network is trained through step S110, the acquired image to be detected can be input into one branch of the two-stream convolutional neural network for target detection to determine the area where the target to be detected in the image to be detected may be located.
[0057] Specifically, after the image of the person to be detected is collected by a camera, it can be input into a two-stream convolutional neural network, and the deep convolution layer of one of the branches can be used to extract the feature information in the image to be detected, thereby obtaining a multi-level deep feature map, and then the deep feature maps of each level are fused using a feature pyramid, and the fused deep feature map is subjected to feature enhancement to extract the region of interest.
[0058] Further, the feature pyramid obtained here is an essential component in a recognition system for detecting objects of different scales; the present application utilizes the multi-scale pyramid hierarchy inherent in a deep convolutional network to construct a feature pyramid with marginal extra loss, which has a top-down architecture with horizontal connections for building high-level semantic feature maps at all scales, and this architecture, called a feature pyramid network (FPN), shows significant improvements over a general feature extractor in several applications.
[0059] Furthermore, the reference feature maps of each level of FPN are enhanced separately, for example, Gaussian non-local attention mechanism can be used layer by layer. While simplifying the network parameters, non-target and background areas are suppressed, making the target area in the feature map more prominent, and achieving accurate and robust detection of safety clothing.
[0060] For the extraction of the possible area where the target to be detected is located, a set of anchor frames of the same scale can be slid on each pyramid level after feature enhancement and mapped to the original image to obtain regions of interest ROIs of different scales.
[0061] In addition, the extracted regions of interest ROIs can be sent again to the convolutional layer with channel attention mechanism to further extract feature information, and each spliced ROI contains feature maps of multiple channels, which not only enriches high-level semantic feature information, but also realizes the channel-based attention mechanism.
[0062] S130: Select the fused single-layer deep feature map and input it into another branch of the two-stream convolutional neural network, and use the category attention mechanism to extract the category attention feature map, and perform weighted summation of the category attention feature map and the extracted region of interest to determine the final detection result, and determine the safety of the clothing according to the detection result.
[0063] In this step, the image to be detected is input into one branch of the two-stream convolutional neural network for target detection through step S120. After determining the area where the target to be detected in the image to be detected may be located, the fused single-layer deep feature map can be further selected and input into another branch of the two-stream convolutional neural network, so that the category attention mechanism can be used in the other branch to extract the category attention feature map.
[0064] After extracting the category attention feature map, it is necessary to fuse the detection results of the two branches of the two-stream convolutional neural network to obtain the final detection result. For example, by weighted fusion of the category attention feature map and the extracted region of interest, an attention feature map of interest can be obtained, in which the target position and target category are selected. Based on the target position and target category, it can be confirmed whether the body area of the person to be detected in the current image to be detected is wearing safety clothing and whether the head area is wearing a helmet.
[0065] Compared with the prior art, in the first branch of the neural network model of this embodiment, after the image to be detected is extracted and fused, the features of each level of the fused feature pyramid are enhanced separately, which can not only refine the target features, but also suppress non-target and background areas; in addition, the region of interest is extracted from the feature maps in the feature pyramid of each level to achieve more accurate detection of specific targets, and significantly improve the accuracy and robustness of safety clothing detection while ensuring the detection speed; in the other branch, through end-to-end training, it is possible to focus on the attention feature map of a specific category, and finally the region of interest of the first branch and the category attention feature map of the second branch are weighted and summed, so that the detection result focused on the specific category can be obtained, effectively improving the target detection accuracy.
[0066] In one embodiment, the step of iteratively training the neural network model using the acquired training data set until the iteration stop condition is met, and obtaining the trained neural network model may include:
[0067] S111: Acquire a training image, annotate the training image and determine the corresponding object position and object category, and obtain a training data set based on the training image, object position and object category;
[0068] S112: inputting the training images in the training data set into the neural network model, taking the corresponding object positions and object categories as outputs of the neural network model, and training the neural network model;
[0069] S113: adjusting the parameters in the neural network model according to the overall loss function obtained after training, and continuing to train the neural network model using the adjusted parameters until the overall loss function reaches a target value, thereby obtaining a trained neural network model.
[0070] In this embodiment, before using the neural network model to detect the clothing of the person to be detected, the pre-established neural network model needs to be trained with a large amount of training data so that the neural network model can be used subsequently for clothing safety detection.
[0071] Specifically, the training data set includes the acquired training images, and the annotated object positions and object categories corresponding to the training images; wherein the acquired training images include but are not limited to images of multiple categories such as personnel at the construction site wearing safety clothes, not wearing safety clothes, wearing safety helmets, and not wearing safety helmets, and each category contains approximately more than 2,000 images; the training images should meet the requirements of targets with different scales (i.e., area sizes), and the light can include multiple types such as sunny, cloudy, and rainy, thereby enriching the feature information of the training samples and effectively enhancing the accuracy and robustness of the deep learning model.
[0072] After obtaining the training data set, the training images in the training data set are used as the input of the neural network model, and the object positions and object categories corresponding to the training images are used as the output of the neural network model. The neural network model is then iteratively trained. After each training, the overall loss function of the neural network model is calculated, and the optimal solution is sought by finding the minimum value of the overall loss function. The parameters in the neural network model are adjusted according to the current value of the overall loss function. The iterative process is terminated after the overall loss function reaches the optimal solution, and a trained neural network model is obtained.
[0073] In one embodiment, the overall loss function may include a classification loss function corresponding to one branch in the neural network model and a category attention loss function corresponding to another branch.
[0074] In this embodiment, since the neural network model used in this application is a two-stream convolutional neural network, the two-stream convolutional neural network includes two branches, one of which is used to perform target detection on the image to be detected, and the other is used for category attention detection. Finally, the results of the two branch detections are fused to obtain the final detection result.
[0075] Therefore, during the model training process, when calculating the overall loss function, it is necessary to calculate the classification loss function corresponding to one branch and the category attention loss function corresponding to the other branch respectively, and perform weighted summation of the classification loss function and the category attention loss function as the overall loss function of the entire neural network target detection.
[0076] For example, since the algorithm proposed in this application is based on a two-stage target detection algorithm, the target detection algorithm may further include an RPN network and a target detector, wherein the classification loss of the RPN stage is defined as follows:
[0077]
[0078] As shown in the above formula, i represents the ordinal number of anchors in a small training batch, and p i is the probability of predicting the i-th anchor as the target, Used to distinguish positive and negative anchor points, t i represents the bounding box predicted by the RPN stage, represents the actual bounding box position of the target, N cls is the size of a small batch for training, N reg is the number of anchors, and λ is a balancing parameter used to balance classification loss and regression loss.
[0079] Furthermore, L cls1 The classification loss function uses exponential loss, which is defined as follows:
[0080] L cls1 = -log(p i )
[0081] Among them, p i is the probability of predicting the i-th anchor as the target.
[0082] And L loc1 The regression loss function uses smoothL1 loss, and the calculation formula is as follows:
[0083]
[0084] Here, x represents the normalized distance. This paper calculates the normalized distances δ[0], δ[1], δ[2], and δ[3] using the following formula:
[0085]
[0086]
[0087] Among them, A x , A y , A w , A h Respectively represent the horizontal coordinate, vertical coordinate of the center position of the anchor box, the width and height of the anchor box, T x , T y , T w , T hThey represent the horizontal and vertical coordinates of the center point of the real target area, and the width and height of the real area respectively.
[0088] Substitute the normalized distances δ[0], δ[1], δ[2], and δ[3] into the smooth L1 loss function, where i represents the sequence number of each group of normalized distances, and obtain the regression loss function L of the bounding box branch loc1 , the calculation formula is:
[0089]
[0090] Furthermore, the loss function of the object detector is defined as follows:
[0091] L(p,u,t u ,v)=L cls2 (p,u)+δ[u≥1]L loc2 (t u ,v)+θL ACL
[0092] Among them, p is the confidence of the predicted target, u is the true category of the target, and t u represents the predicted bounding box corresponding to category u, v represents the location of the real bounding box corresponding to category u, and L cls2 is the classification loss (calculated in the same way as L cls1 is the same), is the logarithmic loss corresponding to the true category, δ and θ are balance parameters (in this paper, δ = θ = 1 is selected), L loc2 is the smooth L1 regression loss function (calculated in the same way as L loc1 The same), [u≥1] is the level indicator function. When u≥1, the level indicator function value is 1, otherwise, the function value is 0, so that only the bounding box loss can be calculated for the foreground target without calculating the regression loss of the background.
[0093] In the formula, L ACL is the category attention loss function, defined as follows:
[0094]
[0095] Among them, N ROI is the number of ROIs, is the attention score of the ROI, L cls2 is the classification loss, p i is the confidence of the target category predicted by the i-th ROI, u i is the true category of the i-th predicted target.
[0096] The confidence of the predicted target can be obtained by extracting the response map of each specific category through the convolution layer that focuses on the category in another branch of the neural network model. The response map is then sent to the global pooling layer, and the value after global pooling is used as the confidence of the target.
[0097] The calculation process of the ROI attention score is as follows: select the response map with the highest confidence as the target category attention feature map. For each target category to be detected, map all ROIs areas to the target category attention feature map, and then obtain all ROIs attention feature maps; then, perform global average pooling on the ROIs attention feature map, extract the attention scores of all ROIs, and obtain the ROI attention score.
[0098] In one embodiment, Figure 2 As shown, Figure 2 A flowchart of a two-stage two-stream convolution algorithm for realizing safety clothing detection using attention features and depth features provided in an embodiment of the present invention; in step S120, the image to be detected is input into one branch of the two-stream convolutional neural network to extract multi-level depth feature maps, and the steps of fusing the depth feature maps of each level using a feature pyramid and performing feature enhancement and extracting RoIs layer by layer may include:
[0099] S121: input the image to be detected into one branch of the two-stream convolutional neural network, use ResNeXt in the branch to extract a deep feature map, and use the FPN feature pyramid to fuse the deep feature maps of at least two levels in ResNeX from top to bottom;
[0100] S122: Use the Gaussian non-local attention mechanism to perform layer-by-layer feature enhancement on the fused deep features, and use RPN to extract the region of interest in the feature-enhanced deep feature map layer by layer, and continue to extract the features of the region of interest to obtain a multi-feature region of interest.
[0101] In this embodiment, in the traditional way of improving the accuracy of the model, the network is generally deepened or widened, but with the increase in the number of hyperparameters (such as the number of channels, filter size, etc.), the difficulty of network design and the computational overhead will also increase. Therefore, in this application, when extracting features of the image to be detected, the ResNeXt structure is selected. This structure can improve the accuracy without increasing the complexity of the parameters, while also reducing the number of hyperparameters.
[0102] After using ResNeXt to extract deep feature maps, the FPN feature pyramid can be used to fuse at least two levels of deep feature maps in ResNeX from top to bottom. Furthermore, the reference feature maps of the C2-C4 levels of ResNeXt can be transformed to the same dimension using a 1×1 convolutional layer, and the feature maps can be fused from top to bottom. This process significantly enhances the semantic information of the low-level feature maps.
[0103] It should be noted that the C1 layer in ResNeXt is not used here because the feature map scale of this layer is too large, which will significantly slow down the calculation speed of the neural network.
[0104] After using the FPN feature pyramid to fuse at least two levels of deep feature maps in ResNeX from top to bottom, the Gaussian non-local attention mechanism can be used to enhance the fused deep features layer by layer, and the RPN can be used to extract the region of interest in the deep feature map after feature enhancement layer by layer, and the features of the region of interest are further extracted to obtain a region of interest with multiple features.
[0105] Specifically, the reference feature maps of each level in the FPN feature pyramid are enhanced layer by layer using the Gaussian non-local attention mechanism. After feature enhancement using the Gaussian non-local attention mechanism, not only the network parameters can be simplified, but also the non-target and background areas can be suppressed, making the target area in the feature map more prominent, thereby achieving accurate and robust detection of safety clothing.
[0106] Next, the feature-enhanced deep feature map is passed through a multi-scale RPN to extract regions of interest ROIs (i.e., areas where the detected object may be located). This operation can be performed by sliding a set of anchor frames of the same scale on each pyramid level after feature enhancement and mapping them to the original image, thereby obtaining regions of interest ROIs of different scales.
[0107] Furthermore, in order to enrich high-level semantic feature information and implement a channel-based attention mechanism, ROIs can be sent to a convolutional layer with a channel attention mechanism to further extract feature information, and each concatenated ROI contains feature maps of multiple channels.
[0108] In one embodiment, in step S122, the step of extracting the region of interest in the feature-enhanced depth feature map layer by layer using RPN, and further extracting the features of the region of interest to obtain a region of interest with multiple features may include:
[0109] S221: using RPN to extract the region of interest in the feature-enhanced depth feature map layer by layer to obtain regions of interest at different scales;
[0110] S222: Send the single-scale region of interest to a convolutional layer with a channel attention mechanism, and use multiple channels in the convolutional layer to splice the feature map of the region of interest to obtain a region of interest with multiple features.
[0111] In this embodiment, the depth feature map after feature enhancement is used to extract regions of interest ROIs (i.e., areas where the target to be detected may be located) through a multi-scale RPN. This operation process can be achieved by sliding a group of anchor frames of the same scale on each pyramid level after feature enhancement, mapping them to the original image, and then obtaining regions of interest ROIs of different scales.
[0112] Furthermore, in order to enrich high-level semantic feature information and implement a channel-based attention mechanism, ROIs can be sent to a convolutional layer with a channel attention mechanism to further extract feature information, and each concatenated ROI contains feature maps of multiple channels.
[0113] The concatenation operation includes but is not limited to the Squeeze operation and the Excitation operation, wherein the Squeeze operation uses the global spatial features of each channel as the representation of the channel and uses global average pooling to generate the statistics of each channel; the Excitation operation learns the degree of dependence of each channel and adjusts different feature maps according to the degree of dependence to obtain the final output.
[0114] It can be understood that the attention mechanism is a resource allocation mechanism, which can be understood as redistributing the originally evenly distributed resources according to the importance of the attention object, so that important units are allocated more, and unimportant or bad units are allocated less. In the structural design of deep neural networks, the resources to be allocated for attention generally refer to weights.
[0115] Channel attention can be understood as what the neural network is looking at, and SENet is a typical example. Each layer of the convolutional network has many convolution kernels, each of which corresponds to a feature channel. Compared with the spatial attention mechanism, channel attention is to allocate resources between each convolution channel, and the allocation granularity is one level larger than the former.
[0116] In one embodiment, Figure 2 As shown, the feature pyramid is an FPN feature pyramid; the step of selecting the fused single-layer depth feature map in step S130 and inputting it into another branch of the two-stream convolutional neural network, and using the category attention mechanism to extract the category attention feature map may include:
[0117] S131: Select the fused P2-level deep feature map and input it into another branch of the two-stream convolutional neural network, and use the convolution layer focused on the category in the branch to extract the response maps of different categories in the P2-level deep feature map;
[0118] S132: Input the response map into the global pooling layer for global pooling to obtain the corresponding confidence, sort the confidences corresponding to the response maps of different categories, and select the response map with the highest confidence as the category attention feature map of the target object.
[0119] In this embodiment, when taking the fused single-layer deep feature map as input to another branch of the two-stream convolutional neural network, the P2-level deep feature map of the FPN feature pyramid can be preferentially selected as the input of the other branch, and then the convolutional layer focusing on the category in the branch is used to extract the response maps of different categories in the P2-level deep feature map.
[0120] It should be noted that since the deep feature map fused through the FPN feature pyramid enhances the semantic information of the low-level feature map, and the selected P2-level reference feature map has a higher resolution of corresponding feature information, inputting the P2-level reference feature map into the convolutional layer focusing on categories is more conducive to the extraction of response maps of different categories.
[0121] After extracting response maps of different categories, the response maps of the corresponding categories can be input into the global pooling layer for global pooling to obtain the corresponding confidence. Then, after sorting the confidences corresponding to the response maps of different categories, the response map with the highest confidence is selected as the category attention feature map of the target object.
[0122] In one embodiment, the step of determining the final detection result after weighted summing the category attention feature map and the extracted region of interest in step S130 includes:
[0123] The extracted region of interest is mapped to the category attention feature map to obtain the interest attention feature map, the target position and target category are determined according to the interest attention feature map, and the target position and target category are used as the final detection result.
[0124] In this embodiment, for a two-stream convolutional neural network, after obtaining the target detection result of one branch and the category attention result of the other branch, the two need to be fused to obtain the final detection result.
[0125] Among them, when the region of interest extracted from the first branch is fused with the category attention feature map obtained from the second branch, the response map with the highest confidence in the current category can be selected as the category attention feature map of the target. For each target category to be detected, all ROIs areas are mapped to the category attention feature map of the target, and then all the attention feature maps of interest, that is, the ROIs attention feature map, can be obtained; then the ROIs attention feature map is globally averaged pooled, and the attention scores of all ROIs are extracted to obtain the ROI attention score.
[0126] The attention score of ROI is used as the weight for weighted fusion of category attention feature maps, and then the weighted fusion detection result can be obtained.
[0127] In one embodiment, Figure 3 As shown, Figure 3 A structural schematic diagram of a clothing safety detection device provided by an embodiment of the present invention; the present invention also provides a clothing safety detection device, including a model training unit 110, a target detection unit 120, and a clothing safety detection unit 130, which specifically includes the following:
[0128] The model training unit 110 is used to iteratively train the neural network model using the acquired training data set until an iteration stop condition is met, thereby obtaining a trained neural network model, wherein the neural network model is a two-stage two-stream convolutional neural network;
[0129] The target detection unit 120 is used to obtain an image to be detected, input the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, use a feature pyramid to fuse the deep feature maps of each level, perform feature enhancement layer by layer, and extract the region of interest;
[0130] The clothing safety detection unit 130 is used to select the fused single-layer deep feature map and input it into another branch of the two-stream convolutional neural network, and use the category attention mechanism to extract the category attention feature map, and determine the final detection result after weighted summation of the category attention feature map and the extracted area of interest, and determine the clothing safety situation according to the detection result.
[0131] Compared with the prior art, in the first branch of the neural network model of this embodiment, after the image to be detected is extracted and fused, the features of each level of the fused feature pyramid are enhanced separately, which can not only refine the target features, but also suppress non-target and background areas; in addition, the region of interest is extracted from the feature maps in the feature pyramid of each level to achieve more accurate detection of specific targets, and significantly improve the accuracy and robustness of safety clothing detection while ensuring the detection speed; in the other branch, through end-to-end training, it is possible to focus on the attention feature map of a specific category, and finally the region of interest of the first branch and the category attention feature map of the second branch are weighted and summed, so that the detection result focused on the specific category can be obtained, effectively improving the target detection accuracy.
[0132] In one embodiment, the present invention further provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the clothing safety detection method as described in any of the above embodiments.
[0133] In one embodiment, the present invention further provides a computer device having computer-readable instructions stored therein. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the clothing safety detection method as described in any one of the above embodiments.
[0134] Indicatively, if Figure 4 As shown, Figure 4 The internal structure diagram of a computer device provided by an embodiment of the present invention is shown in FIG. 200 . The computer device 200 may be provided as a server. Figure 4 The computer device 200 includes a processing component 202, which further includes one or more processors, and a memory resource represented by a memory 201 for storing instructions executable by the processing component 202, such as an application. The application stored in the memory 201 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 202 is configured to execute instructions to perform the clothing safety detection method of any of the above embodiments.
[0135] The computer device 200 may further include a power supply component 203 configured to perform power management of the computer device 200, a wired or wireless network interface 204 configured to connect the computer device 200 to a network, and an input / output (I / O) interface 205. The computer device 200 may operate based on an operating system stored in the memory 201, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.
[0136] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0137] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A clothing safety detection method, characterized in that: include: Iteratively training the neural network model using the acquired training data set until an iteration stop condition is met, thereby obtaining a trained neural network model, wherein the neural network model is a two-stage two-stream convolutional neural network; Acquire an image to be detected, input the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, use a feature pyramid to fuse the deep feature maps of each level, perform feature enhancement layer by layer, and extract regions of interest; The fused single-layer deep feature map is selected and input into another branch of the two-stream convolutional neural network, and the category attention feature map is extracted using the category attention mechanism, and the category attention feature map and the extracted region of interest are weightedly summed to determine the final detection result, and the safety of the clothing is determined according to the detection result; The step of inputting the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, using a feature pyramid to fuse the deep feature maps of each level, and performing feature enhancement layer by layer and extracting the region of interest includes: Input the image to be detected into one branch of the two-stream convolutional neural network, use ResNeXt in the branch to extract a deep feature map, and use the FPN feature pyramid to fuse the deep feature maps of at least two levels in ResNeXt from top to bottom; The Gaussian non-local attention mechanism is used to perform layer-by-layer feature enhancement on the fused deep feature map, and the RPN is used to extract the region of interest in the feature-enhanced deep feature map layer by layer. The features of the region of interest are further extracted to obtain a region of interest with multiple features.
2. A clothing safety detection method according to claim 1, characterized in that: The step of iteratively training the neural network model using the acquired training data set until an iteration stop condition is met to obtain a trained neural network model includes: Acquire a training image, determine the corresponding object position and object category after annotating the training image, and obtain a training data set based on the training image, object position and object category; Inputting the training images in the training data set into the neural network model, taking the corresponding object positions and object categories as outputs of the neural network model, and training the neural network model; The parameters in the neural network model are adjusted according to the overall loss function obtained after training, and the neural network model is continuously trained using the adjusted parameters until the overall loss function reaches a target value, thereby obtaining a trained neural network model.
3. A clothing safety detection method according to claim 2, characterized in that: The overall loss function includes a classification loss function corresponding to one branch in the neural network model and a category attention loss function corresponding to another branch.
4. A clothing safety detection method according to claim 1, characterized in that: The step of extracting the region of interest in the feature-enhanced deep feature map layer by layer using RPN, and further extracting the features of the region of interest to obtain a region of interest with multiple features includes: Use RPN to extract the regions of interest in the deep feature map after feature enhancement layer by layer to obtain regions of interest at different scales; A single-scale region of interest is sent to a convolutional layer with a channel attention mechanism, and the feature maps of the region of interest are spliced using multiple channels in the convolutional layer to obtain a region of interest with multiple features.
5. A clothing safety detection method according to claim 1, characterized in that: The feature pyramid is an FPN feature pyramid; The step of selecting the fused single-layer depth feature map and inputting it into another branch of the two-stream convolutional neural network, and extracting the category attention feature map using the category attention mechanism, comprises: Selecting the fused P2-level deep feature map and inputting it into another branch of the two-stream convolutional neural network, and using the category-focused convolutional layer in the branch to extract response maps of different categories in the P2-level deep feature map; The response map is input into the global pooling layer for global pooling to obtain the corresponding confidence. After sorting the confidences corresponding to the response maps of different categories, the response map with the highest confidence is selected as the category attention feature map of the target object.
6. A clothing safety detection method according to claim 1, characterized in that: The step of determining the final detection result after weighted summing the category attention feature map and the extracted region of interest includes: The extracted region of interest is mapped to the category attention feature map to obtain the interest attention feature map, the target position and target category are determined according to the interest attention feature map, and the target position and target category are used as the final detection result.
7. A clothing safety detection device, characterized in that: include: A model training unit, used to iteratively train the neural network model using the acquired training data set until an iteration stop condition is met, thereby obtaining a trained neural network model, wherein the neural network model is a two-stage two-stream convolutional neural network; The target detection unit is used to obtain an image to be detected, input the image to be detected into one branch of the two-stream convolutional neural network to extract multi-level deep feature maps, use a feature pyramid to fuse the deep feature maps of each level, perform feature enhancement layer by layer, and extract the region of interest; A clothing safety detection unit is used to select a fused single-layer deep feature map and input it into another branch of the two-stream convolutional neural network, and use a category attention mechanism to extract a category attention feature map, perform a weighted summation of the category attention feature map and the extracted region of interest to determine a final detection result, and determine the clothing safety situation according to the detection result; The target detection unit comprises: Input the image to be detected into one branch of the two-stream convolutional neural network, use ResNeXt in the branch to extract a deep feature map, and use the FPN feature pyramid to fuse the deep feature maps of at least two levels in ResNeXt from top to bottom; The Gaussian non-local attention mechanism is used to perform layer-by-layer feature enhancement on the fused deep feature map, and the RPN is used to extract the region of interest in the feature-enhanced deep feature map layer by layer. The features of the region of interest are further extracted to obtain a region of interest with multiple features.
8. A storage medium, characterized in that: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the clothing safety detection method as described in any one of claims 1 to 6.
9. A computer device, characterized in that: The computer device stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the clothing safety detection method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Rotating target detection method based on multi-scale feature integration and attention mechanism
CN111539428A
