Mask wearing detection method, device, equipment and readable storage medium
By using the preset mask detection model of jump connection layer in mask wear detection, the face grayscale map is directly redirected to the target convolutional layer or pooling layer, solving the high cost and low detection efficiency in the existing technology. Problem, efficient mask wearing inspection has been achieved.
Patent Information
- Application Number
- CN202010338359.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-04-26
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2040-04-26
AI Technical Summary
In the prior art, the mask wearing inspection method is costly and has low detection efficiency, making it difficult to apply in occasions with large flow of people.
The face grayscale map is jumped to the target convolutional layer or target pooling layer by jumping to the jump connection layer in the preset mask detection model, and the target feature map is obtained, and input it to the fully connected layer to obtain mask wearing detection result.
This method reduces the processing steps of face pictures, improves the efficiency of mask detection, and does not require purchasing physical instruments, and reduces hardware costs.
Smart Images

Figure CN111523490B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine learning technology, and in particular to a mask wearing detection method, device, equipment and readable storage medium. Background Art
[0002] As the environment changes, there are more and more types of infectious diseases, and viruses transmitted through breathing are also not uncommon. People are required to wear masks in special periods or special areas to reduce the spread of respiratory viruses.
[0003] At present, there are two main ways to detect whether people are wearing masks. Method 1: usually use physical instruments for face scanning and recognition, and method 2: mask wearing detection through algorithms based on Fourier transform and linear Gaussian. However, mask detection through method 1 needs to rely on physical instruments, which are generally expensive and difficult to promote. The calculation process of mask detection through method 2 is relatively complicated, the detection efficiency is low, and it is difficult to apply in occasions with large traffic. Summary of the invention
[0004] The main purpose of this application is to provide a mask wearing detection method, device, equipment and computer storage medium, aiming to solve the technical problems of high cost and low detection efficiency of mask wearing detection methods in the prior art.
[0005] To achieve the above purpose, the embodiment of the present application provides a mask wearing detection method, the steps of the mask wearing detection method include:
[0006] Upon receiving a mask wearing detection request, obtaining a face image to be detected associated with the mask wearing detection request;
[0007] Preprocessing the face image to obtain a face grayscale image;
[0008] The face grayscale image is jumped and input to the target convolution layer or target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map;
[0009] The target feature map is input into the fully connected layer in the preset mask detection model to obtain the mask wearing detection result.
[0010] Optionally, the step of jumping the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map includes:
[0011] Inputting the face grayscale image into a preset mask detection model, processing the face grayscale image through a convolution layer in the preset mask detection model, and obtaining a convolution image;
[0012] Input the convolution image to a skip connection layer of a preset mask detection model, and input the convolution image to a target convolution layer or a target pooling layer through the skip connection layer;
[0013] Processing the convolution image through the target convolution layer to obtain a new convolution image, or processing the convolution image through the target pooling layer to obtain a pooled image;
[0014] The new convolution image or the pooled image is input into the skip connection layer until the new convolution image or the pooled image is input into the last pooling layer through the skip connection layer, and the pooled image output by the last pooling layer is used as the target feature map.
[0015] Optionally, the step of inputting the convolution image to a skip connection layer of a preset mask detection model, and inputting the convolution image to a target convolution layer or a target pooling layer through the skip connection layer includes:
[0016] Inputting the convolution image into the skip connection layer in the preset mask detection model to obtain the gradient value of the convolution image;
[0017] When the gradient value is less than or equal to a preset gradient threshold, determining a target convolution layer corresponding to the gradient value through the jump connection layer, and inputting the convolution image into the target convolution layer;
[0018] When the gradient value is greater than a preset gradient threshold, a target pooling layer corresponding to the gradient value is determined through the jump connection layer, and the convolution image is input into the target pooling layer.
[0019] Optionally, the step of inputting the target feature map into a fully connected layer in a preset mask detection model to obtain a mask wearing detection result includes:
[0020] Input the target feature map into a fully connected layer of a preset mask detection model, obtain the matrix-vector product of the matrix vector corresponding to the target feature map through the fully connected layer, and perform classification according to the matrix-vector product;
[0021] When the matrix-vector product is of the first type, outputting the mask wearing detection result is wearing a mask;
[0022] When the matrix-vector product is of the second type, the output mask wearing detection result is that the mask is not worn.
[0023] Optionally, before the step of jumping the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map, the method includes:
[0024] Obtain a training sample set;
[0025] Extracting a preset proportion of training samples from the training sample set and inputting them into the initial mask detection model, and iteratively training the initial mask detection model;
[0026] Obtain the recognition accuracy of the trained mask detection model;
[0027] When the recognition accuracy is greater than or equal to a preset accuracy threshold, the trained mask detection model is used as a preset mask detection model.
[0028] Optionally, the step of preprocessing the face image to obtain a face grayscale image includes:
[0029] Counting the pixel values of each pixel point in the face image, and sorting the pixel values from small to large to obtain a pixel sequence;
[0030] An intermediate pixel value in the pixel sequence is obtained, and pixel values greater than the intermediate pixel value are replaced with the intermediate pixel value to remove noise in the face image and convert the face image into a face grayscale image.
[0031] Optionally, after the step of inputting the target feature map into a fully connected layer in a preset mask detection model to obtain a mask wearing detection result, the method further includes:
[0032] When the mask wearing detection result is that the mask is not worn, performing identity recognition on the face image to obtain identity information;
[0033] Output a mask wearing reminder containing the identity information.
[0034] The present application also provides a mask wearing detection device, the mask wearing detection device comprising:
[0035] An acquisition module, configured to, upon receiving a mask wearing detection request, acquire a face image to be detected associated with the mask wearing detection request;
[0036] A processing module, used for preprocessing the face image to obtain a face grayscale image;
[0037] A calling module is used to jump the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain a target feature map;
[0038] The output module is used to input the target feature map into the fully connected layer in the preset mask detection model to obtain the mask wearing detection result.
[0039] The present application also provides a mask wearing detection device, which includes: a memory, a processor, and a mask wearing detection program stored in the memory and executable on the processor, wherein the mask wearing detection program implements the steps of the mask wearing detection method as described above when executed by the processor.
[0040] The present application also provides a computer storage medium, on which a mask wearing detection program is stored. When the mask wearing detection program is executed by a processor, the steps of the mask wearing detection method as described above are implemented.
[0041] The present application provides a mask wearing detection method, apparatus, device and readable storage medium. In an embodiment of the present invention, when a mask wearing detection request is received, a face image to be detected associated with the mask wearing detection request is obtained; the face image is preprocessed to obtain a face grayscale image; the face grayscale image is jumped and input to a target convolution layer or a target pooling layer for processing through a jump connection layer in a preset mask detection model to obtain a target feature map; the target feature map is input to a fully connected layer in a preset mask detection model to obtain a mask wearing detection result; in this embodiment, a mask detection model is preset, and the face grayscale image is jumped and input to a target convolution layer or a target pooling layer through a jump connection layer in the preset mask detection model, so that there is no need to execute the steps of each processing layer in the preset mask detection model in sequence, and the processing steps of the face image are reduced through hierarchical jumping, thereby improving the efficiency of mask detection. In addition, in this implementation, there is no need to purchase physical instruments, thereby reducing hardware costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 This is a schematic diagram of an optional device hardware structure of an embodiment of the present application;
[0043] Figure 2 This is a flow chart of the first embodiment of the mask wearing detection method of the present application;
[0044] Figure 3 This is a structural schematic diagram of a preset mask detection model in the first embodiment of the mask wearing detection method of the present application;
[0045] Figure 4 This is a schematic diagram of a specific scenario in which mask detection is performed by using a preset mask detection model in the first embodiment of the mask wearing detection method of the present application;
[0046] Figure 5 This is a schematic diagram of the functional modules of an embodiment of a mask wearing detection device of the present application.
[0047] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0048] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0049] like Figure 1 As shown, Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present application.
[0050] The mask wearing detection device in the embodiment of the present application may be a server device, such as Figure 1 As shown, the mask wearing detection device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0051] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation of the device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0052] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating network communication module, a user interface module, and a mask wearing detection program.
[0053] exist Figure 1 In the device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the mask wearing detection stored in the memory 1005 and perform the operations in the following mask wearing detection method.
[0054] exist Figure 1 In the mask wearing detection device shown, the processor 1001 is used to execute the mask wearing detection program stored in the memory 1005 to implement the following steps:
[0055] Upon receiving a mask wearing detection request, obtaining a face image to be detected associated with the mask wearing detection request;
[0056] Preprocessing the face image to obtain a face grayscale image;
[0057] The face grayscale image is jumped and input to the target convolution layer or target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map;
[0058] The target feature map is input into the fully connected layer in the preset mask detection model to obtain the mask wearing detection result.
[0059] Further, the processor 1001 can call the mask wearing detection program stored in the memory 1005, and execute the step of jumping the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map, including:
[0060] Inputting the face grayscale image into a preset mask detection model, processing the face grayscale image through a convolution layer in the preset mask detection model, and obtaining a convolution image;
[0061] Input the convolution image to a skip connection layer of a preset mask detection model, and input the convolution image to a target convolution layer or a target pooling layer through the skip connection layer;
[0062] Processing the convolution image through the target convolution layer to obtain a new convolution image, or processing the convolution image through the target pooling layer to obtain a pooled image;
[0063] The new convolution image or the pooled image is input into the skip connection layer until the new convolution image or the pooled image is input into the last pooling layer through the skip connection layer, and the pooled image output by the last pooling layer is used as the target feature map.
[0064] Further, the processor 1001 can call the mask wearing detection program stored in the memory 1005, execute the step of inputting the convolution image to the jump connection layer of the preset mask detection model, and inputting the convolution image to the target convolution layer or the target pooling layer through the jump connection layer, including:
[0065] Inputting the convolution image into the skip connection layer in the preset mask detection model to obtain the gradient value of the convolution image;
[0066] When the gradient value is less than or equal to a preset gradient threshold, determining a target convolution layer corresponding to the gradient value through the jump connection layer, and inputting the convolution image into the target convolution layer;
[0067] When the gradient value is greater than a preset gradient threshold, a target pooling layer corresponding to the gradient value is determined through the jump connection layer, and the convolution image is input into the target pooling layer.
[0068] Further, the processor 1001 may call the mask wearing detection program stored in the memory 1005, and execute the step of inputting the target feature map into the fully connected layer in the preset mask detection model to obtain the mask wearing detection result, including:
[0069] Input the target feature map into a fully connected layer of a preset mask detection model, obtain the matrix-vector product of the matrix vector corresponding to the target feature map through the fully connected layer, and perform classification according to the matrix-vector product;
[0070] When the matrix-vector product is of the first type, outputting the mask wearing detection result is wearing a mask;
[0071] When the matrix-vector product is of the second type, the output mask wearing detection result is that the mask is not worn.
[0072] Further, the processor 1001 may call the mask wearing detection program stored in the memory 1005, and before executing the step of jumping the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map, the method includes:
[0073] Obtain a training sample set;
[0074] Extracting a preset proportion of training samples from the training sample set and inputting them into the initial mask detection model, and iteratively training the initial mask detection model;
[0075] Obtain the recognition accuracy of the trained mask detection model;
[0076] When the recognition accuracy is greater than or equal to a preset accuracy threshold, the trained mask detection model is used as a preset mask detection model.
[0077] Further, the processor 1001 may call the mask wearing detection program stored in the memory 1005 to perform the step of preprocessing the face image to obtain a face grayscale image, including:
[0078] Counting the pixel values of each pixel point in the face image, and sorting the pixel values from small to large to obtain a pixel sequence;
[0079] An intermediate pixel value in the pixel sequence is obtained, and pixel values greater than the intermediate pixel value are replaced with the intermediate pixel value to remove noise in the face image and convert the face image into a face grayscale image.
[0080] Further, the processor 1001 may call the mask wearing detection program stored in the memory 1005, and after executing the step of inputting the target feature map into the fully connected layer in the preset mask detection model and obtaining the mask wearing detection result, the method further includes:
[0081] When the mask wearing detection result is that the mask is not worn, performing identity recognition on the face image to obtain identity information;
[0082] Output a mask wearing reminder containing the identity information.
[0083] Based on the above hardware structure, various embodiments of the mask wearing detection method of the present application are proposed.
[0084] Reference Figure 2 In the first embodiment of the mask wearing detection method of the present application, the method includes:
[0085] Step S10, when a mask wearing detection request is received, obtaining a face image to be detected associated with the mask wearing detection request.
[0086] The mask wearing detection method in this embodiment is applied to mask wearing detection equipment in public areas such as subways, hospitals, high-speed rail stations, and libraries.
[0087] The mask wearing detection device receives a mask wearing detection request, and the triggering method of the mask wearing detection request is not specifically limited, that is, the mask wearing detection request can be actively triggered by the user, for example, the user clicks the "Mask Wearing Detection" button on the display page of the mask wearing detection device to actively trigger the mask wearing detection request; in addition, the mask wearing detection request can also be automatically triggered, for example, when the mask wearing detection device recognizes facial information, it automatically triggers the mask wearing detection request.
[0088] When the mask wearing detection device receives a mask wearing detection request, the mask wearing detection device obtains the face image to be detected associated with the mask wearing detection request. It should be noted that the face image to be detected associated with the mask wearing detection request refers to the face image of the user who actively triggers the mask wearing detection request, or the face image of the user who actively triggers the mask wearing detection request and all face images within the preset image collection range of the mask wearing detection device, or the mask wearing detection device collects a video image within a preset range. When the video image contains a face image, the mask wearing detection device automatically triggers the mask wearing detection request. In this embodiment, the number of faces in the face image is not specifically limited, and the number of faces is at least one.
[0089] In addition, the face image to be detected associated with the mask wearing detection request is a photo of a person, and there is no specific restriction on the state of the person in the face image, that is, the face image can be a frontal photo of the person, a side photo of the person, a close-up photo of the person, a full-body photo of the person, etc.
[0090] Step S20, preprocessing the face image to obtain a face grayscale image.
[0091] The mask wearing detection device preprocesses the acquired face image to obtain a face grayscale image, specifically including:
[0092] Counting the pixel values of each pixel point in the face image, and sorting the pixel values from small to large to obtain a pixel sequence;
[0093] An intermediate pixel value in the pixel sequence is obtained, and pixel values greater than the intermediate pixel value are replaced with the intermediate pixel value to remove noise in the face image and convert the face image into a face grayscale image.
[0094] That is, since the face picture is in color, the color of each pixel in the color image is determined by the three components of R, G, and B, and each component has 255 median values, so that a pixel can have a color range of more than 16 million (255×255×255). A grayscale image is a special color image with the same three components of R, G, and B. The range of variation of a pixel is 255, and the description of the grayscale image, like the color image, still reflects the distribution and characteristics of the overall and local chromaticity and brightness levels of the entire image. Therefore, in order to facilitate the subsequent calculation and analysis of whether the user wears a mask in the face picture, it is necessary to pre-process the face picture, that is, to grayscale the face color image into a face grayscale image, thereby obtaining a face grayscale image. Specifically, step S20 in this embodiment includes:
[0095] The mask wearing detection device pre-processes the acquired face image through the grayscale image generation algorithm to obtain the face grayscale image. The grayscale image generation algorithm is a commonly used method in the image processing process. The image to be grayscaled is processed according to the grayscale image generation algorithm to obtain the grayscale image.
[0096] Step S30, jump the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map.
[0097] In this embodiment, a mask detection model is preset in the mask wearing detection device, and the preset mask detection model includes a convolution layer, a pooling layer, a jump connection layer and a fully connected layer. The sum of the number of convolution layers, pooling layers, jump connection layers and fully connected layers in the preset mask detection model is less than the number of layers of an ordinary neural network model. For example, the number of layers of the preset mask detection model is 9. The mask wearing detection device jumps the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain a target feature map. In this way, there is no need to execute the processing steps of each level in sequence, which reduces the image processing steps and further improves the image processing efficiency.
[0098] Reference Figure 3 , Figure 3 This is a schematic diagram of the structure of the preset mask detection model in the first embodiment of the mask wearing detection method of the present application. The preset mask detection model in this embodiment includes an input module, three branches and an output module. The left branch and the middle branch are four two-dimensional convolution layer modules, and the four two-dimensional convolution layer modules include two types of convolution kernels. The convolution kernels of the first and fourth layers of the two-dimensional convolution layer are the same, and the convolution kernels of the second and third layers of the two-dimensional convolution layer are the same. That is, Figure 3 As shown in the figure, the convolution kernels of the first and fourth two-dimensional convolutional layer modules of the left branch are 1×1; the convolution kernels of the second and third two-dimensional convolutional layer modules are k×k, where k can be 3 or 5 or other numbers. The convolution kernels of the first and fourth two-dimensional convolutional layer modules of the middle branch are k×k; the convolution kernels of the second and third two-dimensional convolutional layer modules are 1×1, and similarly, k can be 3 or 5 or other numbers. The right branch is a jump connection layer module. The left branch, the middle branch, and the right branch process the input grayscale face image at the same time, and the processing results of each branch are added and summarized as the output result of grayscale face recognition.
[0099] The mask wearing detection device jumps the face grayscale image to the target convolution layer or target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map. Figure 4 , Figure 4 A schematic diagram of a specific scenario of performing mask detection by a preset mask detection model in the first embodiment of the mask wearing detection method of the present application. Specifically, it includes steps 1 to 9, starting from step 1, inputting a grayscale image of a face to obtain a feature image, the preset mask detection model inputs the feature image to a jump connection layer, the jump connection layer analyzes the feature image, and determines the next target convolution layer or target pooling layer to be processed. For example, the mask wearing detection device inputs the feature image to any one of steps 2 to 8 through the jump connection layer in the preset mask detection model, and finally obtains the target feature map.
[0100] Figure 4 The structure of the preset mask detection model shown in the figure includes 9 convolutional layers, where operator represents the main components of the current layer. The first to eighth convolutional layers are composed of ordinary convolutional layers NConv or Figure 3 The preferred preset mask detection model shown is composed of a convolution layer SConv. For example, the main component of the convolution layer corresponding to step 1 is NConv, 3×3, which means that the convolution layer corresponding to step 1 is composed of a common convolution layer NConv with a convolution kernel of 3×3. Similarly, the main component of the convolution layer corresponding to step 2 is SConv, 3×3, which means that the convolution layer corresponding to step 2 is Figure 3 The convolution layer SConv of the preferred preset mask detection model shown, and k=3, preferably, the convolution kernel 3×3 has moderate computational complexity, ensuring that the computer performance will not be reduced and is conducive to increasing the model depth; the 9th convolution layer is a fully connected layer and also the output layer, that is, it outputs the facial grayscale image recognition results of the 2nd convolution layer to the 8th convolution layer.
[0101] Figure 4 The resolution shown indicates the size of the input face grayscale image of the current layer (convolutional layer), that is, the resolution of the input face grayscale image. When the length and width of the resolution of a certain convolutional layer become half of the previous convolutional layer of this layer, it means that this layer has undergone a pooling operation. For example, the resolution of the convolutional layer corresponding to step 1 is 224×224, and the resolution of the convolutional layer corresponding to stage2 is 112×112, which means that the convolutional layer corresponding to stage2 has undergone a pooling operation. The purpose of the pooling operation is to downsample the input face grayscale image while minimizing the loss of face grayscale image features, thereby generating a thumbnail of the input face grayscale image, thereby reducing the dimension of the face grayscale image features and retaining effective information.
[0102] Figure 4The Channel shown here indicates the number of channels or feature maps, that is, the pixel value of the grayscale image of the face output by the current layer (convolution layer). For example, if the convolution kernel of the convolution layer corresponding to step 2 is 3×3 and the output pixel value is 8, then the parameter quantity can be obtained: 3×3×8=72.
[0103] Figure 4 The layers shown indicate how many repeated operators there are in the current layer (convolutional layer), that is, how many repeated (identical) NConv or repeated (identical) SConv the current convolutional layer consists of. For example, the layers of the convolutional layer corresponding to step 3 is 2, which means that the convolutional layer corresponding to step 3 consists of 2 identical SConv, 3×3; similarly, the layers of the convolutional layer corresponding to step 7 is 4, which means that the convolutional layer corresponding to step 7 consists of 4 identical SConv, 5×5.
[0104] Step S40, input the target feature map into the fully connected layer in the preset mask detection model to obtain the mask wearing detection result.
[0105] In this embodiment, the mask wearing detection device inputs the target feature map into the fully connected layer in the preset mask detection model, performs weighted classification through the fully connected layer, and obtains the mask wearing detection result, specifically including:
[0106] Step a1, inputting the target feature map into the fully connected layer of the preset mask detection model, obtaining the matrix-vector product of the matrix vector corresponding to the target feature map through the fully connected layer, and performing classification according to the matrix-vector product;
[0107] Step a2, when the matrix-vector product is of the first type, outputting the mask wearing detection result as wearing a mask;
[0108] Step a3, when the matrix-vector product is of the second type, outputting the mask wearing detection result as not wearing a mask.
[0109] That is, the mask wearing detection device inputs the target feature map into the fully connected layer of the preset mask detection model, and obtains the matrix-vector product of the matrix vector corresponding to the target feature map through the fully connected layer. The matrix-vector product can be 1 or 0, and classification is performed according to the matrix-vector product; when the target feature map is 1, it is determined to be the first type, and the mask wearing detection device outputs the mask wearing detection result as wearing a mask; when the matrix-vector product is 0, it is determined to be the second type, and the mask wearing detection device outputs the mask wearing detection result as not wearing a mask.
[0110] For example, Figure 4The FC / Output shown represents a fully connected layer or a fully convolutional layer or a mixture of a fully connected layer and a fully convolutional layer. In this embodiment, it can be designed as a combination of 2 fully convolutional layers and 2 fully connected layers, and the output dimension of the last fully connected layer is 2. Then, a classifier is connected after the last fully connected layer to obtain the final output mask wearing detection result.
[0111] In the embodiment of the present application, the mask detection model is preset to be composed of a convolutional layer module, which includes the advantages of a common neural network structure. Each module is a subnetwork that can include a convolutional layer, a pooling layer, and an activation layer. In other words, our network architecture is two-level, the upper level is a module, and the lower level (that is, inside each module) is various layers. Then there can be a jump connection layer between modules and between layers, indicating that a module or layer can skip the subsequent module or layer and then directly send the output result of the module or layer to the subsequent module or layer. Thus, while the structure is concise, it can extract features more comprehensively and faster than the common neural network structure and output the recognition result of the grayscale image of the human face, without the need to purchase physical instruments, thereby improving the recognition accuracy of the grayscale image of the human face, reducing the recognition time and saving the recognition cost.
[0112] In this embodiment, a mask detection model is preset, and the grayscale image of the face is jumped and input to the target convolution layer or the target pooling layer through the jump connection layer in the preset mask detection model. In this way, there is no need to execute the steps of each processing layer in the preset mask detection model in sequence. The processing steps of the face image are reduced through hierarchical jumping, and the efficiency of mask detection is improved. In addition, this implementation does not require the purchase of physical instruments, thereby reducing hardware costs.
[0113] Furthermore, based on the first embodiment of the mask wearing detection method of the present application, a second embodiment of the mask wearing detection method of the present application is proposed.
[0114] This embodiment is a refinement of step S30 in the first embodiment, and specifically includes the following steps in the second embodiment of the mask wearing detection method of the present application:
[0115] Inputting the face grayscale image into a preset mask detection model, processing the face grayscale image through a convolution layer in the preset mask detection model, and obtaining a convolution image;
[0116] Input the convolution image to a skip connection layer of a preset mask detection model, and input the convolution image to a target convolution layer or a target pooling layer through the skip connection layer;
[0117] Processing the convolution image through the target convolution layer to obtain a new convolution image, or processing the convolution image through the target pooling layer to obtain a pooled image;
[0118] The new convolution image or the pooled image is input into the skip connection layer until the new convolution image or the pooled image is input into the last pooling layer through the skip connection layer, and the pooled image output by the last pooling layer is used as the target feature map.
[0119] In this embodiment, the mask wearing detection device inputs the face grayscale image into a preset mask detection model, processes the face grayscale image through the convolution layer in the preset mask detection model, and obtains a convolution image. The convolution image is input into the jump connection layer of the preset mask detection model, and the convolution image is input into the target convolution layer or the target pooling layer through the jump connection layer, specifically, including:
[0120] Step b1, inputting the convolution image into the skip connection layer in the preset mask detection model to obtain the gradient value of the convolution image;
[0121] Step b2, when the gradient value is less than or equal to a preset gradient threshold, determining a target convolution layer corresponding to the gradient value through the jump connection layer, and inputting the convolution image into the target convolution layer;
[0122] Step b3, when the gradient value is greater than a preset gradient threshold, determining the target pooling layer corresponding to the gradient value through the jump connection layer, and inputting the convolution image into the target pooling layer.
[0123] That is, the mask wearing detection device inputs the convolution image into the jump connection layer in the preset mask detection model to obtain the gradient value of the convolution image; the mask wearing detection device compares the gradient value with the preset gradient threshold (the preset gradient threshold can be flexibly set according to the specific scenario). When the gradient value is less than or equal to the preset gradient threshold, the mask wearing detection device determines the target convolution layer corresponding to the gradient value through the jump connection layer (for example, if the gradient value is within the first preset range, the interval jumps to 2 layers), and inputs the convolution image to the target convolution layer; when the gradient value is greater than the preset gradient threshold, the target pooling layer corresponding to the gradient value is determined through the jump connection layer, and the convolution image is input to the target pooling layer.
[0124] In this embodiment, the mask wearing detection device processes the convolution image through the target convolution layer to obtain a new convolution image, or processes the convolution image through the target pooling layer to obtain a pooled image. The mask wearing detection device inputs the new convolution image or the pooled image into the jump connection layer until the new convolution image or the pooled image is input into the last pooling layer through the jump connection layer, and the pooled image output by the last pooling layer is used as the target feature map.
[0125] In this embodiment, the jump connection layer in the preset mask detection model is used to jump, which reduces the execution steps and improves the efficiency of mask recognition.
[0126] Further, based on the above-mentioned embodiment of the mask wearing detection method of the present application, a third embodiment of the mask wearing detection method of the present application is proposed. In the second embodiment of the mask wearing detection method of the present application, before step S30, the following steps are included:
[0127] Obtain a training sample set;
[0128] The mask wearing detection device obtains a training sample set, and the training sample set obtained by the mask wearing detection device includes face pictures of people wearing masks with a first identifier added and face pictures of people not wearing masks with a second identifier added. Specifically, the training sample set refers to pre-prepared face pictures, and these face pictures are marked so that they can be used as training sample sets. Among them, in order to distinguish whether the face picture is wearing a mask, the first identifier is added to the face picture of the person wearing a mask, and the second identifier is added to the face picture of the person not wearing a mask. It should be noted that there is no specific limit on the number of training sample sets, but the number of training sample sets must be sufficient to complete the model training.
[0129] A preset proportion of training samples are extracted from the training sample set and input into the initial mask detection model, and the initial mask detection model is iteratively trained.
[0130] The mask wearing detection device extracts a preset proportion of training samples from the acquired training sample set and inputs them into the initial mask wearing detection neural network model, and the mask wearing detection device then iteratively trains the initial mask wearing detection neural network model. Specifically, in order to gradually use the data in the training sample set to train the preset mask detection model, it is necessary to extract training samples according to a preset proportion and input them into the initial mask wearing detection neural network model in sequence for iterative training, and continuously adjust the initial mask wearing detection neural network model according to the iterative training results, so that the initial mask wearing detection neural network model is closer and closer to the initial preset mask detection model we need. In addition, considering the simplicity and computational complexity of the model, it is only necessary to extract a preset proportion of training samples from the training sample set and input them into the initial mask wearing detection neural network model to iteratively train the initial mask wearing detection neural network model.
[0131] The recognition accuracy of the trained mask detection model is obtained. When the recognition accuracy is greater than or equal to a preset accuracy threshold, the trained mask detection model is used as a preset mask detection model.
[0132] The mask wearing detection device obtains the recognition accuracy of the trained mask wearing detection neural network model. When the recognition accuracy is greater than or equal to the preset accuracy threshold, the mask wearing detection device uses the trained mask wearing detection neural network model as the preset mask detection model. Specifically, a preset accuracy threshold can be set as a reference for training completion. The mask wearing detection device extracts a preset proportion of training samples from the training sample set and inputs them into the initial mask wearing detection neural network model, and iteratively trains the initial mask wearing detection neural network model. Each training corresponds to obtaining the trained mask wearing detection neural network model, and obtaining the recognition accuracy of the trained mask wearing detection neural network model. When the recognition accuracy is greater than or equal to the preset accuracy threshold, the trained mask wearing detection neural network model is used as the preset mask detection model; when the recognition accuracy is less than the preset accuracy threshold, a preset proportion of training samples are continuously extracted from the training sample set and input into the initial mask wearing detection neural network model, and the initial mask wearing detection neural network model is iteratively trained until the recognition accuracy of the trained mask wearing detection neural network model is greater than or equal to the preset accuracy threshold.
[0133] In this embodiment, the mask wearing detection device obtains a training sample set including face pictures of people wearing masks with a first identifier added and face pictures of people not wearing masks with a second identifier added, and extracts a preset proportion of training samples from the training sample set and inputs them into an initial mask wearing detection neural network model, and iteratively trains the initial mask wearing detection neural network model. Then, based on the comparison result of the recognition accuracy of the trained mask wearing detection neural network model with a preset accuracy threshold, the trained mask wearing detection neural network model is used as the preset mask detection model, or the initial mask wearing detection neural network model continues to be trained. In this way, while ensuring the recognition accuracy of the preset mask detection model, the simplicity of the preset mask detection model is achieved, the recognition time of the preset mask detection model is reduced, and the recognition efficiency of the preset mask detection model is improved.
[0134] In addition, refer to Figure 5 The embodiment of the present application further provides a mask wearing detection device, the mask wearing detection device comprising:
[0135] An acquisition module 10 is used to acquire a face image to be detected associated with a mask wearing detection request when a mask wearing detection request is received;
[0136] The processing module 20 is used to pre-process the face image to obtain a face grayscale image;
[0137] The calling module 30 is used to jump the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map;
[0138] The output module 40 is used to input the target feature map into the fully connected layer in the preset mask detection model to obtain the mask wearing detection result.
[0139] The present application also provides a mask wearing detection device, which includes: a memory, a processor, and a mask wearing detection program stored in the memory and executable on the processor, wherein the mask wearing detection program implements the steps of the above-mentioned mask wearing detection method when executed by the processor.
[0140] The present application also provides a computer-readable storage medium, on which a mask wearing detection program is stored. When the mask wearing detection program is executed by a processor, the steps of the above-mentioned mask wearing detection method are implemented.
[0141] In the embodiments of the mask wearing detection method, device, equipment and readable storage medium of the present application, all the technical features of the above-mentioned mask wearing detection method embodiments are included. The expansion and explanation content of the specification are basically the same as those of the above-mentioned mask wearing detection method embodiments, and will not be repeated here.
[0142] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0143] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0144] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0145] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A mask wearing detection method, characterized in that: The mask wearing detection method comprises the following steps: Upon receiving a mask wearing detection request, obtaining a face image to be detected associated with the mask wearing detection request; Preprocessing the face image to obtain a face grayscale image; The face grayscale image is jumped and input to the target convolution layer or target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map; Inputting the target feature map into a fully connected layer in a preset mask detection model to obtain a mask wearing detection result; The step of jumping the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map includes: Inputting the face grayscale image into a preset mask detection model, processing the face grayscale image through a convolution layer in the preset mask detection model, and obtaining a convolution image; Input the convolution image to a skip connection layer of a preset mask detection model, and input the convolution image to a target convolution layer or a target pooling layer through the skip connection layer; Processing the convolution image through the target convolution layer to obtain a new convolution image, or processing the convolution image through the target pooling layer to obtain a pooled image; Inputting the new convolution image or the pooled image into the skip connection layer, until the new convolution image or the pooled image is input into the last pooling layer through the skip connection layer, and taking the pooled image output by the last pooling layer as the target feature map; The step of inputting the convolution image to a skip connection layer of a preset mask detection model, and inputting the convolution image to a target convolution layer or a target pooling layer through the skip connection layer comprises: Inputting the convolution image into the skip connection layer in the preset mask detection model to obtain the gradient value of the convolution image; When the gradient value is less than or equal to a preset gradient threshold, determining a target convolution layer corresponding to the gradient value through the jump connection layer, and inputting the convolution image into the target convolution layer; When the gradient value is greater than a preset gradient threshold, a target pooling layer corresponding to the gradient value is determined through the jump connection layer, and the convolution image is input into the target pooling layer.
2. The mask wearing detection method according to claim 1, characterized in that: The step of inputting the target feature map into a fully connected layer in a preset mask detection model to obtain a mask wearing detection result includes: Input the target feature map into a fully connected layer of a preset mask detection model, obtain the matrix-vector product of the matrix vector corresponding to the target feature map through the fully connected layer, and perform classification according to the matrix-vector product; When the matrix-vector product is of the first type, outputting the mask wearing detection result is wearing a mask; When the matrix-vector product is of the second type, the output mask wearing detection result is that the mask is not worn.
3. The mask wearing detection method according to claim 1, characterized in that: Before the step of jumping the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain the target feature map, the method includes: Obtain a training sample set; Extracting a preset proportion of training samples from the training sample set and inputting them into the initial mask detection model, and iteratively training the initial mask detection model; The recognition accuracy of the trained mask detection model is obtained. When the recognition accuracy is greater than or equal to a preset accuracy threshold, the trained mask detection model is used as a preset mask detection model.
4. The mask wearing detection method according to claim 1, characterized in that: The step of preprocessing the face image to obtain a face grayscale image comprises: Counting the pixel values of each pixel point in the face image, and sorting the pixel values from small to large to obtain a pixel sequence; An intermediate pixel value in the pixel sequence is obtained, and pixel values greater than the intermediate pixel value are replaced with the intermediate pixel value to remove noise in the face image and convert the face image into a face grayscale image.
5. The mask wearing detection method according to any one of claims 1 to 4, characterized in that: After the step of inputting the target feature map into a fully connected layer in a preset mask detection model to obtain a mask wearing detection result, the method further includes: When the mask wearing detection result is that the mask is not worn, performing identity recognition on the face image to obtain identity information; Output a mask wearing reminder containing the identity information.
6. A mask wearing detection device, characterized in that: The mask wearing detection device comprises: An acquisition module, configured to, upon receiving a mask wearing detection request, acquire a face image to be detected associated with the mask wearing detection request; A processing module, used for preprocessing the face image to obtain a face grayscale image; A calling module is used to jump the face grayscale image to the target convolution layer or the target pooling layer for processing through the jump connection layer in the preset mask detection model to obtain a target feature map. The calling module is also used to input the face grayscale image to the preset mask detection model, process the face grayscale image through the convolution layer in the preset mask detection model, and obtain a convolution image; input the convolution image to the jump connection layer in the preset mask detection model to obtain a gradient value of the convolution image; when the gradient value is less than or equal to a preset gradient threshold, determine the target convolution layer corresponding to the gradient value through the jump connection layer, and The convolution image is input to the target convolution layer; when the gradient value is greater than a preset gradient threshold, the target pooling layer corresponding to the gradient value is determined through the jump connection layer, and the convolution image is input to the target pooling layer; the convolution image is processed by the target convolution layer to obtain a new convolution image, or the convolution image is processed by the target pooling layer to obtain a pooling image; the new convolution image or the pooling image is input to the jump connection layer until the new convolution image or the pooling image is input to the last pooling layer through the jump connection layer, and the pooling image output by the last pooling layer is used as the target feature map; The output module is used to input the target feature map into the fully connected layer in the preset mask detection model to obtain the mask wearing detection result.
7. A mask wearing detection device, characterized in that: The mask wearing detection device includes: a memory, a processor, and a mask wearing detection program stored in the memory and executable on the processor. When the mask wearing detection program is executed by the processor, the steps of the mask wearing detection method as described in any one of claims 1 to 5 are implemented.
8. A readable storage medium, characterized in that: The readable storage medium stores a mask wearing detection program, which, when executed by a processor, implements the steps of the mask wearing detection method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Chef cap and mask wearing detection method based on deep learning
CN111062429A