A head detection method and system

By combining the yolov5 algorithm and the SwinTransformer module, the head detection model is optimized to solve the problem of low head detection accuracy in complex scenes, achieve high-accuracy head detection in crowded situations, and ensure the accuracy of people counting.

CN114882440BActive Publication Date: 2024-10-18CHINA UNICOM (GUANGDONG) IND INTERNET CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210599635.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-30
Publication Date
2024-10-18
Estimated Expiration
2042-05-30

AI Technical Summary

Technical Problem

Existing head detection methods have low accuracy in complex real-life scenarios, especially when crowds are crowded and heads are blocking each other, making it difficult to achieve real-time and accurate people counting.

Method used

The initial detection model based on the yolov5 algorithm and the SwinTransformer module is used to pre-process the surveillance image sample set to train the target detection model, and use Alpha-IoU Loss to optimize the detection model to improve the detection ability of small targets and the accuracy of the detection frame.

Benefits of technology

In crowded scenes, the accuracy of head detection is significantly improved, the robustness of the detection model is enhanced, and the accuracy of head counting is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114882440B_ABST
    Figure CN114882440B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer vision, and more specifically, to a method and system for detecting a head. The present invention introduces a Swin Transformer module into the yolov5 algorithm, so that the detection model can better focus on and integrate the global information and context information of the feature map, tap the potential of feature representation, extract more useful features, and improve the accuracy of head detection in crowded scenes. On this basis, the detection head branch of yolov5 is also modified, while the calculation amount of the detection model remains basically unchanged, the detection ability of small targets is improved, and the accuracy of head detection is further improved. In addition, Alpha‑IoU Loss is selected as the loss function for constructing the detection model to improve the detection frame accuracy of the detection model and enhance the robustness of the detection model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision, and more specifically, to a method and system for detecting a human head. Background Art

[0002] With the continuous increase of urban population, crowd counting is an effective means to maintain order and safety in public places such as stations and shopping malls. Through crowd counting, the possibility of hidden dangers can be estimated in order to make management decisions. In transportation places such as subways and stations, crowd counting can be used for security prevention, passenger flow control and vehicle dispatch; in supermarkets and shopping malls, crowd counting can be used for business analysis and business decision-making. Currently, the commonly used crowd counting methods are manual counting, infrared crowd detection technology, computer vision detection technology, etc.

[0003] Manual counting is to arrange staff to count the number of people at the entrance or exit or by visually counting in surveillance videos. This method is more accurate when the number of people is small, but the labor cost is high, and when congestion occurs at a certain moment, it is difficult to quickly obtain the accurate number of people.

[0004] Infrared detection technology uses infrared sensors to detect passing human bodies. When there is a certain interval between pedestrians, it can detect more accurately, but when the interval is small, the detection effect will be very poor.

[0005] Computer vision detection technology is to apply the target detection technology in computer vision to video surveillance, automatically detect the heads of people in the video, and thus realize the head counting. The traditional target detection technology is to extract the HOG, SIFT and other features of the target, and then use AdaBoost, SVM and other algorithms to classify. This method has a relatively low accuracy and poor generalization ability. At present, the target detection technology with better effect is the detection method based on deep learning. Deep learning enables machines to imitate human activities such as vision, hearing and thinking, solves many complex pattern recognition problems, and has achieved many results in the field of computer vision. However, with the increasing application of detection methods based on deep learning, the defects of the detection methods have also emerged. Among them, the most prominent is that when there is crowding and heads are blocked by each other, the accuracy of the existing deep learning target detection method is not high, resulting in poor head detection effect. In the face of crowding and heads blocking each other, only by enhancing the ability of the detection model to extract useful features and making the detection model more accurate in image recognition can the current situation of low target detection accuracy be improved. Existing head detection methods cannot be applied to complex actual scenes. When there is a crowd and heads are blocked by each other, the accuracy of head detection decreases, which has become one of the urgent problems to be solved in the field of computer vision. Therefore, there is an urgent need for a head detection method and system that is applicable to complex actual scenes and can detect heads in images in real time and accurately, thereby achieving accurate head counting. Summary of the invention

[0006] The present invention aims to overcome at least one defect of the above-mentioned prior art and provide a head detection method and system for solving the problem that the existing head detection method has low head detection accuracy in complex practical scenarios.

[0007] The technical solution adopted by the present invention is:

[0008] A head detection method, comprising:

[0009] Collecting surveillance images and establishing a surveillance image sample set; the surveillance images include: a person's head and shoulder images and corresponding annotation frames; the surveillance image sample set includes: a surveillance image training set and a surveillance image test set;

[0010] Preprocessing the monitoring image sample set;

[0011] An initial detection model is established based on the yolov5 algorithm and the SwinTransformer module, and the detection model is trained using the preprocessed monitoring image samples to obtain a target detection model;

[0012] Obtaining a surveillance image set and inputting it into the target detection model;

[0013] The target detection model is used to perform head detection on the monitoring image set to obtain a head detection result.

[0014] As a further solution of the present invention, an initial detection model is established based on the yolov5 algorithm and the SwinTransformer module, and the detection model is trained using the preprocessed monitoring image samples to obtain a target detection model, including:

[0015] Iteratively training the initial detection model using the monitoring image training set to obtain a trained detection model;

[0016] The trained detection model is tested using the surveillance image test set, and corresponding model parameters in the detection model are adjusted according to the test results to obtain the target detection model.

[0017] As a further solution of the present invention, the initial detection model includes: a backbone network, a neck network and a detection head network; the backbone network includes a Focus layer, a first convolutional layer, a first CSP bottleneck layer, a second convolutional layer, a second CSP bottleneck layer, a third convolutional layer, a third CSP bottleneck layer, a fourth convolutional layer, a pooling layer and a first Swin Transformer module connected in sequence; the neck network includes a fifth convolutional layer, a first upsampling layer, a first connection layer, a fourth CSP bottleneck layer, a second Swin Transformer module, a sixth convolutional layer, a second upsampling layer, a second connection layer, a fifth CSP bottleneck layer, a third Swin Transformer module, a seventh convolutional layer, a third upsampling layer, a third connection layer, a sixth CSP bottleneck layer, a fourth Swin Transformer module, eighth convolutional layer, fourth connection layer, seventh CSP bottleneck layer, fifth SwinTransformer module, ninth convolutional layer, fifth connection layer and eighth CSP bottleneck layer; the detection head network includes: a first detection head, a second detection head and a third detection head; the first CSP bottleneck layer is connected to the third connection layer; the second CSP bottleneck layer is connected to the second connection layer; the third CSP bottleneck layer is connected to the first connection layer; the first SwinTransformer module is connected to the fifth convolutional layer; the sixth convolutional layer is connected to the fifth connection layer; the seventh convolutional layer is connected to the fourth connection layer; the sixth CSP bottleneck layer is connected to the first detection head; the seventh CSP bottleneck layer is connected to the second detection head; the eighth CSP bottleneck layer is connected to the third detection head.

[0018] As a further solution of the present invention, the target detection model is used to perform head detection on the monitoring image set to obtain a head detection result, including:

[0019] Performing a slicing operation on the monitoring image set to obtain a slicing feature map;

[0020] Performing multiple first feature extractions on the slice feature map to obtain a first feature map, a second feature map, a third feature map, and a fourth feature map; the first feature extraction is feature extraction performed using a CSP bottleneck layer;

[0021] The fourth feature map is subjected to pooling processing, second feature extraction and upsampling operations, and feature fusion is performed with the third feature map to obtain a fifth feature map; the second feature extraction is feature extraction performed using a Swin Transformer module;

[0022] Performing a second feature extraction on the fifth feature map to obtain a sixth feature map;

[0023] Performing an upsampling operation on the sixth feature map, and performing feature fusion with the second feature map to obtain a seventh feature map;

[0024] Performing a second feature extraction on the seventh feature map to obtain an eighth feature map;

[0025] Performing an upsampling operation on the eighth feature map, and performing feature fusion with the first feature map to obtain a ninth feature map;

[0026] Performing a second feature extraction on the ninth feature map, and performing feature fusion with the eighth feature map to obtain a tenth feature map;

[0027] Performing a second feature extraction on the tenth feature map, and performing feature fusion with the sixth feature map to obtain an eleventh feature map;

[0028] The ninth feature map, the tenth feature map and the eleventh feature map are input into corresponding detection heads, and the detection heads detect medium targets, small targets and extra-small targets to obtain head detection results.

[0029] As a further solution of the present invention, the loss function of the detection model is:

[0030]

[0031] Among them, Loss α-DIoU is the DIoULoss with the alpha parameter introduced, IoU is the intersection over union ratio between the predicted box and the real box, α is the parameter, ρ is the Euclidean distance, b is the coordinate of the center point of the predicted box, and b gt is the coordinate of the center point of the real box, and c is the diagonal distance between the predicted box and the minimum outer rectangle of the real box.

[0032] The solution also provides a head detection system, including:

[0033] The sample module is used to collect monitoring images and establish a monitoring image sample set; the monitoring images include: a person's head and shoulder images and corresponding annotation frames; the monitoring image sample set includes: a monitoring image training set and a monitoring image test set;

[0034] A preprocessing module, used for preprocessing the monitoring image sample set;

[0035] A training module is used to establish an initial detection model based on the yolov5 algorithm and the SwinTransformer module, and to train the detection model using the preprocessed monitoring image samples to obtain a target detection model;

[0036] An image module, used to obtain a monitoring image set and input it into the target detection model;

[0037] The detection module is used to perform head detection on the monitoring image set using the target detection model to obtain a head detection result.

[0038] As a further solution of the present invention, the training module includes:

[0039] An iterative unit, used for iteratively training the initial detection model using the monitoring image training set to obtain a trained detection model;

[0040] The testing unit is used to test the trained detection model using the monitoring image test set, and adjust the corresponding model parameters in the detection model according to the test results to obtain the target detection model.

[0041] As a further solution of the present invention, the initial detection model includes: a backbone network, a neck network and a detection head network; the backbone network includes a Focus layer, a first convolutional layer, a first CSP bottleneck layer, a second convolutional layer, a second CSP bottleneck layer, a third convolutional layer, a third CSP bottleneck layer, a fourth convolutional layer, a pooling layer and a first Swin Transformer module connected in sequence; the neck network includes a fifth convolutional layer, a first upsampling layer, a first connection layer, a fourth CSP bottleneck layer, a second Swin Transformer module, a sixth convolutional layer, a second upsampling layer, a second connection layer, a fifth CSP bottleneck layer, a third Swin Transformer module, a seventh convolutional layer, a third upsampling layer, a third connection layer, a sixth CSP bottleneck layer, a fourth Swin Transformer module, eighth convolutional layer, fourth connection layer, seventh CSP bottleneck layer, fifth SwinTransformer module, ninth convolutional layer, fifth connection layer and eighth CSP bottleneck layer; the detection head network includes: a first detection head, a second detection head and a third detection head; the first CSP bottleneck layer is connected to the third connection layer; the second CSP bottleneck layer is connected to the second connection layer; the third CSP bottleneck layer is connected to the first connection layer; the first SwinTransformer module is connected to the fifth convolutional layer; the sixth convolutional layer is connected to the fifth connection layer; the seventh convolutional layer is connected to the fourth connection layer; the sixth CSP bottleneck layer is connected to the first detection head; the seventh CSP bottleneck layer is connected to the second detection head; the eighth CSP bottleneck layer is connected to the third detection head.

[0042] As a further solution of the present invention, the detection module includes:

[0043] A slicing unit, used for performing a slicing operation on the monitoring image set to obtain a slicing feature map;

[0044] A first extraction unit is used to perform multiple first feature extractions on the slice feature map to obtain a first feature map, a second feature map, a third feature map, and a fourth feature map; the first feature extraction is feature extraction performed using a CSP bottleneck layer;

[0045] a first fusion unit, configured to perform pooling processing, second feature extraction and upsampling operations on the fourth feature map, and perform feature fusion with the third feature map to obtain a fifth feature map; the second feature extraction is feature extraction performed using a SwinTransformer module;

[0046] A second extraction unit, configured to perform a second feature extraction on the fifth feature map to obtain a sixth feature map;

[0047] A second fusion unit is used to perform an upsampling operation on the sixth feature map, and perform feature fusion with the second feature map to obtain a seventh feature map;

[0048] A third extraction unit, configured to perform a second feature extraction on the seventh feature map to obtain an eighth feature map;

[0049] a third fusion unit, configured to perform an upsampling operation on the eighth feature map, and perform feature fusion with the first feature map to obtain a ninth feature map;

[0050] a fourth fusion unit, configured to extract a second feature from the ninth feature map, and perform feature fusion with the eighth feature map to obtain a tenth feature map;

[0051] a fifth fusion unit, configured to extract a second feature from the tenth feature map, and perform feature fusion with the sixth feature map to obtain an eleventh feature map;

[0052] The detection unit is used to input the ninth feature map, the tenth feature map and the eleventh feature map into the corresponding detection head, and the detection head detects medium targets, small targets and very small targets to obtain a head detection result.

[0053] As a further solution of the present invention, the loss function of the detection model is:

[0054]

[0055] Among them, Loss α-DIou is the DIoULoss with the alpha parameter introduced, IoU is the intersection over union ratio between the predicted box and the real box, α is the parameter, ρ is the Euclidean distance, b is the coordinate of the center point of the predicted box, and b gt is the coordinate of the center point of the real box, and c is the diagonal distance between the predicted box and the minimum outer rectangle of the real box.

[0056] Compared with the prior art, the beneficial effects of the present invention are as follows: by introducing the Swin Transformer module into the yolov5 algorithm, the present invention enables the detection model to better focus on and fuse the global information and contextual information of the feature map, tap the potential of feature representation, extract more useful features, and improve the accuracy of head detection in crowded scenes. On this basis, the detection head branch of yolov5 is also modified, while the calculation amount of the detection model remains basically unchanged, the detection ability of small targets is improved, and the accuracy of head detection is further improved. In addition, Alpha-IoU Loss is selected as the loss function for constructing the detection model to improve the detection frame accuracy of the detection model and enhance the robustness of the detection model. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 is a flow chart of the method of the present invention;

[0058] Figure 2 It is the algorithm structure diagram of the present invention;

[0059] Figure 3 It is a schematic diagram of the bottleneck layer of the present invention;

[0060] Figure 4 It is a schematic diagram of the bottleneck layer of the CSP of the present invention;

[0061] Figure 5 Schematic diagram of the pooling layer of the present invention;

[0062] Figure 6 It is a schematic diagram of the Swin Trans module of the present invention;

[0063] Description of the reference numerals: backbone network 100, Focus layer 101, first convolution layer 102, first CSP bottleneck layer 103, second convolution layer 104, second CSP bottleneck layer 105, third convolution layer 106, third CSP bottleneck layer 107, fourth convolution layer 108, pooling layer 109, first Swin Transformer module 110, neck network 200, fifth convolution layer 201, first upsampling layer 202, first connection layer 203, fourth CSP bottleneck layer 204, second Swin Transformer module 205, sixth convolution layer 206, second upsampling layer 207, second connection layer 208, fifth CSP bottleneck layer 209, third Swin Transformer module 210, seventh convolutional layer 211, third upsampling layer 212, third connection layer 213, sixth CSP bottleneck layer 214, fourth SwinTransformer module 215, eighth convolutional layer 216, fourth connection layer 217, seventh CSP bottleneck layer 218, fifth SwinTransformer module 219, ninth convolutional layer 220, fifth connection layer 221, eighth CSP bottleneck layer 222, detection head network 300, first detection head 301, second detection head 302, third detection head 303. DETAILED DESCRIPTION

[0064] The drawings of the present invention are only for illustrative purposes and should not be construed as limiting the present invention. In order to better illustrate the following embodiments, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of the actual product; it is understandable to those skilled in the art that some well-known structures and their descriptions in the drawings may be omitted.

[0065] Example

[0066] like Figure 1As shown, this embodiment provides a head detection method, comprising the following steps:

[0067] S100. Collect surveillance images and establish a surveillance image sample set; the surveillance image includes: a person's head and shoulder image and a corresponding annotation box; the surveillance image sample set includes: a surveillance image training set and a surveillance image test set;

[0068] In order to ensure the diversity of data and make the detection model more generalizable, the source of data also needs to be diverse. In this embodiment, the monitoring image samples are collected from monitoring videos of bus stations, subway stations, streets, shopping malls and other places. When annotating the data, the annotation box in the monitoring image includes the head and shoulders of the person. After the data is annotated, the images in the monitoring image sample set are divided into a training set and a test set according to a ratio of 8:2.

[0069] S200. Preprocessing the monitoring image sample set;

[0070] The number of surveillance images collected is limited, and most surveillance images are often affected by weather factors such as lighting, resulting in a decrease in the quality of the image itself. In order to improve the diversity of training data and enhance the robustness of the model, the surveillance image sample set is preprocessed. The preprocessing includes: Mosaic data enhancement, adaptive anchor frame calculation, adaptive image scaling, adding noise and adjusting image contrast. The Mosaic data enhancement includes: random scaling, random cropping, and random arrangement for splicing. As a preferred embodiment of the present invention, the preprocessing selects to increase noise and adjust image contrast to simulate the impact of lighting in different weather on surveillance data.

[0071] S300. Establish an initial detection model based on the yolov5 algorithm and the SwinTransformer module, and train the detection model using the preprocessed monitoring image samples to obtain a target detection model;

[0072] In order to extract more effective features in the case of high-density crowds, in this embodiment, Swin Transformer modules are introduced into the backbone network and neck network of the yolov5 algorithm respectively. By introducing the Swin Transformer module into the yolov5 algorithm, the present invention enables the detection model to better focus on and fuse the global information and context information of the feature map, tap the potential of feature representation, extract more useful features, and improve the accuracy of head detection in crowded scenes.

[0073] As a further solution of the present invention, S300 includes the following steps:

[0074] S310. Iteratively train the initial detection model using the monitoring image training set to obtain a trained detection model;

[0075] S320. Use the monitoring image test set to test the trained detection model, adjust the corresponding model parameters in the detection model according to the test results, and obtain the target detection model.

[0076] S400. Obtain a monitoring image set and input it into the target detection model;

[0077] S500. Perform head detection on the monitoring image set using the target detection model to obtain a head detection result.

[0078] As a further solution of the present invention, S500 includes the following steps:

[0079] S510. Perform a slicing operation on the monitoring image set to obtain a slicing feature map;

[0080] S520. Perform multiple first feature extractions on the slice feature map to obtain a first feature map, a second feature map, a third feature map, and a fourth feature map; the first feature extraction is feature extraction performed using a CSP bottleneck layer;

[0081] The fourth feature map is subjected to pooling processing, second feature extraction and upsampling operations, and feature fusion is performed with the third feature map to obtain a fifth feature map; the second feature extraction is feature extraction performed using a Swin Transformer module;

[0082] Performing a second feature extraction on the fifth feature map to obtain a sixth feature map;

[0083] Performing an upsampling operation on the sixth feature map, and performing feature fusion with the second feature map to obtain a seventh feature map;

[0084] Performing a second feature extraction on the seventh feature map to obtain an eighth feature map;

[0085] Performing an upsampling operation on the eighth feature map, and performing feature fusion with the first feature map to obtain a ninth feature map;

[0086] Performing a second feature extraction on the ninth feature map, and performing feature fusion with the eighth feature map to obtain a tenth feature map;

[0087] Performing a second feature extraction on the tenth feature map, and performing feature fusion with the sixth feature map to obtain an eleventh feature map;

[0088] S530. Input the ninth feature map, the tenth feature map and the eleventh feature map into the corresponding detection head, and the detection head detects medium targets, small targets and very small targets to obtain a human head detection result.

[0089] The original yolov5 algorithm has three detection head output branches, corresponding to the detection of large, medium and small targets respectively. In the detection of human heads for monitoring images, the detection of small targets needs to be paid attention to. In order to detect smaller human heads, in this embodiment, a detection branch is introduced from the shallow layer of the backbone network of yolov5 for the detection of very small targets, and the original detection branch of large targets is removed. In this way, the detection model strengthens the detection of small targets while the calculation amount remains basically unchanged, thereby improving the accuracy of human head detection. The present invention improves the detection ability of small targets while the calculation amount of the detection model remains basically unchanged by modifying the detection head branch of yolov5, making the head count more accurate.

[0090] like Figure 2As shown, as a further solution of the present invention, the initial detection model in S300 includes: a backbone network 100, a neck network 200 and a detection head network 300; the backbone network includes a Focus layer 101, a first convolutional layer 102, a first CSP bottleneck layer 103, a second convolutional layer 104, a second CSP bottleneck layer 105, a third convolutional layer 106, a third CSP bottleneck layer 107, a fourth convolutional layer 108, a pooling layer 109 and a first Swin Transformer module 110 connected in sequence; the neck network 200 includes a fifth convolutional layer 201, a first upsampling layer 202, a first connection layer 203, a fourth CSP bottleneck layer 204, a second Swin Transformer module 205, a sixth convolutional layer 206, a second upsampling layer 207, a second connection layer 208, a fifth CSP bottleneck layer 209, a third Swin Transformer module 210, seventh convolution layer 211, third upsampling layer 212, third connection layer 213, sixth CSP bottleneck layer 214, fourth Swin Transformer module 215, eighth convolution layer 216, fourth connection layer 217, seventh CSP bottleneck layer 218, fifth Swin Transformer module 219, ninth convolutional layer 220, fifth connection layer 221 and eighth CSP bottleneck layer 222; the detection head network 300 includes: a first detection head 301, a second detection head 302 and a third detection head 303; the first CSP bottleneck layer 103 is connected to the third connection layer 218; the second CSP bottleneck layer 105 is connected to the second connection layer 208; the third CSP bottleneck layer 107 is connected to the first connection layer 203; the first SwinTransformer module 110 is connected to the fifth convolutional layer 201; the sixth convolutional layer 206 is connected to the fifth connection layer 221; the seventh convolutional layer 211 is connected to the fourth connection layer 217; the sixth CSP bottleneck layer 214 is connected to the first detection head 301; the seventh CSP bottleneck layer 218 is connected to the second detection head 302; the eighth CSP bottleneck layer 222 is connected to the third detection head 303.

[0091] As a preferred embodiment of the present invention, the first convolutional layer 102, the second convolutional layer 104, the third convolutional layer 106, the fourth convolutional layer 108, the eighth convolutional layer 216 and the ninth convolutional layer 220 select 2×3 convolutional layers, and the fifth convolutional layer 214, the sixth convolutional layer 102 and the seventh convolutional layer 102 select 1×1 convolutional layers.

[0092] like Figure 3 As shown, the bottleneck layer of the detection model consists of a 1×1 convolution layer and a 3×1 convolution layer.

[0093] like Figure 4As shown, the CSP bottleneck layer of the detection model consists of three 1×1 convolutional layers, N bottleneck layers and a connection layer.

[0094] like Figure 5 As shown, the pooling layer of the detection model consists of two 1×1 convolutional layers, three maximum pooling layers and one connection layer.

[0095] like Figure 6 As shown, the Swin Trans module of the detection model consists of two consecutive Swin Transformer Blocks. Each Swin Transformer Block has an MLP, an MSA module and a LayerNorm (LN) layer.

[0096] Since head detection has problems such as mutual occlusion and noise, in order to improve the detection frame accuracy of the detection model and enhance the robustness of the detection model. In this embodiment, Alpha-IoU Loss is selected as the loss function for constructing the detection model, and the alpha parameter is introduced based on DIoU Loss. The loss function of the detection model in S300 is:

[0097]

[0098] Among them, Loss α-DIou DIoU Loss introduces the alpha parameter, IoU is the intersection over union ratio between the predicted box and the real box, α is the parameter, ρ is the Euclidean distance, b is the coordinate of the center point of the predicted box, and b gt is the coordinate of the center point of the real box, and c is the diagonal distance between the predicted box and the minimum outer rectangle of the real box.

[0099] This embodiment also provides a head detection system, including:

[0100] The sample module is used to collect monitoring images and establish a monitoring image sample set; the monitoring images include: a person's head and shoulder images and corresponding annotation frames; the monitoring image sample set includes: a monitoring image training set and a monitoring image test set;

[0101] A preprocessing module, used for preprocessing the monitoring image sample set;

[0102] A training module is used to establish an initial detection model based on the yolov5 algorithm and the SwinTransformer module, and to train the detection model using the preprocessed monitoring image samples to obtain a target detection model;

[0103] As a further solution of the present invention, the training module includes:

[0104] An iterative unit, used for iteratively training the initial detection model using the monitoring image training set to obtain a trained detection model;

[0105] The testing unit is used to test the trained detection model using the monitoring image test set, and adjust the corresponding model parameters in the detection model according to the test results to obtain the target detection model.

[0106] An image module, used to obtain a monitoring image set and input it into the target detection model;

[0107] The detection module is used to perform head detection on the monitoring image set using the target detection model to obtain a head detection result.

[0108] As a further solution of the present invention, the detection module includes:

[0109] A slicing unit, used for performing a slicing operation on the monitoring image set to obtain a slicing feature map;

[0110] A first extraction unit is used to perform multiple first feature extractions on the slice feature map to obtain a first feature map, a second feature map, a third feature map, and a fourth feature map; the first feature extraction is feature extraction performed using a CSP bottleneck layer;

[0111] a first fusion unit, configured to perform pooling processing, second feature extraction and upsampling operations on the fourth feature map, and perform feature fusion with the third feature map to obtain a fifth feature map; the second feature extraction is feature extraction performed using a SwinTransformer module;

[0112] A second extraction unit, configured to perform a second feature extraction on the fifth feature map to obtain a sixth feature map;

[0113] A second fusion unit is used to perform an upsampling operation on the sixth feature map, and perform feature fusion with the second feature map to obtain a seventh feature map;

[0114] A third extraction unit, configured to perform a second feature extraction on the seventh feature map to obtain an eighth feature map;

[0115] a third fusion unit, configured to perform an upsampling operation on the eighth feature map, and perform feature fusion with the first feature map to obtain a ninth feature map;

[0116] a fourth fusion unit, configured to extract a second feature from the ninth feature map, and perform feature fusion with the eighth feature map to obtain a tenth feature map;

[0117] a fifth fusion unit, configured to extract a second feature from the tenth feature map, and perform feature fusion with the sixth feature map to obtain an eleventh feature map;

[0118] The detection unit is used to input the ninth feature map, the tenth feature map and the eleventh feature map into the corresponding detection head, and the detection head detects medium targets, small targets and very small targets to obtain a head detection result.

[0119] As a further solution of the present invention, in the training module, the initial detection model includes: a backbone network, a neck network and a detection head network; the backbone network includes a Focus layer, a first convolutional layer, a first CSP bottleneck layer, a second convolutional layer, a second CSP bottleneck layer, a third convolutional layer, a third CSP bottleneck layer, a fourth convolutional layer, a pooling layer and a first Swin Transformer module connected in sequence; the neck network includes a fifth convolutional layer, a first upsampling layer, a first connection layer, a fourth CSP bottleneck layer, a second Swin Transformer module, a sixth convolutional layer, a second upsampling layer, a second connection layer, a fifth CSP bottleneck layer, a third Swin Transformer module, a seventh convolutional layer, a third upsampling layer, a third connection layer, a sixth CSP bottleneck layer, a fourth Swin Transformer module, an eighth convolutional layer, a fourth connection layer, a seventh CSP bottleneck layer, a fifth Swin Transformer module, ninth convolutional layer, fifth connection layer and eighth CSP bottleneck layer; the detection head network includes: a first detection head, a second detection head and a third detection head; the first CSP bottleneck layer is connected to the third connection layer; the second CSP bottleneck layer is connected to the second connection layer; the third CSP bottleneck layer is connected to the first connection layer; the first SwinTransformer module is connected to the fifth convolutional layer; the sixth convolutional layer is connected to the fifth connection layer; the seventh convolutional layer is connected to the fourth connection layer; the sixth CSP bottleneck layer is connected to the first detection head; the seventh CSP bottleneck layer is connected to the second detection head; the eighth CSP bottleneck layer is connected to the third detection head.

[0120] As a further solution of the present invention, the loss function of the detection model in the training module is:

[0121]

[0122] Among them, Loss α-DIoU is the DIoULoss with the alpha parameter introduced, IoU is the intersection over union ratio between the predicted box and the real box, α is the parameter, ρ is the Euclidean distance, b is the coordinate of the center point of the predicted box, and b gt is the coordinate of the center point of the real box, and c is the diagonal distance between the predicted box and the minimum outer rectangle of the real box.

[0123] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.

Claims

1. A head detection method, characterized in that: include: Collect surveillance images and establish a surveillance image sample set; The monitoring image includes: a person's head and shoulder image and a corresponding annotation frame; the monitoring image sample set includes: a monitoring image training set and a monitoring image test set; Preprocessing the monitoring image sample set; An initial detection model is established based on the yolov5 algorithm and the Swin Transformer module, and the detection model is trained using the preprocessed monitoring image samples to obtain a target detection model; Obtaining a surveillance image set and inputting it into the target detection model; Using the target detection model to perform head detection on the monitoring image set to obtain a head detection result; The target detection model performs head detection on the monitoring image set to obtain a head detection result, including: Performing a slicing operation on the monitoring image set to obtain a slicing feature map; Performing multiple first feature extractions on the slice feature map to obtain a first feature map, a second feature map, a third feature map, and a fourth feature map; the first feature extraction is feature extraction performed using a CSP bottleneck layer; The fourth feature map is subjected to pooling processing, second feature extraction and upsampling operations, and feature fusion is performed with the third feature map to obtain a fifth feature map; the second feature extraction is feature extraction performed using a Swin Transformer module; Performing a second feature extraction on the fifth feature map to obtain a sixth feature map; Performing an upsampling operation on the sixth feature map, and performing feature fusion with the second feature map to obtain a seventh feature map; Performing a second feature extraction on the seventh feature map to obtain an eighth feature map; Performing an upsampling operation on the eighth feature map, and performing feature fusion with the first feature map to obtain a ninth feature map; Performing a second feature extraction on the ninth feature map, and performing feature fusion with the eighth feature map to obtain a tenth feature map; Performing a second feature extraction on the tenth feature map, and performing feature fusion with the sixth feature map to obtain an eleventh feature map; The ninth feature map, the tenth feature map and the eleventh feature map are input into corresponding detection heads, and the detection heads detect medium targets, small targets and extra-small targets to obtain head detection results.

2. A head detection method according to claim 1, characterized in that: An initial detection model is established based on the yolov5 algorithm and the SwinTransformer module, and the detection model is trained using the preprocessed surveillance image samples to obtain a target detection model, including: Iteratively training the initial detection model using the monitoring image training set to obtain a trained detection model; The trained detection model is tested using the surveillance image test set, and corresponding model parameters in the detection model are adjusted according to the test results to obtain the target detection model.

3. A head detection method according to claim 1, characterized in that: The initial detection model includes: a backbone network, a neck network and a detection head network; the backbone network includes a Focus layer, a first convolutional layer, a first CSP bottleneck layer, a second convolutional layer, a second CSP bottleneck layer, a third convolutional layer, a third CSP bottleneck layer, a fourth convolutional layer, a pooling layer and a first Swin Transformer module connected in sequence; the neck network includes a fifth convolutional layer, a first upsampling layer, a first connection layer, a fourth CSP bottleneck layer, a second Swin Transformer module, a sixth convolutional layer, a second upsampling layer, a second connection layer, a fifth CSP bottleneck layer, a third Swin Transformer module, a seventh convolutional layer, a third upsampling layer, a third connection layer, a sixth CSP bottleneck layer, a fourth Swin Transformer module, an eighth convolutional layer, a fourth connection layer, a seventh CSP bottleneck layer, a fifth Swin Transformer module, ninth convolutional layer, fifth connection layer and eighth CSP bottleneck layer; the detection head network includes: a first detection head, a second detection head and a third detection head; the first CSP bottleneck layer is connected to the third connection layer; the second CSP bottleneck layer is connected to the second connection layer; the third CSP bottleneck layer is connected to the first connection layer; the first Swin Transformer module is connected to the fifth convolutional layer; the sixth convolutional layer is connected to the fifth connection layer; the seventh convolutional layer is connected to the fourth connection layer; the sixth CSP bottleneck layer is connected to the first detection head; the seventh CSP bottleneck layer is connected to the second detection head; the eighth CSP bottleneck layer is connected to the third detection head.

4. A head detection method according to claim 1, characterized in that: The loss function of the detection model is: in, For the introduction of the alpha parameter DIoU of Loss , IoU is the intersection-over-union ratio of the predicted box and the true box, α As parameters, ρ is the Euclidean distance, b is the center point coordinate of the prediction box, b gt is the center point coordinate of the real frame, c It is the diagonal distance between the predicted box and the minimum outer rectangle of the real box.

5. A head detection system, characterized in that: include: The sample module is used to collect monitoring images and establish a monitoring image sample set; The monitoring image includes: a person's head and shoulder image and a corresponding annotation frame; the monitoring image sample set includes: a monitoring image training set and a monitoring image test set; A preprocessing module, used for preprocessing the monitoring image sample set; A training module is used to establish an initial detection model based on the yolov5 algorithm and the Swin Transformer module, and to train the detection model using the preprocessed monitoring image samples to obtain a target detection model; An image module, used to obtain a monitoring image set and input it into the target detection model; A detection module, used to perform head detection on the monitoring image set using the target detection model to obtain a head detection result; The detection module comprises: A slicing unit, used for performing a slicing operation on the monitoring image set to obtain a slicing feature map; A first extraction unit is used to perform multiple first feature extractions on the slice feature map to obtain a first feature map, a second feature map, a third feature map, and a fourth feature map; the first feature extraction is feature extraction performed using a CSP bottleneck layer; a first fusion unit, configured to perform pooling processing, second feature extraction and upsampling operations on the fourth feature map, and perform feature fusion with the third feature map to obtain a fifth feature map; the second feature extraction is feature extraction performed using a SwinTransformer module; A second extraction unit, configured to perform a second feature extraction on the fifth feature map to obtain a sixth feature map; A second fusion unit is used to perform an upsampling operation on the sixth feature map, and perform feature fusion with the second feature map to obtain a seventh feature map; A third extraction unit, configured to perform a second feature extraction on the seventh feature map to obtain an eighth feature map; a third fusion unit, configured to perform an upsampling operation on the eighth feature map, and perform feature fusion with the first feature map to obtain a ninth feature map; a fourth fusion unit, configured to extract a second feature from the ninth feature map, and perform feature fusion with the eighth feature map to obtain a tenth feature map; a fifth fusion unit, configured to extract a second feature from the tenth feature map, and perform feature fusion with the sixth feature map to obtain an eleventh feature map; The detection unit is used to input the ninth feature map, the tenth feature map and the eleventh feature map into the corresponding detection head, and the detection head detects medium targets, small targets and very small targets to obtain a head detection result.

6. A head detection system according to claim 5, characterized in that: The training modules include: An iterative unit, used for iteratively training the initial detection model using the monitoring image training set to obtain a trained detection model; The testing unit is used to test the trained detection model using the monitoring image test set, and adjust the corresponding model parameters in the detection model according to the test results to obtain the target detection model.

7. The head detection system according to claim 5, characterized in that: The initial detection model includes: a backbone network, a neck network and a detection head network; the backbone network includes a Focus layer, a first convolutional layer, a first CSP bottleneck layer, a second convolutional layer, a second CSP bottleneck layer, a third convolutional layer, a third CSP bottleneck layer, a fourth convolutional layer, a pooling layer and a first Swin Transformer module connected in sequence; the neck network includes a fifth convolutional layer, a first upsampling layer, a first connection layer, a fourth CSP bottleneck layer, a second Swin Transformer module, a sixth convolutional layer, a second upsampling layer, a second connection layer, a fifth CSP bottleneck layer, a third Swin Transformer module, a seventh convolutional layer, a third upsampling layer, a third connection layer, a sixth CSP bottleneck layer, a fourth Swin Transformer module, an eighth convolutional layer, a fourth connection layer, a seventh CSP bottleneck layer, a fifth Swin Transformer module, ninth convolutional layer, fifth connection layer and eighth CSP bottleneck layer; the detection head network includes: a first detection head, a second detection head and a third detection head; the first CSP bottleneck layer is connected to the third connection layer; the second CSP bottleneck layer is connected to the second connection layer; the third CSP bottleneck layer is connected to the first connection layer; the first Swin Transformer module is connected to the fifth convolutional layer; the sixth convolutional layer is connected to the fifth connection layer; the seventh convolutional layer is connected to the fourth connection layer; the sixth CSP bottleneck layer is connected to the first detection head; the seventh CSP bottleneck layer is connected to the second detection head; the eighth CSP bottleneck layer is connected to the third detection head.

8. The head detection system according to claim 5, characterized in that: The loss function of the detection model is: in, For the introduction of the alpha parameter DIoU of Loss , IoU is the intersection-over-union ratio of the predicted box and the true box, α As parameters, ρ is the Euclidean distance, b is the center point coordinate of the prediction box, b gt is the center point coordinate of the real frame, c It is the diagonal distance between the predicted box and the minimum outer rectangle of the real box.

Citation Information

Patent Citations

  • Pedestrian tracking method under dense pedestrian flow condition of subway platform

    CN113743260A

  • Safety helmet wearing detection method and system based on YOLO improved model

    CN113781469A

  • Satellite image small target detection method based on improved YOLOv5

    CN114220015A