Personnel violation behavior detection method based on multi-scale channel and context guide aggregation
By improving the YOLOv8 model and introducing multi-scale feature fusion and context-guided aggregation methods, the problems of small target identification and weak features in chemical plant areas are solved, achieving efficient and accurate detection of violations, which is suitable for safety monitoring in chemical plants.
Patent Information
- Application Number
- CN202510827638.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-11-14
AI Technical Summary
The existing YOLOv8 model suffers from low detection accuracy, high computational complexity, and long training time in identifying small targets in chemical plant areas and in dealing with weak features and semantic ambiguity. It is also difficult to effectively identify violations such as smoking and making phone calls.
A method for detecting personnel violations based on multi-scale channels and context-guided aggregation is adopted. By improving the YOLOv8 model, a multi-scale feature fusion module RMCSM, a context-guided aggregation module CGFM, a custom detection head DAFAHead, and an inter-frame history interaction coding module HTIE are introduced to enhance the model's ability to perceive small targets and express features.
It significantly reduces model and computational complexity, improves the accuracy and training speed of small target detection, and enhances the ability to identify violations in complex chemical plant scenarios, thus possessing strong practical value.
Smart Images

Figure CN120954083A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, specifically to a method for detecting personnel violations based on multi-scale channels and context-guided aggregation. Background Technology
[0002] With the continuous improvement of industrial automation and intelligence, machine vision-based behavior recognition technology is being increasingly widely used in industrial safety monitoring. Especially in chemical plants, where high-risk working environments exist (such as flammable, explosive, and highly corrosive materials), real-time monitoring of personnel behavior and timely detection and identification of violations are crucial for ensuring personnel safety and standardizing production management. The current mainstream target detection algorithm, YOLOv8, already possesses strong detection performance in general scenarios.
[0003] However, when facing the detection tasks of specific violations such as smoking and making phone calls in practical applications in chemical plant areas, the following key challenges remain: ① Difficulty in identifying small targets: Cigarettes are small in size and occupy a very small proportion in the image, and are easily interfered with by background noise, making it difficult for detection models to effectively focus on their features. Similarly, in phone calls, the mobile phone, as a small target, is not very salient in the monitoring image and is easily missed or falsely detected. ② Weak features and semantic ambiguity: In the complex background of a factory area, violations by personnel are often accompanied by occlusion, changes in posture, etc., causing the target features to exhibit significant weak semantic features, which is not conducive to the model extracting key behavioral information. Summary of the Invention
[0004] To address the technical challenges of YOLOv8's object detection model training using weights, such as large model parameters, high computational complexity, long training time, and low accuracy in recognizing small targets, this technical solution provides a method for detecting personnel violations based on multi-scale channels and context-guided aggregation. Using the YOLOv8 network model as a baseline, an improved MCSM-YOLO model is derived. The improved detection model has a lighter backbone network, lower computational complexity, and stronger feature representation capabilities. It can quickly and effectively capture and identify small targets in images, making it suitable for detecting personnel violations in chemical plants, thus effectively solving the aforementioned problems.
[0005] This invention is achieved through the following technical solution:
[0006] A method for detecting personnel violations based on multi-scale channels and context-guided aggregation, comprising the following steps:
[0007] Step 1: Using a self-built dataset of violations by personnel in chemical plants, divide the dataset into a training set, a validation set, and a test set;
[0008] Step 2: Improve YOLOv8 and build a new MCSM-YOLO model; the specific steps are as follows:
[0009] Step 2.1: Based on the YOLOv8 backbone structure, a custom multi-scale feature fusion module RMCSM is introduced. Through channel separation, multi-scale convolution and feature fusion strategies, it can effectively capture spatial context information under different receptive fields, enhance the model's ability to perceive multi-scale targets, and improve the detection accuracy of small targets.
[0010] Step 2.2: Add a context-guided aggregation module (CGFM) to the neck structure to achieve dynamic information fusion across channels, reduce information loss between channels, achieve efficient multi-scale information extraction through hierarchical convolutional structures, and combine original features and attention mechanism-extracted features by combining spatial channel attention and multilayer perceptrons to enhance feature expression capabilities.
[0011] Step 2.3: In the detection head part, the original detection head is replaced with a custom DAFAHead detection head; the DAFAHead detection head adopts a dual-branch attention structure and channel dynamic matching mechanism CDMM, which effectively improves the model's ability to identify small targets and weak feature violations through the combination of global semantic modeling and local detail focusing.
[0012] Step 2.4: In the backbone network input stage, the Inter-Frame History Interaction Coding (HTIE) module is introduced to realize the structural modeling of the time series context and enhance the ability to judge continuous violations.
[0013] Step 3: Train the improved MCSM-YOLO model using the training set from Step 1, and evaluate the MCSM-YOLO model based on the training results.
[0014] Step 4: Use the trained improved model to test the test set from Step 1 and output the test results.
[0015] Furthermore, the specific operation method of step 2.1 is as follows:
[0016] Step 2.1.1: The input feature map is first processed through a 1×1 convolution operation to integrate information between channels and enhance feature sharing capabilities;
[0017] Step 2.1.2: The feature map is divided into two parts along the channel dimension in a 1:2 ratio by the Split operation. One part is directly used for subsequent splicing output, and the other part is sent to the Multi_CSM module.
[0018] Step 2.1.3: In the Multi_CSM module, the input is first convolved by 3×3 to form basic spatial features, and then feature decomposition is performed to generate three branch structures;
[0019] Step 2.1.4: The main branch retains the original features for subsequent residual fusion, and the remaining branches stack two or three layers of 3×3 convolutions to construct equivalent 5×5 and 7×7 receptive fields and establish multi-scale feature representations;
[0020] Step 2.1.5: The output features of the three branches are spliced together along the channel dimension to fuse information at different scales extracted from the 3×3, 5×5 and 7×7 receptive fields;
[0021] Step 2.1.6: The concatenated feature maps are recalibrated through 1×1 convolution to achieve dimensionality compression and feature fusion;
[0022] Step 2.1.7: Use a skip connection mechanism to add the residuals of the initial features and deep features to avoid gradient vanishing or exploding and maintain network stability;
[0023] Step 2.1.8: After multi-scale feature map fusion, output a highly expressive feature map to the downstream module of the backbone network for target detection.
[0024] Furthermore, the computational complexity of the 1×1 convolution operation described in step 2.1.1 is:
[0025] FLOPS = C out ×H out ×W out ×(C in ×K×K),
[0026] Among them, C in For the number of input channels, C out H represents the number of output channels. out W out These represent the height and width of the output feature map, respectively, and K is the kernel size.
[0027] The output feature map is calculated using the following formula:
[0028]
[0029] Among them, H in P is the height of the input feature map, S is the padding size, and S is the stride.
[0030] Internally, the module generates three branches through feature decomposition, stacking 1, 2, and 3 3×3 convolutional layers respectively to obtain feature maps with equivalent receptive fields of 3×3, 5×5, and 7×7, denoted as F1, F2, and F3 respectively. The feature maps output from the three branches are concatenated along the channel dimension, and the concatenated features satisfy the formula:
[0031]
[0032] Among them, F concat This represents the result of concatenating the feature maps output from the three branches along the channel dimension. Concat indicates the operation of concatenating feature maps F1, F2, and F3 along the channel dimension. It is a shallow, small receptive field. It is a medium-sensory field in the middle layer. For a deep, large receptive field, C1, C2, and C3 represent the number of channels output by the three multi-scale branches, and H and W represent the spatial dimensions of the feature map, where H is the height and W is the width.
[0033] After the concatenated feature maps are recalibrated via 1×1 convolution, a residual connection mechanism is introduced to fuse the initial decomposed features and deep features. The residual connection is expressed as follows:
[0034] y=F(x,{W i})+x ← ,
[0035] Where x is the input branch feature, F(x,{W i}) represents the features after convolution transformation, and y represents the final fusion result.
[0036] Furthermore, the specific operation method of the context-guided aggregation module CGFM described in step 2.2 is as follows:
[0037] Step 2.2.1: The input feature map P3 is first adjusted by a 1×1 convolution operation to make its channel number consistent with that of the other input feature map P4;
[0038] Step 2.2.2: Concatenate the adjusted feature map with P4 along the channel dimension to form a fused feature;
[0039] Step 2.2.3: The concatenated feature map is input into the SE channel attention module. The module first processes the fused feature map U∈R. H×W×C The space compression operation is performed, and the calculation method is as follows:
[0040]
[0041] Among them, F sq Let U represent the Squeeze operation function, which performs global average pooling on the spatial dimension. U is the input fused feature map, and the information in the H×W spatial dimension is compressed into a single scalar for each channel. c (i,j) represents the pixel value of the c-th channel in the U feature map at position (i,j), Z∈R 1×1×C Indicates the channel descriptor;
[0042] Step 2.2.4: Input the descriptor Z into two fully connected layers to form the activation function, and obtain the channel attention weights S∈R. 1×1×C The excitation function is:
[0043] S=sigmoid(FC2(ReLU(FC1(Z)))),
[0044] Where Z∈R 1×1×C The channel descriptor is obtained from global average pooling, FC1 is the first fully connected layer, FC2 is the second fully connected layer, and S∈R. 1×1×C Channel attention weights are used to adjust the fused feature map U channel by channel;
[0045] Step 2.2.5: Assign the weight S∈R 1×1×C The channel calibration operation is performed by multiplying the original fused feature map U channel by channel, which is expressed as: Y = S⊙U, where ⊙ represents element-wise product and Y is the output feature map;
[0046] Step 2.2.6: Based on the source of the original inputs P3 and P4, split the attention weights into W3 and W4, and multiply them by P3 and P4 channel by channel to obtain the weighted features;
[0047] Step 2.2.7: Concatenate the weighted P3 and P4 to obtain the final fused feature map, which is used as the output of the context-guided aggregation module.
[0048] Furthermore, the DAFAHead detection head described in step 2.3 includes three main parts, which are modules for processing global semantics, local details, and channel dynamic matching, respectively. Each module models and enhances the input features through different paths, fuses the global context information extracted by the Transformer structure with the local detail features extracted by the convolutional structure, and performs adaptive fusion through the channel dynamic matching mechanism, finally outputting an optimized detection feature map.
[0049] Furthermore, the specific operation steps of the DAFAHead detection head described in step 2.3 include:
[0050] Step 2.3.1: Process global semantic features:
[0051] Step 2.3.1.1: The input feature map is first compressed in dimension and spatially integrated by a convolutional encoder;
[0052] Step 2.3.1.2: Input the compressed feature map into the multi-layer Transformer module to extract global context information under multi-head self-attention;
[0053] Step 2.3.1.3: Input the global context features into the cross-task attention mechanism to generate specific response weights based on the detection task, highlighting the target region;
[0054] Step 2.3.1.4: Output and retain global features for fusion with local paths;
[0055] Step 2.3.2: Processing local detailed features:
[0056] Step 2.3.2.1: Fine-grained edge and texture information is extracted from the input feature map using a lightweight convolution stacking module;
[0057] Step 2.3.2.2: After convolution, the function is activated and normalized to form a robust local feature representation;
[0058] Step 2.3.2.3: Output and preserve detailed features for fusion with the global path;
[0059] Step 2.3.3: Perform dynamic matching and fusion of channels:
[0060] Step 2.3.3.1: Concatenate the feature maps of the global path and the local path along the channel dimension;
[0061] Step 2.3.3.2: The CDMM (Dynamic Matching Module) for splicing feature maps into input channels generates fusion scaling coefficients through a fully connected layer;
[0062] Step 2.3.3.3: Perform weighted fusion of the two features according to the scaling factor to output the final detection feature map.
[0063] Furthermore, the encoding module HTIE described in step 2.4 includes an intra-frame feature compression module, a temporal interactive attention module, and a history memory update mechanism, specifically operating as follows:
[0064] Step 2.4.1: The operation steps of the intra-frame feature compression module include:
[0065] Step 2.4.1.1: Input the video frame sequence sequentially into the shared convolutional encoder to extract primary spatial features;
[0066] Step 2.4.1.2: Through size alignment and channel unification operations, the features of multiple frames are standardized into a uniform shape to facilitate subsequent fusion processing;
[0067] Step 2.4.2: The operation steps of the temporal interaction attention module include:
[0068] Step 2.4.2.1: Stack the standardized feature maps from multiple frames into a three-dimensional tensor in the time dimension;
[0069] Step 2.4.2.2: Calculate the contextual dependencies between frames using a self-attention mechanism to generate a temporal attention graph;
[0070] Step 2.4.2.3: Multiply the attention map element-wise with the original frame feature map to enhance the temporal correlation representation;
[0071] Step 2.4.3: The operational steps of the historical memory update mechanism include:
[0072] Step 2.4.3.1: Use a gating unit to model the feature differences between historical frames and the current frame to generate a memory vector;
[0073] Step 2.4.3.2: The memory vector guides the feature update of the current frame, so that the model retains its perception of previous actions;
[0074] Step 2.4.3.3: Use the final fused feature map as one of the inputs to the backbone network to improve the ability to detect continuous violations.
[0075] Furthermore, the self-built dataset mentioned in step 1 contains 5312 images, which are divided into training set, validation set and test set in a ratio of 8:1:1; the images include two categories of violations: chemical plant personnel smoking and making phone calls.
[0076] Beneficial effects
[0077] The present invention proposes a method for detecting personnel violations based on multi-scale channels and context-guided aggregation, which has the following advantages compared with existing technologies:
[0078] (1) This invention effectively reduces model complexity while maintaining detection accuracy, exhibiting significant advantages of lightweight structure and superior performance. By introducing the Residual Multi-Scale Channel Separation (RMCSM) module, the model's ability to perceive targets of different scales, especially small targets, is enhanced. The Context-Guided Aggregation (CGFM) module achieves dynamic fusion of cross-channel information, improving the integrity and robustness of feature representation. The custom DAFAHead detection head employs a dual-branch attention structure and a channel dynamic matching mechanism, strengthening the model's detection accuracy for weak-feature behaviors such as smoking and making phone calls. The introduction of the Inter-Frame History Interaction Coding (HTIE) module improves the temporal context modeling capability and enhances the model's ability to identify continuous violations. The overall improved MCSM-YOLO model not only enhances the detection performance for small targets but also boasts faster training speed and inference efficiency, better adapting to complex, real-time safety monitoring scenarios in chemical enterprises, and possessing strong practical value and application prospects. Attached Figure Description
[0079] Figure 1This is a schematic diagram of the overall process of the present invention.
[0080] Figure 2 This is a network structure diagram of MCSM-YOLO in this invention.
[0081] Figure 3 This is a network structure diagram of the RMCSM module in this invention.
[0082] Figure 4 This is a network structure diagram of the CGFM module in this invention.
[0083] Figure 5 This is a structural diagram of the DAFAHead detection head in this invention.
[0084] Figure 6 This is a structural diagram of the HTIE module in this invention.
[0085] Figure 7 This is a diagram showing the training results of MCSM-YOLO in this invention. Detailed Implementation
[0086] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. The described embodiments are merely some embodiments of the present invention, and not all embodiments. Various modifications and improvements made to the technical solutions of the present invention by those skilled in the art without departing from the design concept of the present invention should fall within the protection scope of the present invention.
[0087] Example 1:
[0088] like Figure 1 As shown, a method for detecting personnel violations based on multi-scale channel and context-guided aggregation includes the following steps:
[0089] Step 1: Use a self-built dataset of violations by chemical plant personnel, and divide the dataset into training set, validation set and test set; the self-built dataset contains 5312 images, which are divided into training set, validation set and test set in a ratio of 8:1:1; the images contain two violation categories of chemical plant personnel: smoking and making phone calls.
[0090] Step 2: Improve YOLOv8 and construct a new MCSM-YOLO model; the modified YOLOv8 model backbone network is as follows: Figure 2 As shown, a new network consists of a single layer of Conv, RMCSM, and CGFM modules, with the addition of an inter-frame history interactive coding module (HTIE) in the input stage. Finally, the detection head is replaced with a custom DAFAHead detection head. The specific operation method for improving YOLOv8 is as follows:
[0091] Step 2.1: Based on the YOLOv8 backbone structure, a custom multi-scale feature fusion module RMCSM is introduced. The structure of the RMCSM module is as follows: Figure 3 As shown, RMCSM, through channel separation, multi-scale convolution, and feature fusion strategies, can effectively capture spatial context information under different receptive fields, enhance the model's ability to perceive multi-scale targets, and improve the detection accuracy of small targets; the specific operation method is as follows:
[0092] Step 2.1.1: The input feature map is first processed through a 1×1 convolution operation to integrate information between channels and enhance feature sharing capabilities;
[0093] Step 2.1.2: The feature map is divided into two parts along the channel dimension in a 1:2 ratio by the Split operation. One part is directly used for subsequent splicing output, and the other part is sent to the Multi_CSM module.
[0094] Step 2.1.3: In the Multi_CSM module, the input is first convolved by 3×3 to form basic spatial features, and then feature decomposition is performed to generate three branch structures;
[0095] Step 2.1.4: The main branch retains the original features for subsequent residual fusion, and the remaining branches stack two or three layers of 3×3 convolutions to construct equivalent 5×5 and 7×7 receptive fields and establish multi-scale feature representations;
[0096] Step 2.1.5: The output features of the three branches are spliced together along the channel dimension to fuse information at different scales extracted from the 3×3, 5×5 and 7×7 receptive fields;
[0097] Step 2.1.6: The concatenated feature maps are recalibrated through 1×1 convolution to achieve dimensionality compression and feature fusion;
[0098] Step 2.1.7: Use a skip connection mechanism to add the residuals of the initial features and deep features to avoid gradient vanishing or exploding and maintain network stability;
[0099] Step 2.1.8: After multi-scale feature map fusion, output a highly expressive feature map to the downstream module of the backbone network for target detection.
[0100] The computational cost of convolution is:
[0101] FLOPS = C out ×H out ×W out ×(C in ×K×K),
[0102] Among them, C in For the number of input channels, C out H represents the number of output channels.out W out These represent the height and width of the output feature map, respectively, and K is the kernel size.
[0103] The output feature map is calculated using the following formula:
[0104]
[0105] Among them, H in P is the height of the input feature map, S is the padding size, and S is the stride.
[0106] Internally, the module generates three branches through feature decomposition, stacking 1, 2, and 3 3×3 convolutional layers respectively to obtain feature maps with equivalent receptive fields of 3×3, 5×5, and 7×7, denoted as F1, F2, and F3 respectively. The feature maps output from the three branches are concatenated along the channel dimension, and the concatenated features satisfy the formula:
[0107]
[0108] Among them, F concat This represents the result of concatenating the feature maps output from the three branches along the channel dimension. Concat indicates the operation of concatenating feature maps F1, F2, and F3 along the channel dimension. It is a shallow, small receptive field. It is a medium-sensory field in the middle layer. For a deep, large receptive field, C1, C2, and C3 represent the number of channels output by the three multi-scale branches, and H and W represent the spatial dimensions of the feature map, where H is the height and W is the width.
[0109] After the concatenated feature maps are recalibrated via 1×1 convolution, a residual connection mechanism is introduced to fuse the initial decomposed features and deep features. The residual connection is expressed as follows:
[0110] y=F(x,{W i})+x ← ,
[0111] Where x is the input branch feature, F(x,{W i}) represents the features after convolution transformation, and y represents the final fusion result.
[0112] Step 2.2: Add a Context-Guided Aggregation Module (CGFM) to the neck structure to achieve dynamic information fusion across channels and reduce information loss between channels. The CGFM module structure is as follows: Figure 4 As shown, CGFM achieves efficient multi-scale information extraction through a hierarchical convolutional structure, and combines spatial channel attention with multilayer perceptrons to enhance feature representation by integrating original features with attention-extracted features. The specific operation of the CGFM module is as follows:
[0113] Step 2.2.1: The input feature map P3 is first adjusted by a 1×1 convolution operation to make its channel number consistent with that of the other input feature map P4;
[0114] Step 2.2.2: Concatenate the adjusted feature map with P4 along the channel dimension to form a fused feature;
[0115] Step 2.2.3: The concatenated feature map is input into the SE channel attention module. The module first processes the fused feature map U∈R. H×W×C The space compression operation is performed, and the calculation method is as follows:
[0116]
[0117] Among them, F sq This represents the Squeeze operation function, which performs global average pooling on the spatial dimension.
[0118] U is the input fused feature map, and the information in the H×W spatial dimension is compressed into a single scalar for each channel. c (i,j) represents the pixel value of the c-th channel in the U feature map at position (i,j), Z∈R 1×1×C Indicates the channel descriptor;
[0119] Step 2.2.4: Input the descriptor Z into two fully connected layers to form the activation function, and obtain the channel attention weights S∈R. 1×1×C The excitation function is:
[0120] S=sigmoid(FC2(ReLU(FC1(Z)))),
[0121] Where Z∈R 1×1×C Channel descriptors obtained from global average pooling, FC1 is the first fully connected layer, FC2 is the second fully connected layer, s∈R 1×1×C Channel attention weights are used to adjust the fused feature map U channel by channel.
[0122] Step 2.2.5: Assign the weight S∈R 1×1×C The channel calibration operation is performed by multiplying the original fused feature map U channel by channel, which is expressed as: Y = S⊙U, where ⊙ represents element-wise product and Y is the output feature map;
[0123] Step 2.2.6: Based on the source of the original inputs P3 and P4, split the attention weights into W3 and W4, and multiply them by P3 and P4 channel by channel to obtain the weighted features;
[0124] Step 2.2.7: Concatenate the weighted P3 and P4 to obtain the final fused feature map, which is used as the output of the context-guided aggregation module.
[0125] Step 2.3: In the detection head section, replace the original detection head with a custom DAFAHead detection head; the structure of the DAFAHead detection head is as follows. Figure 5 As shown, the DAFAHead detection head employs a dual-branch attention structure and a channel dynamic matching mechanism (CDMM). Through a combination of global semantic modeling and local detail focusing, it effectively improves the model's ability to identify small targets and weak-feature violations.
[0126] The DAFAHead detection head comprises three main parts, modules for processing global semantics, local details, and channel dynamic matching, respectively. Each module models and enhances the input features through different paths, fuses global contextual information extracted by the Transformer structure with local detail features extracted by the convolutional structure, and performs adaptive fusion through a channel dynamic matching mechanism, ultimately outputting an optimized detection feature map. The specific operation steps of the DAFAHead detection head include:
[0127] Step 2.3.1: Process global semantic features:
[0128] Step 2.3.1.1: The input feature map is first compressed in dimension and spatially integrated by a convolutional encoder;
[0129] Step 2.3.1.2: Input the compressed feature map into the multi-layer Transformer module to extract global context information under multi-head self-attention;
[0130] Step 2.3.1.3: Input the global context features into the cross-task attention mechanism to generate specific response weights based on the detection task, highlighting the target region;
[0131] Step 2.3.1.4: Output and retain global features for fusion with local paths.
[0132] Step 2.3.2: Processing local detailed features:
[0133] Step 2.3.2.1: Fine-grained edge and texture information is extracted from the input feature map using a lightweight convolution stacking module;
[0134] Step 2.3.2.2: After convolution, the function is activated and normalized to form a robust local feature representation;
[0135] Step 2.3.2.3: Output and preserve detailed features for fusion with the global path.
[0136] Step 2.3.3: Perform dynamic matching and fusion of channels:
[0137] Step 2.3.3.1: Concatenate the feature maps of the global path and the local path along the channel dimension;
[0138] Step 2.3.3.2: The CDMM (Dynamic Matching Module) for splicing feature maps into input channels generates fusion scaling coefficients through a fully connected layer;
[0139] Step 2.3.3.3: Perform weighted fusion of the two features according to the scaling factor to output the final detection feature map.
[0140] Step 2.4: In the backbone network input stage, the Inter-Frame History Interactive Coding (HTIE) module is introduced to achieve structural modeling of the time series context and enhance the ability to detect continuous violations; the HTIE module structure is as follows. Figure 6 As shown; the specific operation steps of the HTIE module include:
[0141] Step 2.4.1: The operation steps of the intra-frame feature compression module include:
[0142] Step 2.4.1.1: Input the video frame sequence sequentially into the shared convolutional encoder to extract primary spatial features;
[0143] Step 2.4.1.2: Through size alignment and channel unification operations, the features of multiple frames are standardized into a uniform shape to facilitate subsequent fusion processing.
[0144] Step 2.4.2: The operation steps of the temporal interaction attention module include:
[0145] Step 2.4.2.1: Stack the standardized feature maps from multiple frames into a three-dimensional tensor in the time dimension;
[0146] Step 2.4.2.2: Calculate the contextual dependencies between frames using a self-attention mechanism to generate a temporal attention graph;
[0147] Step 2.4.2.3: Multiply the attention map element-wise with the original frame feature map to enhance the temporal correlation representation.
[0148] Step 2.4.3: The operational steps of the historical memory update mechanism include:
[0149] Step 2.4.3.1: Use a gating unit to model the feature differences between historical frames and the current frame to generate a memory vector;
[0150] Step 2.4.3.2: The memory vector guides the feature update of the current frame, so that the model retains its perception of previous actions;
[0151] Step 2.4.3.3: Use the final fused feature map as one of the inputs to the backbone network to improve the ability to detect continuous violations.
[0152] Step 3: Train the improved MCSM-YOLO model using the training set from Step 1, and evaluate the MCSM-YOLO model based on the training results.
[0153] Step 4: Use the trained improved model to test the test set from Step 1 and output the test results.
[0154] In this embodiment, the inventors conducted a comparative experiment with the original YOLOv8 network. The specific comparative experiment is shown below:
[0155] The inventors conducted a comparative experiment based on a self-built image dataset of violations by personnel in a chemical plant. This dataset contains samples of various small-target violations, such as smoking and making phone calls. The experiment compared the improved MCSM-YOLO model with the original YOLOv8 model, using the same hardware platform (NVIDIA GeForce RTX 2060 Super graphics card, 8GB VRAM, CUDA version 11.8, PyTorch framework version 1.18) and a unified training strategy (pre-training weights are YOLOv8s.pt, 300 iterations).
[0156] Table 1 Comparison of Model Performance Before and After Improvement
[0157]
[0158]
[0159] Experimental results show that the proposed MCSM-YOLO model significantly optimizes the parameter size and computational efficiency of the model structure while maintaining high detection accuracy. The overall number of parameters in the improved model (including the weights and bias parameters of convolutional layers, fully connected layers, and BatchNorm layers) is reduced from 11,126,358 in the original YOLOv8 model to 4,105,682, a reduction of 63.1%. The model file size is reduced from 22.6MB to 8.9MB, a reduction of 60.6%. The computational complexity (in GFLOPs) is reduced from 28.4 to 14.5, a reduction of 48.9%. In terms of inference efficiency, the average inference time per image is shortened from 7.2ms to 6.7ms, an improvement of 6.9%.
[0160] In terms of detection performance, the MCSM-YOLO model, based on its multi-scale feature fusion and attention enhancement mechanism, demonstrates stronger detection capabilities in small target recognition tasks. It achieves 82.4% on the mAP50 metric, a 2.6 percentage point improvement compared to the original YOLOv8 model (79.8%); the recall rate increases from 75.4% to 77.9%, while the false negative rate decreases by approximately 41.2%.
[0161] In summary, the improved MCSM-YOLO model achieves multi-scale feature enhancement by introducing the RMCSM module, completes contextual semantic alignment and fusion by combining the CGFM module, adds the inter-frame history interaction coding module HTIE in the input stage, and uses a custom DAFAHead detection head to replace the original detection head. As a result, the improved model outperforms existing technologies in terms of detection accuracy, parameter quantity, inference speed, and scene adaptability, and can provide an efficient, stable, and low-cost solution for detecting personnel violations in industrial and chemical scenarios.
[0162] The above embodiments are only for illustrating the technical concept and features of the present invention, and are intended to enable those skilled in the art to understand the content of the present invention and implement it accordingly. They should not be construed as limiting the scope of protection of the present invention. All equivalent changes or modifications made in accordance with the spirit and essence of the present invention should be covered by the present invention.
Claims
1. A method for detecting personnel violations based on multi-scale channels and context-guided aggregation, characterized in that: Including the following steps: Step 1: Using a self-built dataset of violations by personnel in chemical plants, divide the dataset into a training set, a validation set, and a test set; Step 2: Improve YOLOv8 and build a new MCSM-YOLO model; the specific steps are as follows: Step 2.1: Based on the YOLOv8 backbone structure, a custom multi-scale feature fusion module RMCSM is introduced. Through channel separation, multi-scale convolution and feature fusion strategies, spatial context information under different receptive fields is captured. Step 2.2: Add a context-guided aggregation module (CGFM) to the neck structure to perform cross-channel dynamic information fusion, extract multi-scale information through a hierarchical convolutional structure, and combine the original features and attention mechanism-extracted features by combining spatial channel attention and multilayer perceptron. Step 2.3: In the detection head part, the original detection head is replaced with a custom DAFAHead detection head; the DAFAHead detection head adopts a dual-branch attention structure and channel dynamic matching mechanism CDMM, which improves the model's ability to identify small targets and weak feature violations by combining global semantic modeling and local detail focusing. Step 2.4: In the backbone network input stage, the Inter-Frame History Interaction Coding (HTIE) module is introduced to perform structural modeling of the time series context and continuously judge violations. Step 3: Train the improved MCSM-YOLO model using the training set from Step 1, and evaluate the MCSM-YOLO model based on the training results. Step 4: Use the trained improved model to test the test set from Step 1 and output the test results.
2. The method for detecting personnel violations based on multi-scale channel and context-guided aggregation according to claim 1, characterized in that: The specific operation method of step 2.1 is as follows: Step 2.1.1: The input feature map is first processed through a 1×1 convolution operation to integrate information between channels and enhance feature sharing capabilities; Step 2.1.2: The feature map is divided into two parts along the channel dimension in a 1:2 ratio by the Split operation. One part is directly used for subsequent splicing output, and the other part is sent to the Multi_CSM module. Step 2.1.3: In the Multi_CSM module, the input is first convolved by 3×3 to form basic spatial features, and then feature decomposition is performed to generate three branch structures; Step 2.1.4: The main branch retains the original features for subsequent residual fusion, and the remaining branches stack two or three layers of 3×3 convolutions to construct equivalent 5×5 and 7×7 receptive fields and establish multi-scale feature representations; Step 2.1.5: The output features of the three branches are spliced together along the channel dimension to fuse information at different scales extracted from the 3×3, 5×5 and 7×7 receptive fields; Step 2.1.6: The concatenated feature maps are recalibrated through 1×1 convolution to perform dimensionality compression and feature fusion; Step 2.1.7: Use a skip connection mechanism to add the residuals of the initial features and the deep features; Step 2.1.8: After multi-scale feature map fusion, output a highly expressive feature map to the downstream module of the backbone network for target detection.
3. The method for detecting personnel violations based on multi-scale channel and context-guided aggregation according to claim 2, characterized in that: The computational complexity of the 1×1 convolution operation described in step 2.1.1 is: FLOPS=C out ×H out ×W out ×(C in ×K×K), Among them, C in For the number of input channels, C out H represents the number of output channels. out W out These represent the height and width of the output feature map, respectively, and K is the kernel size. The output feature map is calculated using the following formula: Among them, H in P is the height of the input feature map, S is the padding size, and S is the stride. Internally, the module generates three branches through feature decomposition, stacking 1, 2, and 3 3×3 convolutional layers respectively to obtain feature maps with equivalent receptive fields of 3×3, 5×5, and 7×7, denoted as F1, F2, and F3 respectively. The feature maps output from the three branches are concatenated along the channel dimension, and the concatenated features satisfy the formula: Among them, F concat This represents the result of concatenating the feature maps output from the three branches along the channel dimension. Concat indicates the operation of concatenating feature maps F1, F2, and F3 along the channel dimension. It is a shallow, small receptive field. It is a medium-sensory field in the middle layer. For a deep, large receptive field, C1, C2, and C3 represent the number of channels output by the three multi-scale branches, and H and W represent the spatial dimensions of the feature map, where H is the height and W is the width. After the concatenated feature maps are recalibrated via 1×1 convolution, a residual connection mechanism is introduced to fuse the initial decomposed features and deep features. The residual connection is expressed as follows: y=F(x,{W i })+x ← , Where x is the input branch feature, F(x,{W i }) represents the features after convolution transformation, and y represents the final fusion result.
4. The method for detecting personnel violations based on multi-scale channel and context-guided aggregation according to claim 1, characterized in that: The specific operation method of the context-guided aggregation module CGFM described in step 2.2 is as follows: Step 2.2.1: The input feature map P3 is first adjusted by a 1×1 convolution operation to make its channel number consistent with that of the other input feature map P4; Step 2.2.2: Concatenate the adjusted feature map with P4 along the channel dimension to form a fused feature; Step 2.2.3: The concatenated feature map is input into the SE channel attention module. The module first processes the fused feature map U∈R. H ×W×C The space compression operation is performed, and the calculation method is as follows: Among them, F sq This represents the Squeeze operation function, which performs global average pooling on the spatial dimension. U is the input fused feature map, and the information in the H×W spatial dimension is compressed into a single scalar for each channel. c (i,j) represents the pixel value of the c-th channel in the U feature map at position (i,j), Z∈R 1×1×C Indicates the channel descriptor; Step 2.2.4: Input the descriptor Z into two fully connected layers to form the activation function, and obtain the channel attention weights S∈R. 1 ×1×C The excitation function is: S=sigmoid(FC2(ReLU(FC1(Z)))), Where Z∈R 1×1×C Channel descriptors obtained from global average pooling, FC1 is the first fully connected layer, FC2 is the second fully connected layer, s∈R 1×1×C Channel attention weights are used to adjust the fused feature map U channel by channel; Step 2.2.5: Assign the weight S∈R 1×1×C The channel calibration operation is performed by multiplying the original fused feature map U channel by channel, which is expressed as: Y = S⊙U, where ⊙ represents element-wise product and Y is the output feature map; Step 2.2.6: Based on the source of the original inputs P3 and P4, split the attention weights into W3 and W4, and multiply them by P3 and P4 channel by channel to obtain the weighted features; Step 2.2.7: Concatenate the weighted P3 and P4 to obtain the final fused feature map, which is used as the output of the context-guided aggregation module.
5. The method for detecting personnel violations based on multi-scale channel and context-guided aggregation according to claim 1, characterized in that: The DAFAHead detection head described in step 2.3 consists of three main parts, which are modules for processing global semantics, local details, and channel dynamic matching, respectively. Each module models and enhances the input features through different paths, fuses the global context information extracted by the Transformer structure with the local detail features extracted by the convolutional structure, and performs adaptive fusion through the channel dynamic matching mechanism, finally outputting an optimized detection feature map.
6. A method for detecting personnel violations based on multi-scale channel and context-guided aggregation according to claim 1 or 5, characterized in that: The specific operation steps of the DAFAHead detection head described in step 2.3 include: Step 2.3.1: Process global semantic features: Step 2.3.1.1: The input feature map is first compressed in dimension and spatially integrated by a convolutional encoder; Step 2.3.1.2: Input the compressed feature map into the multi-layer Transformer module to extract global context information under multi-head self-attention; Step 2.3.1.3: Input the global context features into the cross-task attention mechanism to generate specific response weights based on the detection task, highlighting the target region; Step 2.3.1.4: Output and retain global features for fusion with local paths; Step 2.3.2: Processing local detailed features: Step 2.3.2.1: Fine-grained edge and texture information is extracted from the input feature map using a lightweight convolution stacking module; Step 2.3.2.2: After convolution, the function is activated and normalized to form a robust local feature representation; Step 2.3.2.3: Output and preserve detailed features for fusion with the global path; Step 2.3.3: Perform dynamic matching and fusion of channels: Step 2.3.3.1: Concatenate the feature maps of the global path and the local path along the channel dimension; Step 2.3.3.2: The CDMM (Dynamic Matching Module) for splicing feature maps into input channels generates fusion scaling coefficients through a fully connected layer; Step 2.3.3.3: Perform weighted fusion of the two features according to the scaling factor to output the final detection feature map.
7. The method for detecting personnel violations based on multi-scale channel and context-guided aggregation according to claim 1, characterized in that: The encoding module HTIE described in step 2.4 includes an intra-frame feature compression module, a temporal interactive attention module, and a history memory update mechanism. The specific operation method is as follows: Step 2.4.1: The operation steps of the intra-frame feature compression module include: Step 2.4.1.1: Input the video frame sequence sequentially into the shared convolutional encoder to extract primary spatial features; Step 2.4.1.2: Standardize the features of multiple frames into a uniform shape through size alignment and channel unification operations; Step 2.4.2: The operation steps of the temporal interaction attention module include: Step 2.4.2.1: Stack the standardized feature maps from multiple frames into a three-dimensional tensor in the time dimension; Step 2.4.2.2: Calculate the contextual dependencies between frames using a self-attention mechanism to generate a temporal attention graph; Step 2.4.2.3: Multiply the attention map element-wise with the original frame feature map to enhance the temporal correlation representation; Step 2.4.3: The operational steps of the historical memory update mechanism include: Step 2.4.3.1: Use a gating unit to model the feature differences between historical frames and the current frame to generate a memory vector; Step 2.4.3.2: The memory vector guides the feature update of the current frame, so that the model retains its perception of previous actions; Step 2.4.3.3: Use the final fused feature map as one of the inputs to the backbone network to improve the ability to detect continuous violations.
8. The method for detecting personnel violations based on multi-scale channel and context-guided aggregation according to claim 1, characterized in that: The self-built dataset mentioned in step 1 contains 5312 images, which are divided into training set, validation set and test set in a ratio of 8:1:1; the images include two categories of violations: chemical plant personnel smoking and making phone calls.
Citation Information
Cited By
Lightweight end-to-end sea surface small target detection method and system based on original digital baseband echo signal
CN121934041A