Safety protection equipment detection method and system for agricultural greenhouse construction scene
By building a lightweight security equipment image detection model SGR-DETR, and using the Lingxi convolutional network and feature fusion module to optimize the model, the problem of insufficient detection accuracy and real-time in smart agricultural greenhouse construction scenarios is solved, and efficient deployment and accurate detection on edge computing devices are achieved.
Patent Information
- Application Number
- CN202510448383.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-10
- Publication Date
- 2025-08-01
AI Technical Summary
In the smart agricultural greenhouse construction scenario, the existing safety protection equipment detection methods have problems such as insufficient detection accuracy and real-time, high model inference complexity, and limited application in complex environments, especially when deploying RT-DETR models on edge computing devices with limited computing power.
Build a lightweight security equipment image detection model SGR-DETR. By introducing the Lingyi convolutional network GSConvNext-Net, the fusion interaction module CAS-AIFI and the new cross-scale feature fusion module Lightweight-CCFM, the backbone network and feature fusion module are optimized, the model complexity is reduced, and the detection accuracy and real-timeness are improved.
It significantly improves the accuracy and real-time detection of safety protection equipment, and can be efficiently deployed on edge computing devices in complex environments, reducing computing resource consumption and reasoning time, providing accurate safety equipment supervision capabilities, and reducing construction risks.
Smart Images

Figure CN120410987A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of safety equipment detection, and in particular relates to a safety protection equipment detection method and system for agricultural greenhouse construction scenarios. Background Art
[0002] Safety accidents caused by illegal operations during construction account for a high proportion of all accidents. Hard hats and reflective vests, as crucial safety equipment, are essential tools for protecting construction workers on-site and are widely used in sectors such as construction, electricity, manufacturing, and transportation. In smart agricultural greenhouse construction, safety accidents caused by illegal operations account for a high proportion. Due to the complex lighting conditions in greenhouses (such as dynamic shadows from shade nets and glare from translucent films) and insufficient safety awareness among construction workers, failure to wear protective equipment properly is a common occurrence, directly exacerbating safety hazards in scaffolding and equipment installation. Therefore, real-time monitoring of safety equipment wear at smart agricultural greenhouse construction sites is of great significance.
[0003] In recent years, advances in computer vision and edge computing have led to widespread application of object detection in various fields. Its application in safety equipment inspection can reduce construction accidents and minimize losses. Following traditional object detection models, the DETR model innovatively employs the Transformer architecture for object detection in the form of an ensemble prediction problem, shifting from the traditional approach of predicting individual objects to a global approach of processing image information. However, its initial performance suffered from poor handling of small objects and slow training convergence. Deformable DETR improves convergence speed and small object detection performance by introducing a deformable attention module, but this results in a more complex model with higher computational and storage overhead. Building on this, RT-DETR considers the importance of feature layer inputs and the impact of classification scores and position confidence on detection. It designs a hybrid encoder consisting of an intra-scale feature interaction module and a cross-scale feature fusion module to process multi-scale features. However, this model is complex and computationally intensive, making it difficult to deploy on edge computing devices with limited computing power. Summary of the Invention
[0004] In response to the above-mentioned deficiencies in the prior art, the present invention provides a safety protection equipment detection method and system for agricultural greenhouse construction scenarios, which solves the problems of current safety protection equipment detection methods in smart agricultural greenhouse construction sites, such as insufficient detection accuracy and real-time performance, high model reasoning complexity, and limited application in complex environments (such as extreme weather conditions). It also solves the problem of deploying the RT-DETR model on edge computing devices with limited computing power when deployed in embedded devices.
[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A method for detecting safety protection equipment for agricultural greenhouse construction scenarios, comprising the following steps:
[0006] S1. Obtain images of safety equipment in the agricultural greenhouse construction scenario;
[0007] S2. Construct a lightweight safety equipment image detection model SGR-DETR;
[0008] S3. Use the safety equipment image detection model SGR-DETR to detect the safety equipment images, obtain the detection results, and complete the detection of the safety protection equipment.
[0009] The beneficial effects of the present invention are as follows: By deploying monitoring equipment at the construction site of intelligent agricultural greenhouses, the present invention can obtain real-time image data of the protective equipment worn by construction workers during agricultural greenhouse construction. Aiming at the characteristics of complex lighting scenarios and agricultural machinery operation scenarios in greenhouses, the images are processed by dynamic noise reduction and feature enhancement to generate a standardized detection image set that adapts to the safety standards of agricultural facility construction. At the same time, by introducing the lightweight safety equipment image detection model SGR-DETR, the present invention solves the problems existing in the current safety protection equipment detection methods in the construction site of intelligent agricultural greenhouses, such as insufficient detection accuracy and real-time performance, high model inference complexity, and limited application in complex environments (such as the influence of extreme weather). Through the lightweight model structure and edge computing acceleration technology, the deployment efficiency of the algorithm on agricultural Internet of Things terminal devices is significantly improved, providing accurate safety equipment supervision capabilities for greenhouse construction scenarios and effectively reducing the operation risks in agricultural facility construction.
[0010] Furthermore, the expression of the loss function of the safety equipment image detection model SGR-DETR is as follows:
[0011] L = λ cls L CE + λ box L GIou + λ query L aux
[0012]
[0013] where L represents the loss function of the SGR-DETR model, and λ cls represents the weight coefficient of the classification loss, L CE represents the classification loss, λ box represents the weight coefficient of the bounding box regression loss, L GIou represents the regression loss, λ query represents the weight coefficient of the auxiliary loss, L auxDenote the auxiliary loss, i denote the index of the prediction box, N denote the total number of prediction box indices, and y i denote the true class label of the i-th prediction box, denote the class probability for the i-th prediction box, GIou denote the Generalized Intersection over Union, denote the bounding box coordinates, B gt denote the true bounding box coordinates, and Hungarian_Matching denote the Hungarian algorithm operation.
[0014] The beneficial effects of the above further scheme are as follows: Through multi-task joint optimization, the present invention significantly improves the performance of safety protection equipment detection. The classification loss (L CE ) optimizes the target class prediction through cross-entropy, reduces false detections and balances the sample distribution; the regression loss (L GIou ) uses the Generalized Intersection over Union to improve the bounding box localization accuracy, especially performing excellently in the case of small targets at a long distance and complex scenes; the auxiliary loss (L aux ) accelerates the training convergence through the Hungarian matching algorithm and enhances the robustness of the model to occluded targets. The weight coefficients (λ cls , λ box , λ query ) flexibly adjust the task weights to ensure the balanced optimization of classification, localization, and matching. The overall design enables the model to achieve significant improvements in detection accuracy (mAP@0.5 reaches 0.963), training efficiency (converges within 150 epochs), and adaptability to complex scenes (the false omission rate is reduced to 8%), providing efficient and reliable technical support for construction site safety supervision.
[0015] Furthermore, the construction method of the safety equipment image detection model SGR-DETR is as follows:
[0016] Improve on the basis of the Real-Time Detection Transformer RT-DETR, replace the Basic Block based on blocks in the backbone network with the GSConvNeXt Block of the Huitong convolutional block, and name it the GSConvNext-Net of the Lingxi convolutional network;
[0017] Combine the convolutional operation with the Additive Self-Attention Mechanism CAS to construct the CAS-AIFI of the Rongzhui interaction module;
[0018] Construct a new cross-scale feature fusion module Lightweight-CCFM through the depthwise separable convolution GSConv to replace the traditional convolution, and complete the construction of the SGR-DETR model.
[0019] The beneficial effects of the above further solution are as follows: By improving the backbone network, including replacing the basic block BasicBlock, performing multiple convolution and pooling operations, and using depthwise separable convolution GSConv to replace depth convolution, etc., and introducing various enhancement and optimization measures, the problem of difficult deployment of the real-time detection transformer RT-DETR at the edge side is solved, the model parameters and computational complexity are greatly reduced, the model performance and convergence effect are improved, key features can be extracted more effectively, the real-time requirements of embedded object detection are met, complex weather conditions can be dealt with, and the accuracy of object detection is improved.
[0020] Furthermore, the safety equipment image detection model SGR-DETR includes:
[0021] The GSConvNext-Net of the Lingxi convolutional network is used to perform 3×3 cascaded convolutional layer processing on the safety equipment image, extract low-level features, and generate a high-resolution feature map S3 through max pooling downsampling; according to the high-resolution feature map S3, the GSConvNeXt Block of the Huitong convolutional block is used to generate a middle-level feature map S4; according to the middle-level feature map S4, the stacked GSConvNeXt Block of the Huitong convolutional block is used for processing, fusing local and global features, and generating a high-level feature map S5 through downsampling;
[0022] The CAS-AIFI of the Rongzhui interaction module is used to achieve local-global feature complementarity based on the high-level feature map S5 through convolutional enhanced local perception and additive self-attention mechanism, and generate a recombined feature map F5;
[0023] The new cross-scale feature fusion module Lightweight-CCFM is used to perform lightweight convolution GSConv and multi-branch topology Conv3xcBlock in parallel on the high-resolution feature map S3, the middle-level feature map S4, and the recombined feature map F5 to extract multi-scale features, and perform channel splicing and element-wise addition on the features of different scales through adaptive weighted fusion to generate a cross-scale fused feature map Output;
[0024] The decoder is used to model the relationship between objects through the self-attention mechanism based on the feature map Output in combination with the object query, generate the position and category of the prediction box, and output the detection results of the construction workers wearing safety helmets and reflective vests.
[0025] The beneficial effects of the above solution are as follows: The present invention introduces a backbone network called the Lingxi Convolutional Network GSConvNext-Net, which significantly reduces network redundancy and computational load while effectively extracting spatial features; replaces the multi-head self-attention mechanism in AIFI with the additive self-attention mechanism CAS to improve model accuracy and resource efficiency; and improves the CCFM component with a new cross-scale feature fusion module Lightweight-CCFM to enhance the model's generalization and feature extraction capabilities in complex environments. Through technologies such as multi-level feature learning, attention mechanisms, data augmentation, and lightweight design, the present invention significantly improves the accuracy, computational efficiency, and model robustness of object detection.
[0026] Furthermore, the expression of the high-level feature map S5 is as follows:
[0027]
[0028] F out = Conv 1×1 (GRN(GELU(F mid )))
[0029]
[0030] where Stacked_Blocks represents the processing of stacked GSConvNeXt Blocks, R represents the real number space, H represents the height of the safety equipment image, W represents the width of the safety equipment image, D3 represents the number of channels of the high-level feature map S5, MaxPool represents the max pooling operation, F out represents the feature map output by the convolutional module, Conv 1×1 represents a 1×1 convolutional operation, D2 represents the number of channels of the middle-level feature map S4, GRN represents global response normalization, GELU represents the Gaussian error linear unit activation function, F mid represents the intermediate feature map in the multi-branch topological structure Conv3xcBlock, C1 represents the intermediate feature map after three consecutive 3×3 convolutional operations, and D1 represents the number of channels of the high-resolution feature map S3.
[0031] Furthermore, the expression of the reorganized feature map F5 is as follows:
[0032]
[0033] Sim(Q, K) = Φ(Q) + Φ(K)
[0034] Φ(Q) = Sigmoid(Conv 3×3 (Q))
[0035] Φ(K) = Sigmoid(Conv 3×3 (K))
[0036] Q = W q ·Flatten(S5)
[0037] K = W k ·Flatten(S5)
[0038] V = W v ·Flatten(S5)
[0039] Wherein, Reshape represents a two-dimensional feature map for reshaping the sequence, O represents the output result of additive self-attention, Softmax represents the Softmax activation function, Sim(Q, K) represents the additive self-attention score, Φ(Q) and Φ(K) respectively represent functions for context mapping of Query and Key, Sigmoid represents the Sigmoid activation function, Conv 3×3 represents a 3×3 convolution operation, W q represents the Query weight matrix, Flatten represents flattening the feature map into a sequence, W k represents the Key weight matrix, W v represents the Value weight matrix, Q, K, and V respectively represent Query, Key, and Value obtained through linear transformation, Query represents the query vector at each position in the current input sequence, Key represents the key vector at each position in the input sequence, and Value represents the actual feature value at each position in the input sequence.
[0040] The beneficial effects of the above further solution are as follows: In the present invention, the CAS attention mechanism is added to AIFI. By combining convolution and the additive self-attention mechanism, the efficiency of the traditional self-attention mechanism in processing image features is improved, while maintaining the advantages of the convolutional neural network. And the complexity of the multi-head self-attention mechanism is reduced by performing specific operations on the Query and Key branches. At the same time, in the fusion interaction module CAS-AIFI, by combining the convolution operation and the additive self-attention mechanism, the model can capture higher fine-grained spatial and channel information, which helps to better retain visual sparse features and avoid information loss on the two-dimensional fractional vector.
[0041] Furthermore, the expression of the feature map Output is as follows:
[0042]
[0043]
[0044] Among them, GSConv represents a lightweight depthwise separable convolution operation, and Upsample represents an upsampling operation. represents the feature map after lightweight convolution processing. represents the middle-level feature map after lightweight convolution processing. represents the feature map after lightweight convolution processing.
[0045] The beneficial effects of the above further scheme are as follows: By introducing the lightweight convolution GSConv to replace the traditional convolution, optimizing the feature fusion module (such as Conv3xcBlock), and adding an additional convolution branch, the model can extract key features more efficiently, reduce the accumulation of redundant information, improve the multi-scale object detection ability, while reducing the computational burden, shortening the inference time, and effectively alleviating the gradient vanishing problem, enhancing the robustness, generalization ability, and stability in complex environments.
[0046] Furthermore, the expressions for the position and category of the predicted bounding box are as follows:
[0047]
[0048] Decoder_Output = MultiHeadAttention(Q obj , Output, Output)
[0049]
[0050] Among them, represents the bounding box coordinates of the predicted position. represents the classification score of the predicted category, W reg represents the weight matrix of the regression branch, Decoder_Output represents the output features of the Transformer decoder, W cls represents the weight matrix of the classification branch, MultiHeadAttention represents the multi-head self-attention mechanism, Q obj represents the object query, Learnable_Embedding represents the learnable position encoding, and d represents the feature dimension.
[0051] The beneficial effects of the above further scheme are as follows: By introducing the lightweight depthwise separable convolution GSConv to replace the traditional convolution, optimizing the feature fusion module (such as Conv3xcBlock), and adding an additional convolution branch, the model can extract key features more efficiently, reduce the accumulation of redundant information, improve the multi-scale object detection ability, while reducing the computational burden, shortening the inference time, and effectively alleviating the gradient vanishing problem, enhancing the robustness, generalization ability, and stability in complex environments.
[0052] The present invention relates to a safety protection equipment detection system for agricultural greenhouse construction scenarios. The safety protection equipment detection method for the said safety protection equipment detection system includes:
[0053] A first processing module, configured to obtain safety equipment images in the agricultural greenhouse construction scenario;
[0054] A second processing module, configured to build a lightweight safety equipment image detection model SGR-DETR;
[0055] A third processing module, configured to use the safety equipment image detection model SGR-DETR to detect the safety equipment images, obtain detection results, and complete the detection of the safety protection equipment.
[0056] The beneficial effects of the present invention are as follows: The present invention is a lightweight SGR-DETR safety protection equipment detection method and system for intelligent agricultural greenhouse construction scenarios. By using the Lingxi convolutional network GSConvNext-Net, network redundancy and computational complexity are reduced. The fusion interaction module CAS-AIFI improves computational efficiency and detection performance. The new cross-scale feature fusion module Lightweight-CCFM optimizes feature fusion. Combining multi-module collaboration and special module design, the model's multi-scale feature extraction and generalization capabilities in complex scenarios are improved, computational resource consumption and inference time are reduced, effectively solving the problem of deploying the real-time detection transformer RT-DETR on edge devices, and it can accurately detect safety protection equipment and promote the development of related fields. Description of the Drawings
[0057] Figure 1 It is the method flow chart of the present invention.
[0058] Figure 2 It is the schematic diagram of the basic network framework of the present invention.
[0059] Figure 3 It is the structural diagram of the benchmark model provided in this embodiment.
[0060] Figure 4 It is the structural schematic diagram of the backbone network Lingxi convolutional network GSConvNext-Net provided in this embodiment.
[0061] Figure 5 It is the structural schematic diagram of the depthwise separable convolution GSConv with a convolution sum of 7x7 provided in this embodiment.
[0062] Figure 6 It is the structural schematic diagram of the fusion interaction module CAS-AIFI provided in this example.
[0063] Figure 7 It is the schematic diagram of extracting similarity by the CAS attention mechanism provided in this example.
[0064] Figure 8 Schematic diagram of the Conv3xcBlock module structure provided in this embodiment.
[0065] Figure 9 Visual detection effect diagram of the RT-DETR-R18 model and the safety equipment image detection model SGR-DETR provided in this embodiment.
[0066] Figure 10 Thermodynamic diagrams output by each model provided in this embodiment. From top to bottom and from left to right, the images are the original input image, the thermodynamic diagram output by the Yolov5m model, the thermodynamic diagram output by the Yolov8m model, the thermodynamic diagram output by the Yolov6s model, the thermodynamic diagram output by the RT-DETR-R18 model, and the thermodynamic diagram output by the SGR-DETR model.
[0067] Figure 11 Schematic diagram of the intelligent construction site safety supervision system based on the cloud-edge-end collaborative architecture.
[0068] Figure 12 Schematic diagram of the system structure of the present invention. Detailed implementation manners
[0069] The following describes the detailed implementation manners of the present invention to facilitate those skilled in the art of the present technology to understand the present invention. However, it should be clear that the present invention is not limited to the scope of the detailed implementation manners. For those of ordinary skill in the art of the present technology, as long as various changes are within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions and creations using the concept of the present invention are within the scope of protection.
[0070] Embodiment 1
[0071] Before explaining the present invention, the following terms are first explained:
[0072] Safety equipment image detection model SGR-DETR: A model improved based on the real-time detection transformer RT-DETR network, which can detect safety equipment images.
[0073] GSConvNext-Net: A new type of backbone network. By performing three 3x3 cascaded convolution operations, max pooling operations, using lightweight convolution GSConv instead of depth convolution, applying LayerNorm (layer normalization), increasing the number of channels, introducing the GELU activation function and GRN (global response normalization) layer, and residual connections on the input image, it can effectively extract spatial features, reduce network redundancy and computational complexity, improve detection speed and real-time performance, and facilitate deployment on edge devices.
[0074] Fusion Interaction Module CAS-AIFI: A module constructed by integrating the additive self-attention mechanism CAS into AIFI (Attention-based Internal Scale Feature Interaction Module). The CAS attention mechanism combines convolution and the additive self-attention mechanism, extracts similarity on the Query and Key branches, retains the original feature dimension, uses depth convolution to capture local spatial relationships, represents the context mapping function through spatial attention and channel attention, improves the efficiency of the traditional self-attention mechanism in processing image features, and enhances the computational efficiency, resource utilization rate, recall rate, and mAP@0.5.
[0075] Cross-scale Feature Fusion Module: An improvement to the CCFM part in the Real-time Detection Transformer RT-DETR model. It uses GSConv (Lightweight Depthwise Separable Convolution) in Slim-neck (lightweight network structure) to replace traditional convolution, combined with batch normalization and Sigmoid activation function processing, reducing the consumption of model computing resources and inference time; proposes a multi-branch topology structure Conv3xcBlock to replace the RepBlock module in RepC3 (Reparameterized C3 module, where C3 usually refers to a structure containing 3 convolutional layers), combines the multi-branch topology structure to extract features in parallel, enriches the feature space, provides multi-scale receptive fields, enhances the network's expression ability, alleviates the gradient vanishing problem, and improves the multi-scale feature extraction ability and generalization ability in complex environments.
[0076] Multi-branch Topology Structure Conv3xcBlock: Conv3xcBlock extracts features in parallel through independent branches of 1×1 and 3×3 convolutions, combines concatenation and addition operations, which belongs to a typical multi-branch topology design, and can effectively enrich the feature space and enhance the model's generalization ability. Combining the multi-branch topology structure, the input features are merged after being processed by two different branches. The multi-branch structure enriches the feature space, enabling the network to extract more effective semantic features; the combination of 1x1 and 3x3 convolutional kernels provides multi-scale receptive fields, enhancing the network's expression ability; deeper features are gradually extracted through the stacking and fusion method; an additional convolutional branch is added for information flow and gradient propagation, alleviating the gradient vanishing problem.
[0077] CAS Attention Mechanism: The core idea is to combine convolution and the additive self-attention mechanism to improve the efficiency of the traditional self-attention mechanism in processing image features while maintaining the advantages of convolutional neural networks. Extract similarity on the Query and Key branches, retain the original feature dimension, use depth convolution to capture local spatial relationships, represent the context mapping function through spatial attention and channel attention, combine convolution operations and the additive self-attention mechanism, capture higher fine-grained spatial and channel information, retain visual sparse features, and avoid information loss on two-dimensional fractional vectors.
[0078] AIFI (Attention-based Internal Scale Feature Interaction Module): The attention-based internal scale feature interaction module performs attention operations on the well-extended two-dimensional features output from the backbone network. After completion, the vectors are recombined into two-dimensional features, and the multi-head self-attention mechanism in Transformer is used for feature interaction, which can effectively capture global and local context information, but has the problems of large parameter quantity and high computational complexity.
[0079] CCFM: The cross-scale feature fusion module based on convolutional neural network is a key part in the real-time detection transformer RT-DETR. Its main function is to solve the multi-scale problem in object detection through cross-scale and cross-channel feature fusion and context information enhancement, ensuring the robustness and generalization ability of the model for objects of different scales. However, the operations before and after feature fusion will cause some redundant features to accumulate, increasing the network parameters and computational burden and affecting feature discriminability.
[0080] Slim-neck (Spatial Pyramid Aggregation Network): A technology or module in which GSConv (depthwise separable convolution) can be used to replace traditional convolution to extract key features through fewer real convolution operations, generate additional features using redundant information, and reduce the consumption of model computing resources and inference time while maintaining performance.
[0081] SPANet: Inspired to improve the feature fusion part in CCFM (Cross Fusion Feature Module), and its related ideas or structures are used to propose the Conv3xcBlock module to enhance the model's multi-scale feature extraction ability and generalization ability in complex environments.
[0082] GELU activation function: While retaining gradient information, it has good gradient smoothness, which can effectively improve the convergence speed and performance of the model.
[0083] GRN (Global Response Normalization) layer (Global Response Normalization): Reduces the dominance of specific channels in the overall feature map through L2 normalization, enhances the feature diversity of the model, and prevents the problem of feature collapse.
[0084] LayerNorm layer normalization: Normalizes the channel dimension of each feature to enhance the stability and training efficiency of the model.
[0085] GSConv: A special convolution structure that extracts key features through fewer real convolution operations, and then uses a series of simple linear transformations to generate "ghost features", realizing the generation of more feature representations with less computing resources and making the model more lightweight.
[0086] Such as Figures 1 - 2As shown in the figure, the present invention provides a method for detecting safety protection equipment for agricultural greenhouse construction scenarios, and the implementation method is as follows:
[0087] S1. Obtain safety equipment images in the agricultural greenhouse construction scenario;
[0088] S2. Construct a lightweight safety equipment image detection model SGR-DETR;
[0089] In this embodiment, the construction method of the safety equipment image detection model SGR-DETR is as follows:
[0090] Based on the real-time detection transformer RT-DETR, improve it by replacing the basic block Basic Block of the backbone network with the GSConvNeXt Block of the Huitong convolutional block, and name it the Lingxi convolutional network GSConvNext-Net;
[0091] Combine the convolutional operation with the additive self-attention mechanism CAS to construct the fusion interaction module CAS-AIFI;
[0092] Replace the traditional convolution with the depthwise separable convolution GSConv to construct a new cross-scale feature fusion module Lightweight-CCFM, and complete the construction of the SGR-DETR model;
[0093] In this embodiment, the safety equipment image detection model SGR-DETR includes:
[0094] The Lingxi convolutional network GSConvNext-Net is used to perform 3×3 tandem convolutional layer processing on the safety equipment image, extract the underlying features, and generate a high-resolution feature map S3 through max-pooling downsampling; according to the high-resolution feature map S3, use the GSConvNeXt Block of the Huitong convolutional block to generate a middle-level feature map S4; according to the middle-level feature map S4, use the stacked GSConvNeXt Blocks of the Huitong convolutional block for processing, fuse local and global features, and generate a high-level feature map S5 through downsampling;
[0095] The fusion interaction module CAS-AIFI is used to achieve local-global feature complementarity based on the high-level feature map S5 through convolutional enhanced local perception and additive self-attention mechanism, and generate a recombined feature map F5;
[0096] The new cross-scale feature fusion module Lightweight-CCFM is used to perform lightweight convolution GSConv and multi-branch topology Conv3xcBlock on the high-resolution feature map S3, the middle-level feature map S4, and the recombined feature map F5 in parallel to extract multi-scale features, and through adaptive weighted fusion, channel splicing and element-wise addition of features of different scales are performed to generate the cross-scale fused feature map Output;
[0097] The decoder is used to generate the positions and categories of the prediction boxes by modeling the relationships between objects through the self-attention mechanism based on the feature map Output in combination with the object queries, and output the detection results of the construction workers wearing safety helmets and reflective vests;
[0098] S3. Use the safety equipment image detection model SGR-DETR to detect the safety equipment image, obtain the detection results, and complete the detection of the safety protection equipment.
[0099] In this embodiment, the safety equipment image detection model SGR-DETR significantly reduces the model complexity and computational amount through the lightweight backbone network GSConvNext-Net, the fused interaction module CAS-AIFI that combines convolution and additive self-attention, and the optimized new cross-scale feature fusion module Lightweight-CCFM, while improving the detection accuracy and the edge device deployment efficiency.
[0100] In this embodiment, as Figure 4 shown, the GSConvNext-Net of the lightweight backbone network adopts the depthwise separable convolution GSConv and the Ghost feature generation technology (the schematic diagram of the depthwise separable convolution GSConv structure is as Figure 5As shown in the figure, it replaces the basic block of the original ResNet (Residual Network), combines Layer Normalization (LayerNorm), GELU activation function, and Global Response Normalization (GRN), significantly reducing the number of parameters and computational complexity, while retaining the multi-scale feature extraction ability, which is suitable for lightweight deployment on edge devices. The integrated interaction module CAS-AIFI combines convolutional operations with additive self-attention mechanism, introducing local perception ability into the Transformer encoder. It extracts local detailed features through convolution, and additive self-attention captures global dependencies, reducing the computational complexity of the multi-head self-attention mechanism, improving the efficiency of feature interaction, and enhancing the robustness of the model to small targets and complex scenes. The new cross-scale feature fusion module Lightweight-CCFM replaces traditional convolution with depthwise separable convolution GSConv, and combines the multi-branch topology Conv3xcBlock to parallelly extract multi-scale features, reducing the accumulation of redundant features. Through cross-channel and cross-scale fusion, it strengthens the interaction of context information, optimizes the multi-object detection ability, and improves the generalization and detection accuracy of the model in occluded and dense scenes.
[0101] In this embodiment, the safety protection equipment image is passed through the Lingxi convolutional network GSConvNext-Net of the backbone network structure to extract three feature maps at different scales, effectively extracting spatial features, reducing the redundant part of the network and the computational complexity of the model. The safety protection equipment image first undergoes three cascaded 3×3 convolutional kernel operations to gradually extract initial spatial features (such as edge contours and basic textures), and the feature map size is compressed through max pooling (MaxPooling) to generate the first-level feature map (high-resolution feature map S3). This layer of feature map has a high resolution and few channels, retaining rich detail information and providing a basis for subsequent feature fusion. The first-level feature map (high-resolution feature map S3) is input into the lightweight Huitong convolutional module (GSConvNeXt Block), which uses depthwise separable convolution (GSConv) and Ghost feature mapping technology to extract key local features while reducing the number of parameters. Combining Layer Normalization (LayerNorm) and GELU non-linear activation function to optimize the feature distribution and enhance the model's ability to capture middle-level semantic information (such as the relationship between target components). Subsequently, max pooling is applied again to compress the feature dimension to generate the second-level feature map (middle-level feature map S4), whose resolution is reduced (such as the original Figure 1 / 8 size), the number of channels is expanded, focusing on the context relevance of the target. The second-level feature map (middle-level feature map S4) is processed by multiple cascaded Huitong convolutional modules GSConvNeXt Block to fuse local details and global context information, gradually extracting high-level abstract features (such as the overall structure of the target). Finally, the third-level feature map (high-level feature map S5) is generated through adaptive pooling or channel compression operation, whose resolution is the smallest (such as the original Figure 1 / 16 size), has the most channels, encodes the global semantic information of the target (such as the category and location of safety equipment), and provides a highly robust feature input for subsequent cross-scale interaction and detection head prediction.
[0102] In this embodiment, the efficiency of safety protection equipment detection at the construction site is significantly improved through multi-stage optimization: First, a diversified image acquisition enhancement model is used to improve the generalization ability of complex scenes; Second, high-resolution underlying features are extracted through three 3×3 convolutions and pooling to retain detail information; Then, the lightweight GSConvNeXt Block is used, combining depthwise separable convolution and Ghost technology, reducing the number of parameters by 50% and strengthening the middle-layer semantic association; Finally, cross-scale feature fusion is used to integrate underlying details, middle-layer context, and high-level global semantics. This series of operations effectively extracts the details and high-level features of the image, reduces the dimension of the feature map, reduces the model parameters and computational complexity, and at the same time uses residual connections to alleviate the problem of gradient disappearance, promoting the effective training and better convergence of the network, which helps to improve the accuracy and performance of the object detection model.
[0103] In this embodiment, as Figures 6 - 7 shown, the output is used for feature fusion with the feature maps of the other two scales. The convolution and additive self-attention combination mechanism in the fusion interaction module CAS-AIFI is used to replace the multi-head self-attention mechanism in the adaptive feature interaction module AIFI (an attention-based internal scale feature interaction module), and the detection performance is further improved by providing high-quality object queries to the decoder. The first-level feature map (high-resolution feature map S3) is input into the lightweight GSConvNeXt Block, and the depthwise separable convolution GSConv and Ghost feature mapping technology are used to extract key local features while reducing the number of parameters. The layer normalization LayerNorm and the GELU non-linear activation function are combined to optimize the feature distribution and enhance the model's ability to capture middle-layer semantic information (such as the relationship between target components). Subsequently, max pooling is applied again to compress the feature dimension and generate the second-level feature map (middle-layer feature map S4), whose resolution is reduced (such as the original Figure 1 / 8 size), and the number of channels is expanded, focusing on the context relevance of the target.
[0104] The CAS attention mechanism is added to AIFI. The core idea of the CAS attention mechanism is to combine convolution and additive self-attention mechanisms, aiming to improve the efficiency of the traditional self-attention mechanism in processing image features while maintaining the advantages of convolutional neural networks. The traditional multi-head self-attention mechanism is a method for calculating the correlation between positions in an input sequence. For a given input K∈R N×d , the self-attention mechanism calculates the output based on the similarity of the Query, Key, and Value matrices, and its expression is as follows:
[0105]
[0106] where Q = W q x, K = W k x, V = W v x represent Query, Key, and Value obtained through linear transformation respectively, N represents the length of the input sequence, and d represents the feature dimension. To reduce the complexity of the multi-head self-attention mechanism (MSA), the CAS attention mechanism extracts similarity on both the Query and Key branches and retains the original feature dimension on each branch. The similarity function is defined as the sum of the context scores of Q ∈ R N×d and K ∈ R N×d .
[0107] The present invention incorporates the CAS attention mechanism into AIFI. By combining convolution and additive self-attention mechanism, the efficiency of the traditional self-attention mechanism in processing image features is improved, while maintaining the advantages of the convolutional neural network. Moreover, the complexity of the multi-head self-attention mechanism is reduced through specific operations on the Query and Key branches.
[0108] In this embodiment, the expression for the sum of the context scores of Q ∈ R N×d and K ∈ R N×d in the fusion interaction module is as follows:[[]]
[0109] Sim(Q, K) = Φ(Q) + Φ(K) s.t. Φ(·) = C(S(·))
[0110] The additive self-attention mechanism CAS uses depth convolution to capture local spatial relationships. It represents Φ(·) through spatial attention S(·) ∈ R N×d and channel attention C(·) ∈ R N×d . Φ(Q) and Φ(K) respectively represent the functions for context mapping of Query and Key, including basic information interaction.
[0111] By combining convolution operations and additive self-attention mechanism, the model can capture higher fine-grained spatial and channel information, which helps to better retain visual sparse features and avoid information loss on two-dimensional fractional vectors.
[0112] In this embodiment, the high-resolution feature map S3 (high-resolution details), the middle-level feature map S4 (middle-level semantics), and the recombined feature map F5 (global context) are input into the new cross-scale feature fusion module Lightweight-CCFM. Multiscale features are extracted in parallel through the lightweight convolution GSConv and the multi-branch topology structure Conv3xcBlock, and then the features of different scales are channel-concatenated and element-wise added through adaptive weighted fusion to generate the fused feature map. The fused feature map is input into the Transformer decoder. Combining the object queries, the relationships between objects are modeled through the self-attention mechanism to generate the positions and categories of the prediction boxes. Subsequently, the detection results (classification scores and bounding box coordinates) are directly output.
[0113] In this embodiment, the new cross-scale feature fusion module Lightweight-CCFM is used to improve the CCFM part of the cross-fusion feature module, enhancing the generalization and feature extraction capabilities of the model in complex scenarios. The classification and coordinate information corresponding to each target frame are obtained through the classification and regression frame branches. The new cross-scale feature fusion module Lightweight-CCFM is an improvement to the CCFM (cross-fusion feature module) part in the real-time detection transformer RT-DETR. The CCFM module fuses the feature map F5 output after being processed by the AIFI (attention-based internal scale feature interaction module), the high-resolution feature map S3 output by the backbone network, and the middle-level feature map to obtain new features. The expression is:
[0114]
[0115] Among them, Output is the output feature map.
[0116] The above fusion method plays a certain role in solving the multi-scale problem in object detection, enabling the model to be robust and generalized when facing objects of different scales. However, in the CCFM (cross-fusion feature module), due to a series of sampling operations such as convolution, batch normalization, and Sigmoid activation functions before and after feature fusion, some redundant features will accumulate, which may increase the network parameters and computational burden and affect the feature discrimination ability. To address this problem, the lightweight convolution GSConv in the Slim-neck (thin neck module) is used to replace the traditional convolution, and it is combined with batch normalization and the Sigmoid activation function for processing. Key features are extracted with fewer convolution operations, and additional features are generated with redundant information, so that the consumption of model computing resources and the inference time can be reduced while maintaining the performance. Furthermore, to improve the multi-scale feature extraction ability of the model and its generalization ability in complex environments, the feature fusion part in the CCFM is improved, and the multi-branch topology structure Conv3xcBlock is proposed to replace the RepBlock (reparameterized block) module in RepC3, as Figure 8As shown, this allows the model to more freely handle input diversity and provide multi-scale receptive fields, enhancing the network's expressive ability. Finally, the combination of 1x1 and 3x3 convolutional kernels provides a multi-scale receptive field, enhancing the network's representational ability. By stacking and fusing to gradually extract deeper features and combining additional convolutional branches for information flow and gradient propagation, this module alleviates the problem of vanishing gradients.
[0117] In the present invention, by introducing lightweight convolution GSConv to replace traditional convolution, optimizing the feature fusion module (such as Conv3xcBlock), and adding additional convolutional branches, the model can more efficiently extract key features, reduce the accumulation of redundant information, improve the multi-scale object detection ability, while reducing the computational burden, shortening the inference time, and effectively alleviating the problem of vanishing gradients, enhancing the robustness, generalization ability, and stability in complex environments. Through multi-branch processing (Conv3xcBlock), the detailed features of the high-resolution feature map S3, the semantic features of the middle-level feature map S4, and the global features of the high-level feature map S5 are integrated. The parallel paths of 1×1 and 3×3 convolutions are used to enhance the multi-scale expressive ability, and finally the detection accuracy is improved. It extracts features of different scales through parallel paths, combines multiple convolutional kernels to enhance the expressive ability, which conforms to the core definition of the multi-branch design. The input features of the multi-branch topology (Conv3xcBlock) are processed through two independent branches: Branch 1: 1×1 convolution extracts local features; Branch 2: 3×3 convolution expands the receptive field; Combine the branch results: fuse multi-scale features through channel concatenation (Concat) and element-wise addition (⊕).
[0118] In this embodiment, combined with the multi-branch topological structure, without significantly increasing the model complexity, features are extracted in parallel through different paths, enabling the model to more flexibly handle input diversity. Specifically, the input features are processed through two different branches and then combined. The multi-branch structure enriches the feature space, enabling the network to extract more effective semantic features. In addition, the combination of 1x1 and 3x3 convolutional kernels provides a multi-scale receptive field, thus enhancing the network's expressive ability; finally, deeper features are gradually extracted through the way of stacking and fusing. Through the multi-branch topological structure, when the model complexity is relatively slightly increased, the input features are processed through different branches and combined. The combination of 1x1 and 3x3 convolutional kernels provides a multi-scale receptive field, and deep features are extracted through stacking and fusing, thereby enriching the feature space, enhancing the network's expressive ability, and flexibly handling input diversity.
[0119] In summary, the safety equipment image detection model SGR-DETR model is improved based on the real-time detection converter RT-DETR. By replacing the Basic Block of the backbone network with the GSConvNeXt Block of the Huitong convolution block and naming it the Lingxi convolution network GSConvNext-Net. The backbone network GSConvNext-Net processes the input image X ∈ R H×W×3 in three stages:
[0120] 1. Low-level feature extraction (generating a high-resolution feature map S3), retaining high-resolution details: 3×3 concatenated convolution: C1 = Conv 3×3 (GELU(LayerNorm(X))), max pooling (MaxPool):
[0121] 2. Middle-level feature extraction (generating a middle-level feature map S4): GSConvNeXt Block lightweight residual module: F min = GSConv 7×7 (S3), F out = Conv 1×1 (GRN(GELU(F mid ))), GSConv: Depthwise Separable Convolution, with the number of parameters reduced to 1 / 3 to 1 / 4 of traditional convolution. GRN (Global Response Normalization): Enhancing feature diversity through L2 normalization.
[0122] 3. High-level feature extraction (generating a recombined feature map F5): Stacking GSConvNeXt Blocks:
[0123]
[0124] Among them, Stacked_Blocks represents the processing of stacked GSConvNeXt Blocks, R represents the real number space, here referring to the dimensions of the feature map (such as height, width, number of channels), H represents the height of the safety equipment image, W represents the width of the safety equipment image, D3 represents the number of channels of the high-level feature map S5, MaxPool represents the max pooling operation, F out represents the final output feature map of the convolution module (such as GSConvNeXt Block), generated through steps such as depthwise separable convolution, activation function, normalization, and channel adjustment, Conv 1×1Denotes a 1×1 convolution operation, used for adjusting the number of channels or feature fusion. D2 represents the number of channels of the middle feature map S4 (e.g., 128). GRN represents global response normalization, GELU represents the Gaussian error linear unit activation function, F mid Denotes the middle feature map in the multi-branch topological structure GSConvNeXt Block, generated by depthwise separable convolution (GSConv). C1 represents the middle feature map after three consecutive 3×3 convolution operations. D1 represents the number of channels of the high-resolution feature map S3 (e.g., 64).
[0125] Then, the CAS attention mechanism is added to the feature interaction module AIFI. The CAS attention mechanism combines convolution and additive self-attention mechanisms to form the fused interaction module CAS-AIFI. The fused interaction module CAS-AIFI processes the input high-level feature map in five steps:
[0126] 1. Flattened linear transformation:
[0127] Q = W q ·Flatten(S5), K = W k ·Flatten(S5), V = W v ·Flatten(S5);
[0128] 2. Convolutional enhanced local perception:
[0129] Φ(Q) = Sigmoid(Conv 3×3 (Q)), Φ(K) = Sigmoid(Conv 3×3 (K));
[0130] 3. Additive self-attention score:
[0131] Sim(Q, K) = Φ(Q) + Φ(K)
[0132] 4. Attention output:
[0133]
[0134] 5. Reconstruct feature map:
[0135]
[0136] Among them, Reshape means restructuring the sequence into a two-dimensional feature map, O represents the output result of additive self-attention, Softmax represents the Softmax activation function, Sim(Q, K) represents the additive self-attention score, Φ(Q) and Φ(K) respectively represent the functions for context mapping of Query and Key, Sigmoid represents the Sigmoid activation function, which is used to generate spatial or channel attention weights, Conv 3×3 represents a 3×3 convolution operation, W q represents the Query weight matrix, Flatten means flattening the feature map into a sequence for Transformer input, W k represents the ey weight matrix, W v represents the Value weight matrix, Q, K, and V respectively represent Query, Key, and Value obtained through linear transformation. Query represents the query vector at each position in the current input sequence, Key represents the key vector at each position in the input sequence, and Value represents the actual feature value at each position in the input sequence.
[0137] Then, the high-resolution feature map S3 (high-resolution details), the middle-level feature map S4 (middle-level semantics), and the reshaped feature map (global context) are input into the new cross-scale feature fusion module Lightweight-CCFM. The new cross-scale feature fusion module Lightweight-CCFM processes the input feature maps in three steps:
[0138] 1. Lightweight convolution processing:
[0139]
[0140] 2. Multi-branch topological structure Conv3xcBlock:
[0141] Branch1 = Conv 1×1 (S i )
[0142] Branch2 = Conv 1×1 (S i )
[0143] Fused1 = Concat(Branch1, Branch2), i ∈ {3, 4, 5}
[0144] 3. Cross-scale fusion:
[0145]
[0146] Among them, GSConv represents lightweight depthwise separable convolution, and Upsample represents an upsampling operation, such as bilinear interpolation, which is used to restore the resolution of the feature map. represents the feature map after lightweight convolution processing. represents the middle-level feature map after lightweight convolution processing. represents the feature map after lightweight convolution processing. Branch1 represents a 1×1 convolution to extract local features and focus on fine-grained information, such as the edge of the safety helmet and the texture of the reflective vest. Branch2 represents a 3×3 convolution to expand the receptive field and capture context associations, such as the overall shape of the object or occlusion relationships. i represents the input feature map, Conv 1×1 represents a 1×1 convolution operation. Fused1 represents the fused feature map, which contains complementary information extracted from multiple branches. Concat represents channel concatenation, which merges the outputs of different branches along the channel dimension.
[0147] Finally, the fused feature map is input into the Transformer decoder. The Transformer decoder processes the input image in three steps:
[0148] 1. Object query:
[0149]
[0150] (N: the preset maximum number of detected objects (e.g., 100));
[0151] 2. Decoder self-attention:
[0152] Decoder_Output = MultiHeadAttention(Q obj , Output, Output);
[0153] 3. Feed-forward network (FFN) prediction:
[0154]
[0155] Among them, represents the bounding box coordinates of the predicted position. represents the classification score of the predicted class. W reg represents the weight matrix of the regression branch, which is used to predict the bounding box coordinates from the decoder output. Decoder_Output represents the output features of the Transformer decoder, which contains the result of the interaction between object queries and fused features. W clsRepresents the weight matrix of the classification branch, mapping the decoder output to category probability, MultiHeadAttention represents the multi-head self-attention mechanism, which is used to model the global dependency between features, Q obj Represents object query Object Queries, learnable position encoding, Learnable_Embedding represents learnable position encoding, that is, object query, ObjectQueries, used to initialize the position and category information of the detected target) d represents the feature dimension.
[0156] In this embodiment, the loss function of the safety equipment image detection model SGR-DETR is analyzed as follows:
[0157] 1. Total loss:
[0158] L=λ cls L CE +λ box L GIou +λ query L aux
[0159] 2. Classification loss (cross entropy):
[0160]
[0161] 3. Regression loss (GIoU loss):
[0162]
[0163] 4. Auxiliary loss (query matching loss):
[0164]
[0165] Among them, L represents the loss function of the SGR-DETR model, λ cls Represents the weight coefficient of classification loss, which is used to balance the importance of classification task in the total loss, L CE represents the classification loss, λ box Represents the weight coefficient of the bounding box regression loss, which is used to adjust the contribution of the positioning task, L GIou represents the regression loss, λ query Represents the weight coefficient of auxiliary loss (such as query matching loss), which optimizes the matching process between target query and real box, L aux Represents auxiliary loss, i represents the index of the prediction box, traverses all prediction results, N represents the total number of prediction boxes, y i Represents the true category label of the i-th prediction box (one-hot encoding, if it does not match the true box, it is the background class, $p_i$ represents the class probability of the $i$-th predicted bounding box, and GIou represents the Generalized Intersection over Union, which measures the overlap and positional differences between the predicted bounding box and the ground truth bounding box. denotes the bounding box coordinates, $B$ gt denotes the ground truth bounding box coordinates, and Hungarian_Matching represents the optimal matching of predicted bounding boxes and ground truth bounding boxes through the Hungarian algorithm, calculating the matching cost (such as classification + regression loss).
[0166] In summary, the present invention extracts three feature maps at different scales from the safety protection device image through the GSConvNext-Net, a flexible convolutional network of the backbone network structure, effectively extracts spatial features, reduces the redundant part of the network and the computational amount of the model; uses the output to perform feature fusion with the feature maps of the other two scales, replaces the multi-head self-attention mechanism in AIFI with the CAS-AIFI attention mechanism of the fusion interaction module, and further improves the detection performance by providing high-quality object queries to the decoder. The new cross-scale feature fusion module Lightweight-CCFM is used to improve the CCFM part, enhance the generalization and feature extraction capabilities of the model in complex scenarios, and obtain the classification and coordinate information corresponding to each target frame through the classification and regression frame branches.
[0167] Embodiment 2
[0168] As Figure 12 shown, the present invention provides a safety protection equipment detection system for the agricultural greenhouse construction scenario. The safety protection equipment detection method for the safety protection equipment detection method described in Embodiment 1 includes:
[0169] The first processing module is used to obtain the safety equipment image in the agricultural greenhouse construction scenario;
[0170] The second processing module is used to construct a lightweight safety equipment image detection model SGR-DETR;
[0171] The third processing module is used to use the safety equipment image detection model SGR-DETR to detect the safety equipment image, obtain the detection result, and complete the detection of the safety protection equipment.
[0172] In this embodiment, images of the construction site are collected in real time to obtain the original visual information of the construction site, and three feature maps are extracted at different scales to provide basic data for subsequent processing. The image data collected by the camera is received and preprocessed. This includes performing multiple convolution operations to capture image features, reducing the dimension of the feature map through pooling operations to reduce the computational amount, and also performing module replacement to generate special features, and performing normalization processing, adjusting the number of channels, introducing activation functions and normalization layers, etc., to optimize the data features and provide more efficient data for subsequent processing. Based on the deep learning model, object detection is performed on the data preprocessed by the edge device. The extracted features are deeply processed to make the features work better together, accurately determine the possible areas and related information of the target, such as the category and location of the target, etc., to achieve intelligent monitoring and analysis of the construction site. The processing results of the cloud intelligent detection module are received, the results are summarized and analyzed, the accurate category and location and other information of the target in the image are determined, and the final detection results are output. At the same time, on-site real-time control can be performed according to the detection results, such as issuing safety warnings, adjusting the construction process, etc., to achieve effective management and feedback on the safety of the construction site.
[0173] In this embodiment, images of the construction site are collected, and three feature maps are extracted at different scales. Subsequently, the output feature maps are processed by the fusion interaction module CAS-AIFI and the new cross-scale feature fusion module Lightweight-CCFM. The smallest-sized deep feature map (high-level feature map S5), which contains high-level semantic information (such as the overall structure of the target), is input. The global context modeling of the high-level feature map S5 is performed by the fusion interaction module CAS-AIFI. Convolution operations are performed to extract local detailed features, and the global dependence relationship is captured by the additive self-attention mechanism, and the feature map after attention interaction (denoted as the recombined feature map F5) is output, retaining the global information and enhancing the feature expression ability. By inputting the shallow feature map (high-resolution feature map S3, retaining details), the middle-level feature map (middle-level feature map S4, containing medium semantics), and the deep feature map (recombined feature map F5) processed by the fusion interaction module CAS-AIFI, multi-scale feature fusion is performed through the new cross-scale feature fusion module Lightweight-CCFM, and the fused unified feature map is output, which contains rich multi-scale information. The processing results are summarized, and the fused feature map output by the new cross-scale feature fusion module Lightweight-CCFM is input. The target query is generated by the Transformer decoder, and the target category and bounding box are predicted through the classification and regression branches. Finally, the detection results of construction workers wearing safety helmets and reflective vests are output, and real-time deployment to edge devices is supported.
[0174] In this embodiment, in terms of image acquisition and processing, a series of operations such as three consecutive 3x3 convolutions are first performed on the input image to extract features. At the same time, methods such as max pooling are used to reduce the dimension of the feature map to optimize the image data processing flow. Through staged convolution, pooling, and lightweight modules (GSConvNeXt Block), features are gradually extracted and compressed. While reducing redundant calculations, three multi-scale feature maps of large (high-resolution feature map S3), medium (middle-layer feature map S4), and small (high-layer feature map S5) are generated, taking into account details, semantics, and global information. During the training process, evaluation metrics such as accuracy, recall, mAP, number of parameters, and FLOPs are used for experimental analysis to effectively balance the model complexity and performance, and achieve efficient deployment of the model on edge computing devices, so as to accurately detect safety protection equipment at the construction site.
[0175] In this embodiment, as shown in Table 1, Table 1 is a performance comparison table of different lightweight backbone networks. The GSConvNext-Net of the Lingxi convolutional network not only reduces the model parameters and computational volume by 42.05% and 47.44% respectively, but also slightly improves the recall rate and accuracy, making both the recall rate and mAP reach the highest values. On the premise of not losing accuracy, the backbone network lightweight method of this model achieves a balance between detection speed and accuracy, and is particularly suitable for edge computing scenarios in outdoor construction sites.
[0176] Table 1
[0177]
[0178] In this embodiment, the CAS (fusion interaction module) calculates the attention score through a linear combination method, reducing the demand for computing resources. And it extracts local features through the convolutional layer, and uses additive self-attention to enhance the ability to capture global information, thereby improving the feature expression ability while maintaining computational efficiency. The model improved by using the fusion interaction module CAS-AIFI not only has a decrease in the number of parameters (20.151) and computational volume (57.5), but also maintains high performance in the recall rate (0.903) and mAP@0.5 (0.963), as shown in Table 2, Table 2 is a performance comparison table of different attention mechanism modules.
[0179] Table 2
[0180]
[0181] The fusion interaction module CAS-AIFI performs special processing on the Query and Key branches during calculation, uses depth convolution to capture relationships and specific function table mapping, can capture fine-grained information, preserve features, and prevent information loss. For a given input X∈R N×d, the self-attention mechanism calculates the output based on the similarity of three matrices, Query, Key, and Value. Its expression is as follows:
[0182]
[0183] Where: Q = W q x, K = W k x, V = W v x are Query, Key, and Value obtained through linear transformation respectively. N represents the length of the input sequence, and d represents the feature dimension. The processed features are fused with the other two-scale feature maps through CCFM (Cross-Fusion Feature Module) to provide high-quality queries for the decoder and improve performance. In the experiment, indicators such as recall rate and mAP@0.5 increase, which helps in complex scene detection.
[0184] In this embodiment, to reduce the complexity of the multi-head self-attention mechanism (MSA), the CAS attention mechanism extracts similarity on both the Query and Key branches and retains the original feature dimension on each branch. The similarity function is defined as the sum of the context scores of Q ∈ R N×d and K ∈ R N×d . Its expression is as follows:
[0185] Sim(Q, K) = Φ(Q) + Φ(K) s.t. Φ(·) = C(S(·))
[0186] Where CAS uses depth convolution to capture local spatial relationships, and through spatial attention S(·) ∈ R N×d and channel attention C(·) ∈ R N×d to represent Φ(·). Φ(Q) and Φ(K) respectively represent the functions for context mapping of Query and Key, which contain basic information interaction
[0187] In this embodiment, the present invention is based on the real-time detection converter RT-DETR. The experimental hardware configuration is CPU (Intel Xeon Platinum 8474C), GPU (NVIDIA RTX4090D), the operating system is ubuntu20.04, the deep learning framework is PyTorch 2.0.0, the CUDA version is 11.8, and the Python version is 3.8. The safety protection equipment dataset used comes from the Kaggle website, including 10,500 pictures of two types of equipment, namely safety helmets and reflective vests. Among them, 7,350 pictures are used for training, 1,575 pictures are used for validation, and 1,575 pictures are used for testing. The size of the pictures input into the model is 640×640, the training batch is 4, the initial learning rate is 0.0001, the learning rate momentum value is 0.9, the AdamW optimizer is used, and it is trained for 150 epochs to finally obtain the improved model weights.
[0188] In this embodiment, the depthwise separable convolution GSConv in Slim-neck (thin neck network) is used to replace the standard convolution Conv. Since the CCFM (cross-fusion feature module) will undergo operations such as convolution, batch normalization, and Sigmoid activation function during the feature fusion process, redundant features are easily generated. These redundant features not only lack effective information but also increase the parameters and computational burden of the network, reducing the discriminability of features. The depthwise separable convolution GSConv extracts key features through fewer real convolution operations, generates additional features using redundant information, and reduces the consumption of computational resources and inference time of the model. The structural design of the depthwise separable convolution GSConv significantly reduces the computational complexity while maintaining performance.
[0189] In this embodiment, the multi-branch topological structure Conv3xcBlock is introduced. Combining with the multi-branch topological structure, features are extracted in parallel through different paths to enhance the model's multi-scale feature extraction ability and generalization ability in complex environments. Specifically, the input features are processed through two different branches and then merged. This multi-branch structure enriches the feature space and enables the network to extract more effective semantic features. In addition, the combination of 1x1 and 3x3 convolution kernels provides multi-scale receptive fields, enhancing the expression ability of the network.
[0190] In this embodiment, deeper features are gradually extracted in a stacked fusion manner. Finally, an additional convolutional branch is added to propagate information flow and gradients to alleviate the problem of gradient disappearance.
[0191] In this embodiment, the detection accuracy evaluation metrics are Precision and Recall, and the calculation formulas are as follows:
[0192]
[0193] Among them, Precision is the proportion of the number of correctly predicted positive samples (TP) in the total number of positive samples predicted by the model (TP + FP), and Recall is the proportion of the number of correctly predicted positive samples in all positive samples (TP + FN). Among them, TP is a true positive event, that is, the result given by the model is consistent with the result of the sample and is positive; FP is a false positive event, that is, the result given by the model is positive, but the result of the sample is negative; FN is a false negative event, the result given by the model is negative, but the result of the sample is positive.
[0194] In this embodiment, according to the values of recall and precision, the average precision AP can be obtained. Its original definition is the area size enclosed by the Precision-Recall curve and the two coordinate axes. The formula is as follows:
[0195]
[0196] Among them, P(R) represents Precision as a function of Recall R, and dR represents the differential operation symbol.
[0197] The AP value is used to evaluate the quality of the object detection result of the model in a certain category. The higher the AP value, the more accurate the detection result of this category by the model;
[0198] After averaging the AP values of all categories, the mean average precision mAP is obtained to measure the overall detection effect of the model. The formula for the mAP value is as follows:
[0199]
[0200] Among them, mAP@0.5 is commonly used to measure the precision of the model. mAP@0.5 means that when the IoU is set to 0.5, the average value of all categories is calculated.
[0201] In this embodiment, in order to measure the complexity and required computing resources of each model, this article compares the number of parameters (Parameters) and floating-point operations per second (FLOPs) in various models. The number of parameters (Parameters) reflects the complexity and capacity of the model and is usually used to measure the scalability and computing resource requirements of the model. Floating-point operations per second (FLOPs) are used to measure the running efficiency of the model during the inference process and are directly related to the real-time performance of the model:
[0202] FLOPs = 2 × C out × H out × W out (C in × k 2 + bias)
[0203] Among them, C is the number of channels, H and W represent the size of the feature map, k is the size of the convolutional kernel, and 1 GFLOPs = 10 9 FLOPs.
[0204] In this embodiment, in order to more detailedly test the real-time performance of each model, after optimizing with Tensor RT, the model is deployed on an edge computing device (NVIDIA Jetson Xavier NX), and the FPS value is obtained through inference on this device. FPS represents the number of image frames that the model can process per second. The higher the FPS value, the more suitable the model is for real-time detection tasks:
[0205]
[0206] Among them, t is the time required to predict one frame, and the unit is millisecond ms.
[0207] In this embodiment, in order to verify the effectiveness of the improved method, Yolov6s, Yolov5m, Yolov8m and their variants, as well as the baseline model RT-DETR-R18 are selected for comparison, as Figure 3 shown. The experimental results are shown in Table 3 below. Table 3 is a comprehensive performance comparison table of mainstream object detection models:
[0208] Table 3
[0209]
[0210] Among them, the safety equipment image detection model SGR-DETR is superior to other Yolo series models such as Yolov5m in terms of accuracy. The safety equipment image detection model SGR-DETR adopts technologies such as a hybrid encoder and IOU-aware query selection to improve detection accuracy, making it more effective in complex environments, but also resulting in an increase in the number of parameters and a decrease in FPS. In practical engineering applications, the acceptability of the number of parameters and FPS depends on the application scenario and requirements. For example, in the detection of safety protection equipment at the construction site, the detection accuracy is crucial for the safety of personnel and the construction progress. As long as the basic prerequisites for real-time detection are met, the above performance trade-offs are acceptable in practical applications, despite the increase in the number of parameters and the decrease in the detection speed.
[0211] In this embodiment, a new backbone network of the Lingxi convolutional network GSConvNext-Net is proposed, which can effectively extract spatial features, reduce redundancy and computational complexity, improve the detection speed and real-time performance, and is conducive to the deployment of edge devices. The CAS attention mechanism is introduced to construct the fused interaction module CAS-AIFI, which fuses convolution and additive self-attention, makes up for the lack of detail capture, reduces the computational complexity, and improves the efficiency and resource utilization rate. The lightweight convolution GSConv is used to replace the standard convolution Conv, reducing the accumulation of redundant features, resource consumption, and inference time. Inspired by PANet (Spatial Pyramid Aggregation Network), the Conv3xcBlock (multi-branch topological structure) module is proposed to replace the RepBlock (reparameterized block). Combining with the multi-branch topological structure, it enhances the multi-scale feature extraction and generalization ability without significantly increasing the complexity. The chart data verifies the improvement effect from dimensions such as the number of parameters, floating-point operation count, recall rate, and average precision, as shown in Table 4, which is a performance comparison table of module combination ablation experiments.
[0212] Table 4
[0213]
[0214] In this embodiment, the detection effects of the present invention and the benchmark model RT-DETR-R18 are visually compared. As Figure 9 shown, the original input image is on the left, the detection output of the benchmark model RT-DETR-R18 is in the middle, and the detection output of the improved model of the present invention is on the right. In Figure 9 (a), when the camera is far from the construction workers or the detection target is small, the benchmark model RT-DETR-R18 misses detections, and the missed detection targets are marked with blue arrows. However, the improved model in this paper can accurately identify the reflective vests worn by construction workers, largely overcoming the difficulties of long-distance detection or small-target detection. In Figure 9 (b) and Figure 9 (c), the benchmark model fails to detect occluded targets in crowded scenes and misses detections, and the missed detection targets are also marked with blue arrows. The improved model in this paper captures more effective features, enhances the feature extraction ability in complex construction scenes, and makes the model have stronger anti-occlusion performance.
[0215] In this embodiment, Grad-CAM++ is used to generate the model heatmap effect to verify the improved SGR-DETR model. Figure 10 It is shown that from top to bottom and from left to right are: the original input image, the heatmaps of the outputs of Yolov5m, Yolov8m, Yolov6s, RT-DETR-R18 models, and the heatmap of the output of the improved SGR-DETR model. Blue and red respectively represent the degree of attention of the model to the image area, blue means no attention, and red means high attention. Figure 10The improved SGR-DETR model can more effectively focus on the areas to be detected, with higher detection accuracy and full attention to each object in the image.
[0216] As Figure 11 shown, Figure 11 The presented "cloud-edge-device" collaborative information processing architecture for construction site safety supervision is designed according to the hierarchical computing idea, which can optimize the real-time detection efficiency and resource utilization rate. It is divided into three core levels from bottom to top: the device level, that is, the terminal devices at the construction site, such as high-definition cameras and sensors, which are used to collect image and environmental data in real time, such as personnel positions, lighting conditions, etc., and transmit these raw data to the edge device; the edge level, that is, the edge device, such as NVIDIA Jetson Xavier NX, on which a lightweight safety protection equipment detection model SGR-DETR is deployed. This model includes a backbone network GSConvNext-Net (parameter quantity reduced by 42.05%), a related CAS-AIFI module (fusion interaction module) (mAP@0.5 reaches 0.965), and a Lightweight-CCFM (new cross-scale feature fusion module) (computing volume reduced by 59.89%), which can achieve high-precision detection in complex scenarios such as occlusion, small targets, and dynamic lighting, with a recall rate of 0.904, mAP@0.5 of 0.963, and a real-time inference performance of 32.2 FPS, thus significantly reducing the dependence on cloud computing power; the cloud level, that is, the cloud server, which is responsible for model training optimization, multi-node data collaborative management, and long-term storage, can remotely update detection strategies and algorithm iterations, and can also create a global supervision view for large-scale construction projects.
[0217] In terms of data flow, after the raw data collected by the terminal device is processed in real time by the edge device, only key results, such as alarm information, statistical reports, etc., will be uploaded to the cloud. In this way, the network bandwidth occupancy and computing latency are significantly reduced. This architecture has many technical advantages: in terms of lightweight and real-time performance, the edge device model is designed with both reduced parameter quantity and computing volume. For example, using GSConv (lightweight depthwise separable convolution) to replace traditional convolution can adapt to low-computing-power devices and meet the millisecond-level response requirements; in terms of the robustness of complex scenarios, multi-scale feature fusion and attention enhancement technologies can effectively handle the occlusion of construction workers, the change of target size, and the interference of bad weather; in the dimension of cost and energy efficiency optimization, through local processing, the consumption of cloud resources is reduced, and the overall computing power cost is reduced by more than 50%. Looking ahead, it is planned to incorporate extreme weather data such as rain, fog, and night for training, and a dynamic adaptive module will also be developed to further improve the generalization ability of the model in a changing environment and boost the large-scale application of the "cloud-edge-device" architecture in fields such as smart construction sites and industrial inspections.
[0218] In this embodiment, as Figure 12The shown safety equipment detection system can implement the technical solutions in the above embodiments of the safety equipment detection method. Its working principle and the advantages brought are similar to those described before, and will not be repeated here.
[0219] In this embodiment, the present application can divide the functional units according to the safety equipment detection method. Each function can be assigned to different functional units respectively, or two or more functions can be integrated into a single processing unit. The above integration unit can be implemented in the form of hardware or achieved by means of software functional units. It should be noted that the division of units in the present invention is only for illustrative purposes and is only a logical division method. Other division methods can be adopted in actual applications.
[0220] In this embodiment, to achieve the principle and advantages of the safety equipment detection method, the safety equipment detection system includes a hardware architecture and / or software module that performs corresponding functions. Those skilled in the art should easily recognize that, in combination with the various schematic units and algorithm steps described in the embodiments disclosed in the present invention, the present invention can be implemented by hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or driven by computer software depends on the specific technical solution application and design constraints. Different methods can be adopted for each specific application to implement the described function, but such an implementation method should not be regarded as exceeding the scope of the present application.
Claims
1. A safety protection equipment detection method for agricultural greenhouse construction scenarios, characterized in that, It includes the following steps: S1. Obtain the safety equipment images in the agricultural greenhouse construction scenario; S2. Construct a lightweight safety equipment image detection model SGR-DETR; S3. Use the safety equipment image detection model SGR-DETR to detect the safety equipment images, obtain the detection results, and complete the detection of the safety protection equipment.
2. The safety protection equipment detection method for agricultural greenhouse construction scenarios according to claim 1, characterized in that The expression of the loss function of the safety equipment image detection model SGR-DETR is as follows: L = λ cls L CE + λ box L GIou + λ query L aux Among them, L represents the loss function of the SGR-DETR model, λ cls represents the weight coefficient of the classification loss, L CE represents the classification loss, λ box represents the weight coefficient of the bounding box regression loss, L GIou represents the regression loss, λ query represents the weight coefficient of the auxiliary loss, L aux represents the auxiliary loss, i represents the index of the predicted box, N represents the total number of predicted box indices, y i represents the true class label of the i-th predicted box, represents the class probability of the i-th predicted box, GIou represents the Generalized Intersection over Union, represents the bounding box coordinates, B gt represents the true bounding box coordinates, Hungarian_Matching represents the Hungarian algorithm operation.
3. The safety protection equipment detection method for the agricultural greenhouse construction scenario according to claim 1, characterized in that, The construction method of the safety equipment image detection model SGR-DETR is as follows: Improve on the basis of the real-time detection transformer RT-DETR, replace the basic block Basic Block of the backbone network with the GSConvNeXt Block of the Huitong convolutional block, and name it the Lingxi convolutional network GSConvNext-Net; Combine the convolutional operation with the additive self-attention mechanism CAS to construct the fused interaction module CAS-AIFI; Replace the traditional convolution with the depthwise separable convolution GSConv to construct a new cross-scale feature fusion module Lightweight-CCFM, and complete the construction of the SGR-DETR model.
4. The safety protection equipment detection method for the agricultural greenhouse construction scenario according to claim 1, characterized in that The safety equipment image detection model SGR-DETR includes: The Lingxi convolutional network GSConvNext-Net is used to perform 3×3 tandem convolutional layer processing on the safety equipment images, extract low-level features, and generate a high-resolution feature map S3 through max pooling downsampling; according to the high-resolution feature map S3, use the GSConvNeXt Block of the Huitong convolutional block to generate a middle-level feature map S4; according to the middle-level feature map S4, use the stacked GSConvNeXt Blocks of the Huitong convolutional block for processing, fuse local and global features, and generate a high-level feature map S5 through downsampling; The fused interaction module CAS-AIFI is used to achieve local-global feature complementarity based on the high-level feature map S5 through convolutional enhanced local perception and the additive self-attention mechanism, and generate a recombined feature map F5; The new cross-scale feature fusion module Lightweight-CCFM is used to perform lightweight convolution GSConv and multi-branch topology Conv3xcBlock on the high-resolution feature map S3, middle-level feature map S4, and recombined feature map F5 in parallel to extract multi-scale features, and perform channel splicing and element-wise addition on the features of different scales through adaptive weighted fusion to generate a cross-scale fused feature map Output; The decoder is used to model the relationship between objects through the self-attention mechanism based on the feature map Output in combination with the object query, generate the position and category of the prediction box, and output the detection results of the construction workers wearing safety helmets and reflective vests.
5. The safety protection equipment detection method for the agricultural greenhouse construction scenario according to claim 4, characterized in that, The expression of the high-level feature map S5 is as follows: F out = Conv 1×1 (GRN(GELU(F mid ))) Among them, Stacked_Blocks represents the processing of stacked Huitong convolutional block GSConvNeXt Block, R represents the real number space, H represents the height of the safety equipment image, W represents the width of the safety equipment image, D3 represents the number of channels of the high-level feature map S5, MaxPool represents the max pooling operation, F out represents the feature map output by the convolutional module, Conv 1×1 represents the 1×1 convolutional operation, D2 represents the number of channels of the middle-level feature map S4, GRN represents global response normalization, GELU represents the Gaussian error linear unit activation function, F mid represents the intermediate feature map in the multi-branch topology Conv3xcBlock, C1 represents the intermediate feature map after three 3×3 cascaded convolutional operations, and D1 represents the number of channels of the high-resolution feature map S3.
6. The safety protection equipment detection method for the agricultural greenhouse construction scenario according to claim 5, characterized in that The expression of the recombined feature map F5 is as follows: Sim(Q,K) = Φ(Q) + Φ(K) Φ(Q) = Sigmoid(Conv 3×3 (Q)) Φ(K) = Sigmoid(Conv 3×3 (K)) Q = W q ·Flatten(S5) K = W k ·Flatten(S5) V = W v ·Flatten(S5) Among them, Reshape represents the two-dimensional feature map for sequence recombination, O represents the output result of additive self-attention, Softmax represents the Softmax activation function, Sim(Q, K) represents the additive self-attention score, Φ(Q) and Φ(K) respectively represent the functions for context mapping of Query and Key, Sigmoid represents the Sigmoid activation function, Conv 3×3 represents the 3×3 convolution operation, W q represents the Query weight matrix, Flatten represents flattening the feature map into a sequence, W k represents the Key weight matrix, W v represents the Value weight matrix, Q, K, and V respectively represent Query, Key, and Value obtained through linear transformation. Query represents the query vector at each position in the current input sequence, Key represents the key vector at each position in the input sequence, and Value represents the actual feature value at each position in the input sequence.
7. The safety protection equipment detection method for the agricultural greenhouse construction scenario according to claim 6, wherein The expression of the feature map Output is as follows: Among them, GSConv represents a lightweight depthwise separable convolution operation, and Upsample represents an upsampling operation. represents the feature map after lightweight convolution processing. represents the intermediate feature map after lightweight convolution processing. represents the feature map after lightweight convolution processing.
8. The safety protection equipment detection method for the agricultural greenhouse construction scenario according to claim 7, characterized in that The expressions of the position and category of the prediction box are as follows respectively: Decoder_Output = MultiHeadAttention(Q obj , Output, Output) Among them, denote the bounding box coordinates of the predicted position, denote the classification scores of the predicted classes, W reg denote the weight matrix of the regression branch, Decoder_Output denotes the output features of the Transformer decoder, W cls denote the weight matrix of the classification branch, MultiHeadAttention denotes the multi-head self-attention mechanism, Q obj denote the target query, Learnable_Embedding denotes the learnable position encoding, and d denotes the feature dimension.
9. A safety protection equipment detection system for the construction scenario of agricultural greenhouses, characterized in that, The safety protection equipment detection method for executing the safety protection equipment detection method described in any one of claims 1-8 includes: The first processing module is used to obtain the safety equipment images in the construction scenario of agricultural greenhouses; The second processing module is used to construct a lightweight safety equipment image detection model SGR-DETR; The third processing module is used to detect the safety equipment images by using the safety equipment image detection model SGR-DETR to obtain the detection results and complete the detection of safety protection equipment.
Citation Information
Cited By
Protective equipment wearing detection method based on deep learning, electronic equipment and product
CN121582971A
Deep learning-based protective equipment wearing detection method, electronic device and product
CN121582971B
