Face mask recognition method based on YOLOV5

Through the YOLO_V5 facial mask recognition method, medical staff who are not wearing or wearing irregularly can be monitored and reminded in real time, which solves the problem of lax mask wearing in hospitals and effectively protects the health and safety of medical staff.

CN118537792APending Publication Date: 2024-08-23GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410627870.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-21
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

In hospitals, medical staff tend to forget to wear masks or wear them in irregular ways during busy diagnosis and treatment processes, which leads to lax implementation of protective measures and requires proactive reminders from other staff to correct them.

Method used

The facial mask recognition method based on YOLO_V5 is used to monitor the facial features of medical staff in real time through the camera. The pre-trained Face_Mask.pt model is used for image preprocessing and feature extraction. It combines the loss function and non-maximum suppression algorithm to identify and output whether Wear masks and wear them in a standardized manner, and send reminders in a timely manner.

Benefits of technology

It achieves efficient and accurate monitoring and reminders of the wearing of masks by medical staff, ensuring that protection standards in the hospital are strictly implemented and improving the health and safety of medical staff.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537792A
    Figure CN118537792A
Patent Text Reader

Abstract

The invention belongs to the field of hospital visual management and control. The invention discloses a facial mask recognition method based on YOLOV5. According to the method, a mask detection system of a YOLO target detection framework and a real-time face mask detection and standard wearing recognition method in a natural environment are used, in order to enable the YOLO framework to be suitable for real-time acquisition, a lightweight convolutional neural network is selected, and the target detection framework adopts a single convolutional neural network to carry out real-time target detection. According to the method, the performance is optimized on the basis of an original algorithm, and the whole network is improved to different degrees at a Head end, a reference network, a Neck network and an output layer. The YOL05V learning model of the system is pre-programmed, and has good program limitation. And a consistent result can be provided under the condition of complex environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention represents an innovation in the field of hospital visual control, specifically introducing a cutting-edge object detection method based on computer vision and machine learning. This method can efficiently and accurately monitor whether medical staff in hospitals are wearing masks and whether they are wearing them properly, thereby ensuring that protective measures are strictly enforced within hospitals and protecting the health and safety of medical staff. Background Art

[0002] In a rigorous medical environment, to ensure the health and safety of every medical staff member, the hospital has established strict protective procedures, which clearly stipulate that doctors must wear masks correctly while practicing. However, in the busy diagnosis and treatment process, for various reasons, doctors sometimes forget to wear masks or wear them improperly. In such cases, other personnel are often required to proactively remind them to ensure strict compliance with the regulations. However, considering the dual needs of efficiency and accuracy, we have innovatively developed an intelligent reminder system based on target recognition. This system can monitor and accurately identify the facial features of medical staff in real time. If a medical staff member is detected not wearing a mask or wearing it improperly, the system will immediately issue a reminder, allowing timely correction to ensure that the hospital's protective standards are strictly enforced. Summary of the Invention

[0003] In order to solve the problems existing in the background technology, the present invention proposes a facial mask recognition method based on YOLO_V5 to remind medical staff who are not wearing masks or are not wearing them properly in the hospital.

[0004] 1. A facial mask recognition method based on YOLO_V5, characterized in that it comprises the following steps:

[0005] S1: First, initialize the system parameters to ensure that the system is in the best state. Then, configure the camera parameters to ensure that the captured image quality meets the subsequent processing requirements.

[0006] S2: After receiving the image, the system performs a series of preprocessing operations on the image. These operations include resizing the image to a standard 640x640 pixel size and performing numerical normalization on the image data to improve the efficiency and accuracy of subsequent processing.

[0007] S3: The pre-processed image is then fed into the pre-trained Face_Mask.pt model. This model has been trained on a large amount of data and is capable of accurately identifying facial and mask features.

[0008] S4: In the Face_Mask.pt model, a pre-trained convolutional neural network is used to extract features from the input image. These features will be used for subsequent object classification and coordinate regression tasks.

[0009] S5: Based on feature extraction, the system applies predefined priori boxes to scan the feature map. For each priori box, the system performs object classification and coordinate regression to determine whether a face exists and the location and size of the face.

[0010] S6: To remove redundant predictions, the system uses a loss function and non-maximum suppression algorithm to merge overlapping prediction boxes. This step ensures that the final output prediction results are both accurate and concise.

[0011] S7: After completing the image recognition task for the current frame, the system accepts the next frame and returns to step S2 for a new round of image processing. This process will continue to achieve continuous video stream processing.

[0012] S8: Finally, the system outputs the detection results. These results include the predicted category, confidence level, and box location. This information is displayed to the user in an appropriate manner or used for subsequent data analysis and processing.

[0013] Furthermore, the camera of S1 is used for real-time monitoring and transmits real-time data to the computer.

[0014] Furthermore, the Face_Mask.pt in S2 requires dataset collection, category labeling, and model training.

[0015] Furthermore, the training preprocessing for Face_Mask.pt in S2 uses Mosaic data augmentation. This method is particularly effective for small objects. Mosaic is randomly padded with 4 samples, and Mosaic data augmentation is mixed in the form of scaling and cropping.

[0016] Furthermore, the loss function of S6 and the method of non-maximum suppression are:

[0017] Now there are two arbitrary properties A and B. Find a minimum closed shape C so that C can contain A and B. Then calculate the ratio of the area of ​​C that does not cover A and B divided by the area C and the difference between IoU and IoU. Therefore, GIoULoss can be expressed as

[0018]

[0019] The CIOU-Loss and GIOU-Loss formulas are the same.

[0020]

[0021]

[0022] Where v is a parameter to measure whether the aspect ratio is consistent;

[0023] Furthermore, the output of S8 includes the detection results. The results include the predicted category (indicating whether the mask is worn or not), the confidence level (indicating the reliability of the prediction result), and the position of the box (indicating the location of the target category in the image).

[0024] This paper uses the fast-detection YOLO V5L.pt as a research object to build a detection network. To address the need for rapid detection during high-volume inspections, the system monitors and accurately identifies the facial features of medical staff in real time. If a medical staff member is detected not wearing a mask or wearing one improperly, the system will immediately issue a reminder, allowing for timely correction and ensuring strict compliance with hospital protection standards. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 Schematic diagram of the method and hardware configuration of the present invention;

[0026] Figure 2 This is a flowchart of the face mask recognition program of the method of the present invention;

[0027] Figure 3 A flow chart of the training procedure of the method of the present invention;

[0028] Figure 4 Flow chart of the verification procedure of the method of the present invention; DETAILED DESCRIPTION

[0029] In order to make the above features and application scenarios of the present invention clearer and easier to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0030] Example 1.

[0031] like Figure 1 , which is a schematic diagram of the method and hardware configuration of the present invention. This embodiment provides a facial mask recognition method based on YOLO_V5, and its hardware includes a computer and a camera.

[0032] The camera is used for:

[0033] Transmit hospital images to the computer in real time.

[0034] The computer is used for:

[0035] The video stream obtained from the camera is analyzed and processed to obtain the predicted category, confidence level, and location of the frame.

[0036] Example 2.

[0037] like Figure 2 The figure below shows a flowchart of the face and mask recognition program for the present invention. The present invention uses the YOLOV5 algorithm to collect and recognize facial features. The software interface uses PyQT5. It can identify faces and masks in videos and display the final results on the program interface.

[0038] First, the system parameters are initialized to ensure that the system is in the best state. Then, the camera parameters are configured to ensure that the captured image quality meets the subsequent processing requirements.

[0039] After receiving the image, the system performs a series of preprocessing operations on the image. These operations include resizing the image to a standard 640x640 pixel size and performing numerical normalization on the image data to improve the efficiency and accuracy of subsequent processing.

[0040] The pre-processed images are then fed into the pre-trained Face_Mask.pt model, which has been trained on a large amount of data and is capable of accurately identifying facial and mask features.

[0041] In the Face_Mask.pt model, a pre-trained convolutional neural network is used to extract features from the input image. These features will be used for subsequent object classification and coordinate regression tasks.

[0042] Based on feature extraction, the system applies predefined priori boxes to scan the feature map. For each priori box, the system performs target classification and coordinate regression to determine whether a face exists and the location and size of the face.

[0043] To remove redundant predictions, the system uses a loss function and non-maximum suppression algorithm to merge overlapping prediction boxes. This step ensures that the final output prediction results are both accurate and concise.

[0044] After completing the image recognition task for the current frame, the system accepts the next frame and returns to step S2 for a new round of image processing. This process will continue to achieve continuous video stream processing.

[0045] Finally, the system outputs the detection results. These results include the predicted category, confidence level, and box location. This information is displayed to the user in an appropriate manner or used for subsequent data analysis and processing.

[0046] Example 3.

[0047] like Figure 3 Shown is a flow chart of the training procedure of the method of the present invention.

[0048] When building the model, you need to download the pre-trained model yolov5s.pt trained with the COCO dataset in advance.

[0049] Then the feature extraction network is fed into the Pytorch framework to initialize the network and train the network weights, and a second training is performed by collecting a labeled face mask dataset.

[0050] Finally, we get the Face_Mask.pt model that is sensitive to face masks.

[0051] Output various parameter graphs representing model performance, such as confusion matrix, Precision growth curve, Recall growth curve, and F1 Score curve.

[0052] Example 4.

[0053] like Figure 4 FIG. 4 is a flow chart of the verification procedure of the method of the present invention.

[0054] Output the image to be verified from the verification set.

[0055] The verification model is the Face_Mask.pt model obtained after training.

[0056] Only by performing non-maximum threshold processing can the prediction boxes with higher consistency be screened out in one step.

[0057] Based on the prediction results, post-processing boxes, labels, scores (confidence) are obtained.

[0058] Then, for each picture, three different types of information can be obtained. This information is processed again to obtain the confusion matrix, Precision growth curve, Recall growth curve and F1 Score curve.

[0059] Finally, by calculating these indicators, the final classification effect is obtained.

[0060] For examples 3 and 4, the addition of the Precision growth curve, Recall growth curve, and F1 Score curve

[0061] The confusion matrix comparison results include four cases: TP, FP, TN, and FN. Based on these four parameters, we can get some performance evaluation of the trained model.

[0062]

[0063] The above expression "Accuracy" represents the proportion of all correct classification results to the total number of observations. It represents the probability that the model correctly predicts the correct value for each of the training set labeled "mask" and "face." A higher accuracy indicates a better system.

[0064]

[0065] Precision is the proportion of correct predictions among all the results where the model predicts positive. In other words, in this training, the system predicts the proportion of masks and faces that are actually correct.

[0066]

[0067] Recall is the ratio of the model's predicted correct values ​​among all the results with positive true values. In other words, it is the ratio of the system's true masks to the predicted masks and faces in this training.

[0068] The number of confusion matrix uses these data as input variables to construct fuzzy relationship vectors, and finally there is a score. Based on the secondary index, a third-level index is generated, namely F1 Score

[0069]

[0070] Because the original model pre-trained on the COCO dataset has a better fit for face recognition, the F1 score for the face is consistently higher than the F1 score for the mask throughout the training process. The overall F1 score reaches 84%, indicating that the entire system has achieved a high level of performance.

[0071] The foregoing description is merely a preferred embodiment of the present invention. Furthermore, those skilled in the art will readily appreciate that various modifications and variations of the present invention may be made while maintaining the principles of the present invention. If such modifications and variations fall within the scope of the claims and their equivalents, such modifications and variations shall also be considered within the scope of protection of the present invention.

Claims

1. A facial mask recognition method based on YOLO_V5, characterized in that: The following steps are involved: S1: First, initialize the system parameters to ensure that the system is in the best state. Then, configure the camera parameters to ensure that the captured image quality meets the subsequent processing requirements. S2: After receiving the image, the system performs a series of preprocessing operations on the image. These operations include resizing the image to a standard 640x640 pixels and performing numerical normalization on the image data to improve the efficiency and accuracy of subsequent processing. S3: The pre-processed image is then transferred to the pre-trained Face_Mask.pt model. This model has been trained with a large amount of data and has the ability to accurately recognize human faces and mask features. S4: In the Face_Mask.pt model, a pre-trained convolutional neural network is used to extract features from the input image. These features will be used for subsequent object classification and coordinate regression tasks. S5: Based on feature extraction, the system applies a predefined priori box to scan the feature map. For each priori box, the system performs target classification and coordinate regression to determine whether there is a face and the location and size of the face. S6: In order to remove redundant prediction results, the system uses the loss function and non-maximum suppression algorithm to merge overlapping prediction boxes. This step ensures that the final output prediction results are both accurate and concise. S7: After completing the image recognition task of the current frame, the system accepts the next frame of image and returns to step S2 for a new round of image processing. This process will continue to achieve continuous video stream processing. S8: Finally, the system outputs the detection results. These results include the predicted category, confidence, and box location. This information will be displayed to the user in an appropriate manner or used for subsequent data analysis and processing.

2. The method according to claim 1, characterized in that The S1's camera is used for real-time monitoring and transmits real-time data to the computer.

3. The method according to claim 1, characterized in that The Face_Mask.pt of S2 requires dataset collection, category labeling and model training.

4. The method according to claim 1, characterized in that: The training preprocessing of Face_Mask.pt in S2 uses Mosaic data enhancement. This method is particularly effective for small-sized objects. Mosaic is randomly filled with 4 samples, and Mosaic data enhancement is mixed in the form of scaling and cropping.

5. The method according to claim 1, characterized in that The loss function of S6 and the method of non-maximum suppression are: Now there are two arbitrary properties of A and B. Find a minimum closed shape C so that C can contain A and B. Then calculate the ratio of the area of ​​C that does not cover A and B divided by the area C and the IoU subtracted. Therefore, GIoU Loss can be expressed as The CIOU-Loss and GIOU-Loss formulas are the same. Where v is a parameter to measure whether the aspect ratio is consistent.

6. The method according to claim 1, characterized in that The output of S8 is the detection result. The result includes the predicted category: indicating whether the mask is worn or whether it is worn properly. The confidence: indicating the reliability of the prediction result. And the position of the box: indicating the position of the target category in the image.