Smoking behavior detection method based on SDVGNet network
Through the design of the SDVGNet network, convolution operations and attention mechanism feature extraction are used, combined with upsampling and spatial channel refinement fusion, to solve the problem of insufficient accuracy and stability of existing smoking behavior detection methods in complex scenes, and achieve Efficient and accurate smoking behavior detection.
Patent Information
- Application Number
- CN202410633363.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-05-21
AI Technical Summary
Existing smoking behavior detection methods lack detection accuracy and stability in complex scenarios, and traditional models are highly complex, consume large amounts of computing resources, cannot detect in real time, have poor generalization capabilities, and are prone to misjudgments and missed detections.
The SDVGNet network is used to construct an image data set containing cigarettes, and the convolution operation and attention mechanism feature extraction are designed, combined with upsampling and spatial channel refinement fusion, to reduce redundant features and improve the accuracy and generalization ability of smoking behavior detection.
It improves the accuracy and network performance of smoking behavior detection, reduces computational complexity, enhances the ability to identify smoking behavior, and reduces misjudgments and missed detections.
Smart Images

Figure CN118587762A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of behavior detection, and in particular, relates to a smoking behavior detection method based on a SDVGNet network. Background Art
[0002] The research results of smoking behavior detection can be divided into detection methods based on hardware devices and wireless signals, and those based on computer vision. Among them, the detection methods based on hardware devices and wireless signals have poor adaptability and are not effective in some special scenarios. In view of these limitations, smoking behavior detection methods based on computer vision have been widely used in recent years. At the same time, the monitoring system has gradually entered the intelligent era from the simulation era, the networking era, and the high-definition era. Monitoring resources are no longer used as local monitoring functions, but are combined with computer vision to achieve intelligent monitoring. According to the characteristics of smoke generated by smoking, the use of image processing related algorithms to extract suspected smoke areas and accurately segment and identify them can greatly improve the high false alarm rate and low detection rate of traditional smoke detectors.
[0003] Comparative Document 1: Chinese Patent Document No. 202210652952.6, published on July 15, 2022, records a "kitchen smoking detection method and system using neural network and infrared image matching". The method includes: obtaining infrared images and visible light images of the target area; marking fixed high temperature areas in the visible light image; performing position registration on the infrared image and the visible light image; extracting high temperature areas that do not overlap with the fixed high temperature areas from the infrared image as high temperature candidate areas; using a multi-task convolutional neural network to detect the head area from the visible light image, and deforming the head area to obtain a candidate area for cigarette position information; based on the position registration relationship between the infrared image and the visible light image, detecting whether the high temperature candidate area overlaps with the cigarette position information candidate area. If there is an overlap, it is judged that smoking behavior exists; otherwise, it is judged that there is no smoking behavior. This invention can significantly improve the detection speed and accuracy of smoking detection in kitchen scenes.
[0004] Comparative Document 1 requires processing with both visible light images and infrared images. If one of the images is of poor quality or incomplete, it may affect the final detection result. Multi-task convolutional neural network, head area detection, position registration and other steps make the whole system more complex, requiring a lot of computing resources and time to complete these steps, and the computational complexity is high.
[0005] Comparative Document 2: Chinese Patent Document No. 202111402315.5, published on March 22, 2022, records a "gas station smoking behavior detection and alarm method based on deep learning". The method includes: real-time acquisition of target gas station images through a preset camera; identification and positioning of the position of smokers in the current target gas station image through a preset smoking detection algorithm; control of the flash to flash at the smokers to alert the smokers. The present invention uses a smoking detection algorithm to analyze the gas station images acquired in real time, detect whether there is smoking behavior, and promptly alert the gas station of smoking behavior when it exists; it also reduces the burden on gas station staff, can work 24 hours a day, ensures the safety of the gas station, and ensures zero smoking in the gas station scene, avoiding mis-viewing and omissions in existing smoking detection methods for gas station scenes.
[0006] The accuracy and stability of the algorithm in Comparative Document 2 are affected by factors such as light, angle, and occlusion, resulting in unsatisfactory detection results.
[0007] Comparative Document 3: Chinese Patent Document No. 202110038437.4, published on April 30, 2021, records a "method and system for identifying and processing smokers at oil production sites". The method uses a camera to take photos of the oil production site to obtain environmental photos; uses a recognition model to determine whether there are cigarette butts in the environmental photos; wherein the recognition model is obtained by machine learning training using multiple sets of data; the multiple sets of data include first-category data and second-category data; each set of data in the first category of data includes: photos containing cigarette butts and labels indicating that cigarette butts are contained in the photos; each set of data in the second category of data includes: photos that do not contain cigarette butts and labels indicating that cigarette butts are not contained in the photos; in the case of cigarette butts in the environmental photos, it is determined that the personnel at the oil production site are smoking, and an early warning signal is issued. The present invention extracts multi-scale features of the image, obtains multi-layer feature mapping, obtains a feature pyramid, solves the scale change problem, and can quickly and accurately identify cigarette butts in on-site photos.
[0008] In Comparative Document 3, judging whether smoking occurs solely based on whether there are cigarette butts in the photo may lead to misjudgment. For example, a cigarette butt does not necessarily mean that someone is smoking, but may be caused by other reasons.
[0009] Finally, the traditional method of cigarette butt recognition uses methods based on FasterRCNN model or YOLOv5 model for recognition. The FasterRCNN model is highly complex and cannot perform real-time detection. The model also does not consider the different scales of cross-domain object detection. The YOLOv5 model is limited by data samples, and the effect of the model in actual application cannot reach the final test results; the model also has weak generalization ability, and the detection effect depends on self-made data sets.
[0010] In view of this, the present invention is proposed. Summary of the invention
[0011] The technical problem to be solved by the present invention is to overcome the deficiencies of the prior art and provide a smoking behavior detection method based on the SDVGNet network, which solves the problems raised in the above-mentioned background technology.
[0012] In order to solve the above technical problems, the basic concept of the technical solution adopted by the present invention is:
[0013] A smoking behavior detection method based on SDVGNet network includes the following steps:
[0014] Step 1: Build an image dataset containing cigarettes, collect images containing cigarettes in various scenes, and use LabelImg annotation software to make the collected cigarette images into a dataset in PASCAL VOC format;
[0015] Step 2: Data preprocessing and data set division: annotate the image data containing cigarettes, label them as smoking and non-smoking, and then divide the annotated data into training set, validation set and test set;
[0016] Step 3: Design the SDVGNet network. In the SDVGNet network, for the input picture containing cigarettes, convolution operation and feature extraction operation based on attention mechanism are first used to extract features to obtain feature maps containing cigarettes. Then, upsampling and spatial channel refinement fusion operations are used to perform multi-scale feature fusion and context enhancement operations on the feature maps containing cigarettes, and these features are passed to the output layer for final regression prediction.
[0017] Step 4: Network training and verification. Based on the SDVGNet network designed in Step 3, the parameters of each layer are trained and updated. All neural network parameters are initialized first, and the cross entropy loss function is used to measure the difference between the model prediction results and the true labels. Then the test set obtained in Step 2 is input into the SDVGNet network. The performance of the SDVGNet network in the smoking behavior detection task is evaluated by the accuracy of the SDVGNet network in recognizing smoking behaviors in the test set images. Finally, the hyperparameters and structure of the network are adjusted according to the verification results.
[0018] Step 5: Apply to the smoking behavior detection task and apply the trained SDVGNet network to the smoking behavior detection task.
[0019] Optionally, the SDVGNet network consists of a C3MRA module, a PCAK module, and a SMConv module, and the PCAK module includes a channel attention module PCAM and a spatial attention module PSAM.
[0020] Optionally, perform the following steps when designing the SDVGNet network:
[0021] Step 3.1: Capture the local cross-channel information interaction of the feature map containing cigarettes. Input the feature map containing cigarettes into the C3MRA module, and then divide it into two paths. The lower path passes through a Conv for a 1×1 convolution operation, and the upper path passes through a Conv for a 1×1 convolution operation and a Bottleneck to increase the receptive field and reduce the amount of calculation. Then the two results pass through a Concat, and finally pass through a Conv for a 1×1 convolution operation and an MRA to capture the local cross-channel information interaction;
[0022] Step 3.2: Feature enhancement of the feature map containing cigarettes. The PCAK module uses the attention mechanism to enhance the feature map containing cigarettes. The channel attention module PCAM and the spatial attention module PSAM are connected in parallel to perform attention mechanisms in space and channels. The channel attention weight and spatial attention weight are inferred along the two dimensions of channel and space respectively. Then, the two attention weights are feature fused (Concat) to obtain the spatial attention weight represented by the fused channel. The spatial attention weights represented by the two fused channels are obtained through a multi-layer perceptron and activated by a sigmoid function. Finally, the spatial attention weights represented by the two fused channels are multiplied by the input feature map containing cigarettes respectively, and the results are added to obtain the feature-enhanced feature map containing cigarettes.
[0023] Step 3.3: Reduce the redundant features of the feature graph containing cigarettes. Use the SMConv module to reduce the redundant features of the feature graph containing cigarettes. In the SMConv module, for the input feature graph containing cigarettes F∈R c×h×w It is divided into two paths, the upper path is input to the spatial reconstruction unit (SRU) to obtain the spatially refined feature map F containing cigarettes 1 , the next path is input to the channel reconstruction unit (CRU) to obtain the channel refinement containing the cigarette feature map F 2 , and then refine the space to include the cigarette feature map F 1 and channel refinement contains the feature map F of cigarettes 2 Use the feature fusion (Concat) operation for splicing, and then pass through the multi-layer perceptron layer (MLP) to obtain the spatial channel refined fusion feature maps P and Q containing cigarettes. Finally, add the spatial channel refined fusion feature maps P and Q containing cigarettes to obtain the spatial channel refined fusion feature map K containing cigarettes.
[0024] Step 3.4: For the input image F containing cigarettes, first perform two Conv operations to downsample it to obtain the compressed feature map F 1 ; Then apply C3ECA module to extract features to obtain feature map F 2 ; Then perform a Conv operation on the obtained feature map and apply the C3ECA module to extract features to obtain the feature map F 3 ; Then the feature map F 3 Input to the PCAK module to enhance its features and obtain the feature map F 4 ; Then the feature map F 4 Input to the SMConv module to reduce the redundant features in the feature map to obtain the feature map F 5 ; For the feature map F 5 Apply the Upsample operation to upsample and obtain the feature map F 6 ; The feature map F 2 With the feature map F 6 Perform a feature fusion operation (Concat) to obtain the feature map F 7 ; Then F 7 Input to the SMConv module to reduce the redundant features in the feature map to obtain the feature map F 8 ; Finally, F 8 Input it into Conv2d for a two-dimensional convolution operation to obtain the final smoking behavior detection result.
[0025] Optionally, the steps for capturing the local cross-channel information interaction of the feature graph containing cigarettes in Step 3.1 are:
[0026] Step 3.1.1: Perform a global maximum pooling operation on the input feature map containing cigarettes, and then perform a one-dimensional convolution operation with a convolution kernel size of M. After the ReLU activation function, the weight ω of each channel is obtained, as shown in the formula below:
[0027] ω=R(C1D M (x)) (1)
[0028] Where ω is the weight of the channel; R is the ReLU activation function; C1D represents one-dimensional convolution, M is the size of the convolution kernel, x is the input feature map containing cigarettes, and finally the weight is multiplied by the corresponding element of the original input feature map containing cigarettes to obtain the final output feature map containing cigarettes.
[0029] Optionally, Step 3.2 includes the steps of enhancing the feature map of cigarettes:
[0030] Step 3.2.1: The input of PCAM is a feature map F containing cigarettes, and the dimension is set to H×W×C; where H, W, and C are the height, width, and number of channels of the feature map, respectively. The input feature map containing cigarettes is subjected to global L2 norm pooling (L2Pool) and global maximum pooling (MaxPool) to obtain two 1×1×C feature maps containing cigarettes. The two feature maps containing cigarettes obtained by average pooling and maximum pooling are then processed using a shared fully connected layer (SharedMLP). The results obtained by the shared fully connected layer are then added and activated using the Sigmoid activation function to obtain the channel attention weight F of the input feature map F containing cigarettes. c (between 0 and 1), with a size of 1×1×C. Since each channel of the feature layer containing cigarettes extracts a certain level of feature information, PPCAM focuses on what level of feature information in the image is more important. In order to effectively calculate channel attention, the spatial dimension method of compressing the input feature map is adopted, and its calculation formula is as follows:
[0031] F c =σ(MLP(L2Pool(F))+MLP(MaxPool(F))) (2)
[0032] Where σ is the Sigmoid activation function, MLP is the fully connected layer, L2Pool is the L2 norm pooling, MaxPool is the maximum pooling, F is the input feature map containing cigarettes, and Fc is the channel attention weight of the feature map F containing cigarettes.
[0033] Step 3.2.2: The input of PSAM is the feature map F containing cigarettes, and the dimension is set to H×W×C; where H, W, and C are the height, width, and number of channels of the feature map, respectively. The feature map is pooled by maximum pooling and L2 norm pooling to obtain two H×W×1 feature maps, and then the two feature maps containing cigarettes are concatenated by the feature map fusion (Concat) operation to obtain a H×W×2 feature map, which is then converted into a H×W×1 feature map containing cigarettes through a 7×7 convolution, and then activated by a sigmoid function to obtain the spatial attention weight F of the feature map F containing cigarettes. s (between 0 and 1), the size is H×W×1. The calculation formula is as follows:
[0034] F s =σ(Cov 7×7 ([L2Pool(F)+MaxPool(F)])) (3)
[0035] Where σ is the Sigmoid activation function, Cov 7×7 is a 7×7 convolution operation, L2Pool is L2 norm pooling, MaxPool is maximum pooling, F is the input feature map containing cigarettes, F s is the spatial attention weight of the feature map F of the cigarette;
[0036] Step 3.2.3: Add the channel attention weight F of the feature map F containing cigarettes obtained by PCAM c The spatial attention weight F of the feature map F containing cigarettes obtained by PSAM s After a Concat, feature fusion is performed to obtain the spatial attention weight F represented by the fusion channel. cs , the size is (H×W+C)×1×1. Then, after an MLP layer, the spatial attention weights of the two fused channels are obtained. and Then apply the sigmoid function to fuse the spatial attention weights represented by the channel and activation;
[0037] Step 3.2.4: Finally, the spatial attention weights represented by the fusion channel and Multiply them with the input feature map F containing cigarettes to obtain two spatial attention-enhanced feature maps represented by the fusion channel, and then add the two feature maps to obtain the final feature-enhanced feature map F PCAK .
[0038] Optionally, the steps of reducing redundant features of the feature graph containing cigarettes in Step 3.3 are:
[0039] Step 3.3.1: In the spatial reconstruction unit, the input feature map F containing cigarettes is first normalized by subtracting the mean (and dividing by the standard deviation (), and then using the trainable parameter γ∈R in the normalization (GN) layer c To measure the variance of spatial pixels for each batch and channel, normalize the correlation weight P γ ∈R c From formula (4),
[0040]
[0041] Step 3.3.2: Then use the Sigmoid function to convert P γ The weight value of the re-weighted feature map containing cigarettes is mapped to the range (0, 1) and gated by a threshold, setting the threshold weight to 1, and obtaining the information weight P 1 , set it to 0, and get the non-information weight P 2 ; Finally, the input feature map F containing cigarettes is multiplied by P 1 and P 2 Get two weighted features: the feature map containing cigarettes with large amount of information and the feature map containing cigarettes with less information
[0042] Step 3.3.3: Then, the feature map containing cigarettes and To perform the reconstruction operation, first convert the feature map containing cigarettes Split into two channels with a feature map of 1 / 2 of the original channel and Then the feature map containing cigarettes Split into two channels with a feature map of 1 / 2 of the original channel and Then cross-re structure, that is, and Perform feature fusion to obtain F P1 ;Bundle and Perform feature fusion to obtain F P2 , and finally the cross-reconstructed feature map containing cigarettes and Add together to obtain the spatially refined feature map F containing cigarettes 1 The calculation process is shown in formula (5).
[0043]
[0044] in, is element-wise multiplication; is the sum of elements; ∪ is feature fusion (Concat). After applying MSU to the intermediate input feature map F containing cigarettes, not only the features with large information content are separated from the features with small information content, but also they are reconstructed to enhance the representative features and suppress the redundant features in the spatial dimension.
[0045] Step 3.3.4: In the channel reconstruction unit (MCU), for the input feature map F∈R containing cigarettes c×h×w First, the channel of F is evenly divided into two parts, each with 1 / 2C. Then, 1×1 convolution is used to compress the channel containing the feature map of cigarettes to improve its computational efficiency. up and F low . up The efficient convolution operations GWC and PWC are used respectively and the results are added together to obtain the feature map M containing the cigarette, so as to extract high-level representative information and reduce the computational cost; low Use efficient convolution operation PWC, and then combine the result with F low Take the union to get the feature map N containing cigarettes, and then use the simplified SKNet method to adaptively merge the feature maps M and N containing cigarettes to get the channel-refined feature map F containing cigarettes 2 .
[0046] After adopting the above technical solution, the present invention has the following beneficial effects compared with the prior art. Of course, any product implementing the present invention does not necessarily need to achieve all the advantages described below at the same time:
[0047] 1. The present invention can capture the local cross-channel information interaction of the feature graph containing cigarettes. Compared with the traditional network, the present invention introduces the MRA attention mechanism, which can not only process local features but also capture the global context, thereby improving the overall performance and generalization ability of the network.
[0048] 2. The present invention can infer the channel attention weight and the spatial attention weight along the two dimensions of channel and space respectively, and then perform feature fusion on the two attention weights to obtain the spatial attention weight represented by the fused channel, so as to enhance the features and let the network focus on more important features to improve the accuracy of SDVGNet network in detecting smoking behavior, and the present application can enhance the features of feature maps containing cigarettes. Compared with the traditional network, the present invention constructs a PCAK module to enhance the features using the attention mechanism, which can improve the accuracy of the network in identifying smoking behavior and requires fewer parameters.
[0049] 3. The present invention can reduce the redundant features of feature graphs containing cigarettes. Compared with the traditional network, the present invention constructs an SMConv module to reduce redundant features, refines features at the spatial level and channel level and fuses the two to reduce the redundant features of feature graphs containing cigarettes.
[0050] The specific implementation modes of the present invention are further described in detail below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] The drawings described below are only some embodiments. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0052] In the figure:
[0053] Figure 1 A flow chart of the smoking behavior detection method;
[0054] Figure 2 It is the SDVGNet network structure diagram of the present invention;
[0055] Figure 3 It is the C3MRA structure diagram of the present invention;
[0056] Figure 4 It is the structural diagram of the MRA module of the present invention;
[0057] Figure 5 This is the PCAK attention mechanism structure diagram of the present invention;
[0058] Figure 6 One of the PCAM structure diagrams of the present invention;
[0059] Figure 7 The second PSAM structure diagram of the present invention;
[0060] Figure 8 It is the structural diagram of the SMConv module of the present invention;
[0061] Fig. 9 This is one of the MSU structure diagrams of the present invention;
[0062] Fig.10 This is the second MCU structure diagram of the present invention.
[0063] It should be noted that these drawings and textual descriptions are not intended to limit the conceptual scope of the present invention in any way, but are intended to illustrate the concept of the present invention for those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0064] The present invention will now be described in further detail with reference to the accompanying drawings.
[0065] See also Figure 1-10 As shown, in this embodiment, a smoking behavior detection method based on the SDVGNet network is provided, comprising the following steps:
[0066] Step 1: Construct an image dataset containing cigarettes, collect images containing cigarettes in various scenes, and use LabelImg annotation software to make the collected cigarette images into a dataset in PASCAL VOC format; the image data is obtained by collecting images containing cigarettes from the Internet using monitoring equipment in scenes such as kitchens, scenic spots, showrooms, buildings, squares, offices, cabins, city streets, etc., and taking close-up and long-range shots to construct a dataset.
[0067] Step 2: Data preprocessing and data set division: annotate the image data containing cigarettes, label them as smoking and non-smoking, and then divide the annotated data into training set, validation set and test set; the ratio of training set, validation set and test set is 6:2:2. The network structure is as follows Figure 2 shown.
[0068] Step 3: Design the SDVGNet network. In the SDVGNet network, for the input image containing cigarettes, first use convolution operation and feature extraction operation based on attention mechanism to extract features to obtain feature maps containing cigarettes, then use upsampling and spatial channel refinement fusion operation to perform multi-scale feature fusion and context enhancement operation to perform multi-scale feature fusion on the feature maps containing cigarettes, and pass these features to the output layer for final regression prediction. The SDVGNet network consists of C3MRA module, PCAK module, SMConv module, PCAK module includes channel attention module PCAM and spatial attention module PSAM.
[0069] Step 4: Network training and verification. Based on the SDVGNet network designed in Step 3, the parameters of each layer are trained and updated. All neural network parameters are initialized first, and the cross entropy loss function is used to measure the difference between the model prediction results and the true labels. Then the test set obtained in Step 2 is input into the SDVGNet network, and the performance of the SDVGNet network in the task of smoking behavior detection is evaluated by the accuracy of the SDVGNet network in recognizing smoking behavior in the test set. Finally, according to the verification results, the hyperparameters and structures of the network such as the learning rate and regularization parameter are adjusted. The training set is input into the SDVGNet network for training. During the training process, Batch_size is set to 20, the number of iterations is set to 200 rounds, and the stochastic gradient descent algorithm is used to complete the back propagation in the training process. The Adam optimizer is used to adaptively adjust the learning rate to help the SDVGNet network converge quickly. Then the preprocessed verification set is input into the trained network to obtain the accuracy of the network in detecting smoking behavior in images containing cigarettes, and the accuracy is used to evaluate the performance of the network on the verification set.
[0070] The test set obtained in Step 2 is input into the SDVGNet network. The performance of the SDVGNet network in the smoking behavior detection task is evaluated by the accuracy of the SDVGNet network in recognizing smoking behaviors in the images in the test set. Then, the relevant parameters of the SDVGNet network are adjusted according to the performance to improve the performance of the SDVGNet network.
[0071] Step 5: Apply to the smoking behavior detection task and apply the trained SDVGNet network to the smoking behavior detection task.
[0072] The following steps are performed when designing a SDVGNet network:
[0073] Step 3.1: Capture the local cross-channel information interaction of the feature map containing cigarettes. Input the feature map containing cigarettes into the C3MRA module, and then divide it into two paths. The lower path passes through a Conv for a 1×1 convolution operation, and the upper path passes through a Conv for a 1×1 convolution operation and a Bottleneck to increase the receptive field and reduce the amount of calculation. Then the two results pass through a Concat, and finally pass through a Conv for a 1×1 convolution operation and an MRA to capture the local cross-channel information interaction; the C3MRA module structure is as follows Figure 3 shown.
[0074] Step 3.1.1: Perform a global maximum pooling operation on the input feature map containing cigarettes, and then perform a one-dimensional convolution operation with a convolution kernel size of M. After the ReLU activation function, the weight ω of each channel is obtained, as shown in the formula below:
[0075] ω=R(C1D M (x)) (1)
[0076] Where ω is the weight of the channel; R is the ReLU activation function; C1D represents one-dimensional convolution, M is the size of the convolution kernel, x is the input feature map containing cigarettes, and finally the weight is multiplied by the corresponding element of the original input feature map containing cigarettes to obtain the final output feature map containing cigarettes. The MRA module structure is as follows Figure 4 shown.
[0077] It should be noted that the role of the Bottleneck module is to reduce the number of parameters and the amount of calculation. In this module, the input feature map is first subjected to a 1×1 convolution operation to reduce the number of channels to half of the original number, and then a 3×3 convolution operation is performed to double the number of channels. First, dimensionality reduction helps the convolution kernel to better understand the feature information, and then dimensionality increase helps to extract more and more detailed features. Finally, the residual structure is used to add the result to the input feature map to avoid the problem of gradient disappearance.
[0078] Embodiment: Assume that the dimension of the input feature map A containing cigarettes is 160×160×128 (height×width×channel). After it is input into the C3MRA module, the C3MRA module first divides it into two paths. The lower path undergoes a 1×1 convolution to halve the number of channels to obtain a feature map B with a dimension of 160×160×64. The upper path first undergoes a 1×1 convolution to halve the number of channels to obtain a feature map C with a dimension of 160×160×64. Then, the feature map is first reduced in dimension through a Bottleneck, and then upgraded to obtain a feature map D with a dimension of 160×160×64. Then, it is added to the input feature map C to obtain a feature map E with a dimension of 160×160×64. Then, the feature map B and the feature map E are fused through a Concat operation to obtain a feature map F with a dimension of 160×160×128. Then, the feature map F undergoes a 1×1 convolution to double the number of channels to obtain a feature map G with a dimension of 160×160×256.
[0079] The feature map G is input to the MRA module. First, a global maximum pooling operation is performed on it to obtain a feature map H with a dimension of 1×1×256. Then a one-dimensional convolution operation with a convolution kernel size of k is performed to learn the importance between different channels. The feature map I with a dimension of 1×1×256 is obtained and then activated by a sigmoid function. Finally, the feature map I is multiplied by the input feature map G channel by channel to obtain a feature map J with a dimension of 160×160×256.
[0080] Step 3.2: Feature enhancement of the feature map containing cigarettes. The PCAK module uses the attention mechanism to enhance the feature map containing cigarettes. The channel attention module PCAM and the spatial attention module PSAM are connected in parallel to perform attention mechanisms in space and channels. The channel attention weight and spatial attention weight are inferred along the two dimensions of channel and space respectively. Then, the two attention weights are feature fused (Concat) to obtain the spatial attention weight represented by the fused channel. The spatial attention weights represented by the two fused channels are obtained through a multi-layer perceptron and activated by a sigmoid function. Finally, the spatial attention weights represented by the two fused channels are multiplied by the input feature map containing cigarettes respectively, and the results are added to obtain the feature-enhanced feature map containing cigarettes. The PCAK structure is as follows: Figure 5 shown.
[0081] Step 3.2.1: The input of PCAM is a feature map F containing cigarettes, and the dimension is set to H×W×C; where H, W, and C are the height, width, and number of channels of the feature map, respectively. The input feature map containing cigarettes is subjected to global L2 norm pooling (L2Pool) and global maximum pooling (MaxPool) to obtain two 1×1×C feature maps containing cigarettes. The two feature maps containing cigarettes obtained by average pooling and maximum pooling are then processed using a shared fully connected layer (SharedMLP). The results obtained by the shared fully connected layer are then added and activated using the Sigmoid activation function to obtain the channel attention weight F of the input feature map F containing cigarettes. c (between 0 and 1), with a size of 1×1×C. Since each channel of the feature layer containing cigarettes extracts a certain level of feature information, PPCAM focuses on what level of feature information in the image is more important. In order to effectively calculate channel attention, the spatial dimension method of compressing the input feature map is adopted, and its calculation formula is as follows:
[0082] F c =σ(MLP(L2Pool(F))+MLP(MaxPool(F))) (2)
[0083] In the formula, σ is the Sigmoid activation function, MLP is the fully connected layer, L2Pool is the L2 norm pooling, MaxPool is the maximum pooling, F is the input feature map containing cigarettes, and Fc is the channel attention weight of the feature map F containing cigarettes. The PPCAM structure is as follows Figure 6 shown.
[0084] Step 3.2.2: The input of PSAM is the feature map F containing cigarettes, and the dimension is set to H×W×C; where H, W, and C are the height, width, and number of channels of the feature map, respectively. The feature map is pooled by maximum pooling and L2 norm pooling to obtain two H×β×1 feature maps, and then the two feature maps containing cigarettes are concatenated by the feature map fusion (Concat) operation to obtain a H×W×2 feature map, which is then converted into a H×β×1 feature map containing cigarettes through a 7×7 convolution, and then activated by a sigmoid function to obtain the spatial attention weight F of the feature map F containing cigarettes. s (between 0 and 1), the size is H×β×1. The calculation formula is as follows:
[0085] F s =σ(Cov 7×7 ([L2Pool(F)+MaxPool(F)])) (3)
[0086] Where σ is the Sigmoid activation function, Cov 7×7 is a 7×7 convolution operation, L2Pool is L2 norm pooling, MaxPool is maximum pooling, F is the input feature map containing cigarettes, F s is the spatial attention weight of the cigarette feature map F; the PSAM structure is as follows Figure 7 shown.
[0087] Step 3.2.3: Compare the channel attention weight Fc of the feature map F containing cigarettes obtained by PCAM with the spatial attention weight Fc of the feature map F containing cigarettes obtained by PSAM s After a Concat, feature fusion is performed to obtain the spatial attention weight F represented by the fusion channel. cs , the size is (H×W+C)×1×1. Then, after an MLP layer, the spatial attention weights of the two fused channels are obtained. and Then apply the sigmoid function to fuse the spatial attention weights represented by the channel and activation;
[0088] Step 3.2.4: Finally, the spatial attention weights represented by the fusion channel and Multiply them with the input feature map F containing cigarettes to obtain two spatial attention-enhanced feature maps represented by the fusion channel, and then add the two feature maps to obtain the final feature-enhanced feature map F PCAK
[0089] It should be noted that L2 norm pooling selects the L2 norm within the pooling window as output.
[0090] Embodiment: Assume that the dimension of the feature map F containing cigarettes input to PCAK is 20×20×1024 (height×width×channel), input it to the PCAM module, perform global L2 norm pooling (L2Pool) and global maximum pooling (MaxPool) on the feature map A containing cigarettes to obtain two 1×1×1024 feature maps containing cigarettes, and then process the two feature maps containing cigarettes obtained by average pooling and maximum pooling using a shared fully connected layer (SharedMLP), and then add the results obtained by the shared fully connected layer and activate them using the Sigmoid activation function to obtain the channel attention weight F of the input feature map F containing cigarettes c (between 0 and 1), with a size of 1×1×1024. The feature map F containing cigarettes is then input into the PSAM module, which is pooled by maximum pooling and L2 norm pooling to obtain two 20×20×1 feature maps C and D. The two feature maps C and D containing cigarettes are then concatenated by the feature map fusion (Concat) operation to obtain the H×W×2 feature map E. The feature map E is then convolved by a 7×7 operation to obtain the feature map G with half the channel. The feature map F containing cigarettes is then activated by a sigmoid function to obtain the spatial attention weight F. s (between 0 and 1), with a size of 20×20×1. Then the channel attention weight F of the feature map F containing cigarettes obtained by PCAM is c The spatial attention weight F of the feature map F containing cigarettes obtained by PSAM s After a Concat, feature fusion is performed to obtain the spatial attention weight F represented by the fusion channel. cs (Size is 1064×1×1). Then, after passing through an MLP layer, the spatial attention weights of the two fused channels are obtained. (size 20×20×1) and (size is 1×1×1024), and then the sigmoid function is applied to the spatial attention weights represented by the fusion channel and Activation. Finally, the spatial attention weight represented by the fusion channel and Multiply them with the input feature map F containing cigarettes to obtain two spatial attention-enhanced feature maps represented by the fusion channel, and then add the two feature maps to obtain the final feature-enhanced feature map F PCAK (Size is 20×20×1024)
[0091] Step 3.3: Reduce the redundant features of the feature graph containing cigarettes. Use the SMConv module to reduce the redundant features of the feature graph containing cigarettes. In the SMConv module, for the input feature graph containing cigarettes F∈Rc×h×w It is divided into two paths, the upper path is input to the spatial reconstruction unit (SRU) to obtain the spatially refined feature map F containing cigarettes 1 , the next path is input to the channel reconstruction unit (CRU) to obtain the channel refinement containing the cigarette feature map F 2 , and then refine the space to include the cigarette feature map F 1 and channel refinement contains the feature map F of cigarettes 2 The feature fusion (Concat) operation is used for splicing, and then the spatial channel refined fusion feature maps P and Q containing cigarettes are obtained through the multi-layer perceptron layer (MLP). Finally, the spatial channel refined fusion feature maps P and Q containing cigarettes are added together to obtain the spatial channel refined fusion feature map K containing cigarettes; the SMConv module structure is as follows: Figure 8 shown.
[0092] Step 3.3.1: In the spatial reconstruction unit, the input feature map F containing cigarettes is first normalized by subtracting the mean μ and dividing it by the standard deviation σ, and then the trainable parameter γ∈R in the normalization (GN) layer is used. c To measure the variance of spatial pixels for each batch and channel, normalize the correlation weight P γ ∈R c From formula (4),
[0093]
[0094] Step 3.3.2: Then use the Sigmoid function to convert P γ The weight value of the re-weighted feature map containing cigarettes is mapped to the range (0, 1) and gated by a threshold, setting the threshold weight to 1, and obtaining the information weight P 1 , set it to 0, and get the non-information weight P 2 ; Finally, the input feature map F containing cigarettes is multiplied by P 1 and P 2 Get two weighted features: the feature map containing cigarettes with large amount of information and the feature map containing cigarettes with less information
[0095] Step 3.3.3: Then, the feature map containing cigarettes and To perform the reconstruction operation, first convert the feature map containing cigarettes Split into two channels with a feature map of 1 / 2 of the original channel and Then the feature map containing cigarettes Split into two channels with a feature map of 1 / 2 of the original channel and Then cross-re structure, that is, and Perform feature fusion to obtain F P1 ;Bundle and Perform feature fusion to obtain F P2 , and finally the cross-reconstructed feature map containing cigarettes and Add together to obtain the spatially refined feature map F containing cigarettes 1 The calculation process is shown in formula (5).
[0096]
[0097] in, is element-wise multiplication; is the sum of elements; ∪ is feature fusion (Concat). After applying MSU to the intermediate input feature map F containing cigarettes, not only the features with large information content are separated from the features with small information content, but also they are reconstructed to enhance the representative features and suppress the redundant features in the spatial dimension. The MSU structure is as follows Fig. 9 shown.
[0098] Step 3.3.4: In the channel reconstruction unit (MCU), for the input feature map F∈R containing cigarettes c×h×w First, the channel of F is evenly divided into two parts, each with 1 / 2C. Then, 1×1 convolution is used to compress the channel containing the feature map of cigarettes to improve its computational efficiency. up and F low . up The efficient convolution operations GWC and PWC are used respectively and the results are added together to obtain the feature map M containing the cigarette, so as to extract high-level representative information and reduce the computational cost; low Use efficient convolution operation PWC, and then combine the result with F low Take the union to get the feature map N containing cigarettes, and then use the simplified SKNet method to adaptively merge the feature maps M and N containing cigarettes to get the channel-refined feature map F containing cigarettes 2 MCU structure is as follows Fig.10 shown.
[0099] It should be noted that the reconstruction operation is to add features with more information and features with less information to generate features with more information and save space.
[0100] Further explanation: SKNet (Selective Kernel Network) is a deep neural network architecture for image classification and target detection tasks. Its core innovation is the introduction of selective multi-scale convolution kernels (SelectiveKernel) and a novel attention mechanism, which improves the ability of feature extraction without increasing the complexity of the network. SKNet is designed to solve the problem of multi-scale information fusion, so that the network can adapt to features of different scales. Specifically, it first uses a global average pooling operation on the input feature maps M and N to combine the global spatial information and channel statistics to obtain the pooled M 1 and N 1 Then for M 1 and N 1 Do Softmax to get the feature weight vector β 1 and β 2 , and finally use the feature weight vector to get the output F 2 =β1×M 1 +β2×N 1 , F 2 That is the characteristic of channel extraction.
[0101] Step 3.4: For the input image F containing cigarettes, first perform two Conv operations to downsample it to obtain the compressed feature map F 1 ; Then apply C3ECA module to extract features to obtain feature map F 2 ; Then perform a Conv operation on the obtained feature map and apply the C3ECA module to extract features to obtain the feature map F 3 ; Then the feature map F 3 Input to the PCAK module to enhance its features and obtain the feature map F 4 ; Then the feature map F 4 Input to the SMConv module to reduce the redundant features in the feature map to obtain the feature map F 5 ; For the feature map F 5 Apply the Upsample operation to upsample and obtain the feature map F 6 ; The feature map F 2 With the feature map F 6 Perform a feature fusion operation (Concat) to obtain the feature map F 7 ; Then F 7 Input to the SMConv module to reduce the redundant features in the feature map to obtain the feature map F 8 ; Finally, F 8 Input it into Conv2d for a two-dimensional convolution operation to obtain the final smoking behavior detection result.
[0102] The present invention is not limited to the above-mentioned embodiments. Anyone should be aware that any structural changes made under the enlightenment of the present invention, and any technical solutions that are the same or similar to the present invention, fall within the protection scope of the present invention. The technology, shape, and structural parts not described in detail in the present invention are all well-known technologies.
Claims
1. A smoking behavior detection method based on SDVGNet network, characterized in that: The following steps are involved: Step 1: Build an image dataset containing cigarettes, collect images containing cigarettes in various scenes, and use LabelImg annotation software to make the collected cigarette images into a dataset in PASCAL VOC format; Step 2: Data preprocessing and data set division: annotate the image data containing cigarettes, label them as smoking and non-smoking, and then divide the annotated data into training set, validation set and test set; Step 3: Design the SDVGNet network. In the SDVGNet network, for the input picture containing cigarettes, convolution operation and feature extraction operation based on attention mechanism are first used to extract features to obtain feature maps containing cigarettes. Then, upsampling and spatial channel refinement fusion operations are used to perform multi-scale feature fusion and context enhancement operations on the feature maps containing cigarettes, and these features are passed to the output layer for final regression prediction. Step 4: Network training and verification. Based on the SDVGNet network designed in Step 3, the parameters of each layer are trained and updated. All neural network parameters are initialized first, and the cross entropy loss function is used to measure the difference between the model prediction results and the true labels. Then the test set obtained in Step 2 is input into the SDVGNet network. The performance of the SDVGNet network in the smoking behavior detection task is evaluated by the accuracy of the SDVGNet network in recognizing smoking behaviors in the test set images. Finally, the hyperparameters and structure of the network are adjusted according to the verification results. Step 5: Apply to the smoking behavior detection task and apply the trained SDVGNet network to the smoking behavior detection task.
2. The smoking behavior detection method based on SDVGNet network according to claim 1, characterized in that: The SDVGNet network consists of the C3MRA module, the PCAK module, and the SMConv module. The PCAK module includes the channel attention module PCAM and the spatial attention module PSAM.
3. The smoking behavior detection method based on SDVGNet network according to claim 2 is characterized in that: The following steps are performed when designing a SDVGNet network: Step 3.1: Capture the local cross-channel information interaction of the feature map containing cigarettes. Input the feature map containing cigarettes into the C3MRA module, and then divide it into two paths. The lower path passes through a Conv for a 1×1 convolution operation, and the upper path passes through a Conv for a 1×1 convolution operation and a Bottleneck to increase the receptive field and reduce the amount of calculation. Then the two results pass through a Concat, and finally pass through a Conv for a 1×1 convolution operation and an MRA to capture the local cross-channel information interaction; Step 3.2: Feature enhancement of the feature map containing cigarettes. The PCAK module uses the attention mechanism to enhance the feature map containing cigarettes. The channel attention module PCAM and the spatial attention module PSAM are connected in parallel to perform attention mechanisms in space and channels. The channel attention weight and spatial attention weight are inferred along the two dimensions of channel and space respectively. Then, the two attention weights are feature fused (Concat) to obtain the spatial attention weight represented by the fused channel. The spatial attention weights represented by the two fused channels are obtained through a multi-layer perceptron and activated by a sigmoid function. Finally, the spatial attention weights represented by the two fused channels are multiplied by the input feature map containing cigarettes respectively, and the results are added to obtain the feature-enhanced feature map containing cigarettes. Step 3.3: Reduce the redundant features of the feature graph containing cigarettes. Use the SMConv module to reduce the redundant features of the feature graph containing cigarettes. In the SMConv module, for the input feature graph containing cigarettes F∈R c×h×w It is divided into two paths, the upper path is input to the spatial reconstruction unit (SRU) to obtain the spatially refined feature map F containing cigarettes 1 , the next path is input to the channel reconstruction unit (CRU) to obtain the channel refinement containing the cigarette feature map F 2 , and then refine the space to include the cigarette feature map F 1 and channel refinement contains the feature map F of cigarettes 2 Use the feature fusion (Concat) operation for splicing, and then pass through the multi-layer perceptron layer (MLP) to obtain the spatial channel refined fusion feature maps P and Q containing cigarettes. Finally, add the spatial channel refined fusion feature maps P and Q containing cigarettes to obtain the spatial channel refined fusion feature map K containing cigarettes. Step 3.4: For the input image F containing cigarettes, first perform two Conv operations to downsample it to obtain the compressed feature map F 1 ; Then apply C3ECA module to extract features to obtain feature map F 2 ; Then perform a Conv operation on the obtained feature map and apply the C3ECA module to extract features to obtain feature map F3; then input feature map F3 into the PCAK module to enhance its features to obtain feature map F4; then input feature map F4 into the SMConv module to reduce the redundant features in the feature map to obtain feature map F5; apply the Upsample operation to upsample feature map F5 to obtain feature map F6; 2 A feature fusion operation (Concat) is performed with feature map F6 to obtain feature map F7; F7 is then input into the SMConv module to reduce the redundant features in the feature map to obtain feature map F8; finally, F8 is input into Conv2d for a two-dimensional convolution operation to obtain the final smoking behavior detection result.
4. The smoking behavior detection method based on SDVGNet network according to claim 3 is characterized in that: Step 3.1: The steps to capture the local cross-channel information interaction of the feature graph containing cigarettes are: Step 3.1.1: Perform a global maximum pooling operation on the input feature map containing cigarettes, and then perform a one-dimensional convolution operation with a convolution kernel size of M. After the ReLU activation function, the weight ω of each channel is obtained, as shown in the formula below: ω=R(C1D M (x)) (1) Where ω is the weight of the channel; R is the ReLU activation function; C1D represents one-dimensional convolution, M is the size of the convolution kernel, x is the input feature map containing cigarettes, and finally the weight is multiplied by the corresponding element of the original input feature map containing cigarettes to obtain the final output feature map containing cigarettes.
5. The smoking behavior detection method based on SDVGNet network according to claim 3 is characterized in that: Step 3.2 includes the steps of enhancing the feature map of cigarettes: Step 3.2.1: The input of PCAM is a feature map F containing cigarettes, and the dimension is set to H×W×C; where H, W, and C are the height, width, and number of channels of the feature map, respectively. The input feature map containing cigarettes is subjected to global L2 norm pooling (L2Pool) and global maximum pooling (MaxPool) to obtain two 1×1×C feature maps containing cigarettes. The two feature maps containing cigarettes obtained by average pooling and maximum pooling are then processed using a shared fully connected layer (SharedMLP). The results obtained by the shared fully connected layer are then added and activated using the Sigmoid activation function to obtain the channel attention weight F of the input feature map F containing cigarettes. c (between 0 and 1), with a size of 1×1×C. Since each channel of the feature layer containing cigarettes extracts a certain level of feature information, PPCAM focuses on what level of feature information in the image is more important. In order to effectively calculate channel attention, the spatial dimension method of compressing the input feature map is adopted, and its calculation formula is as follows: F c =σ(MLP(L2Pool(F))+MLP(MaxPool(F))) (2) In the formula, σ is the Sigmoid activation function, MLP is the fully connected layer, L2Pool is the L2 norm pooling, MaxPool is the maximum pooling, F is the input feature map containing cigarettes, and F c is the channel attention weight of the feature map F containing cigarettes. Step 3.2.2: The input of PSAM is the feature map F containing cigarettes, and the dimension is set to H×W×C; where H, W, and C are the height, width, and number of channels of the feature map, respectively. The feature map is pooled by maximum pooling and L2 norm pooling to obtain two H×W×1 feature maps, and then the two feature maps containing cigarettes are concatenated by the feature map fusion (Concat) operation to obtain a H×W×2 feature map, which is then converted into a H×W×1 feature map containing cigarettes through a 7×7 convolution, and then activated by a sigmoid function to obtain the spatial attention weight F of the feature map F containing cigarettes. s (between 0 and 1), the size is H×W×1. The calculation formula is as follows: F s =σ(Cov 7×7 ([L2Pool(F)+MaxPool(F)])) (3) Where σ is the Sigmoid activation function, Cov 7×7 is a 7×7 convolution operation, L2Pool is L2 norm pooling, MaxPool is maximum pooling, F is the input feature map containing cigarettes, F s is the spatial attention weight of the feature map F of the cigarette; Step 3.2.3: Add the channel attention weight F of the feature map F containing cigarettes obtained by PCAM c The spatial attention weight F of the feature map F containing cigarettes obtained by PSAM s After a Concat, feature fusion is performed to obtain the spatial attention weight F represented by the fusion channel. cs , the size is (H×W+C)×1×1. Then, after an MLP layer, the spatial attention weights of the two fused channels are obtained. and Then apply the sigmoid function to fuse the spatial attention weights represented by the channel and activation; Step 3.2.4: Finally, the spatial attention weights represented by the fusion channel and Multiply them with the input feature map F containing cigarettes to obtain two spatial attention-enhanced feature maps represented by the fusion channel, and then add the two feature maps to obtain the final feature-enhanced feature map F PCAK .
6. The smoking behavior detection method based on SDVGNet network according to claim 3 is characterized in that: The steps to reduce the redundant features of the feature graph containing cigarettes in Step 3.3 are: Step 3.3.1: In the spatial reconstruction unit, the input feature map F containing cigarettes is first normalized by subtracting the mean (and dividing by the standard deviation (), and then using the trainable parameter γ∈R in the normalization (GN) layer c To measure the variance of spatial pixels for each batch and channel, normalize the correlation weight P γ ∈R c From formula (4), Step 3.3.2: Then use the Sigmoid function to convert P γ The weight value of the re-weighted feature map containing cigarettes is mapped to the range (0, 1) and gated by the threshold. The threshold weight is set to 1 to obtain the informative weight P1, and it is set to 0 to obtain the non-informative weight P2. Finally, the input feature map F containing cigarettes is multiplied by P1 and P2 respectively to obtain two weighted features: the feature map containing cigarettes with large information content and the feature map containing cigarettes with less information Step 3.3.3: Then, the feature map containing cigarettes and To perform the reconstruction operation, first convert the feature map containing cigarettes Split into two channels with a feature map of 1 / 2 of the original channel and Then the feature map containing cigarettes Split into two channels with a feature map of 1 / 2 of the original channel and Then cross-re structure, that is, and Perform feature fusion to obtain F P1 ;Bundle and Perform feature fusion to obtain F P2 , and finally the cross-reconstructed feature map containing cigarettes and Add together to obtain the spatially refined feature map F containing cigarettes 1 The calculation process is shown in formula (5). in, is element-wise multiplication; is the sum of elements; ∪ is feature fusion (Concat). After applying MSU to the intermediate input feature map F containing cigarettes, not only the features with large information content are separated from the features with small information content, but also they are reconstructed to enhance the representative features and suppress the redundant features in the spatial dimension. Step 3.3.4: In the channel reconstruction unit (MCU), for the input feature map F∈R containing cigarettes c×h×w First, the channel of F is evenly divided into two parts, each with 1 / 2C. Then, 1×1 convolution is used to compress the channel containing the feature map of cigarettes to improve its computational efficiency. up and F low . up The efficient convolution operations GWC and PWC are used respectively and the results are added together to obtain the feature map M containing the cigarette, so as to extract high-level representative information and reduce the computational cost; low Use efficient convolution operation PWC, and then combine the result with F low Take the union to get the feature map N containing cigarettes, and then use the simplified SKNet method to adaptively merge the feature maps M and N containing cigarettes to get the channel-refined feature map F containing cigarettes 2 .
Citation Information
Patent Citations
Oil field on-site micro-target detection method and system based on deep learning
CN114170548A
Light smoking detection method and system
CN115240118A
Model training method, smoking behavior detection method and model training device
CN117423163A
Method and apparatus for segmenting sky area, and convolutional neural network
US20200034648A1
Cited By
CNN (Convolutional Neural Network) smoke and fire detection method and system based on double attention mechanisms
CN120088740A
A CNN firework detection method and system based on a double attention mechanism
CN120088740B
