Intensive face detection method, device and computer equipment
By improving the combination of the YOLOV8 model and the TensorRT engine, the problem of rapid recognition and statistics of multiple faces was solved, enabling rapid and accurate crowd size judgment and early warning in crowded places, thus improving the efficiency and accuracy of face detection.
Patent Information
- Application Number
- CN202411904002.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-12-23
AI Technical Summary
Existing technologies are insufficient for quickly and accurately identifying and counting multiple faces in crowded places, limiting their application scenarios.
An improved YOLOV8 model is adopted, incorporating a HAM hybrid attention mechanism, normalized Wasserstein distance, and Block reparameters. Combined with the TensorRT engine to accelerate processing, it achieves fast face detection and count determination.
It enables rapid and accurate identification and judgment of crowd size in high-traffic areas, and provides timely warnings when the number exceeds a preset limit, making it easier for administrators to manage crowd flow.
Smart Images

Figure CN119832496B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of face recognition, in particular to a dense face detection method and device and computer equipment. BACKGROUND
[0002] With the rapid development of face recognition technology, face recognition is increasingly widely used in access control systems, intelligent protection and other fields. Through face recognition technology, the identity of the person to be recognized can be quickly and non-contactly identified, which has great application prospects. However, the current mainstream face recognition technology mainly targets near-distance target recognition and detection, and the target detected each time is usually only a single target, and multiple targets in the area are not identified and determined, so the application scenarios are still limited.
[0003] Therefore, for important places such as community streets, campuses, entrances and exits of train stations, and entrances and exits of subway stations, where people flow needs to be controlled and the number of people is large, a method for quickly and accurately identifying and determining the number of faces in the place is needed to realize the counting of the number of people and assist the administrator in diverting the crowd. SUMMARY
[0004] The technical problem to be solved by the present application is to provide a dense face detection method, device and computer equipment, aiming to solve the problem of rapid face recognition of multiple faces.
[0005] To solve the above technical problems, the technical scheme adopted by the present application is as follows: a dense face detection method, comprising:
[0006] Importing a training set picture to train an improved YOLOV8 model to obtain a visual detection model; the improved YOLOV8 model comprises: introducing a HAM hybrid attention mechanism in a C2f module of a general YOLOV8 model; introducing a small target detection head; using a normalized Wasserstein distance as a measurement standard for calculating the similarity between the training model and the actual model; introducing a Block reparameterization to optimize the running speed of the entire YOLOV8 model;
[0007] Deploying the visual detection model to a development board;
[0008] Using a TensorRT engine to accelerate the processing of the visual detection model;
[0009] Performing target detection on the images collected by the camera through the visual detection model;
[0010] Determining whether the number of faces in the recognition area is greater than a preset target number;
[0011] If the number of faces in the recognition area is greater than the preset target number, a prompt is sent to the administrator.
[0012] Further, the improved YOLOV8 model includes a Backbone network, a Neck network and a Head network; the improved YOLOV8 model is trained by importing the training set pictures to obtain a visual detection model, which includes:
[0013] The training set pictures are imported into the improved YOLOV8 model to convert them into pictures of a preset size;
[0014] The pictures of the preset size are input into the Backbone network, and the C2f module is used to repeatedly operate and extract features by introducing a HAM hybrid attention mechanism, and a first specified size picture is output;
[0015] The first specified size picture is input into the Neck network to repeatedly calculate feature maps, and a second specified size picture is output;
[0016] The second specified size picture is input into the Head network to splice feature maps, and the spliced feature maps are used as the features for detection and judgment of the detection head to obtain the visual detection model.
[0017] Further, the visual detection model is accelerated by using a TensorRT engine, which includes:
[0018] Before inference, the TensorRT uses a calibration data set to estimate the dynamic range of the weights and activation values of the visual detection model;
[0019] The minimum value and the maximum value of each layer of the visual detection model are determined by the calibration data set, assuming that the maximum range of a layer of activation values is [-m, m], and the range of INT8 values is [-127, 127], then the scaling factor S is:
[0020]
[0021] During actual inference, the floating point activation value X is converted into:
[0022] X INT8 = round(S*X)
[0023] When the inference is completed, the INT8 result is dequantized into a floating point number by using the same scaling factor S:
[0024]
[0025] During the inference process, the GPU uses a specific INT8 kernel to calculate and complete the acceleration of the visual detection model.
[0026] Further, the HAM mixed attention mechanism introduced in the C2f module of the general YOLOV8 model is specifically that the average pooling and maximum pooling of the input feature input branch of the C2f module are summed, so that the YOLOV8 model learns the degree information of the corresponding target and the discriminative features of the corresponding target respectively; the maximum pooling encodes the saliency information of the target to supplement the global information encoded by the average pooling.
[0027] Further, the calculation formula of the maximum pooling is:
[0028] Max_O[i,j]=max(input[i*size:(i+1)*size,j*size:(j+1)*size])
[0029] Where Max_O[i,j] represents a pixel value in the output feature map after pooling, input is the input feature map, and size is the window size of the pooling operation.
[0030] The calculation formula of the average pooling is:
[0031] Ave_O[i,j]=mean(input[i*size:(i+1)*size,j*size:(j+1)*size])
[0032] Where Ave_O[i,j] represents a pixel value in the output feature map after pooling, input is the input feature map, size is the window size of the pooling operation, and mean represents the average value of the pixels inside.
[0033] Further, in the step of adopting the normalized Wasserstein distance as a measurement standard for calculating the similarity between the training model and the actual model, a Gaussian distribution is adopted, and the formula is:
[0034]
[0035] Where μ is the mean of the distribution, representing the center position of the distribution; σ is the standard deviation, representing the width of the distribution; and exp represents the natural exponential function.
[0036] Further, the Block re-parameterization is introduced to optimize the running speed of the entire YOLOV8 model, including:
[0037] The re-parameterizable dual-resolution network is placed in the C2f module, the Bottleneck function model inside the C2f module is replaced with the RDRNet function model, the re-parameterizable dual-resolution network is used to obtain shallow features, and the feature map is divided into a semantic branch and a detail branch; the semantic branch is used to learn deep semantic information, and the detail branch is used to capture spatial detail information.
[0038] The application also provides a dense face detection device, comprising:
[0039] A model training module is configured to import a training set picture to train an improved YOLOV8 model to obtain a visual detection model; the improved YOLOV8 model comprises: introducing a HAM hybrid attention mechanism in a C2f module of a general YOLOV8 model; introducing a small target detection head; adopting a normalized Wasserstein distance as a measurement standard for calculating the similarity between a training model and an actual model; and introducing a Block reparameterization to optimize the running speed of the entire YOLOV8 model;
[0040] A model deployment module is configured to deploy the visual detection model to a development board;
[0041] A model acceleration module is configured to use a TensorRT engine to accelerate the processing of the visual detection model;
[0042] A face detection module is configured to perform target detection on an image collected by a camera through the visual detection model;
[0043] A face quantity judgment module is configured to judge whether the number of faces in a recognition area is greater than a preset target number;
[0044] A face quantity warning module is configured to send a prompt to a manager if the number of faces in the recognition area is greater than the preset target number.
[0045] The application also provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the dense face detection method according to any one of the above when executing the computer program.
[0046] The application also provides a storage medium storing a computer program, wherein the computer program can implement the dense face detection method according to any one of the above when executed by a processor.
[0047] The application has the following beneficial effects: the HAM hybrid attention mechanism is introduced in the C2f module of the general YOLOV8 model; the small target detection head is introduced; the normalized Wasserstein distance is adopted as the measurement standard for calculating the similarity between the training model and the actual model; the Block reparameterization is introduced to optimize the running speed of the entire YOLOV8 model; the number of people in a statistical occasion can be quickly and accurately identified and judged; when the number exceeds the preset number, a warning is given in time, and the manager can conveniently divert the crowd. BRIEF DESCRIPTION OF DRAWINGS
[0048] The specific structure of the application will be described in detail below with reference to the drawings.
[0049] Figure 1 A dense face detection method flow chart for an embodiment of the present application;
[0050] Figure 2 A dense face detection device block diagram for an embodiment of the present application;
[0051] Figure 3 An improved YOLOV8 model network structure diagram for an embodiment of the present application;
[0052] Figure 4 A precision rate iteration data comparison diagram for three different YOLOV8 models for an embodiment of the present application;
[0053] Figure 5 A schematic block diagram of a computer device for an embodiment of the present application. DETAILED DESCRIPTION
[0054] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0055] It should be understood that, when used in the specification and the appended claims, the terms “comprise” and “include” indicate the presence of described features, integers, steps, operations, elements, and / or components, but do not exclude one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0056] It should also be understood that the terms used in the present application specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the present application specification and the appended claims, the singular forms “a”, “an” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0057] It should be further understood that the term “and / or” used in the present application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0058] As shown in Figure 1 the first embodiment of the present application is a dense face detection method, comprising the steps of:
[0059] S10, import the training set picture to train the improved YOLOV8 model to obtain a visual detection model; the improved YOLOV8 model comprises: introducing a HAM hybrid attention mechanism in a C2f module of a general YOLOV8 model; introducing a small target detection head P2; adopting a normalized Wasserstein distance as a measurement standard for calculating the similarity between the training model and the actual model; and introducing a Block reparameterization to optimize the running speed of the entire YOLOV8 model.
[0060] In a specific embodiment, the HAM hybrid attention mechanism introduced in the C2f module of the general YOLOV8 model is specifically that, after summing the average pooling and the maximum pooling of the input feature input branch of the C2f module, the YOLOV8 model learns the degree information of the corresponding target and the discriminative features of the corresponding target respectively; the saliency information of the target is encoded through the maximum pooling to supplement the global information encoded by the average pooling.
[0061] In a specific embodiment, the calculation formula of the maximum pooling is:
[0062] Max_O[i,j]=max(input[i*size:(i+1)*size,j*size:(j+1)*size])
[0063] Wherein, Max_O[i,j] represents a certain pixel value in the output feature map after pooling, input is an input feature map, and size is a window size of the pooling operation.
[0064] The calculation formula of the average pooling is:
[0065] Ave_O[i,j]=mean(input[i*size:(i+1)*size,j*size:(j+1)*size])
[0066] Wherein, Ave_O[i,j] represents a certain pixel value in the output feature map after pooling, input is an input feature map, size is a window size of the pooling operation, and mean represents the average value of the pixels inside.
[0067] In a specific embodiment, in the measurement standard for calculating the similarity between the training model and the actual model by adopting the normalized Wasserstein distance, a Gaussian distribution is adopted, and the formula is:
[0068]
[0069] Wherein, μ is the mean of the distribution, representing the center position of the distribution. σ is the standard deviation, indicating the width of the distribution. The smaller σ is, the sharper the curve is, and the more concentrated the data distribution is; the larger σ is, the flatter the curve is, and the more dispersed the data distribution is. exp represents the natural exponential function.
[0070] In a specific embodiment, the introduction of the Block re-parameterization to optimize the running speed of the entire YOLOV8 model includes:
[0071] Put the re-parameterizable dual-resolution network into the C2f module, replace the Bottleneck function model inside the C2f module with the RDRNet function model, use the re-parameterizable dual-resolution network to obtain shallow features, and split the feature map into a semantic branch and a detail branch. The semantic branch is used to learn deep semantic information, and the detail branch is used to capture spatial detail information.
[0072] In a specific embodiment, the improved YOLOV8 model includes a Backbone network, a Neck network, and a Head network; and the importing of the training set pictures to train the improved YOLOV8 model to obtain a visual detection model includes:
[0073] S11, importing the training set pictures into the improved YOLOV8 model to convert them into pictures of a preset size;
[0074] S12, inputting the pictures of the preset size into the Backbone network, repeatedly operating the C2f module through the introduction of the HAM hybrid attention mechanism to extract features, and outputting pictures of a first specified specification;
[0075] S13, inputting the pictures of the first specified specification into the Neck network to repeatedly calculate feature maps, and outputting pictures of a second specified specification;
[0076] S14, inputting the pictures of the second specified specification into the Head network to splice feature maps, using the spliced feature maps as the features for detection and judgment of the detection head, and obtaining a visual detection model.
[0077] In a specific embodiment, the improved YOLOV8 model is trained using a deep learning network, and the parameters used for training are epochs=300, device='0', batch=4, seed=42. The selected NWD parameter nwd_ratio is 0.5, which is a balance coefficient, i.e., NWD and IOU each take 50%, adjusted according to the number of small targets in the dataset. The dataset used in this patent is the JHU-CROWD++ dataset, which is a large-scale unrestricted crowd counting dataset. Compared with existing datasets, it can better reflect the characteristics of dense crowds. It collects pictures of crowds in various different scenes and environmental conditions. The picture data used as the training set and the validation set contains 14491 pictures and 137,000 annotations, i.e., an average of 9.4 faces per picture. After normalization calculation, most of the face sizes are within 0.03*0.03, i.e., the face occupies less than 1% of the picture size. This provides a very rich and dense face annotation set, which is suitable for dense crowd detection. Then we input the dataset into our improved YOLOV8 improved model, as shown in Figure 3 , the steps are as follows:
[0078] Step 1, initialize the input picture and convert it to a 3-channel picture with a size of 640*640.
[0079] Step 2, enter the Backbone network part, input the converted picture into the convolution network Conv, and convert it to a feature map with a channel number of 64 and a size compression of 320*320 (i.e., 320*320*64).
[0080] Step 3, continue to input the feature map with a channel number of 64 and a size compression of 320*320 into module ①, which contains convolution network Conv and C2f module. Convolution network Conv will convert the picture to a feature map with a channel number of 128 and a size compression of 160*160. Then input the picture into the improved core module C2f, which performs three C2f operations. The C2f module adds a HAM hybrid attention mechanism, and finally outputs a feature map with a channel number of 128 and a size compression of 160*160.
[0081] Step 4, perform step 3 three times, but the second and third times will additionally perform three C2f operations.
[0082] Step 5, input the data processed by multiple convolution operations into the improved SPPF module, and finally output a picture with a size of 20*20*1024.
[0083] Step 6, enter the Neck network part: input the above picture into module ②, which includes an upsampling module Upsample, a splicing module Concat, and a C2f module. The 20*20*1024 feature map is input into the upsampling module Upsample and is converted into a 40*40*1024 feature map, and then is input into the splicing module Concat and spliced with the 40*40*512 feature map processed by C2f in step 4, and finally a 40*40*512 feature map is output.
[0084] Step 7, repeat step 6 twice, i.e. the Neck part performs step 6 for a total of 3 times, and finally outputs the corresponding size feature map of each module ② C2f, and a total of 40*40*512, 80*80*256, 160*160*128 generated pictures are output, and finally a picture with a size of 160*160*128 is output.
[0085] Step 8, enter the Head network part: first input the picture obtained in step 7 into the detection head module Detect, which is used as a feature map for detection judgment, i.e. the corresponding picture size of the detection head is 160*160.
[0086] Step 9, input the picture obtained in step 7 into module ③ at the same time, which includes a convolution network Conv, a splicing module Concat, and a C2f module. The picture is first changed in size by convolution, and the picture size is changed to 80*80, and then input into the splicing module Concat and spliced with the C2f output of the Neck (i.e. the result of step 7 80*80), and then input into the C2f module to generate a 80*80 feature map, and then input it into the second detection head for detection judgment.
[0087] Step 10, repeat step 9 twice; i.e. the Head network part performs step 9 for a total of 3 times, and finally outputs the corresponding size feature map of each module ③ C2f, and inputs it into the detection head for judgment. The splicing object of the splicing module Concat in the last time is the output of the SPPF module.
[0088] Step 11, use the four detection heads for model detection judgment, thereby completing model training.
[0089] S20, deploy the visual detection model to the development board.
[0090] The improved target detection algorithm is deployed to the Jetson ORIN NX board of NVIDIA company. The Jetson Orin NX module is extremely small, but can provide up to 100TOPS of AI performance, suitable for use as an edge deployment recognition algorithm. At the same time, the trained model is optimized by tensorRT, which is a high-performance inference engine based on deep learning used by NVIDIA. It is designed for deployment in production environments and can significantly improve the inference speed and efficiency of deep learning models running on NVIDIA GPUs. With NoMachine software, remote wireless monitoring of camera output content can be realized, and finally the administrator can assist in outputting the recognition result to observe the crowd density and realize intelligent crowd distribution.
[0091] S30, accelerating the visual detection model by using the TensorRT engine.
[0092] In an embodiment, further, the accelerating the visual detection model by using the TensorRT engine comprises:
[0093] S31, before inference, the TensorRT uses the calibration data set to estimate the dynamic range of the weight and activation value of the visual detection model.
[0094] In this embodiment, since the INT8 precision is low, the purpose of calibration is to find the optimal scaling factor of each layer to ensure that the model accuracy can be maintained at a relatively good level under low precision.
[0095] S32, determine the minimum and maximum values of each layer of the visual detection model through the calibration data set. Assuming that the maximum range of a layer activation value is [-m, m], and the range of INT8 value is [-127, 127], then the scaling factor S is:
[0096]
[0097] During actual inference, the floating-point activation value X becomes:
[0098] X INT8 = round(S*X)
[0099] At the end of inference, the INT8 result is dequantized to a floating-point number by using the same scaling factor S:
[0100]
[0101] S33, in the reasoning process, the GPU uses specific INT8 kernels for calculation, completing the acceleration processing of the visual detection model. These kernels are more efficient than FP32 or FP16 kernels because the calculation resources and memory bandwidth required for 8-bit integer operations are significantly reduced.
[0102] In this embodiment, the weights and activation values in the model are quantized from floating point to 8-bit integer, usually quantizing FP32 to INT8, to reduce the calculation and storage overhead.
[0103] S40, the visual detection model is used to detect the target in the image collected by the camera.
[0104] S50, determine whether the number of faces in the recognition area is greater than the preset target number.
[0105] S60, if the number of faces in the recognition area is greater than the preset target number, a prompt is sent to the manager.
[0106] Table 1: Comparison of prediction results of three different models.
[0107]
[0108] Among them, YOLOV8-Ori is the original YOLO model, YOLOV8-HAM is the improved model added with hybrid attention mechanism HAM, and YOLOV8-Improve is the hybrid model improved by the patent.
[0109] Among them,
[0110]
[0111] TP (True positives): the number of correctly classified positive examples, i.e. the number of instances (samples) that are actually positive and classified as positive by the classifier.
[0112] FP (False positives): the number of incorrectly classified positive examples, i.e. the number of instances that are actually negative but classified as positive by the classifier.
[0113] FN (False negatives): the number of incorrectly classified negative examples, i.e. the number of instances that are actually positive but classified as negative by the classifier.
[0114] TN (True negatives): the number of correctly classified negative examples, i.e. the number of instances that are actually negative and classified as negative by the classifier.
[0115] For the data in Table 1, precision is a measure of the proportion of positive samples (i.e., detected targets) that the model correctly predicted. F1-score is the harmonic mean of precision and recall. It takes into account both the precision and recall of the model, especially suitable for class imbalance scenarios. mAP (Mean Average Precision) is an important indicator in the performance evaluation of target detection models, which is usually calculated at different Intersection over Union (IoU) thresholds. mAP 0.5 represents the average precision at an IoU threshold of 0.5.
[0116] It can be found that the improved model YOLOV8-Improve of the present patent has better improvements in precision, F1-score and mAP 0.5, which are key indicators of visual recognition, compared with the original model and the simple attention improved model, as shown in the results of Figure 4
[0117] As shown in Figure 2 The embodiment of the present application also provides a dense face detection device, which comprises:
[0118] A model training module 10 is configured to import a training set picture to train an improved YOLOV8 model, so as to obtain a visual detection model. The improved YOLOV8 model comprises: introducing a HAM hybrid attention mechanism in a C2f module of a general YOLOV8 model; introducing a small target detection head P2; adopting a normalized Wasserstein distance as a measurement standard for calculating the similarity between the training model and the actual model; and introducing a Block reparameterization to optimize the running speed of the entire YOLOV8 model.
[0119] A model deployment module 20 is configured to deploy the visual detection model to a development board.
[0120] A model acceleration module 30 is configured to use a TensorRT engine to accelerate the processing of the visual detection model.
[0121] A face detection module 40 is configured to perform target detection on images collected by a camera through the visual detection model.
[0122] A face number judgment module 50 is configured to judge whether the number of faces in a recognition area is greater than a preset target number.
[0123] A face warning module 60 is configured to issue a prompt to a manager if the number of faces in the recognition area is greater than the preset target number.
[0124] It should be noted that the specific implementation process of the above dense face detection device can be clearly understood by those skilled in the art, and can refer to the corresponding description in the foregoing method embodiments. For the convenience and brevity of description, it will not be repeated here.
[0125] The above dense face detection device can be implemented in the form of a computer program, which can run on a computer device as shown in the figure. Figure 5
[0126] Please refer to Figure 5 , Figure 5 is a schematic block diagram of a computer device provided by an embodiment of the present application. The computer device 500 can be a terminal or a server, wherein the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, a wearable device, and an electronic device with a communication function. The server can be a stand-alone server or a server cluster composed of multiple servers.
[0127] Please refer to Figure 5 , the computer device 500 includes a processor 502, a memory and a network interface 505 connected through a system bus 501, wherein the memory can include a non-volatile storage medium 503 and an internal memory 504.
[0128] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, which when executed, can cause the processor 502 to perform a dense face detection method.
[0129] The processor 502 is configured to provide computing and control capabilities to support the operation of the entire computer device 500.
[0130] The internal memory 504 provides an environment for the running of the computer program 5032 in the non-volatile storage medium 503, which when executed by the processor 502, can cause the processor 502 to perform a dense face detection method.
[0131] The network interface 505 is configured to perform network communication with other devices. Those skilled in the art can understand that Figure 5 the structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device 500 to which the scheme of the present application is applied. The specific computer device 500 can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0132] The processor 502 is configured to run the computer program 5032 stored in the memory to implement the dense face detection method as described above.
[0133] It should be understood that, in the embodiments of the present application, the processor 502 can be a central processing unit (CPU), and the processor 502 can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0134] It can be understood by those skilled in the art that all or part of the processes in the method of the above embodiments can be completed by a computer program instructing related hardware. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the above method embodiments.
[0135] Therefore, the present application also provides a storage medium. The storage medium can be a computer readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. The program instructions are executed by the processor to make the processor execute the dense face detection method as described above.
[0136] The storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, and various computer readable storage media that can store program codes.
[0137] Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0138] In several embodiments provided by the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. For example, the embodiments of the apparatus described above are merely schematic. For example, the division of the units is merely a logical function division. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In this way, the inventive idea can be implemented.
[0139] The steps in the method embodiments of the present application can be adjusted, combined and deleted in sequence according to actual needs. The units in the apparatus embodiments of the present application can be combined, divided and deleted according to actual needs. In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.
[0140] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a storage medium. Based on such understanding, the technical solutions of the present application, essentially or in the contribution to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0141] The above describes only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed by the present application, and these modifications or replacements should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A dense face detection method, characterized in that, include: An improved YOLOV8 model is trained using imported training set images to obtain a visual detection model. The improved YOLOV8 model includes: introducing a HAM hybrid attention mechanism into the C2f module of the general YOLOV8 model; introducing a small target detection head; using normalized Wasserstein distance as a metric for calculating the similarity between the trained model and the actual model; and introducing Block reparameters to optimize the overall running speed of the YOLOV8 model. Specifically, the introduction of the HAM hybrid attention mechanism into the C2f module of the general YOLOV8 model involves summing the average pooling and max pooling operations in the input feature input branch of the C2f module, allowing the YOLOV8 model to learn the degree information and discriminative features of the corresponding target, respectively; and using max pooling to encode the saliency information of the target to supplement the global information encoded by average pooling. Deploy the visual inspection model onto the development board; The TensorRT engine is used to accelerate the processing of visual detection models; Target detection is performed on images captured by the camera using a visual detection model; Determine whether the number of faces within the recognition area is greater than the preset target number; If the number of faces in the recognition area exceeds the preset target number, a prompt will be sent to the management personnel; The acceleration of the visual detection model using the TensorRT engine includes: Before inference, TensorRT uses a calibration dataset to estimate the dynamic range of the weights and activation values of the visual detection model; The minimum and maximum values of each layer of the visual detection model are determined by calibrating the dataset. Assuming the maximum range of activation values for a layer is [-m, m] and the range of INT8 values is [-127, 127], then the scaling factor S is: In actual reasoning, the floating-point activation value X becomes after quantization: X INT8 =round(S*X) At the end of the inference, the INT8 result is dequantized to a floating-point number using the same scaling factor S: During inference, the GPU uses the INT8 core to perform calculations, thereby accelerating the processing of the visual detection model; The introduction of Block reparameters to optimize the running speed of the entire YOLOv8 model includes: A reparameterizable dual-resolution network is placed into the C2f module, and the Bottleneck function model inside the C2f module is replaced with the RDRNet function model. Shallow features are obtained using the reparameterizable dual-resolution network, and the feature maps are split into semantic branches and detail branches. The semantic branch is used to learn deep semantic information, and the detail branch is used to capture spatial detail information.
2. The intensive face detection method as described in claim 1, characterized in that, The improved YOLOv8 model includes a Backbone network, a Neck network, and a Head network; the improved YOLOv8 model is trained using imported training set images to obtain a visual detection model, which includes: Import the training set images into the improved YOLOv8 model and convert them into images of a preset size; An image of a preset size is input into the Backbone network. The C2f module, which incorporates a HAM hybrid attention mechanism, performs repeated operations to extract features and outputs an image of the first specified size. The image of the first specified size is input into the Neck network for repeated feature map calculations, and the image of the second specified size is output. The image of the second specified size is input into the Head network for feature map stitching. The stitched feature map is used as the feature for detection and judgment by the detection head to obtain the visual detection model.
3. The intensive face detection method as described in claim 1, characterized in that, The formula for calculating maximum pooling is: Max_O[i,j]=max(input[i*size:(i+1)*size,j*size:(j+1)*size]) Where Max_O[i,j] represents a pixel value in the output feature map after pooling, input is the input feature map, and size is the window size of the pooling operation; The formula for calculating average pooling is: Ave_O[i,j]=mean(input[i*size:(i+1)*size,j*size:(j+1)*size]) Where Ave_O[i,j] represents a pixel value in the output feature map after pooling, input is the input feature map, size is the window size of the pooling operation, and mean represents the average value of the pixels in the pool.
4. A dense face detection device, characterized in that, include: The model training module is used to import training set images to train an improved YOLOV8 model, resulting in a visual detection model. The improved YOLOV8 model includes: introducing a HAM hybrid attention mechanism into the C2f module of the general YOLOV8 model; introducing a small target detection head; using normalized Wasserstein distance as a metric for calculating the similarity between the trained model and the actual model; and introducing Block reparameters to optimize the overall running speed of the YOLOV8 model. Specifically, introducing the HAM hybrid attention mechanism into the C2f module of the general YOLOV8 model involves summing the average pooling and max pooling operations in the input feature input branch of the C2f module, allowing the YOLOV8 model to learn the degree information and discriminative features of the corresponding target, respectively; and using max pooling to encode the saliency information of the target to supplement the global information encoded by average pooling. The model deployment module is used to deploy the visual inspection model to the development board; The model acceleration module is used to accelerate the processing of visual detection models using the TensorRT engine; The face detection module is used to perform target detection on images captured by the camera using a visual detection model; The face count determination module is used to determine whether the number of faces in the recognition area is greater than the preset target number; The face count warning module is used to issue a prompt to the management personnel if the number of faces in the recognition area exceeds the preset target number; Specifically, the model acceleration module is used for: Before inference, TensorRT uses a calibration dataset to estimate the dynamic range of the weights and activation values of the visual detection model; The minimum and maximum values of each layer of the visual detection model are determined by calibrating the dataset. Assuming the maximum range of activation values for a layer is [-m, m] and the range of INT8 values is [-127, 127], then the scaling factor S is: In actual reasoning, the floating-point activation value X becomes after quantization: X INT8 =round(S*X) At the end of the inference, the INT8 result is dequantized to a floating-point number using the same scaling factor S: During inference, the GPU uses the INT8 core to perform calculations, thereby accelerating the processing of the visual detection model; The model training module incorporates Block reparameters to optimize the overall YOLOv8 model's running speed, including: A reparameterizable dual-resolution network is placed into the C2f module, and the Bottleneck function model inside the C2f module is replaced with the RDRNet function model. Shallow features are obtained using the reparameterizable dual-resolution network, and the feature maps are split into semantic branches and detail branches. The semantic branch is used to learn deep semantic information, and the detail branch is used to capture spatial detail information.
5. A computer device, characterized in that: The computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the intensive face detection method as described in any one of claims 1 to 3.
6. A storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, can implement the intensive face detection method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Robot end face detection method based on YOLO-RGGNet
CN112464912A
Lightweight small target detection method based on improved YOLOv8
CN119091129A