Power target detection method and system based on data enhancement and attention mechanism
By adopting a deep learning model in power transmission drone target detection combined with data augmentation and attention mechanism, the problem that traditional methods are difficult to identify small targets in complex environments and low resolution conditions is solved, achieving higher detection accuracy and lower missed detection error rate.
Patent Information
- Application Number
- CN202411801850.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-18
AI Technical Summary
Traditional power transmission drone target detection methods are difficult to accurately identify small targets under complex environments and low-resolution image conditions, resulting in a high rate of missed detection and false detection.
A deep learning-based object detection model is adopted, combining data augmentation and attention mechanism, feature extraction is performed through the CSPDarknet network structure, and a two-way feature pyramid network is fusion for multi-scale features, and a CBAM attention mechanism is introduced into the detection head to improve the recognition ability of small targets.
It effectively improves the detection ability of multi-scale targets, especially small targets, suppresses background noise, highlights target information, and reduces missed detection and false detection rates.
Smart Images

Figure CN119649032A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine learning and computer vision technology, and in particular to a power target detection method and system based on data enhancement and attention mechanism. Background Art
[0002] The statements in this section merely mention background art related to the present invention and do not necessarily constitute prior art.
[0003] In the modern power industry, power transmission drones are widely used to inspect power lines and related equipment. This automated method improves inspection efficiency and reduces labor costs.
[0004] However, transmission UAVs face many challenges in target detection, especially when detecting small targets, traditional detection methods often do not work well. The main reasons are: the distribution of targets in the image is uneven, especially small targets are difficult to identify; secondly, since transmission lines and equipment are usually scattered over a wide area, targets may be obscured or confused with the background, increasing the complexity of identification; and, when the resolution of the image is low, the target details are blurred, which may cause the detection algorithm to fail to accurately identify, especially small power facilities such as insulators and conductors, which are prone to missed detection and false detection; and, complex environmental factors, such as weather changes (such as rain, fog, snow) and lighting conditions (such as shadows, reflections), further affect the visibility and recognition accuracy of the target. For the above reasons, traditional target detection methods face high missed detection and false detection rates in the application of transmission UAVs. Summary of the invention
[0005] The present invention provides a power target detection method and system based on data enhancement and attention mechanism to solve the problem that traditional solutions cannot accurately identify small targets in power inspections due to the influence of complex environments in power inspection scenarios and the low resolution of collected images.
[0006] According to a first aspect of an embodiment of the present invention, a power target detection method based on data enhancement and attention mechanism is provided, comprising:
[0007] Acquire a target image during a power inspection process, wherein the target image includes power equipment of different sizes to be inspected and a background;
[0008] Based on the target image to be detected, a pre-trained deep learning-based target detection model is used to obtain power equipment of different sizes in the target image to realize the detection of power targets; wherein, the deep learning-based target detection model specifically performs the following processing procedures: for the target image to be detected, a backbone network based on the CSPDarknet network structure is used to extract features of different scales to obtain feature maps of different scales; based on the obtained feature maps of different scales, a neck network based on a bidirectional feature pyramid network structure is used to perform bidirectional linking and multi-scale feature fusion to obtain a fused feature map; based on the obtained fused feature map, a pre-built detection head that considers the attention mechanism is used to obtain detection results of different scales.
[0009] Furthermore, the training of the target detection model specifically includes: acquiring inspection images containing different power equipment under different environmental conditions to construct a data set; annotating the images in the data set, and dividing the targets in the data set into different sizes based on the size of each target in the annotation results and a preset threshold; cropping the targets in each image in the data set as target detection results, wherein the cropping uses different cropping sizes according to the size results of the target division; and training the pre-constructed target detection model based on the samples in the constructed data set to obtain a trained target detection model.
[0010] Furthermore, the targets in each image in the data set are cropped, specifically: targets with a size smaller than a preset threshold are classified as small targets, and targets with a size greater than or equal to the preset threshold are classified as large targets; small targets are cropped using a cropping area of a first size to ensure the clarity of the target, and large targets are cropped using a cropping area of a second size to ensure the detailed features of the target, wherein the first size is smaller than the second size.
[0011] Furthermore, the target detection model is based on the YOLOv5 architecture, including a backbone network based on the CSPDarknet network structure, a neck network based on the bidirectional feature pyramid network structure, and a detection head introducing the CBAM attention mechanism.
[0012] Furthermore, the detection head considering the attention mechanism specifically performs the following processing: the attention mechanism includes a channel attention module and a spatial attention module; first, the input feature map is subjected to average pooling and maximum pooling respectively; the results of average pooling and maximum pooling are spliced after being processed by a multi-layer perceptron to obtain channel weights; then the channel weights are applied to the original feature map to obtain a weighted feature map; average pooling and maximum pooling are performed on the obtained weighted feature map respectively, the two obtained spatial feature maps are spliced, and the spatial attention map is generated after sequentially undergoing dimensionality reduction by a convolutional layer and activation function processing, and the spatial attention map is applied to the weighted feature map to obtain a feature map processed by the attention mechanism; based on the feature map processed by the attention mechanism, combined with a pre-set classifier, a target detection result is obtained.
[0013] Furthermore, the processing process of the channel attention module is specifically expressed as follows:
[0014] F′=σ(MLP(AvgPool(F))+MLP(MaxPool(F)))⊙F
[0015] Among them, σ is the activation function, AvgPool() is the average pooling operation, MaxPool() is the maximum pooling operation, MLP() represents the multi-layer perceptron, F is the original feature, and F′ is the weighted feature map;
[0016] The processing process of the spatial attention module is specifically expressed as follows:
[0017] F″=σ(f 7*7 (AvgPool(F′)+MaxPool(F′)))⊙F′.
[0018] Among them, σ is the activation function, f 7*7 is a 7*7 convolution, AvgPool() is an average pooling operation, MaxPool() is a maximum pooling operation, F is the original feature, F′ is the weighted feature map, and F″ is the feature map processed by the attention mechanism.
[0019] Furthermore, the hyperparameter optimization of the target detection model is specifically as follows: an objective function is constructed by minimizing the difference between the average accuracy of the target detection model on a preset validation set and the average time of target detection; based on the constructed objective function, the hyperparameters are optimized and solved by a clustering algorithm to obtain the optimal hyperparameters.
[0020] According to a second aspect of an embodiment of the present invention, a power target detection system based on data enhancement and attention mechanism is provided, comprising:
[0021] A data acquisition unit, which is used to acquire a target image during a power inspection process, wherein the target image includes power equipment of different sizes to be inspected and a background;
[0022] The target detection unit is used to obtain power equipment of different sizes in the target image based on the target image to be detected through a pre-trained deep learning-based target detection model, so as to realize the detection of power targets; wherein, the deep learning-based target detection model specifically performs the following processing procedures: for the target image to be detected, a backbone network based on the CSPDarknet network structure is used to extract features of different scales to obtain feature maps of different scales; based on the obtained feature maps of different scales, a neck network based on a bidirectional feature pyramid network structure is used to perform bidirectional linking and multi-scale feature fusion to obtain a fused feature map; based on the obtained fused feature map, detection results of different scales are obtained through a pre-built detection head that considers the attention mechanism.
[0023] According to a third aspect of an embodiment of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the above-mentioned power target detection method based on data enhancement and attention mechanism.
[0024] According to a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program / instruction is stored. When the computer program / instruction is executed by a processor, the above-mentioned power target detection method based on data enhancement and attention mechanism is implemented.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] The scheme of the present invention provides a method and system for detecting electric power targets based on data enhancement and attention mechanism. The scheme proposes a target detection model based on deep learning. The target detection model replaces the feature fusion module in the traditional YOLOv5 model with a bidirectional feature pyramid network, which can effectively fuse features from different scales, and improve the model's detection ability for multi-scale targets (especially small targets) by effectively utilizing information from different network layers. At the same time, the scheme introduces an attention mechanism to obtain the spatial importance of each feature and suppress background features, so that the model can learn in different feature dimensions and improve the recognition ability of small targets. In particular, in low-resolution images, background noise can be effectively suppressed and target information can be highlighted.
[0027] The scheme proposes an intelligent cropping method for small targets in images, which can effectively improve the resolution of small targets and improve the training ability. At the same time, by rotating, flipping, adjusting brightness and contrast, etc., the diversity of samples is increased to help the model better adapt to different environmental changes and target characteristics, making it more stable when facing complex backgrounds and small targets.
[0028] Compared with the traditional solution of embedding the attention mechanism into the feature extraction network, the solution described in the present invention applies the attention mechanism (i.e., the CBAM structure) to the detection head, which can improve the ability to extract prediction network features. The solution described in this application combines the attention mechanisms of space and channel dimensions. The spatial attention module is used to clarify the position of small targets, while the channel attention module is used to evaluate the importance of feature channels, helping the model to effectively ignore irrelevant background information and improve detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0030] Figure 1 This is an overall flow chart of the power target detection method based on data enhancement and attention mechanism according to an embodiment of the present invention;
[0031] Figure 2 Schematic diagram of the overall structure of the target detection model described in an embodiment of the present invention. DETAILED DESCRIPTION
[0032] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0033] It should be noted that the terms used herein are only for describing specific embodiments, and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that the terms "include" and "have" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.
[0035] In one or more embodiments, this embodiment provides a power target detection method based on data enhancement and attention mechanism, which specifically includes the following processing process:
[0036] Step 1: Acquire a target image during a power inspection process, wherein the target image includes power equipment of different sizes to be inspected and a background;
[0037] Step 2: Based on the target image to be detected, a pre-trained deep learning-based target detection model is used to obtain power equipment of different sizes in the target image to realize the detection of power targets; wherein, the deep learning-based target detection model specifically performs the following processing procedures: for the target image to be detected, a backbone network based on the CSPDarknet network structure is used to extract features of different scales to obtain feature maps of different scales; based on the obtained feature maps of different scales, a neck network based on a bidirectional feature pyramid network structure is used to perform bidirectional linking and multi-scale feature fusion to obtain a fused feature map; based on the obtained fused feature map, a pre-built detection head that considers the attention mechanism is used to obtain detection results of different scales.
[0038] In a specific implementation, the training of the target detection model specifically includes: acquiring inspection images containing different power equipment under different environmental conditions to construct a data set; annotating the images in the data set, and dividing the targets in the data set into different sizes based on the size of each target in the annotation results and a preset threshold; cropping the targets in each image in the data set as target detection results, wherein the cropping uses different cropping sizes according to the size results of the target division; and training the pre-constructed target detection model based on the samples in the constructed data set to obtain a trained target detection model.
[0039] It should be noted here that before performing target detection, data set construction is a crucial step, and different target detection tasks may require different types of data. In the target detection of power transmission drones, the main detection targets include insulators, wires, and electric towers. The appearance features of these targets in the image are different, so it is necessary to define the features of each target in detail to provide accurate label information for subsequent model training. In the data collection process, in addition to capturing the target itself, the impact of environmental factors on target recognition should also be considered. For example, the target may present different visual features under different weather conditions (such as sunny, cloudy or rainy days), and changes in illumination will also affect the quality of the image. In order to improve the robustness of the model, data taken at different times and environmental conditions are collected. Specifically, the scheme described in this embodiment collects inspection images under different seasons, lighting conditions, and weather conditions to ensure the diversity and comprehensiveness of the data set. By shooting images with power transmission drones, a data set specifically for a specific task is constructed to ensure that the images cover various environmental conditions and target types. The diversity of data collection will help the model to more accurately identify and classify targets in practical applications.
[0040] In the specific implementation, the image can be annotated using tools such as LabelImg. The annotation process needs to ensure that each target is accurately selected and the annotation results conform to the YOLO format. Each line of annotation should contain the target category and the corresponding bounding box coordinates, expressed in the form of center point coordinates (x, y) and width and height (w, h).
[0041] In one or more embodiments, the collected image data needs to be preprocessed as follows:
[0042] It is necessary to check the quality of the images and remove blurry, noisy or inappropriate images. In addition to removing low-quality images, it is also necessary to check the number of samples in each category to ensure the balance of the dataset. The reason is that an unbalanced number of samples will cause the model to perform well in some categories and poorly in other categories. For categories with severely unbalanced number of samples, ensure that each category has enough samples for the model to learn by adding samples or data augmentation.
[0043] Among them, data enhancement is an effective means to improve the generalization ability of the model. For small target data, based on the above cropping method, it can be combined with rotation, flipping, adjusting brightness, contrast, saturation and other means to simulate different lighting conditions, generate more training samples, and improve its performance in practical applications. In addition to the above data enhancement methods, it also includes rotation, mirror flipping, adjusting the brightness of the image and other methods.
[0044] In a specific implementation, the targets in each image in the data set are cropped, specifically: targets with a size smaller than a preset threshold are classified as small targets, and targets with a size greater than or equal to the preset threshold are classified as large targets; small targets are cropped using a cropping area of a first size to ensure the clarity of the target, and large targets are cropped using a cropping area of a second size to ensure the detailed features of the target, wherein the first size is smaller than the second size.
[0045] Specifically, the cutting process includes the following steps:
[0046] First, the size of each target in the dataset is counted, and the width and height of each target are calculated to determine its size. By traversing each target in the annotated image, the size distribution of the target is obtained, and small targets and large targets are reasonably divided, thus providing data support for the subsequent cropping process.
[0047] Secondly, based on the size statistics, the target size is divided into small targets and large targets according to the preset threshold. For example, a small target is defined as a target with an area less than a certain threshold of 32×32 pixels, and a large target is defined as a target with an area greater than or equal to 32×32. The reason for this setting is that small targets usually require greater attention and magnification processing to ensure clarity, while large targets need to maintain details and integrity.
[0048] Then, for each target, the center coordinates of the target are calculated based on its annotation information to ensure that the cropped image can be focused on the target and improve the accuracy of subsequent detection. The center coordinates obtained here will be used as the center point of subsequent cropping, where the center point is calculated as follows:
[0049]
[0050] Among them, x min is the x coordinate of the upper left corner of the target bounding box, y min is the y coordinate of the upper left corner of the target bounding box, x max is the x coordinate of the lower right corner of the target bounding box, y max The y coordinate of the lower right corner of the target bounding box.
[0051] Finally, the target is cropped according to its size and center coordinates: Small target cropping: For small targets, a larger cropping area of 128×128 pixels is set to ensure that the target is clearly visible in the image (mainly by increasing the size of the target relative to the image). Large target cropping: For large targets, a cropping size of 256×256 pixels is used to maintain the detailed features of the target. By adjusting the cropping size, small targets can be prevented from being blurred in the image and the feature information of large targets can be ensured not to be compressed, thereby improving the recognition ability of the model. If the cropping box exceeds the boundary, the position of the cropping box can be dynamically adjusted according to the center point of the target and the target size. Ensure that the coordinates of the cropping box always remain within the valid range of the image. The non-maximum suppression (NMS) strategy is used to remove duplicate images for the cropped image. According to the IoU threshold of 0.5, other images that overlap with the current image by more than the threshold are removed.
[0052] In one or more embodiments, for the samples obtained after cropping, the sample data is further expanded by rotating, flipping, adjusting brightness, and Poisson fusion to achieve data enhancement, so as to improve the model's adaptability to different environments and conditions, increase the diversity of samples, and thus improve the generalization performance of the model.
[0053] In the specific implementation, the target detection model is based on the YOLOv5 architecture, including a backbone network based on the CSPDarknet network structure, a neck network based on the bidirectional feature pyramid network structure, and a detection head introducing the CBAM attention mechanism.
[0054] Specifically, the scheme described in this embodiment adopts the YOLO series model as the basic architecture of target detection. YOLOv5 has efficient real-time detection capability and can simultaneously detect multiple targets in an image in a single forward propagation. In the scheme described in this embodiment, the YOLOv5 architecture is selected according to the characteristics of power facilities, and targeted improvements are made on the basis of YOLOv5. The specific improvements are: BiFPN (Bidirectional Feature Pyramid Network) is used to enhance the feature fusion capability, GIoU (Generalized Intersection over Union) is used as the loss function, and an attention mechanism is introduced to increase the focus on key areas, which is specifically used for power transmission UAV target detection, such as Figure 2 As shown, the overall structure of the target detection model is as follows:
[0055] Backbone network: CSPDarknet is the basic network of YOLOv5, which adopts a cross-stage partially connected structure and can effectively capture features. For the power transmission drone detection task, it is used to process various features in complex environments.
[0056] Neck network: BiFPN bidirectional feature transfer allows features to flow bidirectionally between different scales. Since small targets (such as insulators and wires) may exhibit different characteristics at different scaling ratios, the model can better integrate this information through bidirectional transfer and enhance the detection capability of small targets. BiFPN optimizes feature fusion and increases the focus on small targets by assigning learned weights to each feature layer.
[0057] Detection head: includes convolutional layers, attention mechanisms, and preset classifiers.
[0058] Specifically, based on the constructed target detection model, the image to be detected is input into the backbone network of the target detection model to quickly extract multi-level features in the image; however, since YOLOv5 itself may face the problem of feature information loss when processing small targets (this is mainly due to the loss of details caused by the downsampling process), therefore, in the scheme described in this embodiment, the feature map will be input into the BiFPN network for bidirectional linking and multi-layer feature fusion. Through bottom-up feature fusion, feature maps from different scales are effectively integrated. BiFPN transfers information between different levels, and uses upsampling and downsampling operations to combine low-level features (rich in detail information) with high-level features (rich in semantic information). After feature fusion by BiFPN, in order to further improve the detection accuracy of the model, the feature maps output in the neck network are respectively sent to three prediction networks and the CBAM attention module, and finally the output of the target box, category confidence and category probability is generated.
[0059] In the power image, in addition to the information such as insulators, there is also complex background information. This information will accumulate and form information redundancy during the convolution process. In order to focus on the key positions in the image, the introduction of the attention mechanism can extract the key features in the network and suppress the interference of irrelevant information. Therefore, the channel attention mechanism CBAM (Convolutional Block Attention Module) is adopted here. The spatial attention is used to focus on the position of the small target, and the channel attention is used to ignore the background information in the image that is irrelevant to the target. Specifically, the CBAM includes a channel attention module (CAM) and a spatial attention module (SAM), where:
[0060] Channel Attention Module (CAM) The channel attention module is used to generate channel weights and highlight the features of important channels. The calculation process is as follows: first, the input feature map F is average pooled and max pooled, and then concatenated after being processed by a multi-layer perceptron (MLP) to obtain channel weights. Finally, the channel weights are applied to the original feature map to obtain F′.
[0061] F′=σ(MLP(AvgPool(F))+MLP(MaxPool(F)))⊙F
[0062] Among them, σ is the activation function, AvgPool() is the average pooling operation, and MaxPool() is the maximum pooling operation.
[0063] The spatial attention module (SAM) is used to generate spatial weights and focus on important locations in the feature map. The feature map F′ is average pooled and max pooled to obtain a spatial feature map. The two spatial feature maps are concatenated and reduced to one channel through a convolutional layer. Then, the activation function is used to generate a spatial attention map. The spatial weight is applied to the weighted feature map to obtain F″.
[0064] F″=σ(f 7*7 (AvgPool(F′)+MaxPool(F′)))⊙F′
[0065] Among them, σ is the activation function, f 7*7 It is a 7*7 convolution, AvgPool() is an average pooling operation, and MaxPool() is a maximum pooling operation.
[0066] In the detection head of YOLOv5, the feature map F″ processed by the attention mechanism is used for target detection.
[0067] In a specific implementation, the hyperparameter optimization of the target detection model is specifically as follows: an objective function is constructed by minimizing the difference between the average accuracy of the target detection model on a preset validation set and the average time of target detection; based on the constructed objective function, the hyperparameters are optimized and solved through a clustering algorithm to obtain the optimal hyperparameters.
[0068] Specifically, in order to improve the accuracy and real-time reasoning speed of the target detection model so that the drone can provide immediate feedback and response during the inspection process, the solution described in this embodiment defines the following objective function:
[0069] Define an objective function F to balance the accuracy and efficiency of the model:
[0070] F=w1·mAP-w2·Inference_Time
[0071] Among them, F is the objective function, mAP is the average accuracy of the model on the validation set, Inference_Time represents the average time of target detection on each picture, and w1 and w2 represent weight coefficients.
[0072] The hyperparameters optimized here are learning rate, batch size and number of anchor boxes. The objective function F can also be expressed as a function of the hyperparameters:
[0073] F(α,batch_size,num_anchors)=w1·mAP(α,batch_size,num_anchors)-w2·
[0074] Inference_Time(α,batch_size,num_anchors)
[0075] The particle swarm optimization (PSO) algorithm is used to optimize the above hyperparameters. PSO is a swarm-based global optimization algorithm that simulates the movement of particles in the search space to find the optimal solution. Each particle represents a set of hyperparameters, including learning rate, batch size, and number of anchor boxes.
[0076] Particle i =(α i ,batch_size i ,num_anchors i )
[0077] A certain number of particles are randomly generated. Each particle updates its speed and position according to the following formula during the search process.
[0078] v i,j =w·v i,j +c1·r1·(p i,j -x i,j )+c2·r2·(g j -x i,j )
[0079] Among them, v i,j represents the velocity of particle i in dimension j. i,j Represents the current position of particle i in dimension j. i,j represents the individual optimal position of particle i. j represents the global optimal position. r1 and r2 represent random numbers between [0,1]. c1 and c2 represent acceleration constants set to 1.5.
[0080] The position update formula is as follows:
[0081] x i,j =v i,j +v i,j
[0082] The optimization process includes the following steps:
[0083] (1) Initialize particles: Create particles and randomly assign hyperparameters.
[0084] (2) Evaluate particles: Use the objective function F to evaluate the performance of each particle and calculate its mAP and inference time.
[0085] (3) Update particle position: Update the particle position according to the velocity update formula.
[0086] (4) Update individual and global best: If the performance of a particle is better than its historical best, its individual best is updated; if the performance is better than the global best, the global best is updated.
[0087] (5) Iterative update: Repeat steps (2) to (4) until the set number of iterations is reached.
[0088] After the optimization is completed, the best hyperparameters found are used, and then the model is trained. The first is forward propagation, which inputs the training data into the model and calculates the predicted output. In this process, the model generates a prediction result for the input data based on the current parameters. Next, the loss calculation is required, and the loss is calculated based on the predicted result and the actual label. The loss function includes GIoU loss, confidence loss, and classification loss to evaluate the performance of the model in the target detection task. In the training process, backpropagation is an indispensable step. Through the backpropagation algorithm, the model parameters are updated according to the loss value to reduce the loss value.
[0089] At the end of each round of training, regularly monitor the change in loss value. During the training process, record the loss value at the end of each epoch to observe the trend during the training process. By saving the model weights, you can ensure that the optimal solution will not be lost due to performance degradation caused by parameter adjustment during the training process. The model with the best performance on the validation set will be saved for subsequent use and verification.
[0090] Model validation is a key step to ensure that the model performs well on unseen data. The process of preparing the validation set is crucial to the evaluation of the model. Reasonable division of the dataset is the basis for effective validation, with a ratio of 70% for training, 15% for validation, and 15% for testing. In model validation, indicators such as precision and recall are used to evaluate the accuracy and completeness of the model in detection. Precision reflects the correctness of the model's predictions, while recall measures the model's complete recognition ability of the target. The mAP of each category is calculated by IoU (Intersection over Union) to comprehensively evaluate the performance of the model.
[0091] Model testing is an important step in evaluating the final performance of the model. The test set is used to finally evaluate the performance of the model, ensuring that the preprocessing of the test set is consistent with that of the training and validation sets.
[0092] In one or more embodiments, corresponding to the above method, this embodiment provides a power target detection system based on data enhancement and attention mechanism, including:
[0093] A data acquisition unit, which is used to acquire a target image during a power inspection process, wherein the target image includes power equipment of different sizes to be inspected and a background;
[0094] The target detection unit is used to obtain power equipment of different sizes in the target image based on the target image to be detected through a pre-trained deep learning-based target detection model, so as to realize the detection of power targets; wherein, the deep learning-based target detection model specifically performs the following processing procedures: for the target image to be detected, a backbone network based on the CSPDarknet network structure is used to extract features of different scales to obtain feature maps of different scales; based on the obtained feature maps of different scales, a neck network based on a bidirectional feature pyramid network structure is used to perform bidirectional linking and multi-scale feature fusion to obtain a fused feature map; based on the obtained fused feature map, detection results of different scales are obtained through a pre-built detection head that considers the attention mechanism.
[0095] In further embodiments, there is also provided:
[0096] An electronic device includes a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the method described in Embodiment 1 is performed. For the sake of brevity, no further description is given here.
[0097] It should be understood that in this embodiment, the processor may be a central processing unit CPU, and the processor may also be other general-purpose processors, digital signal processors DSP, application-specific integrated circuits ASIC, off-the-shelf programmable gate arrays FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0098] The memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.
[0099] A computer-readable storage medium is used to store computer instructions. When the computer instructions are executed by a processor, the method described in embodiment 1 is completed.
[0100] The method in the first embodiment can be directly embodied as a hardware processor, or a combination of hardware and software modules in the processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. To avoid repetition, it will not be described in detail here.
[0101] Those skilled in the art will appreciate that the units, i.e., algorithm steps, of the various examples described in the present embodiment can be implemented in electronic hardware or in a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0102] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. The power target detection method based on data enhancement and attention mechanism is characterized by: include: Acquire a target image during a power inspection process, wherein the target image includes power equipment of different sizes to be inspected and a background; Based on the target image to be detected, the pre-trained deep learning-based target detection model is used to obtain power equipment of different sizes in the target image to achieve power target detection; Among them, the target detection model based on deep learning specifically performs the following processing procedures: for the target image to be detected, a backbone network based on the CSPDarknet network structure is used to extract features of different scales to obtain feature maps of different scales; based on the obtained feature maps of different scales, a neck network based on a bidirectional feature pyramid network structure is used to perform bidirectional linking and multi-scale feature fusion to obtain a fused feature map; based on the obtained fused feature map, a detection head that considers the attention mechanism is pre-constructed to obtain detection results of different scales.
2. The power target detection method based on data enhancement and attention mechanism as claimed in claim 1, characterized in that: The training of the target detection model specifically includes: acquiring inspection images containing different power equipment under different environmental conditions to construct a data set; annotating the images in the data set, and dividing the targets in the data set into different sizes based on the size of each target in the annotation results and a preset threshold; cropping the targets in each image in the data set as target detection results, wherein the cropping uses different cropping sizes according to the size results of the target division; and training the pre-constructed target detection model based on the samples in the constructed data set to obtain a trained target detection model.
3. The power target detection method based on data enhancement and attention mechanism as claimed in claim 2, characterized in that: The target in each image in the data set is cropped, specifically: for targets whose size is smaller than a preset threshold, they are classified as small targets, and for targets whose size is greater than or equal to the preset threshold, they are classified as large targets; for small targets, a cropping area of a first size is used for cropping to ensure the clarity of the target, and for large targets, a cropping area of a second size is used for cropping to ensure the detailed features of the target, wherein the first size is smaller than the second size.
4. The power target detection method based on data enhancement and attention mechanism as claimed in claim 1, characterized in that: The target detection model is based on the YOLOv5 architecture, including a backbone network based on the CSPDarknet network structure, a neck network based on the bidirectional feature pyramid network structure, and a detection head introducing the CBAM attention mechanism.
5. The power target detection method based on data enhancement and attention mechanism as claimed in claim 1, characterized in that: The detection head considering the attention mechanism specifically performs the following processing: The attention mechanism includes a channel attention module and a spatial attention module; first, average pooling and maximum pooling are performed on the input feature map respectively; the results of average pooling and maximum pooling are spliced after being processed by a multi-layer perceptron to obtain channel weights; then the channel weights are applied to the original feature map to obtain a weighted feature map; average pooling and maximum pooling are performed on the obtained weighted feature map respectively, and the two obtained spatial feature maps are spliced, and the spatial attention map is generated after the convolution layer dimensionality reduction and activation function processing in sequence, and the spatial attention map is applied to the weighted feature map to obtain the feature map processed by the attention mechanism; Based on the feature map processed by the attention mechanism and combined with the pre-set classifier, the target detection result is obtained.
6. The power target detection method based on data enhancement and attention mechanism as claimed in claim 5, characterized in that: The processing process of the channel attention module is specifically expressed as follows: F′=σ(MLP(AvgPool(F))+MLP(MaxPool(F)))⊙F Among them, σ is the activation function, AvgPool() is the average pooling operation, MaxPool() is the maximum pooling operation, MLP() represents the multi-layer perceptron, F is the original feature, and F′ is the weighted feature map; The processing process of the spatial attention module is specifically expressed as follows: F″=σ(f 7*7 (AvgPool(F′)+MaxPool(F′)))⊙F′。 Among them, σ is the activation function, f 7*7 is a 7*7 convolution, AvgPool() is an average pooling operation, MaxPool() is a maximum pooling operation, F is the original feature, F′ is the weighted feature map, and F″ is the feature map processed by the attention mechanism.
7. The power target detection method based on data enhancement and attention mechanism as claimed in claim 1, characterized in that: The hyperparameter optimization of the target detection model is specifically: constructing an objective function by minimizing the difference between the average accuracy of the target detection model on a preset validation set and the average time of target detection; Based on the constructed objective function, the cluster algorithm is used to optimize the hyperparameters and obtain the optimal hyperparameters.
8. The power target detection system based on data enhancement and attention mechanism is characterized by: include: A data acquisition unit, which is used to acquire a target image during a power inspection process, wherein the target image includes power equipment of different sizes to be inspected and a background; The target detection unit is used to obtain power equipment of different sizes in the target image based on the target image to be detected through a pre-trained deep learning-based target detection model, so as to realize the detection of power targets; wherein, the deep learning-based target detection model specifically performs the following processing procedures: for the target image to be detected, a backbone network based on the CSPDarknet network structure is used to extract features of different scales to obtain feature maps of different scales; based on the obtained feature maps of different scales, a neck network based on a bidirectional feature pyramid network structure is used to perform bidirectional linking and multi-scale feature fusion to obtain a fused feature map; based on the obtained fused feature map, detection results of different scales are obtained through a pre-built detection head that considers the attention mechanism.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the power target detection method based on data enhancement and attention mechanism as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instruction is executed by a processor, the power target detection method based on data enhancement and attention mechanism as described in any one of claims 1-7 is implemented.
Citation Information
Cited By
Biomass material detection method and system based on Yolov5
CN121392407A