Intensive face detection method and device and computer equipment
Through the combination of the improved YOLOV8 model and TensorRT engine, the problem of difficulty in quickly identifying multiple faces in the existing technology is solved, and the rapid and accurate facial recognition and population count statistics are achieved in high traffic occasions, and timely warning administrators to divert the population.
Patent Information
- Application Number
- CN202411904002.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-23
AI Technical Summary
Existing facial recognition technology is difficult to quickly and accurately identify and count multi-faceted faces, especially in situations with large traffic, which cannot effectively assist administrators in diversion of people.
The improved YOLOV8 model is adopted, and the HAM hybrid attention mechanism is introduced into the C2f module of the general YOLOV8 model, the small object detection head is introduced, the normalized Wasserstein distance is used as a similarity metric, and the Block re-parameter is introduced to optimize the running speed of the model. Deploy the visual detection model to the development board, and use the TensorRT engine to accelerate processing, collect images through the camera for object detection, judge the number of faces and issue early warning to the administrator.
It realizes rapid and accurate identification and judgment of the number of people, and promptly warns when the number exceeds the preset number, which facilitates administrators to divert the population and improves the application efficiency of facial recognition technology in high traffic occasions.
Smart Images

Figure CN119832496A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of face recognition technology, and in particular to an intensive face detection method, device and computer equipment. Background Art
[0002] With the rapid development of face recognition technology, face recognition is increasingly being used in access control systems, smart protection and other fields. Face recognition technology can quickly and contactlessly identify the person being identified, and has great application prospects. However, the current mainstream face recognition technology is mainly aimed at target recognition and detection at close range, and the target detected each time is usually only a single one, and there is no recognition and determination of multiple targets in the area, so the application scenarios are still relatively limited.
[0003] Therefore, for important places with large crowd flow that require crowd control, such as community streets, campuses, railway station entrances and exits, and subway station entrances and exits, it is necessary to provide a method that can quickly and accurately identify and determine the number of faces in the statistical place, so as to realize the counting of the number of people and assist administrators in diverting the crowd. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a dense face detection method, device and computer equipment, aiming to solve the problem of fast face recognition of multiple faces.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is: a dense face detection method, comprising:
[0006] Importing training set pictures to train an improved YOLOV8 model to obtain a visual detection model; the improved YOLOV8 model includes: 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 metric for calculating the similarity between a training model and an actual model; and introducing a Block weight parameter to optimize the running speed of the entire YOLOV8 model;
[0007] Deploy the visual inspection model to the development board;
[0008] Use the TensorRT engine to accelerate the processing of visual inspection models;
[0009] Perform target detection on images captured by the camera through a visual detection model;
[0010] Determine whether the number of faces in the recognition area is greater than the preset target number;
[0011] If the number of faces in the recognition area is greater than the preset target number, a prompt will be sent to the administrator.
[0012] Furthermore, the improved YOLOV8 model includes a Backbone network, a Neck network and a Head network; the imported training set images are used to train the improved YOLOV8 model, and the visual detection model obtained includes:
[0013] Import the training set images into the improved YOLOV8 model and convert them into images of preset size;
[0014] Input the image of preset size into the Backbone network, introduce the HAM hybrid attention mechanism to perform multiple repeated operations in the C2f module to extract features, and output the image of the first specified size;
[0015] Input the image of the first specified specification into the Neck network to perform multiple repeated feature map calculations, and output the image of the second specified specification;
[0016] The image of the second specified specification is input into the Head network for feature map splicing. The spliced feature map is used as the feature for detection and judgment by the detection head to obtain a visual detection model.
[0017] Furthermore, the use of the TensorRT engine to accelerate the visual detection model includes:
[0018] Before inference, TensorRT uses a calibration dataset to estimate the dynamic range of weights and activation values of the visual detection model;
[0019] The minimum and maximum values of each layer of the visual detection model are determined by the calibration data set. Assuming that the maximum range of activation values of a layer is [-m, m] and the range of INT8 values is [-127, 127], the scaling factor S is:
[0020]
[0021] During actual inference, the floating-point activation value X is quantized to become:
[0022] X INT8 =round(S*X)
[0023] At the end of inference, the INT8 result is dequantized to floating point using the same scaling factor S:
[0024]
[0025] During inference, the GPU uses specific INT8 kernels for calculations to accelerate the processing of the visual detection model.
[0026] Furthermore, the HAM hybrid attention mechanism is introduced into the C2f module of the general YOLOV8 model as follows: the average pooling and maximum pooling of the input feature input branch of the C2f module are summed up, so that 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 by the maximum pooling to supplement the global information encoded by the average pooling.
[0027] Furthermore, 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] Among them, 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 for average pooling is:
[0031] Ave_O[i,j]=mean(input[i*size:(i+1)*size,j*size:(j+1)*size])
[0032] Among them, 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 means to find the average value of the pixels inside.
[0033] Furthermore, in the use of normalized Wasserstein distance as a metric for calculating the similarity between the training model and the actual model, Gaussian distribution is used, and the formula is:
[0034]
[0035] Among them, μ is the mean of the distribution, representing the center position of the distribution; σ is the standard deviation, indicating the width of the distribution; exp represents the natural exponential function.
[0036] Furthermore, the introduction of Block weight parameters to optimize the running speed of the entire YOLOV8 model includes:
[0037] The reparameterizable dual-resolution network is placed in the C2f module, and the Bottleneck function model inside the C2f module is replaced with the RDRNet function model. The reparameterizable dual-resolution network is used to obtain shallow features, and the feature map is 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.
[0038] The present invention also provides a dense face detection device, comprising:
[0039] The model training module is used to import the training set pictures to train the improved YOLOV8 model to obtain the visual detection model; the improved YOLOV8 model includes: introducing the HAM hybrid attention mechanism in the C2f module of the general YOLOV8 model; introducing the small target detection head; using the normalized Wasserstein distance as a metric for calculating the similarity between the training model and the actual model; introducing the Block weight parameter to optimize the running speed of the entire YOLOV8 model;
[0040] Model deployment module, used to deploy the visual inspection model to the development board;
[0041] Model acceleration module, used to accelerate the processing of visual detection models using the TensorRT engine;
[0042] The face detection module is used to perform target detection on images collected by the camera through a visual detection model;
[0043] A face quantity determination module is used to determine whether the number of faces in the recognition area is greater than a preset target number;
[0044] The face quantity warning module is used to issue a prompt to the management personnel if the number of faces in the recognition area is greater than the preset target number.
[0045] The present invention also provides a computer device, which includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the intensive face detection method as described in any one of the above items is implemented.
[0046] The present invention also provides a storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the intensive face detection method as described in any one of the above items can be implemented.
[0047] The beneficial effects of the present invention are as follows: by introducing the HAM hybrid attention mechanism into the C2f module of the general YOLOV8 model; introducing a small target detection head; using the normalized Wasserstein distance as a metric for calculating the similarity between the training model and the actual model; introducing the Block weight parameter to optimize the running speed of the entire YOLOV8 model; being able to quickly and accurately identify and judge the number of people in a statistical occasion, and when the number exceeds the preset number, timely issuing an early warning, it is convenient for administrators to divert the crowd. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The specific structure of the present invention is described in detail below in conjunction with the accompanying drawings.
[0049] Figure 1 This is a flow chart of a dense face detection method according to an embodiment of the present invention;
[0050] Figure 2 A block diagram of a dense face detection device according to an embodiment of the present invention;
[0051] Figure 3 This is a network structure diagram of an improved YOLOV8 model according to an embodiment of the present invention;
[0052] Figure 4 This is a comparison chart of the accuracy iteration data of three different YOLOV8 models in an embodiment of the present invention;
[0053] Figure 5 A schematic block diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0056] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0057] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0058] like Figure 1 As shown, the first embodiment of the present invention is: a dense face detection method, comprising the steps of:
[0059] S10. Import the training set pictures to train the improved YOLOV8 model to obtain a visual detection model; the improved YOLOV8 model includes: introducing a HAM hybrid attention mechanism in the C2f module of the general YOLOV8 model; introducing a small target detection head P2; using the normalized Wasserstein distance as a metric for calculating the similarity between the training model and the actual model; and introducing a Block weight parameter to optimize the running speed of the entire YOLOV8 model.
[0060] In a specific embodiment, the HAM hybrid attention mechanism is introduced in the C2f module of the general YOLOV8 model. Specifically, the average pooling and maximum pooling of the input feature input branch of the C2f module are summed up, so that 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 by 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] Among them, 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;
[0064] The calculation formula for average pooling is:
[0065] Ave_O[i,j]=mean(input[i*size:(i+1)*size,j*size:(j+1)*size])
[0066] Among them, 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 means to find the average value of the pixels inside.
[0067] In a specific embodiment, the normalized Wasserstein distance is used as a metric for calculating the similarity between the training model and the actual model, and Gaussian distribution is used, and the formula is:
[0068]
[0069] Where μ is the mean of the distribution, representing the center of the distribution. σ is the standard deviation, representing 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 Block weight parameters to optimize the running speed of the entire YOLOV8 model includes:
[0071] The reparameterizable dual-resolution network is placed in the C2f module, and the Bottleneck function model inside the C2f module is replaced with the RDRNet function model. The reparameterizable dual-resolution network is used to obtain shallow features, and the feature map is 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.
[0072] In a specific embodiment, the improved YOLOV8 model includes a Backbone network, a Neck network and a Head network; the imported training set images are used to train the improved YOLOV8 model, and the visual detection model obtained includes:
[0073] S11, import the training set images into the improved YOLOV8 model and convert them into images of preset size;
[0074] S12, inputting a picture of a preset size into the Backbone network, introducing the HAM hybrid attention mechanism to perform repeated operations on the C2f module to extract features, and outputting a picture of a first specified size;
[0075] S13, inputting the image of the first specified specification into the Neck network to perform multiple repeated feature map calculations, and outputting the image of the second specified specification;
[0076] S14. Input the image of the second specified specification into the Head network for feature map splicing. The spliced feature map is used as the feature for detection and judgment by the detection head to obtain 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, wherein the selected NWD parameter nwd_rat io is selected as 0.5, which is a balance coefficient, that is, NWD and IOU are each 50%, and are adjusted according to the number of small targets in the data set. The data set used in this patent is the JHU-CROWD++ data set, which is a large-scale unconstrained crowd counting data set. Compared with the existing data sets, it can better reflect the characteristics of dense crowds. It collects pictures of crowds under various scenes and environmental conditions. Among them, the picture data used as training sets and validation sets contains 14491 pictures and 137,000 annotations, that is, there are 9.4 faces in each picture on average, and the size of the face in each picture is normalized. After calculation, the size of most faces is within the size of 0.03*0.03, that is, the proportion of faces is 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 need to input the dataset into our improved YOLOV8 improved model, such as Figure 3 As shown, the steps are as follows:
[0078] Step 1: Initialize the input image and convert it into a 3-channel image of size 640*640.
[0079] Step 2: Enter the Backbone network part and input the converted image into the convolutional network Conv, converting it into a feature map with 64 channels and compressed size of 320*320 (i.e. 320*320*64).
[0080] Step 3. Continue to input the feature map with 64 channels and compressed size of 320*320 into module ①. Module ① contains convolutional network Conv and C2f modules. Convolutional network Conv will convert the image into a feature map with 128 channels and compressed size of 160*160. Then input the image into the improved core module C2f and perform C2f three times. The C2f module adds the HAM hybrid attention mechanism and finally outputs a feature map with 128 channels and compressed size of 160*160.
[0081] Step 4: Execute the operation of step 3 three times, but perform three additional C2f operations the second and third times.
[0082] Step 5: Input the data after multiple convolution processing 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 contains an upsampling module Upsample, a concatenation module Concat, and a C2f module. The 20*20*1024 feature map is input into the upsampling module Upsample and converted into a 40*40*1024 feature map. Then it is input into the concatenation module Concat and concatenated with the feature map of size 40*40*512 after C2f processing in step 4. Finally, the feature map of size 40*40*512 is output.
[0084] Step 7. Repeat step 6 twice, that is, the Neck part performs step 6 three times in total. Finally, the feature map of the corresponding size will be output in C2f of each module ②. The total output image specifications are: 40*40*512, 80*80*256, 160*160*128), and finally the output size is 160*160*128.
[0085] Step 8, enter the Head network part: First, the image obtained at the end of step 7 will be input into the detection head module Detect, which will be used as the feature map for detection judgment. That is, the corresponding image size of the detection head is 160*160.
[0086] Step 9. At the same time, the image obtained in step 7 is input into module ③, which contains a convolution network Conv, a concatenation module Concat, and a C2f module. The image is first convolved to change the image size to 80*80, and then enters the concatenation module Concat, and is concatenated with the C2f output corresponding to Neck (i.e., the result of step 7 output 80*80), and then input into the C2f module to generate a feature map of size 80*80, which is then input into the detection head for detection and judgment.
[0087] Step 10: Repeat step 9 twice; that is, the head network part performs step 9 three times in total, and finally outputs a feature map of the corresponding size in the C2f of each module ③, and inputs it into the detection head for judgment. The concatenation object of the last concatenation module Concat is the output of the SPPF module.
[0088] Step 11: Use the four detection heads for model detection and judgment to complete model training.
[0089] S20. Deploy the visual detection model to the development board.
[0090] This patent deploys the improved target detection algorithm to NVIDIA's Jetson ORIN NX board. The Jetson Orin NX module is extremely small, but can provide up to 100TOPS of AI performance, which is suitable for edge deployment recognition algorithms. At the same time, it is optimized with 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 greatly improve the inference speed and efficiency of deep learning models running on NVIDIA GPUs. With NoMachine software, remote wireless surveillance camera output can be realized, and finally the administrator can cooperate with the output recognition results, observe the density of the crowd, and realize intelligent diversion of the crowd.
[0091] S30. Use the TensorRT engine to accelerate the processing of the visual detection model.
[0092] In a specific embodiment, further, the use of the TensorRT engine to accelerate the visual detection model includes:
[0093] S31. Before inference, TensorRT uses a calibration dataset to estimate the dynamic range of weights and activation values of the visual detection model.
[0094] In this embodiment, due to the low precision of INT8, the purpose of calibration is to find the optimal scaling factor for each layer to ensure that good model accuracy can be maintained under low precision.
[0095] S32. Determine the minimum and maximum values of each layer of the visual detection model through the calibration data set. Assume that the maximum range of the activation value of a layer is [-m,m], and the range of the INT8 value is [-127,127]. Then the scaling factor S is:
[0096]
[0097] During actual inference, the floating-point activation value X is quantized to become:
[0098] X INT8 =round(S*X)
[0099] At the end of inference, the INT8 result is dequantized to floating point using the same scaling factor S:
[0100]
[0101] S33. During inference, the GPU uses specific INT8 kernels for computation to accelerate the processing of visual detection models. These kernels are more efficient than FP32 or FP16 kernels because the computational 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 numbers to 8-bit integers, usually quantizing FP32 to INT8, to reduce computational and storage overhead.
[0103] S40: Perform target detection on the image captured by the camera through a visual detection model.
[0104] S50: Determine whether the number of faces in the recognition area is greater than a preset target number.
[0105] S60: If the number of faces in the recognition area is greater than a 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-Or i is the original YOLO model, YOLOV8-HAM is an improved model with the hybrid attention mechanism HAM added, and YOLOV8-Improve is the hybrid model improved by this patent.
[0109] in,
[0110]
[0111]
[0112]
[0113]
[0114] TP (True positives): The number of samples that are correctly classified as positive examples, that is, the number of instances (number of samples) that are actually positive examples and are classified as positive examples by the classifier.
[0115] FP (False positives): The number of instances that are mistakenly classified as positive examples, that is, the number of instances that are actually negative examples but are classified as positive examples by the classifier.
[0116] FN (False negatives): The number of instances that are mistakenly classified as negative examples, that is, the number of instances that are actually positive examples but are classified as negative examples by the classifier.
[0117] TN (True negatives): The number of instances that are correctly classified as negative examples, that is, the number of instances that are actually negative examples and are classified as negative examples by the classifier.
[0118] For the data in Table 1, precision is a measure of the ratio of positive samples (i.e., detected targets) correctly predicted by the model to all predicted positive samples. F1-score is the harmonic mean of precision and recall. It takes into account the precision and recall of the model, and is particularly suitable for scenarios with imbalanced categories. 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 when the IoU threshold is 0.5.
[0119] It can be found that the improved model YOLOV8-Improve in this patent has a good improvement in accuracy, F1-score and mAP 0.5, which are key indicators of visual recognition, compared with the original version and the simple attention improvement model. The results are as follows Figure 4 shown.
[0120] like Figure 2 As shown, an embodiment of the present invention further provides a dense face detection device, comprising:
[0121] The model training module 10 is used to import the training set pictures to train the improved YOLOV8 model to obtain the visual detection model; the improved YOLOV8 model includes: introducing the HAM hybrid attention mechanism in the C2f module of the general YOLOV8 model; introducing the small target detection head P2; using the normalized Wasserstein distance as a metric for calculating the similarity between the training model and the actual model; introducing the Block weight parameter to optimize the running speed of the entire YOLOV8 model;
[0122] A model deployment module 20, used to deploy the visual inspection model to the development board;
[0123] A model acceleration module 30, used to accelerate the visual detection model using the TensorRT engine;
[0124] A face detection module 40 is used to perform target detection on images collected by the camera through a visual detection model;
[0125] A face quantity determination module 50, used to determine whether the number of faces in the recognition area is greater than a preset target number;
[0126] The face warning module 60 is used to issue a prompt to the management personnel if the number of faces in the recognition area is greater than a preset target number.
[0127] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned intensive face detection device can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0128] The above-mentioned intensive face detection device can be implemented in the form of a computer program. The computer program can be used in Figure 5 Runs on the computer device shown.
[0129] See also Figure 5 , Figure 5 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a terminal or a server, wherein the terminal may be an electronic device with communication functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device. The server may be an independent server or a server cluster composed of multiple servers.
[0130] See also Figure 5 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0131] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute an intensive face detection method.
[0132] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0133] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute an intensive face detection method.
[0134] The network interface 505 is used to communicate with other devices over the network. Figure 5 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0135] The processor 502 is used to run a computer program 5032 stored in the memory to implement the intensive face detection method as described above.
[0136] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may 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 gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0137] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. 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 embodiment of the above method.
[0138] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the intensive face detection method as described above.
[0139] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.
[0140] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0141] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0142] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0143] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0144] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A dense face detection method, characterized in that: include: Importing training set pictures to train an improved YOLOV8 model to obtain a visual detection model; the improved YOLOV8 model includes: 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 metric for calculating the similarity between a training model and an actual model; and introducing a Block weight parameter to optimize the running speed of the entire YOLOV8 model; Deploy the visual inspection model to the development board; Use the TensorRT engine to accelerate the processing of visual inspection models; Perform target detection on images captured by the camera through a visual detection model; Determine whether the number of faces in the recognition area is greater than the preset target number; If the number of faces in the recognition area is greater than the preset target number, a prompt will be sent to the administrator.
2. The intensive face detection method according to claim 1, characterized in that: The improved YOLOV8 model includes a Backbone network, a Neck network and a Head network; the imported training set images are used to train the improved YOLOV8 model, and the visual detection model obtained includes: Import the training set images into the improved YOLOV8 model and convert them into images of preset size; Input the image of preset size into the Backbone network, introduce the HAM hybrid attention mechanism to perform multiple repeated operations in the C2f module to extract features, and output the image of the first specified size; Input the image of the first specified specification into the Neck network to perform multiple repeated feature map calculations, and output the image of the second specified specification; The image of the second specified specification is input into the Head network for feature map splicing. The spliced feature map is used as the feature for detection and judgment by the detection head to obtain a visual detection model.
3. The intensive face detection method according to claim 1, characterized in that: The use of the TensorRT engine to accelerate the visual detection model includes: Before inference, TensorRT uses a calibration dataset to estimate the dynamic range of 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 the calibration data set. Assuming that the maximum range of activation values of a layer is [-m, m] and the range of INT8 values is [-127, 127], the scaling factor S is: During actual inference, the floating-point activation value X is quantized to become: X INT8 =round(S*X) At the end of inference, the INT8 result is dequantized to floating point using the same scaling factor S: During inference, the GPU uses specific INT8 kernels for calculations to accelerate the processing of the visual detection model.
4. The intensive face detection method according to claim 1, characterized in that: The HAM hybrid attention mechanism is introduced into the C2f module of the general YOLOV8 model as follows: the average pooling and the maximum pooling of the input feature input branch of the C2f module are summed up, so that 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 by the maximum pooling to supplement the global information encoded by the average pooling.
5. The intensive face detection method according to claim 4, characterized in that: The calculation formula of the maximum pooling is: Max_O[i,j]=max(input[i*size:(i+1)*size,j*size:(j+1)*size]) Among them, 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 calculation formula for average pooling is: Ave_O[i,j]=mean(input[i*size:(i+1)*size,j*size:(j+1)*size]) Among them, 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 means to find the average value of the pixels inside.
6. The intensive face detection method according to claim 1, characterized in that: In the method of using the normalized Wasserstein distance as a metric for calculating the similarity between the training model and the actual model, Gaussian distribution is used, and the formula is: Among them, μ is the mean of the distribution, representing the center position of the distribution; σ is the standard deviation, indicating the width of the distribution; exp represents the natural exponential function.
7. The intensive face detection method according to claim 1, characterized in that: The introduction of Block weight parameters to optimize the running speed of the entire YOLOV8 model includes: The reparameterizable dual-resolution network is placed in the C2f module, and the Bottleneck function model inside the C2f module is replaced with the RDRNet function model. The reparameterizable dual-resolution network is used to obtain shallow features, and the feature map is 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.
8. A dense face detection device, characterized in that: include: The model training module is used to import the training set pictures to train the improved YOLOV8 model to obtain the visual detection model; the improved YOLOV8 model includes: introducing the HAM hybrid attention mechanism in the C2f module of the general YOLOV8 model; introducing the small target detection head; using the normalized Wasserstein distance as a metric for calculating the similarity between the training model and the actual model; introducing the Block weight parameter to optimize the running speed of the entire YOLOV8 model; Model deployment module, used to deploy the visual inspection model to the development board; Model acceleration module, used to accelerate the processing of visual detection models using the TensorRT engine; The face detection module is used to detect targets in images collected by the camera through a visual detection model; A face quantity determination module, used to determine whether the number of faces in the recognition area is greater than a preset target number; The face quantity warning module is used to issue a prompt to the management personnel if the number of faces in the recognition area is greater than the preset target number.
9. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the intensive face detection method according to any one of claims 1 to 7 when executing the computer program.
10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the intensive face detection method according to any one of claims 1 to 7 can be implemented.
Citation Information
Patent Citations
Robot end face detection method based on YOLO-RGGNet
CN112464912A
Lightweight small target detection method based on improved YOLOv8
CN119091129A