Training method and device of safety equipment detection model, equipment and storage medium
By introducing the self -attention mechanism and depth separation convolutional module in the safety equipment detection model, weighted and integrated the feature map, and solved the problem of the existing lightweight target detection model. Higher detection accuracy and performance.
Patent Information
- Application Number
- CN202411238410.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2025-01-28
AI Technical Summary
The existing light-weight object detection model has low detection accuracy and low detection performance at the power operation site.
Put forward a training method for safety equipment detection models. By obtaining the sample image, preliminary feature extraction, using the self -attention mechanism and depth separation convolutional module to weigh the feature maps, combine the feature fusion module for adaptive fusion, and finally based on the basis of the characteristic fusion module. The difference between the prediction results and the actual results is trained.
Improve the detection accuracy and detection performance, be able to maintain high -quality detection performance under the condition of limited computing power, and it is suitable for real -time safety monitoring scenarios.
Smart Images

Figure CN119380261A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of target detection, and in particular to a training method, apparatus, computer device, computer-readable storage medium and computer program product for a safety equipment detection model. Background Art
[0002] Power operation is a high-risk operation with various potential safety risks. At the power operation site, safety equipment detection is a key factor to ensure the safety of workers and equipment. At present, a power operation safety detection method based on lightweight network is proposed. By designing a lightweight target detection model to perform target detection at the power operation site, real-time and efficient monitoring of the power operation site can be achieved, which improves the monitoring efficiency of the power operation site.
[0003] However, existing lightweight object detection models suffer from low detection accuracy and poor detection performance. Summary of the invention
[0004] Based on this, it is necessary to provide a training method, device, computer equipment, computer-readable storage medium and computer program product for a safety equipment detection model that can improve detection accuracy and detection performance in response to the above-mentioned technical problems.
[0005] In a first aspect, the present application provides a method for training a safety equipment detection model, comprising:
[0006] Obtaining sample images; the sample images are annotated with actual safety equipment detection results in power operation scenarios;
[0007] The sample image is input into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features;
[0008] Input the initial image features into a plurality of depthwise separable convolution modules with a self-attention mechanism preset in the safety equipment detection model to be trained, obtain feature maps of different sizes through each depthwise separable convolution module, obtain the attention weight of each feature map through the self-attention mechanism, and weight each feature map using the attention weight to obtain weighted feature maps of different sizes;
[0009] The weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the fused feature map;
[0010] According to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model.
[0011] In one of the embodiments, the feature fusion module includes a cross-level feature aggregation subunit and a squeeze excitation subunit;
[0012] The weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, including:
[0013] The weighted feature maps of different sizes are input into the cross-level feature aggregation subunit for pixel-level splicing to obtain the weighted feature maps of different sizes after splicing, and the weighted feature maps of different sizes after splicing are convolved using the pre-set convolution kernel parameters to obtain the fused semantic features;
[0014] The squeeze excitation subunit obtains an initial fused feature map according to the weighted feature maps of different sizes after splicing and the channel attention weights corresponding to the weighted feature maps of different sizes after splicing;
[0015] A fused feature map is obtained according to the fused semantic features and the initial fused feature map.
[0016] In one embodiment, the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the fused feature map, including:
[0017] Input the fused feature map into the global pooling module in the safety equipment detection model to be trained to obtain a global feature vector;
[0018] The global feature vector is input into the main detection module with a preset self-attention mechanism, and the attention weight matrix corresponding to the global feature vector is obtained through the self-attention mechanism. The attention weight matrix is used to weight the global feature vector in different dimensions to obtain a weighted global feature vector;
[0019] The safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the weighted global feature vector.
[0020] In an exemplary embodiment, the safety equipment detection model to be trained further includes an auxiliary detection module and a main detection module;
[0021] According to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model, including:
[0022] The auxiliary detection module obtains a first predicted image feature according to the weighted feature maps of different sizes after splicing and the weighted global feature vector of the first part, and the main detection module obtains a second predicted image feature according to the weighted global feature vector other than the weighted global feature vector of the first part;
[0023] Obtaining a predicted safety equipment detection result according to the first predicted image feature and the second predicted image feature;
[0024] Based on the difference and a quantization error loss function preset for the safety equipment detection model to be trained, a corresponding first model loss value is obtained, and based on the difference and a safety equipment detection loss function preset for the safety equipment detection model to be trained, a corresponding second model loss value is obtained;
[0025] According to the first model loss value and the second model loss value, the model parameters of the safety equipment detection model to be trained are adjusted accordingly until both the quantization error loss function and the safety equipment detection loss function converge, thereby obtaining a trained safety equipment detection model.
[0026] In one embodiment, the quantization error loss function is composed of a target existence loss function and a target classification loss function; the predicted safety equipment detection result includes a predicted safety equipment position and a predicted safety equipment category; the actual safety equipment detection result includes an actual safety equipment position and an actual safety equipment category;
[0027] Based on the difference and a quantization error loss function preset for the safety equipment detection model to be trained, a corresponding first model loss value is obtained, including:
[0028] Based on the difference between the predicted position of the safety equipment and the actual position of the safety equipment, and the target existence loss function, a corresponding target existence loss value is obtained;
[0029] According to the difference between the predicted category of the safety equipment and the actual category of the safety equipment, and the target classification loss function, the corresponding target classification loss value is obtained;
[0030] Get the pre-set weight coefficients, linear terms and adaptive weights for the quantization error loss function; the weight coefficients are used to balance the importance of the target existence loss value and the target classification loss value, and the adaptive weights are used to dynamically adjust the weights of the target existence loss value and the target classification loss value;
[0031] Based on the weight coefficient, the linear term and the adaptive weight, the target existence loss value and the target classification loss value are weighted to obtain the first model loss value.
[0032] In an exemplary embodiment, obtaining a corresponding second model loss value based on the difference and a safety equipment detection loss function preset for the safety equipment detection model to be trained includes:
[0033] Obtaining a sample weight pre-set for each sample image, and obtaining an application weight set for each category of sample images;
[0034] The predicted category of safety equipment, the actual category of safety equipment, the sample weight and the application weight are multiplied to obtain the corresponding loss value of the third model;
[0035] A weighted summation process is performed on multiple third model loss values to obtain a second model loss value.
[0036] In one embodiment, obtaining a sample image includes:
[0037] Collect raw images and raw videos from power operation sites;
[0038] The video frames contained in the original video are saved to obtain the video frame images corresponding to the original video;
[0039] The original image and the video frame image are combined to obtain the original sample image, and the original sample image is annotated with the actual safety equipment detection result to obtain the sample image.
[0040] In a second aspect, the present application also provides a training device for a safety equipment detection model, comprising:
[0041] An image acquisition module is used to acquire sample images; the sample images are annotated with actual safety equipment detection results in power operation scenarios;
[0042] A feature extraction module is used to input the sample image into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features;
[0043] A feature weighting module is used to input the initial image features into a plurality of depthwise separable convolution modules preset with a self-attention mechanism in the safety equipment detection model to be trained, obtain feature maps of different sizes through each depthwise separable convolution module, obtain the attention weight of each feature map through the self-attention mechanism, and weight each feature map using the attention weight to obtain weighted feature maps of different sizes;
[0044] A result prediction module is used to input weighted feature maps of different sizes into a feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains a predicted safety equipment detection result of the sample image based on the fused feature map;
[0045] The model training module is used to perform model training on the safety equipment detection model to be trained according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, so as to obtain the trained safety equipment detection model.
[0046] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0047] Obtaining sample images; the sample images are annotated with actual safety equipment detection results in power operation scenarios;
[0048] The sample image is input into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features;
[0049] Input the initial image features into a plurality of depthwise separable convolution modules with a self-attention mechanism preset in the safety equipment detection model to be trained, obtain feature maps of different sizes through each depthwise separable convolution module, obtain the attention weight of each feature map through the self-attention mechanism, and weight each feature map using the attention weight to obtain weighted feature maps of different sizes;
[0050] The weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the fused feature map;
[0051] According to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model.
[0052] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:
[0053] Obtaining sample images; the sample images are annotated with actual safety equipment detection results in power operation scenarios;
[0054] The sample image is input into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features;
[0055] Input the initial image features into a plurality of depthwise separable convolution modules with a self-attention mechanism preset in the safety equipment detection model to be trained, obtain feature maps of different sizes through each depthwise separable convolution module, obtain the attention weight of each feature map through the self-attention mechanism, and weight each feature map using the attention weight to obtain weighted feature maps of different sizes;
[0056] The weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the fused feature map;
[0057] According to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model.
[0058] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:
[0059] Obtaining sample images; the sample images are annotated with actual safety equipment detection results in power operation scenarios;
[0060] The sample image is input into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features;
[0061] Input the initial image features into a plurality of depthwise separable convolution modules with a self-attention mechanism preset in the safety equipment detection model to be trained, obtain feature maps of different sizes through each depthwise separable convolution module, obtain the attention weight of each feature map through the self-attention mechanism, and weight each feature map using the attention weight to obtain weighted feature maps of different sizes;
[0062] The weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the fused feature map;
[0063] According to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model.
[0064] The training method, device, computer equipment, computer-readable storage medium and computer program product of the above-mentioned safety equipment detection model obtain a sample image marked with an actual safety equipment detection result, input the sample image into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features, and inputs the initial image features into multiple depthwise separable convolution modules preset with a self-attention mechanism in the safety equipment detection model to be trained, and obtains feature maps of different sizes through the depthwise separable convolution modules, and obtains the attention weight of each feature map through the self-attention mechanism, and weights each feature map using the attention weight to obtain weighted feature maps of different sizes, and then inputs the weighted feature maps of different sizes into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image based on the fused feature map, and finally, according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model. By adding a self-attention mechanism and a feature fusion module to the model results, the detection accuracy of the model is improved by weighting and fusing the feature maps, and the model can still maintain high-quality detection performance even when computing power is limited. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0066] FIG1 is a diagram of an application environment of a training method for a safety equipment detection model in one embodiment;
[0067] FIG2 is a schematic diagram of a flow chart of a method for training a safety equipment detection model in one embodiment;
[0068] FIG3 is a schematic diagram of a process for obtaining a fusion feature map in one embodiment;
[0069] FIG4 is a schematic diagram of a process for obtaining predicted safety equipment detection results in another embodiment;
[0070] FIG5 is a schematic diagram of a model structure of a safety equipment detection model in another embodiment;
[0071] FIG6 is a block diagram of a training device for a safety equipment detection model in one embodiment;
[0072] FIG. 7 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0073] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0074] The training method of the safety equipment detection model provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 obtains a sample image marked with the actual safety equipment detection result in the power operation scenario through the terminal 102, and then inputs the sample image into the safety equipment detection model to be trained. The backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features, and then inputs the initial image features into a plurality of depthwise separable convolution modules preset with a self-attention mechanism in the safety equipment detection model to be trained, and obtains feature maps of different sizes through the depthwise separable convolution modules, and obtains the attention weight of each feature map through the self-attention mechanism, and weights each feature map using the attention weight to obtain weighted feature maps of different sizes, and then inputs the weighted feature maps of different sizes into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image based on the fused feature map, and finally, according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. The server 104 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. Safety equipment can be safety gloves, safety helmets, insulating boots, etc., which are used to protect the personal safety of workers at power operation sites.
[0075] In an exemplary embodiment, as shown in FIG2 , a training method for a safety equipment detection model is provided, and the method is applied to the server 104 in FIG1 as an example for explanation, including the following steps S201 to S205 . Among them:
[0076] Step S201, obtaining a sample image; the sample image is annotated with actual safety equipment detection results in the power operation scene.
[0077] Step S202: input the sample image into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features.
[0078] Among them, the sample image can be understood as a photo taken of the workers at the power operation site, with the inspection results of the installation equipment equipped on the workers marked in the photo; the safety equipment detection model is a network model with a lightweight network structure. The backbone module includes convolutional layers and activation layers. The convolutional layer is used for feature extraction, and the activation layer is used to introduce nonlinearity. The combination can better understand the complex features in the image.
[0079] For example, the server 104 obtains a sample image from the terminal 102 via the network, and inputs the sample image into the safety equipment detection model to be trained. The backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features, thereby laying a data foundation for subsequent multi-branch feature extraction.
[0080] In step S203, the initial image features are input into a plurality of depthwise separable convolution modules with a self-attention mechanism preset in the safety equipment detection model to be trained, feature maps of different sizes are obtained through each depthwise separable convolution module, and the attention weight of each feature map is obtained through the self-attention mechanism, and each feature map is weighted by the attention weight to obtain weighted feature maps of different sizes.
[0081] Among them, the depthwise separable convolution module can be understood as a convolution method that reduces the computational complexity and the number of parameters by decomposing the standard convolution operation into two simpler steps; the attention weight can be understood as a mechanism in deep learning that helps the model automatically focus on more important information in the input data.
[0082] Optionally, the server 104 inputs the initial image features into a plurality of depthwise separable convolution modules with a self-attention mechanism preset in the safety equipment detection model to be trained, obtains feature maps of different sizes through each depthwise separable convolution module, obtains the attention weight of each feature map through the self-attention mechanism, and weights each feature map using the attention weight to obtain weighted feature maps of different sizes. By designing the attention mechanism and the depthwise separable convolution module, the computational complexity of the model is reduced, and it can be efficiently deployed in a computing power-constrained environment while maintaining a high detection accuracy.
[0083] In step S204, the weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image based on the fused feature map.
[0084] Among them, fusion feature maps can be understood as a common technique in deep learning, especially when processing multimodal data (such as images and text, multiple sensor data, etc.). By combining feature maps from different sources or different levels, the model can obtain richer information.
[0085] For example, the server 104 inputs the weighted feature maps at different sizes into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image based on the fused feature map. By designing a feature fusion module to obtain a plurality of weighted feature maps at different sizes for adaptive fusion, the feature focus of the model is further enhanced, and the key protective equipment details can be finely identified, the operational safety risk factors can be highly accurately identified, and a data foundation is laid for subsequent model training.
[0086] Step S205 , performing model training on the safety equipment detection model to be trained according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, to obtain a trained safety equipment detection model.
[0087] Optionally, the server 104 obtains a corresponding model loss value based on the difference between the predicted safety equipment detection result and the actual safety equipment detection result and the loss function pre-set for the safety equipment detection model to be trained, and performs model training on the model parameters of the safety equipment detection model to be trained based on the model loss value to obtain a trained safety equipment detection model. By adjusting and training the model parameters of the model, the detection effect of the model is improved and the credibility of the model output result is enhanced.
[0088] In the training method of the above-mentioned safety equipment detection model, a sample image annotated with the actual safety equipment detection result is obtained, and the sample image is input into the safety equipment detection model to be trained. The backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features, and the initial image features are input into a plurality of depthwise separable convolution modules preset with a self-attention mechanism in the safety equipment detection model to be trained. Feature maps of different sizes are obtained through the depthwise separable convolution modules, and the attention weight of each feature map is obtained through the self-attention mechanism. The feature maps are weighted using the attention weight to obtain weighted feature maps of different sizes. After that, the weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image based on the fused feature map. Finally, according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model. By adding a self-attention mechanism and a feature fusion module to the model results, the detection accuracy of the model is improved by weighting and fusing the feature maps, and the model can still maintain high-quality detection performance even when computing power is limited.
[0089] In an exemplary embodiment, as shown in FIG3 , the feature fusion module includes a cross-level feature aggregation subunit and a squeeze excitation subunit, and the weighted feature maps of different sizes are input into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, including steps S301 to S303. Wherein:
[0090] In step S301, weighted feature maps of different sizes are input into the cross-level feature aggregation subunit for pixel-level splicing to obtain weighted feature maps of different sizes after splicing, and convolution operation is performed on the weighted feature maps of different sizes after splicing using pre-set convolution kernel parameters to obtain fused semantic features.
[0091] Among them, the cross-level feature aggregation subunit can be understood as a unit that combines feature maps from different sources or different levels, the convolution kernel parameters can be understood as the length and width of the convolution layer; the fused semantic features can be understood as the text information features in the image.
[0092] For example, server 104 inputs weighted feature maps of different sizes into the cross-level aggregation subunit to stitch the weighted feature maps at the pixel level to obtain stitched weighted feature maps of different sizes, and uses pre-set convolution kernel parameters to form a convolution layer, and performs convolution operations on the stitched weighted feature maps of different sizes to obtain fused semantic features, which further enhances the model's understanding of the sample image and lays a data foundation for the subsequent generation of fused feature maps.
[0093] In step S302, the squeeze excitation subunit obtains an initial fused feature map according to the weighted feature maps of different sizes after splicing and the channel attention weights corresponding to the weighted feature maps of different sizes after splicing.
[0094] Step S303, obtaining a fused feature map according to the fused semantic features and the initial fused feature map.
[0095] Among them, the squeeze excitation subunit can be understood as a mechanism to enhance the performance of neural networks, by dynamically adjusting the channel weights of feature maps to increase the model's attention to important features.
[0096] Optionally, the squeeze excitation subunit obtains an initial fused feature map based on the weighted feature maps of different sizes after splicing and the channel attention weights corresponding to the weighted feature maps of different sizes after splicing, and finally combines the fused semantic feature map and the initial fused map to obtain a fused feature map. By designing the squeeze excitation subunit, the model's attention to important features is further enhanced, thereby improving the feature focus of the generated fused feature map, which is beneficial to improving the output effect of the model.
[0097] In an exemplary embodiment, as shown in FIG4 , the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the fusion feature map, including steps S401 to S403. Among them:
[0098] Step S401: input the fused feature map into the global pooling module in the safety equipment detection model to be trained to obtain a global feature vector.
[0099] Among them, the global pooling module can be understood as compressing the feature dimension of the fused feature map, performing global feature extraction, outputting a feature vector of fixed dimension, and preventing overfitting of the model.
[0100] For example, server 104 inputs the fused feature map into the data pooling module in the safety equipment detection model to be trained, compresses the feature dimension of the fused feature map, and further performs global feature extraction to output a global feature vector of a fixed dimension. The design of the global pooling module simplifies the network structure and enhances the robustness of the model, and lays a data foundation for the subsequent generation of predicted safety equipment detection results.
[0101] Step S402: input the global feature vector into the main detection module with a preset self-attention mechanism, obtain the attention weight matrix corresponding to the global feature vector through the self-attention mechanism, and use the attention weight matrix to weight the global feature vector in different dimensions to obtain a weighted global feature vector.
[0102] Step S403 : The safety equipment detection model to be trained obtains a predicted safety equipment detection result of the sample image according to the weighted global feature vector.
[0103] Among them, the main detection module can include a fully connected layer with an activation function and a fully connected output layer; the attention weight matrix can be understood as allowing the model to selectively focus on different parts of the input instead of treating all parts equally. Since the global feature vector is composed of multiple feature vectors, it is necessary to use the attention weight matrix to extract the most critical parts.
[0104] Optionally, the server 104 inputs the global feature vector into a main detection module with a preset self-attention mechanism, obtains the attention weight matrix corresponding to the global feature vector through the self-attention mechanism, multiplies the global feature vector and the attention weight matrix, and then weights the result after the multiplication at different temperatures to obtain a weighted global feature vector, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the weighted global feature vector. The above further enhances the model's understanding of the image features of the sample image, thereby improving the credibility of the model output result.
[0105] In one embodiment, the safety equipment detection model to be trained further includes an auxiliary detection module and a main detection module;
[0106] According to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, the safety equipment detection model to be trained is trained to obtain a trained safety equipment detection model, including: the auxiliary detection module obtains the first predicted image feature according to the weighted feature maps at different sizes after splicing and the weighted global feature vector of the first part, and the main detection module obtains the second predicted image feature according to the weighted global feature vector other than the weighted global feature vector of the first part; the predicted safety equipment detection result is obtained according to the first predicted image feature and the second predicted image feature; based on the difference and the quantization error loss function pre-set for the safety equipment detection model to be trained, a corresponding first model loss value is obtained, and based on the difference and the safety equipment detection loss function pre-set for the safety equipment detection model to be trained, a corresponding second model loss value is obtained; according to the first model loss value and the second model loss value, the model parameters of the safety equipment detection model to be trained are adjusted accordingly until the quantization error loss function and the safety equipment detection loss function converge, so as to obtain the trained safety equipment detection model.
[0107] Among them, the auxiliary detection module consists of a global pooling layer and a fully connected layer; the weighted global feature vector in the first part can be understood as a randomly selected weighted global feature vector.
[0108] For example, the auxiliary detection module obtains the first predicted image feature according to the weighted feature maps of different sizes after splicing and the weighted global feature vector of the first part, and the main detection model obtains the second predicted image feature according to the weighted global feature vector other than the weighted global feature vector of the first part, and then obtains the final predicted safety equipment detection result based on the first predicted image feature and the second predicted image feature, and then obtains the corresponding first model loss value based on the difference and the quantization error loss function pre-set for the safety equipment detection model to be trained, and obtains the corresponding second model loss value based on the difference and the safety equipment detection loss function pre-set for the safety equipment detection model to be trained, and finally weighted sums the first model loss value and the second model loss value according to the preset weight coefficient to obtain the final model loss value, and adjusts the model parameters of the safety equipment detection model to be trained according to the model loss value, until the quantization error loss function and the safety equipment detection loss function converge, and obtains the trained safety equipment detection model. The enhanced auxiliary detection module enhances the robustness of the model, and finally adjusts the model parameters according to the first model loss value and the second model loss value, thereby improving the precision of the model parameter adjustment.
[0109] In one embodiment, the quantization error loss function is composed of a target existence loss function and a target classification loss function; the predicted safety equipment detection result includes a predicted safety equipment position and a predicted safety equipment category; the actual safety equipment detection result includes an actual safety equipment position and an actual safety equipment category;
[0110] Based on the difference and a quantization error loss function preset for the safety equipment detection model to be trained, a corresponding first model loss value is obtained, including:
[0111] Based on the difference between the predicted position of the safety equipment and the actual position of the safety equipment, and the target existence loss function, a corresponding target existence loss value is obtained;
[0112] According to the difference between the predicted category of the safety equipment and the actual category of the safety equipment, and the target classification loss function, the corresponding target classification loss value is obtained;
[0113] Get the pre-set weight coefficients, linear terms and adaptive weights for the quantization error loss function; the weight coefficients are used to balance the importance of the target existence loss value and the target classification loss value, and the adaptive weights are used to dynamically adjust the weights of the target existence loss value and the target classification loss value;
[0114] Based on the weight coefficient, the linear term and the adaptive weight, the target existence loss value and the target classification loss value are weighted to obtain the first model loss value.
[0115] Optionally, a quantization error loss function is designed and optimized as follows:
[0116] 1. Design the target existence loss function and use the smooth L1 loss function to measure the position error of the detection box. Assume that The detection box predicted by the model, is the real target box, then the target existence loss can be expressed as:
[0117]
[0118] 2. Design the target classification loss function and use the cross entropy loss function to measure the classification accuracy of the model for the target category. Then the target classification loss can be expressed as:
[0119]
[0120] Where N is the number of samples, C is the number of categories, is the actual category label, is the class probability predicted by the model;
[0121] The quantization error loss is expressed as a combination of the target existence loss and the target classification loss, that is, the quantization target loss function is expressed as:
[0122]
[0123] in is the weight coefficient used to balance the importance of the two loss terms;
[0124] 3. By introducing a linear term and adaptive weights, the original target existence loss and target classification loss can be combined and optimized, and the optimized expression is:
[0125]
[0126] This optimization introduces a linear term ,in is the coefficient of the adaptive weight, and is an adaptive weight, which is used to adjust the relative importance of target existence loss and target classification loss. By introducing this linear term and adaptive weight, the weights of target existence loss and target classification loss can be dynamically adjusted according to the performance of the model during training, thereby improving the training effect and performance of the model.
[0127] In one embodiment, based on the difference and a safety equipment detection loss function preset for the safety equipment detection model to be trained, obtaining a corresponding second model loss value includes:
[0128] Obtain the sample weights pre-set for each sample image, and obtain the application weights set for each category of sample images; multiply the predicted category of safety equipment, the actual category of safety equipment, the sample weights, and the application weights to obtain the corresponding third model loss value; perform weighted summation on multiple third model loss values to obtain the second model loss value.
[0129] For example, the safety equipment detection loss function is designed and optimized as follows:
[0130] 1. Design a safety equipment detection loss function. Each category is represented by c, and the corresponding true label is , the probability distribution predicted by the model is , then the safety equipment detection loss function can be expressed as:
[0131]
[0132] Where N is the number of samples, C is the number of categories, is the true label of the cth category in the ith sample, is the probability of the cth category in the ith sample predicted by the model.
[0133] 2. Apply weights to each category c by introducing category weight adjustment and sample weighting , considering the imbalance problem of positive and negative samples, apply weights to each sample i Therefore, the optimized safety equipment detection loss function can be expressed as:
[0134]
[0135] Where N is the number of samples, C is the number of categories, is the true label of category c in the i-th sample, is the probability of category c predicted by the model. The loss function designed in this way combines category weight adjustment and sample weighting. During use, it can better cope with the possible category imbalance and sample imbalance in safety equipment detection, thereby improving the performance and robustness of the model.
[0136] In one embodiment, obtaining a sample image includes:
[0137] Original images and original videos are collected from the power operation site; video frames contained in the original video are saved to obtain video frame images corresponding to the original video; original images and video frame images are combined to obtain original sample images, and the original sample images are annotated with actual safety equipment detection results to obtain sample images.
[0138] For example, pictures and videos are collected from power operation sites; the collected videos are processed by saving the images frame by frame. If the motion amplitude of the characters in the video is small, the video is first processed at double speed and then the images are saved frame by frame; the collected pictures are preliminarily manually screened and integrated with the picture files obtained after video processing to form a comprehensive data set of power operation scenes; based on the comprehensive data set, data enhancement technology is applied to further process it to obtain diversified high-quality data samples; after processing with data enhancement technology, the safety gloves, helmets and insulating boots of the workers at the power operation site in the images of the data set are annotated; the data in the data set is divided into a training set and a validation set in a ratio of 8:2.
[0139] By performing image processing on the pre-collected images in the above manner, not only the number of images used for model training is increased, but also the validity and availability of sample images are improved, thereby improving the training results of the safety equipment detection model.
[0140] In an exemplary embodiment, as shown in FIG5 , a model architecture diagram of a safety equipment detection model is provided, wherein the model includes a backbone module, a multi-branch feature extraction module, a feature fusion module, a global pooling module, a main detection module, and an auxiliary detection module:
[0141] The backbone module consists of an initial convolutional layer and a Mish activation layer. The multi-branch feature extraction module contains three parallel depth-wise separable convolutional branches, and a self-attention mechanism is added to each branch. The feature fusion module is formed by adding a cross-level feature aggregation submodule before the squeeze excitation submodule. The function of the global pooling module is implemented by the global average pooling layer. The main detection module includes a fully connected layer (with Mish activation) and a fully connected output layer with a self-attention mechanism, while the auxiliary detection module consists of a global pooling and a fully connected layer.
[0142] Based on this architecture, a specific implementation method for training a safety equipment detection model is given:
[0143] 1. The input image data first enters the backbone module for preliminary feature extraction, and then enters the feature extraction module for processing; the image data is annotated with the safety equipment detection results in the power operation scenario.
[0144] 2. Next, the multi-branch feature extraction module gradually extracts more abstract and semantic features. Each branch outputs feature maps of different sizes to capture the feature information of the input image at different scales. Combined with the self-attention mechanism, the extracted feature maps are weighted to improve the expressiveness of the features.
[0145] 3. The output feature maps of each branch of the multi-branch feature extraction module are fed to the feature fusion module for adaptive fusion. Prior to this, the feature maps of each branch are spliced at the pixel level through the added cross-level feature aggregation submodule, and the convolution kernel is used to fuse the high-level and low-level semantic features across scales.
[0146] 4. The fused feature map is passed through the global pooling module to obtain the global feature vector.
[0147] 5. After the global feature vector is weighted by the self-attention mechanism of the main detection module, a part of it enters the auxiliary detection module, obtains features from the output of the cross-level feature aggregation submodule, generates auxiliary detection output, plays a role of supervision and regularization in the training stage, and the other part remains in the main detection module.
[0148] 6. After entering the main detection module, the final result output is obtained through the fully connected layer.
[0149] Compared with the prior art, this application has the following advantages:
[0150] (1) Lightweight design, optimized for RISC / PI processors, enabling fast reasoning on edge devices without relying on complex transmission and cloud servers.
[0151] (2) The multi-branch self-attention mechanism and cross-level feature aggregation can accurately identify the details of key protective equipment and identify operational safety risk factors with high precision.
[0152] (3) Designs such as attention weighting and depthwise separable convolution reduce the amount of computation and can be efficiently deployed in environments with limited computing power while maintaining high detection accuracy.
[0153] (4) The auxiliary detection branch plays a supervisory and regularization role, further improving network performance.
[0154] (5) The overall lightweight and compact design is suitable for real-time safety monitoring scenarios, can detect risks in a timely manner and respond quickly, and provide real-time and accurate safety solutions for power operations.
[0155] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0156] Based on the same inventive concept, the embodiment of the present application also provides a training device for a safety equipment detection model for implementing the training method for the safety equipment detection model involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the embodiments of the training device for one or more safety equipment detection models provided below can refer to the limitations of the training method for the safety equipment detection model above, and will not be repeated here.
[0157] In an exemplary embodiment, as shown in FIG6 , a training device for a safety equipment detection model is provided, comprising: an image acquisition module 601, a feature extraction module 602, a feature weighting module 603, a result prediction module 604 and a model training module 605, wherein:
[0158] The image acquisition module 601 is used to acquire sample images; the sample images are annotated with actual safety equipment detection results in power operation scenarios.
[0159] The feature extraction module 602 is used to input the sample image into the safety equipment detection model to be trained, and the backbone module in the safety equipment detection model to be trained performs preliminary feature extraction based on the sample image to obtain initial image features.
[0160] The feature weighting module 603 is used to input the initial image features into multiple depthwise separable convolution modules with self-attention mechanisms preset in the safety equipment detection model to be trained, obtain feature maps of different sizes through each depthwise separable convolution module, and obtain the attention weight of each feature map through the self-attention mechanism, and weight each feature map using the attention weight to obtain weighted feature maps of different sizes.
[0161] The result prediction module 604 is used to input the weighted feature maps of different sizes into the feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image based on the fused feature map.
[0162] The model training module 605 is used to perform model training on the safety equipment detection model to be trained according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, so as to obtain a trained safety equipment detection model.
[0163] In one embodiment, the feature fusion module includes a cross-level feature aggregation subunit and a squeeze excitation subunit; the result prediction module 604 is also used to input weighted feature maps of different sizes into the cross-level feature aggregation subunit for pixel-level splicing to obtain weighted feature maps of different sizes after splicing, and use pre-set convolution kernel parameters to perform convolution operations on the weighted feature maps of different sizes after splicing to obtain fused semantic features; the squeeze excitation subunit obtains an initial fused feature map based on the weighted feature maps of different sizes after splicing and the channel attention weights corresponding to the weighted feature maps of different sizes after splicing; and obtains a fused feature map based on the fused semantic features and the initial fused feature map.
[0164] In one embodiment, the result prediction module 604 is further used to input the fused feature map into the global pooling module in the safety equipment detection model to be trained to obtain a global feature vector; input the global feature vector into the main detection module with a preset self-attention mechanism, obtain the attention weight matrix corresponding to the global feature vector through the self-attention mechanism, and use the attention weight matrix to weight the global feature vector in different dimensions to obtain a weighted global feature vector; the safety equipment detection model to be trained obtains the predicted safety equipment detection result of the sample image according to the weighted global feature vector.
[0165] In an exemplary embodiment, the safety equipment detection model to be trained further includes an auxiliary detection module and a main detection module, and the model training module 605 further includes:
[0166] The feature prediction submodule is used for the auxiliary detection module to obtain the first predicted image feature based on the weighted feature maps at different sizes after splicing and the weighted global feature vector of the first part, and the main detection module to obtain the second predicted image feature based on the weighted global feature vector other than the weighted global feature vector of the first part.
[0167] The result prediction submodule is used to obtain a predicted safety equipment detection result according to the first predicted image feature and the second predicted image feature.
[0168] The loss value acquisition submodule is used to obtain the corresponding first model loss value based on the difference and the quantization error loss function pre-set for the safety equipment detection model to be trained, and to obtain the corresponding second model loss value based on the difference and the safety equipment detection loss function pre-set for the safety equipment detection model to be trained.
[0169] The model training submodule is used to adjust the model parameters of the safety equipment detection model to be trained according to the first model loss value and the second model loss value, until the quantization error loss function and the safety equipment detection loss function converge, thereby obtaining the trained safety equipment detection model.
[0170] In one embodiment, the quantization error loss function is composed of a target existence loss function and a target classification loss function; the predicted safety equipment detection result includes a predicted safety equipment position and a predicted safety equipment category; the actual safety equipment detection result includes an actual safety equipment position and an actual safety equipment category;
[0171] The loss value acquisition submodule is further used to obtain the corresponding target existence loss value based on the difference between the predicted position of the safety equipment and the actual position of the safety equipment, and the target existence loss function; obtain the corresponding target classification loss value according to the difference between the predicted category of the safety equipment and the actual category of the safety equipment, and the target classification loss function; obtain the weight coefficient, linear term and adaptive weight pre-set for the quantization error loss function; the weight coefficient is used to balance the importance of the target existence loss value and the target classification loss value, and the adaptive weight is used to dynamically adjust the weight of the target existence loss value and the target classification loss value; based on the weight coefficient, linear term and adaptive weight, the target existence loss value and the target classification loss value are weighted to obtain the first model loss value.
[0172] In an exemplary embodiment, the loss value acquisition submodule is further used to obtain the sample weights pre-set for each sample image, and to obtain the application weights set for each category of sample images; to multiply the predicted safety equipment category, the actual safety equipment category, the sample weights, and the application weights to obtain the corresponding third model loss value; and to perform weighted summation on multiple third model loss values to obtain the second model loss value.
[0173] In one embodiment, the image acquisition module 601 is further used to collect original images and original videos from the power operation site; save the video frames contained in the original video to obtain the video frame images corresponding to the original video; combine the original images and the video frame images to obtain the original sample images, and annotate the original sample images with the actual safety equipment detection results to obtain the sample images.
[0174] Each module in the training device of the safety equipment detection model can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0175] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG7. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store sample image data, loss function, original video data, and original image data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a training method for a safety equipment detection model is implemented.
[0176] Those skilled in the art will understand that the structure shown in FIG. 7 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0177] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the training method of the safety equipment detection model of the above embodiment is implemented.
[0178] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the training method of the safety equipment detection model of the above embodiment is implemented.
[0179] In one embodiment, a computer program product is provided, including a computer program, which implements the training method of the safety equipment detection model of the above embodiment when executed by a processor.
[0180] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0181] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0182] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0183] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A training method for a safety equipment detection model, characterized in that: The method comprises: Acquire a sample image; the sample image is annotated with actual safety equipment detection results in a power operation scenario; Inputting the sample image into the safety equipment detection model to be trained, and performing preliminary feature extraction by a backbone module in the safety equipment detection model to be trained based on the sample image to obtain initial image features; Inputting the initial image features into a plurality of depthwise separable convolution modules preset with a self-attention mechanism in the safety equipment detection model to be trained, obtaining feature maps of different sizes through each of the depthwise separable convolution modules, obtaining an attention weight of each of the feature maps through the self-attention mechanism, and weighting each of the feature maps using the attention weight to obtain weighted feature maps of different sizes; Inputting weighted feature maps of different sizes into a feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and obtaining a predicted safety equipment detection result of the sample image by the safety equipment detection model to be trained according to the fused feature map; According to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, model training is performed on the safety equipment detection model to be trained to obtain a trained safety equipment detection model.
2. The method according to claim 1, characterized in that: The feature fusion module includes a cross-level feature aggregation subunit and a squeeze excitation subunit; The step of inputting weighted feature maps of different sizes into a feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map includes: Inputting the weighted feature maps of different sizes into the cross-level feature aggregation subunit for pixel-level splicing to obtain the weighted feature maps of different sizes after splicing, and performing convolution operation on the weighted feature maps of different sizes after splicing using pre-set convolution kernel parameters to obtain fused semantic features; The squeeze excitation subunit obtains an initial fused feature map according to the weighted feature maps of different sizes after splicing and the channel attention weights corresponding to the weighted feature maps of different sizes after splicing; The fused feature map is obtained according to the fused semantic features and the initial fused feature map.
3. The method according to claim 2, characterized in that The step of obtaining the predicted safety equipment detection result of the sample image by the safety equipment detection model to be trained according to the fused feature map includes: Inputting the fused feature map into a global pooling module in the safety equipment detection model to be trained to obtain a global feature vector; Input the global feature vector into a main detection module preset with a self-attention mechanism, obtain an attention weight matrix corresponding to the global feature vector through the self-attention mechanism, and use the attention weight matrix to weight the global feature vector in different dimensions to obtain a weighted global feature vector; The safety equipment detection model to be trained obtains a predicted safety equipment detection result of the sample image according to the weighted global feature vector.
4. The method according to claim 2, characterized in that: The safety equipment detection model to be trained also includes an auxiliary detection module and a main detection module; The step of performing model training on the safety equipment detection model to be trained according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result to obtain the trained safety equipment detection model includes: The auxiliary detection module obtains a first predicted image feature according to the weighted feature maps of different sizes after stitching and the weighted global feature vector of the first part, and the main detection module obtains a second predicted image feature according to the weighted global feature vector other than the weighted global feature vector of the first part; Obtaining the predicted safety equipment detection result according to the first predicted image feature and the second predicted image feature; Based on the difference and a quantization error loss function preset for the safety equipment detection model to be trained, obtaining a corresponding first model loss value, and based on the difference and a safety equipment detection loss function preset for the safety equipment detection model to be trained, obtaining a corresponding second model loss value; According to the first model loss value and the second model loss value, the model parameters of the safety equipment detection model to be trained are adjusted accordingly until the quantization error loss function and the safety equipment detection loss function converge, thereby obtaining a trained safety equipment detection model.
5. The method according to claim 4, characterized in that The quantization error loss function is composed of a target existence loss function and a target classification loss function; the predicted safety equipment detection result includes a predicted safety equipment position and a predicted safety equipment category; The actual safety equipment detection result includes the actual position of the safety equipment and the actual category of the safety equipment; The obtaining a corresponding first model loss value based on the difference and a quantization error loss function preset for the safety equipment detection model to be trained comprises: Based on the difference between the predicted position of the safety equipment and the actual position of the safety equipment, and the target existence loss function, obtaining a corresponding target existence loss value; According to the difference between the predicted category of the safety equipment and the actual category of the safety equipment, and the target classification loss function, a corresponding target classification loss value is obtained; Obtaining a weight coefficient, a linear term, and an adaptive weight pre-set for the quantization error loss function; the weight coefficient is used to balance the importance of the target existence loss value and the target classification loss value, and the adaptive weight is used to dynamically adjust the weight of the target existence loss value and the target classification loss value; Based on the weight coefficient, the linear term and the adaptive weight, the target existence loss value and the target classification loss value are weighted to obtain the first model loss value.
6. The method according to claim 5, characterized in that The obtaining a corresponding second model loss value based on the difference and a safety equipment detection loss function preset for the safety equipment detection model to be trained comprises: Obtaining a sample weight preset for each of the sample images, and obtaining an application weight set for each category of sample images; Multiplying the predicted category of the safety equipment, the actual category of the safety equipment, the sample weight, and the application weight to obtain a corresponding third model loss value; A weighted summation process is performed on multiple third model loss values to obtain the second model loss value.
7. The method according to claim 1, characterized in that The obtaining of the sample image comprises: Collect raw images and raw videos from power operation sites; The video frames contained in the original video are saved to obtain video frame images corresponding to the original video; The original image and the video frame image are combined to obtain an original sample image, and the original sample image is annotated with actual safety equipment detection results to obtain the sample image.
8. A training device for a safety equipment detection model, characterized in that: The device comprises: An image acquisition module, used to acquire sample images; the sample images are annotated with actual safety equipment detection results in power operation scenarios; A feature extraction module, used for inputting the sample image into the safety equipment detection model to be trained, and performing preliminary feature extraction based on the sample image by a backbone module in the safety equipment detection model to be trained to obtain initial image features; A feature weighting module, used for inputting the initial image features into a plurality of depthwise separable convolution modules preset with a self-attention mechanism in the safety equipment detection model to be trained, obtaining feature maps of different sizes through each of the depthwise separable convolution modules, obtaining an attention weight of each of the feature maps through the self-attention mechanism, and weighting each of the feature maps using the attention weight to obtain weighted feature maps of different sizes; A result prediction module is used to input weighted feature maps of different sizes into a feature fusion module in the safety equipment detection model to be trained for adaptive fusion to obtain a fused feature map, and the safety equipment detection model to be trained obtains a predicted safety equipment detection result of the sample image according to the fused feature map; The model training module is used to perform model training on the safety equipment detection model to be trained according to the difference between the predicted safety equipment detection result and the actual safety equipment detection result, so as to obtain a trained safety equipment detection model.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Disease and pest monitoring and diagnosis method based on lightweight deep separation convolution model
CN119851143A
Range extender temperature prediction model training method, range extender control method and controller
CN120106250A
Multi-camera imaging method and system for head-mounted device
CN120128692A
Power equipment defect detection method and device, computer equipment, readable storage medium and program product
CN120182875A
Power equipment defect detection method and device, computer device, readable storage medium and program product
CN120182875B