A small target-oriented lightweight transmission line hazard DETR detection method
Patent Information
- Application Number
- CN202611016832.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-10-30
AI Technical Summary
[0004]本发明目的在于解决现有主干网络在多次下采样过程中,造成的小尺度异物与细粒度缺陷信息衰减,以及深层网络计算量大的问题;解决现有特征融合阶段采用固定规则网格插值,导致边缘响应被平滑处理、小尺度目标与复杂背景差异减弱的问题;以及解决现有边界框回归损失函数缺乏对几何形态一致性的约束,导致细长或比例异常目标定位结果偏移、空间关系判断不可靠的问题,提出一种面向小目标的轻量化输电线路隐患DETR检测方法
[0045]检测结果模块对模型输出的原始检测结果进行后处理,过滤置信度低于预设值的低质量预测框,最终输出包含隐患类别、空间坐标、置信度得分的结构化检测数据,实现安全距离计算与风险评估,为输电线路隐患预警提供可直接调用的决策依据。
Smart Images

Figure CN123016053A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of static hazard detection technology for power transmission lines, and in particular relates to a lightweight DETR detection method for small-target power transmission lines. Background Technology
[0002] Static hazard detection of power transmission lines is based on single-frame images, focusing on both the spatial positioning accuracy and multi-scale representation capability of the target, while maintaining controllable computational scale under actual deployment conditions. Existing technologies typically employ target detection models for identification. The closest existing technology to this invention is the RT-DETR detection model. This model adopts an end-to-end detection structure, and its device or system mainly consists of a convolutional backbone, a feature fusion module (HybridEncoder), a Transformer encoding and decoding structure (Decoder), and a detection head. Its operation process is as follows: the input image is downsampled step-by-step by the backbone network to form multi-scale features; high-level semantic features are entered into the Transformer module for global modeling; and finally, the detection head outputs the category and bounding box parameters.
[0003] Currently, existing technologies suffer from the following shortcomings: First, insufficient representation of small-scale targets: As network layers deepen, feature map resolution continuously decreases, resulting in a relatively limited effective response area for distant small-scale hazards (such as distant kites or thin films) in deep features. When the background is complex, local target features are easily disturbed, weakening their representation strength. Second, poor feature fusion recovery capability: In the feature fusion stage, RT-DETR uses a fixed bilinear interpolation method for upsampling, failing to adaptively adjust for content differences in different regions, making it difficult to effectively compensate for detailed information. Third, unstable regression of slender targets: Existing models use a combination of L1 loss and GIoU loss, which has relatively limited constraints on proportional perturbations in scenarios with large aspect ratios (such as slender foreign objects). Small fluctuations in scale or center can easily cause fluctuations in risk assessment results. Fourth, high computational complexity: The Transformer module increases global semantic modeling capabilities but also increases computational load, making it difficult to meet real-time requirements under the limited computing power of UAVs. Summary of the Invention
[0004] The purpose of this invention is to address the problems of information attenuation of small-scale foreign objects and fine-grained defects caused by multiple downsampling processes in existing backbone networks, as well as the large computational load of deep networks; to solve the problem that the use of fixed regular grid interpolation in the existing feature fusion stage leads to the smoothing of edge responses and the weakening of the difference between small-scale targets and complex backgrounds; and to solve the problem that the existing bounding box regression loss function lacks constraints on geometric consistency, resulting in the offset of the positioning results of slender or proportionally abnormal targets and unreliable spatial relationship judgments. Therefore, this invention proposes a lightweight DETR detection method for small targets in transmission lines.
[0005] To achieve the objective of this invention, a lightweight DETR detection method for small-target transmission lines is disclosed, comprising the following steps:
[0006] Step 1: Image preprocessing; Standardize the raw inspection images of arbitrary resolution acquired by the UAV to generate standardized tensors;
[0007] Step 2: Lightweight multi-scale feature extraction; The standardized image tensor is input into the EPNet backbone network, and through multiple stages of downsampling and feature extraction, a hierarchical multi-scale feature representation system is formed.
[0008] Step 3: Dynamic adaptive feature fusion; The adaptive fusion of cross-scale features is completed in the hybrid encoder to generate multi-scale enhanced features that fuse global semantics and local details;
[0009] Step 4: Global semantic modeling and feature decoding; global semantic modeling is performed on the fused multi-scale enhanced features using the Transformer encoding and decoding structure to generate a prediction set containing the target category and preliminary bounding box parameters;
[0010] Step 5: Bounding box regression and target detection output based on shape constraint ShapeIoU; The detection head performs final optimization on the preliminary prediction set output by the Transformer decoder to complete the target class probability prediction and bounding box parameter regression.
[0011] Step 6: Output the detection results of potential hazards in transmission lines; Post-process the original detection results output by the model, filter out low-quality prediction boxes with confidence scores below the preset value, and finally output structured detection data containing hazard category, spatial coordinates, and confidence scores to realize safe distance calculation and risk assessment, providing a decision basis that can be directly called for early warning of potential hazards in transmission lines.
[0012] Furthermore, the images are first uniformly scaled to 640×640 pixels, and then mean and variance are normalized. At the same time, data augmentation strategies that conform to the physical structure constraints of the transmission line are applied, including horizontal flipping, small-angle rotation of ±10° to 15°, and brightness and contrast perturbation. Operations that destroy spatial consistency, such as vertical flipping and strong perspective transformation, are avoided. Finally, a standardized tensor that meets the model input requirements is generated, providing a reliable data foundation for subsequent feature extraction.
[0013] Furthermore, in step 2, the standardized image tensor is input into the EPNet backbone network, and feature maps of four scales, S2 (160×160), S3 (80×80), S4 (40×40), and S5 (20×20), are generated through four stages of progressive downsampling. In each stage, the EPBlock module completes part of the convolutional reduction calculation and multi-scale attention-enhanced feature extraction. The shallow features retain the spatial details of small targets, while the deep features extract the semantic category information of the targets, forming a hierarchical multi-scale feature representation system.
[0014] Furthermore, the EPNet backbone network adopts the EPBlock lightweight multi-scale feature extraction module, which includes a channel grouping module, a first feature branch, a second feature branch, a residual connection unit, and a feature output port.
[0015] The channel grouping module first divides the feature map output from the previous layer into 8 groups along the channel dimension, providing a foundation for subsequent dual-branch parallel computation. The channel grouping strategy can effectively reduce the computational complexity of a single branch, while providing finer-grained feature units for the spatial-channel joint modeling of the multi-scale attention mechanism, ensuring the efficiency and targeting of subsequent feature enhancement operations.
[0016] The first feature branch is the convolution operation branch, which is responsible for completing the basic feature extraction task. The core adopts partial convolution (PConv) operation, which only performs 3×3 standard convolution operation on 25% of the channels, while maintaining the identity mapping of the remaining 75% of the channels. The theoretical computational cost is only 1 / 16 of that of standard convolution. After the convolution is completed, the operation channels are concatenated with the identity mapping channels to restore the original number of channels. Without significantly reducing the feature expression ability, the number of parameters and computational cost of the backbone network are greatly reduced.
[0017] The second feature branch is the attention enhancement branch, which adaptively recalibrates the features output by the convolution branch. First, global average pooling is performed along the horizontal and vertical directions by spatial orientation encoding subunits to extract long-range dependency information across space. Then, the neighborhood structure features extracted by the local 3×3 convolution branch are combined to generate spatial-channel joint attention weights. Finally, the weights are mapped to the 0-1 interval by the Sigmoid function and multiplied element-wise with the original features to enhance the feature response of small target regions and suppress interference information from complex backgrounds.
[0018] The residual connection unit adds the input features and the attention-enhanced features element by element to construct the residual learning path, which effectively solves the gradient vanishing problem in the training process of deep networks, ensures that the model can converge stably, and enables the network to learn more refined feature differences, thereby improving the ability to identify minor hidden dangers.
[0019] The feature output port outputs the enhanced feature map processed by EPBlock to the next EPBlock module or hybrid encoder, ensuring the continuous transmission of the feature flow in the backbone network and providing high-quality feature input for subsequent cross-scale feature fusion and global modeling.
[0020] Furthermore, in step 3, the S5 deep feature map output by the backbone is first dynamically upsampled to the S4 size using DySample, and then fused element-wise with the S4 feature. The fused feature is then upsampled to the S3 size using DySample and fused with the S3 feature a second time. Throughout the process, the sampling coordinates are shifted towards the high-response region of the small target by predicting the sampling point offset, thus avoiding the edge smoothing problem of fixed interpolation. Finally, a multi-scale enhanced feature that fuses global semantics and local details is generated.
[0021] Furthermore, the DySample dynamic upsampling module, which integrates cross-scale feature fusion, replaces the original RT-DETR's bilinear fixed interpolation upsampling. Through content-aware adaptive sampling coordinate adjustment, it solves the problems of blurred edges and loss of details of small targets caused by fixed interpolation. Without increasing the computational load, it significantly improves the detail preservation of small targets during feature fusion. The DySample dynamic upsampling module includes a low-resolution feature input port, a high-resolution feature input port, an offset prediction convolution unit, a local neighborhood coordinate fine-tuning unit, a sampling coordinate generation unit, a content-aware resampling unit, and a cross-scale feature fusion unit.
[0022] The low-resolution feature input port receives low-resolution feature maps from the deep layers of the backbone, including two scales: S5 (20×20) and S4 (40×40). These features contain rich semantic category information, but have low spatial resolution. The structural details of small targets at a distance have been downsampled and compressed multiple times, and need to be upsampled to restore spatial resolution before being fused with shallow features. The high-resolution feature input port receives high-resolution feature maps from the shallow layers of the backbone, including two scales: S4 (40×40) and S3 (80×80). These features retain clear spatial edges and texture details, but have weak semantic information. They need to be fused with deep semantic features to achieve accurate target recognition and localization.
[0023] The offset prediction convolutional unit is the core of dynamic upsampling. It processes the input low-resolution feature map through 1×1 convolution and predicts the sampling offset corresponding to each pixel. 2×s² offsets are predicted at each position, where s is the upsampling factor. This provides coordinate basis for subsequent adaptive sampling, enabling the sampling points to automatically adjust their positions according to the feature content.
[0024] The local neighborhood coordinate fine-tuning unit constrains the magnitude of the predicted original offset, limiting it to within ±2 pixels to avoid the sampling points deviating too much from their original positions, which would lead to unstable feature fusion. Then, the PixelShuffle operation rearranges the channel-dimensional offset into the spatial-dimensional sampling coordinates, realizing the mapping of the offset from the channel space to the image space.
[0025] The sampling coordinate generation unit first generates basic regular grid coordinates to ensure the overall continuity of sampling. Then, it adds the basic grid coordinates to the fine-tuned offset to obtain the final adaptive sampling coordinate set, which enables the sampling points to shift to the high-response area of small targets, thereby achieving accurate sampling with content awareness.
[0026] The content-aware resampling unit samples pixel values from the low-resolution feature map through bilinear interpolation based on the generated adaptive sampling coordinates, and generates an upsampled high-resolution feature map. When there is a high-response region of a small target in the low-resolution feature map, the sampling coordinates will automatically converge to that region, thereby preserving clearer edge information and avoiding the edge smoothing effect of fixed interpolation.
[0027] The cross-scale feature fusion unit adds the upsampled low-resolution feature map to the corresponding high-resolution feature map element by element to complete the cross-scale feature fusion. This allows the fused features to contain both deep semantic information and shallow detail information. Finally, the multi-scale enhanced feature map is output to the Transformer encoder, providing a foundation for subsequent global semantic modeling.
[0028] Furthermore, in step 4, the fused multi-scale enhanced features are modeled globally using the Transformer encoder-decoder structure. First, the transformer encoder performs global context encoding on the feature map to enhance the semantic association between features in different regions. Then, the transformer decoder uses 300 learnable query vectors to perform cross-attention interaction with the encoded features to generate a prediction set containing the target category and preliminary parameters of the bounding box, thus achieving end-to-end target set prediction without relying on anchor design and manual hyperparameter tuning.
[0029] Furthermore, a complete calculation process for ShapeIoU combined with boundary regression loss is adopted to replace the original RT-DETR L1+GIoU loss function. By introducing orientation-weighted center distance and scale consistency constraints, the problem of insufficient constraints on the geometric shape of slender targets by traditional loss functions is solved, significantly improving the positioning accuracy and stability of aspect ratio anomalies. The process includes a predicted bounding box parameter input port, a true bounding box annotation parameter input port, an intersection-over-union (IoU) basic calculation unit, an aspect ratio adaptive weight allocation unit, an orientation-weighted center distance penalty term calculation unit, a scale consistency constraint term calculation unit, a ShapeIoU loss value synthesis unit, and a network backpropagation optimization unit.
[0030] The predicted bounding box parameter input port receives the predicted bounding box parameters output by the detection head, including the target center point coordinates (x, y), width w, and height h. These parameters are the model's preliminary estimate of the target's spatial location and scale, and need to be continuously optimized through the constraints of the loss function to make them approximate the true labeled values.
[0031] The true bounding box annotation parameter input port receives manually annotated true bounding box parameters, including the true center point coordinates (x_gt, y_gt), the true width w_gt, and the true height h_gt, which serve as the benchmark values for loss calculation and are used to measure the degree of spatial matching between the predicted bounding box and the true target.
[0032] The basic calculation unit of Intersection over Union (IoU) first calculates the IoU between the predicted bounding box and the ground truth bounding box. As a basic term of the loss function, it intuitively reflects the degree of spatial overlap of the bounding boxes. However, IoU cannot provide an effective gradient when the two boxes do not overlap, and it is not sensitive to the proportional shift of slender targets. Therefore, it needs to be supplemented and improved by subsequent constraint terms.
[0033] The aspect ratio adaptive weight allocation unit calculates the directional weighting coefficients α_w and α_h based on the aspect ratio of the real bounding box. When the target is slender, the weight of the corresponding geometric principal direction will automatically increase, guiding the model to prioritize optimizing the localization error in that direction, so that the predicted box can be better aligned with the geometry of the real target, thus solving the problem that the traditional loss function is insufficient for slender targets.
[0034] The orientation-weighted center distance penalty calculation unit calculates the weighted distance penalty between the center point of the predicted box and the center point of the ground truth box based on adaptive weights. Compared with the equal-weighted center distance of GIoU, orientation-weighted can more accurately constrain the center position of slender targets, reduce the error in calculating the safe distance due to center offset, and improve the reliability of risk assessment.
[0035] The scale consistency constraint calculation unit calculates the difference in the aspect ratio between the predicted box and the ground truth box, and introduces an exponential mapping form of scale consistency penalty. When the aspect ratio deviation is small, the gradient remains smooth, and when the deviation is large, the penalty intensity is rapidly increased, which accelerates the convergence of the geometric shape and effectively suppresses the shape deviation caused by the imbalance of aspect ratio.
[0036] The ShapeIoU loss synthesis unit weights and synthesizes the IoU base term, the orientation-weighted center distance term, and the scale consistency constraint term to obtain the final ShapeIoU loss value. It comprehensively considers the overlap, center position, and shape ratio of the bounding box to achieve all-round constraints on the bounding box, enabling the predicted box to more accurately fit the spatial shape of the real target.
[0037] The network backpropagation optimization unit performs a weighted summation of the ShapeIoU loss, L1 coordinate loss, and classification loss to obtain the model's total loss value. Then, it updates all the model's parameters through the backpropagation algorithm, continuously iterating and optimizing the model's detection accuracy and positioning stability, ultimately enabling the model to achieve accurate hazard detection and positioning in complex scenarios.
[0038] Furthermore, in step 5, the preliminary prediction set output by the Transformer decoder is finally optimized by the detection head to complete the target category probability prediction and bounding box parameter regression. During the training phase, a joint optimization strategy of L1 coordinate loss and ShapeIoU shape constraint loss is adopted. The prediction box is guided to align with the geometry of the real target through orientation weighting and scale consistency constraints. During the inference phase, the target prediction result with the highest confidence is directly output to improve the localization stability of slender targets and irregular targets.
[0039] To achieve the objectives of this invention, a lightweight DETR detection system for small targets in power transmission lines is also disclosed, comprising an image preprocessing module, a lightweight multi-scale feature extraction module, a dynamic adaptive feature fusion module, a global semantic modeling and feature decoding module, a bounding box regression and target detection output module, and a detection result module.
[0040] The image preprocessing module performs standardization processing on the raw inspection images of arbitrary resolution acquired by the UAV to generate a standardized tensor;
[0041] The lightweight multi-scale feature extraction module inputs the standardized image tensor into the EPNet backbone network, and forms a hierarchical multi-scale feature representation system through multiple stages of downsampling and feature extraction.
[0042] The dynamic adaptive feature fusion module completes the adaptive fusion of cross-scale features in the hybrid encoder, generating multi-scale enhanced features that fuse global semantics and local details;
[0043] The global semantic modeling and feature decoding module performs global semantic modeling on the fused multi-scale enhanced features through the Transformer encoding and decoding structure, generating a prediction set containing the target category and preliminary bounding box parameters;
[0044] The bounding box regression and object detection output module performs final optimization on the preliminary prediction set output by the Transformer decoder through the detection head, completing the object category probability prediction and bounding box parameter regression;
[0045] The detection results module performs post-processing on the raw detection results output by the model, filters out low-quality prediction boxes with confidence scores below the preset value, and finally outputs structured detection data containing hazard categories, spatial coordinates, and confidence scores, realizing safe distance calculation and risk assessment, and providing a decision-making basis that can be directly called for early warning of transmission line hazards.
[0046] The significant advancement of this invention compared to existing technologies lies in:
[0047] 1) Significantly improves detection accuracy. Under the same parameter scale, the mAP@0.5 of this invention reaches 93.1%, which is 5.2 percentage points higher than the benchmark model;
[0048] 2) Effectively reduce computational complexity and improve real-time performance. By introducing partial convolution (PConv), the number of model parameters is reduced from 19.87M to 17.2M, while the inference speed (FPS) is increased from 141 to 190, which fully meets the real-time requirements of UAV edge deployment.
[0049] 3) Enhance the ability to recognize small targets in complex scenes. The dynamic sampling (DySample) mechanism enables the model to have more stable feature representation and less false negative rate for small targets (such as plastic film, kite, bird's nest) in difficult scenes such as complex background interference, strong light degradation and local occlusion.
[0050] 4) Improve the stability of positioning for slender targets: The introduced ShapeIoU constraint makes the bounding box regression more stable when the model faces slender targets with abnormal aspect ratios, maintaining the relative spatial relationship between targets and providing a reliable basis for subsequent risk assessment.
[0051] To more clearly illustrate the functional characteristics and structural parameters of the present invention, further explanation is provided below in conjunction with the accompanying drawings and specific embodiments. Attached Figure Description
[0052] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0053] Figure 1 This is a block diagram illustrating the principle of the lightweight DETR detection system for small-target transmission lines, based on the present invention.
[0054] Figure 2 This is a flowchart of a static hazard detection method for transmission lines based on EDS-DETR;
[0055] Figure 3 This is a schematic diagram of the EPBlock lightweight feature extraction module structure.
[0056] Figure 4 This is a block diagram of the dynamic upsampling DySample feature fusion module.
[0057] Figure 5 This is a flowchart of the bounding box regression loss calculation process based on ShapeIoU shape constraints. Detailed Implementation
[0058] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0059] like Figure 1 As shown, Figure 1 This is a lightweight DETR detection system for power transmission lines targeting small targets. It presents the core architecture and module collaboration of an improved EDS-DETR lightweight static hazard detection system. While fully retaining the end-to-end detection process of RT-DETR and the original Transformer encoding and decoding structure, it makes targeted optimizations to address three core pain points in power transmission line inspection scenarios: easy attenuation of small target features, unstable positioning of slender targets, and limited computing power at the edge. Ultimately, it achieves a balance between detection accuracy, inference speed, and model lightweighting, and can be directly deployed on UAV-borne edge computing platforms.
[0060] Lightweight Multi-Scale Backbone Network (EPNet) Unit: This unit replaces the original ResNet18 backbone network of RT-DETR. It reconstructs the ResNet18 backbone while retaining the hierarchical feature output format of the four stages. The core innovation lies in the design of the EPBlock feature extraction module, which integrates partial convolution (PConv) and efficient multi-scale attention (EMA). By selectively calculating the channel, the number of backbone parameters is reduced. At the same time, the ability of deep features to express the hidden dangers at long distances and small scales is enhanced by spatial-channel joint attention. Finally, the number of backbone parameters is compressed from 19.87M to 17.2M, providing a high-quality multi-scale feature foundation for subsequent feature fusion and global modeling.
[0061] HybridEncoder Unit: This unit is responsible for cross-layer fusion and global semantic enhancement of multi-scale features output from the backbone. The core improvement is to replace the original bilinear fixed interpolation upsampling with the DySample dynamic upsampling mechanism. This module is deployed only in the two key fusion layers S5→S4 and S4→S3. Through content-aware adaptive sampling coordinate adjustment, it solves the problem of blurred edges of small targets caused by fixed interpolation. Without increasing the amount of computation, it improves the detail retention of small targets in the feature fusion process and reduces missed detections caused by loss of edge information.
[0062] Transformer Encoding / Decoding Unit: This unit fully retains the original encoding / decoding structure of RT-DETR. It performs global context modeling on the fused multi-scale features through the transformer encoder, enhancing the semantic association between features in different regions. Then, the transformer decoder uses learnable query vectors and encoded features to perform cross-attention interaction, achieving end-to-end target set prediction. This avoids the anchor point design and non-maximum suppression post-processing of traditional detection models, simplifies the engineering deployment process, and ensures the stability and consistency of the detection process.
[0063] Detection Head Output Unit: This unit performs final category prediction and bounding box regression on the output of the Transformer decoder. The core improvement is to replace the original L1+GIoU joint loss with a ShapeIoU loss function that includes shape consistency constraints. By using orientation-weighted center distance and scale consistency constraints, it enhances the geometric constraint capability for targets such as slender floating objects with abnormal aspect ratios and irregular bird nests, improves the bounding box positioning accuracy, and reduces false judgments of safety distance caused by boundary offset. Finally, it outputs a structured detection result that includes hazard category, confidence level, and spatial coordinates.
[0064] like Figure 2The diagram illustrates the complete execution chain of the EDS-DETR model from receiving raw UAV inspection images to outputting the final hazard detection results, including the following steps:
[0065] S100, Image Preprocessing Step: This step standardizes the original inspection images of arbitrary resolution collected by the UAV. First, the images are uniformly scaled to 640×640 pixels, and then mean and variance are normalized. At the same time, data augmentation strategies that conform to the physical structure constraints of the transmission line are applied, including horizontal flipping, small angle rotation of ±10°~15°, brightness and contrast perturbation, etc., avoiding the use of vertical flipping, strong perspective transformation and other operations that destroy spatial consistency. Finally, a standardized tensor that meets the model input requirements is generated, providing a reliable data foundation for subsequent feature extraction.
[0066] S200, Lightweight Multi-Scale Feature Extraction Step: This step inputs the standardized image tensor into the EPNet backbone network and generates feature maps at four scales (S2 (160×160), S3 (80×80), S4 (40×40), and S5 (20×20) through four stages of progressive downsampling. Each stage uses the EPBlock module to perform feature extraction by "partial convolutional downsampling + multi-scale attention enhancement". Shallow features retain spatial detail information of small targets, while deep features extract semantic category information of targets, forming a hierarchical multi-scale feature representation system.
[0067] S300, Dynamic Adaptive Feature Fusion Step: This step completes the adaptive fusion of cross-scale features in the hybrid encoder. First, the S5 deep feature map output by the backbone is dynamically upsampled to the S4 size using DySample and fused element-wise with the S4 features. Then, the fused features are upsampled to the S3 size using DySample and fused with the S3 features a second time. Throughout the process, the sampling coordinates are shifted towards the high-response region of the small target by predicting the sampling point offset, avoiding the edge smoothing problem of fixed interpolation. Finally, multi-scale enhanced features that fuse global semantics and local details are generated.
[0068] S400, Global Semantic Modeling and Feature Decoding Steps: This step uses the Transformer encoder-decoder structure to perform global semantic modeling on the fused multi-scale enhanced features. First, the transformer encoder performs global context encoding on the feature map to enhance the semantic association between features in different regions. Then, the transformer decoder uses 300 learnable query vectors to perform cross-attention interaction with the encoded features to generate a prediction set containing the target category and preliminary parameters of the bounding box, achieving end-to-end target set prediction without relying on anchor design and manual hyperparameter tuning.
[0069] S500, Target Detection and Bounding Box Regression with Shape Constraints: This step optimizes the initial prediction set output by the Transformer decoder using the detection head, completing target category probability prediction and bounding box parameter regression. During the training phase, a joint optimization strategy of L1 coordinate loss and ShapeIoU shape constraint loss is adopted. The predicted box is guided to align with the geometry of the real target through orientation weighting and scale consistency constraints. During the inference phase, the target prediction result with the highest confidence is directly output, effectively improving the localization stability of slender and irregular targets.
[0070] S600, Output Steps for Transmission Line Hazard Detection Results: This step post-processes the original detection results output by the model, filters out low-quality prediction boxes with a confidence score below 0.5, and finally outputs structured detection data containing hazard category, spatial coordinates, and confidence score. This data can be directly connected to the subsequent safety distance calculation and risk assessment modules, providing a directly callable decision basis for transmission line hazard early warning.
[0071] Figure 2 The correspondence between the six complete execution steps and the three core steps in the handover document is as follows:
[0072] Figure 2 It is broken down into 6 sequentially connected independent stages according to the complete engineering execution sequence of the algorithm from input to output, covering all necessary steps from the original image input to the final detection result output. The specific correspondence of each stage is as follows:
[0073] The first step is the S100 image preprocessing stage, which is a common pre-processing step that all object detection models must have, serving as a data standardization preparation before feature extraction.
[0074] The second step is the S200 lightweight multi-scale feature extraction stage, which corresponds to the design of the EPNet lightweight backbone network.
[0075] Next is the S300 dynamic adaptive feature fusion stage, which corresponds to the design of the DySample dynamic upsampling module.
[0076] Next is the S400 global semantic modeling and feature decoding stage, which is the original conventional structure of the RT-DETR model. As an intermediate transition stage between feature fusion and bounding box regression, it has been merged into the latter half of S300, responsible for receiving the fused multi-scale features and completing global semantic encoding and decoding.
[0077] Next is the bounding box regression stage with shape constraints in S500, which corresponds to the design of the ShapeIoU shape constraint loss function.
[0078] Finally, there is the S600 detection result output stage, which is a common post-processing operation that all object detection models have. It is mainly responsible for filtering low-confidence predicted boxes and outputting the results after bounding box regression.
[0079] Specifically, in S200, a lightweight multi-scale backbone network EPNet is constructed, with structural reconstruction based on ResNet18. An EPBlock module is introduced in the deeper layers, embedding a Partial Convolution (PConv) module that only processes a subset of channels. Convolution operations are performed while maintaining the identity mapping for the remaining channels to reduce computational complexity. An efficient multi-scale attention (EMA) mechanism is embedded within EPBlock, constructing spatial orientation encoding paths and local convolution branches based on channel grouping. By establishing cross-spatial and cross-channel dependencies, adaptive recalibration of the feature maps is performed. The specific structural principle of this EPBlock module is as follows: Figure 3 As shown. Figure 3 The internal structure of EPBlock, the core building block of the EPNet backbone network, is shown. It is the core carrier for the invention to achieve "lightweight + multi-scale feature enhancement". Through the dual-branch parallel design, it solves the inherent contradiction of "high computational cost and insufficient expression of small target features" in traditional convolutional modules. While significantly reducing the number of model parameters, it significantly improves the feature discrimination ability of small-scale hidden dangers in complex backgrounds.
[0080] Channel grouping module: This module first divides the feature map output from the previous layer into 8 groups along the channel dimension, providing a foundation for subsequent dual-branch parallel computation. The channel grouping strategy can effectively reduce the computational complexity of a single branch, while providing finer-grained feature units for spatial-channel joint modeling of multi-scale attention mechanisms, ensuring the efficiency and targeting of subsequent feature enhancement operations.
[0081] First feature branch (convolution operation branch): This branch is responsible for completing the basic feature extraction task. The core adopts partial convolution (PConv) operation, only performing 3×3 standard convolution operation on 25% of the channels, and maintaining the identity mapping of the remaining 75% of the channels. The theoretical computational cost is only 1 / 16 of that of standard convolution. After the convolution is completed, the operation channels are concatenated with the identity mapping channels to restore the original number of channels. Without significantly reducing the feature expression ability, the number of parameters and computational cost of the backbone network are greatly reduced.
[0082] The second feature branch (attention enhancement branch): This branch adaptively recalibrates the features output by the convolution branch. First, it performs global average pooling along the horizontal and vertical directions using spatial orientation encoding subunits to extract long-range dependency information across space. Then, it combines the neighborhood structure features extracted by the local 3×3 convolution branch to generate spatial-channel joint attention weights. Finally, it maps the weights to the 0-1 interval using the Sigmoid function and multiplies them element-wise with the original features to enhance the feature response of small target regions and suppress interference information from complex backgrounds.
[0083] Residual Connection Unit: This unit adds the input features and the attention-enhanced features element-wise to construct a residual learning path, effectively solving the gradient vanishing problem in the deep network training process, ensuring that the model can converge stably, and enabling the network to learn more refined feature differences, thereby improving the ability to identify minor hidden dangers.
[0084] Feature Output Port: This port outputs the enhanced feature map processed by EPBlock to the next EPBlock module or hybrid encoder, ensuring the continuous transmission of the feature flow in the backbone network and providing high-quality feature input for subsequent cross-scale feature fusion and global modeling.
[0085] In the cross-scale feature fusion path of the hybrid encoder (S5 to S4, S4 to S3), dynamic upsampling using DySample replaces the original fixed interpolation upsampling. This step is achieved through... Convolution predicts the original offset and generates a set of sampling coordinates, allowing sampling points to be fine-tuned in their local neighborhood. When structural boundaries exist in the low-resolution features, the sampling coordinates move closer to these regions, reducing edge blurring. The specific principle of this dynamic upsampling feature fusion module is as follows: Figure 4 As shown, Figure 4 The internal structure of the DySample dynamic upsampling module for cross-scale feature fusion of the present invention is shown. It replaces the original bilinear fixed interpolation upsampling of RT-DETR. Through content-aware adaptive sampling coordinate adjustment, it solves the problems of blurred edges and loss of details of small targets caused by fixed interpolation. Without increasing the amount of computation, it significantly improves the detail retention of small targets in the feature fusion process.
[0086] Low-resolution feature input port: This port receives low-resolution feature maps from the deep layers of the backbone, including two scales: S5 (20×20) and S4 (40×40). These features contain rich semantic category information, but have low spatial resolution. The structural details of small targets at a distance have been downsampled and compressed multiple times. They need to be upsampled to restore the spatial resolution before being fused with shallow features.
[0087] High-resolution feature input port: This port receives high-resolution feature maps from the shallow layers of the backbone, including two scales: S4 (40×40) and S3 (80×80). These features retain clear spatial edges and texture details, but have weak semantic information. They need to be fused with deep semantic features to achieve accurate target recognition and localization.
[0088] Offset Prediction Convolutional Unit: This unit is the core of dynamic upsampling. It processes the input low-resolution feature map through 1×1 convolution to predict the sampling offset corresponding to each pixel. 2×s² offsets are predicted for each position (s is the upsampling factor), providing coordinate basis for subsequent adaptive sampling, so that the sampling points can automatically adjust their positions according to the feature content.
[0089] Local Neighborhood Coordinate Fine-tuning Unit: This unit constrains the magnitude of the predicted original offset, limiting it to ±2 pixels to prevent the sampling points from deviating too much from their original positions, which would lead to unstable feature fusion. Then, the PixelShuffle operation rearranges the channel-dimensional offset into the spatial-dimensional sampling coordinates, realizing the mapping of the offset from the channel space to the image space.
[0090] Sampling coordinate generation unit: This unit first generates basic regular grid coordinates to ensure the overall continuity of sampling. Then, it adds the basic grid coordinates to the fine-tuned offset to obtain the final adaptive sampling coordinate set, which enables the sampling points to shift to the high-response area of small targets, thereby achieving accurate sampling with content awareness.
[0091] Content-aware resampling unit: This unit samples pixel values from the low-resolution feature map through bilinear interpolation based on the generated adaptive sampling coordinates, and generates an upsampled high-resolution feature map. When there is a high-response region of a small target in the low-resolution feature map, the sampling coordinates will automatically converge to that region, thereby preserving clearer edge information and avoiding the edge smoothing effect of fixed interpolation.
[0092] Cross-scale feature fusion unit: This unit adds the upsampled low-resolution feature map to the corresponding high-resolution feature map element by element to complete cross-scale feature fusion. This allows the fused features to contain both deep semantic information and shallow detail information. Finally, it outputs a multi-scale enhanced feature map to the Transformer encoder, providing a foundation for subsequent global semantic modeling.
[0093] In the detection head output stage, joint boundary regression loss is used for network optimization, and the overall loss function is defined as follows: in A shape consistency extension is introduced, adaptively allocating distance penalty weights based on the aspect ratio of the real target to guide the predicted bounding box to converge preferentially along the principal geometric direction. Simultaneously, a scale consistency constraint term is introduced to suppress shape deviations caused by aspect ratio imbalances. The specific calculation process for this ShapeIoU loss is as follows: Figure 5 As shown, Figure 5 This paper demonstrates the complete calculation process of the ShapeIoU joint boundary regression loss proposed in this invention, which replaces the original RT-DETR L1+GIoU loss function. By introducing orientation-weighted center distance and scale consistency constraints, it solves the problem of insufficient constraints on the geometric shape of slender targets by traditional loss functions, and significantly improves the positioning accuracy and stability of targets with abnormal aspect ratios.
[0094] Predicted bounding box parameter input port: This port receives the predicted bounding box parameters output by the detection head, including the target center point coordinates (x, y), width w, and height h. These parameters are the model's preliminary estimate of the target's spatial location and scale, and need to be continuously optimized through the constraints of the loss function to make them approximate the true labeled values.
[0095] Input port for ground truth bounding box annotation parameters: This port receives manually annotated ground truth bounding box parameters, including ground truth center point coordinates (x_gt, y_gt), ground truth width w_gt, and ground truth height h_gt, which serve as the baseline values for loss calculation and are used to measure the degree of spatial matching between the predicted bounding box and the ground truth target.
[0096] Intersection over Union (IoU) Basic Calculation Unit: This unit first calculates the Intersection over Union (IoU) between the predicted bounding box and the ground truth bounding box, which serves as the basic term of the loss function and intuitively reflects the degree of spatial overlap of the bounding boxes. However, IoU cannot provide an effective gradient when the two boxes do not overlap, and it is not sensitive to the proportional shift of slender targets. Therefore, it needs to be supplemented and improved by subsequent constraint terms.
[0097] The width-to-height ratio adaptive weight allocation unit calculates the directional weighting coefficients α_w and α_h based on the width-to-height ratio of the real bounding box. When the target is slender, the weight of the corresponding geometric principal direction will automatically increase, guiding the model to prioritize optimizing the localization error in that direction, so that the predicted bounding box can be better aligned with the geometry of the real target, thus solving the problem of insufficient constraints of traditional loss functions on slender targets.
[0098] Orientation-weighted center distance penalty calculation unit: This unit calculates the weighted distance penalty between the center point of the predicted box and the center point of the ground truth box based on adaptive weights. Compared with the equal weighted center distance of GIoU, orientation weighting can more accurately constrain the center position of slender targets, reduce the error in calculating the safe distance caused by center offset, and improve the reliability of risk assessment.
[0099] Scale consistency constraint calculation unit: This unit calculates the difference in aspect ratio between the predicted box and the ground truth box, and introduces an exponential mapping form of scale consistency penalty. When the aspect ratio deviation is small, the gradient remains smooth, and when the deviation is large, the penalty intensity is rapidly increased, which accelerates the convergence of the geometric shape and effectively suppresses the shape deviation caused by the imbalance of aspect ratio.
[0100] ShapeIoU Loss Synthesis Unit: This unit combines the IoU base term, orientation-weighted center distance term, and scale consistency constraint term to obtain the final ShapeIoU loss value. It comprehensively considers the overlap, center position, and shape ratio of the bounding box to achieve all-round constraints on the bounding box, enabling the predicted box to more accurately fit the spatial shape of the real target.
[0101] Network backpropagation optimization unit: This unit performs a weighted summation of ShapeIoU loss, L1 coordinate loss, and classification loss to obtain the total loss value of the model. Then, it updates all parameters of the model through the backpropagation algorithm, continuously iterating and optimizing the detection accuracy and positioning stability of the model, ultimately enabling the model to achieve accurate hazard detection and positioning in complex scenarios.
[0102] Notes on English abbreviations:
[0103] RT-DETR: Benchmark Target Detection Model, an end-to-end detection structure.
[0104] EDS-DETR: An improved static hazard detection model proposed in this invention.
[0105] EPNet: Lightweight multi-scale backbone network.
[0106] Transformer: The encoding and decoding structure in the model, used for global modeling.
[0107] ResNet18: A basic residual network structure, upon which the backbone network is reconstructed in this invention.
[0108] PConv: Partial Convolution, used to perform feature extraction while controlling the computational scale.
[0109] EMA: Efficient Multi-scale Attention, used to establish cross-spatial and cross-channel dependencies.
[0110] DySample: A dynamic sampling method / dynamic upsampling mechanism used to preserve local details during cross-scale information transmission.
[0111] IoU: Intersection over Union, representing the degree of overlap between the predicted bounding box and the ground truth bounding box.
[0112] GIoU: Generalized Intersection over Union (IOU) loss, a combined constraint term for bounding box optimization.
[0113] ShapeIoU: A joint boundary regression loss form that includes shape consistency constraints.
[0114] L1: L1 loss, a basic coordinate regression constraint term.
[0115] FPS: Inference speed, used to measure the real-time performance of a model and its processing frame rate.
[0116] Params: The number of parameters used to measure the computational scale and resource consumption of the model.
[0117] mAP: Mean Average Precision, used to characterize the overall detection quality at different IoU thresholds.
[0118] Example
[0119] I. Experimental Hardware and Software Environment Configuration
[0120] All experiments in this embodiment were completed on a unified hardware and software platform, covering two typical scenarios: cloud training and UAV-based edge deployment. The specific configurations are as follows:
[0121] Cloud training hardware: Intel Xeon Gold 6430 CPU + NVIDIA RTX 3080 Ti GPU (12GB GDDR6X VRAM)
[0122] Edge deployment test hardware: NVIDIA Jetson Xavier NX edge computing platform (8GB VRAM, mainstream configuration for drones).
[0123] Software environment: PyTorch 2.1.0 deep learning framework, CUDA 12.1 parallel computing architecture, OpenCV 4.8.0 image processing library.
[0124] Standardized input for the model: All input images are standardized to a resolution of 640×640 pixels.
[0125] II. Construction of Experimental Dataset
[0126] This embodiment uses a self-built TIFD (Transmission Line Foreign Object Detection) dataset for foreign object detection in transmission lines, specifically designed for typical static hidden danger scenarios in transmission channels. The specific construction process is as follows:
[0127] Raw data collection: By integrating historical drone inspection images provided by the State Grid Electric Power Research Institute of a certain province, supplementary data from on-site aerial photography by the research team, and publicly available resource samples, a total of 1,698 original and valid images were obtained, covering four core static hazards: bird nests, balloons, kites, and plastic film. The images comprehensively include typical inspection scenarios with complex backgrounds (trees, buildings, mountains, and water), different weather conditions (sunny, cloudy, foggy, and snowy), multiple shooting angles (overhead, low-angle, and side shots), and different degrees of obstruction.
[0128] Data annotation and augmentation: The LabelImg tool was used for manual object annotation in PASCALVOC format. All samples underwent two manual reviews to ensure the accuracy of bounding box positions and category annotations. To address the issues of insufficient sample size and unbalanced category distribution in the original data, data augmentation strategies that conform to the physical structure constraints of transmission lines were adopted. These strategies included geometric augmentation (horizontal flipping, small-angle rotation of ±10°~15°, scale jitter, and random cropping with target preservation constraints), image augmentation (brightness, contrast, saturation perturbation, gamma correction, and mild motion blur), and instance-level copy-paste augmentation. Ultimately, the dataset size was expanded to 9607 images, and the distribution of samples in each category tended to be more balanced.
[0129] Dataset partitioning: The dataset was randomly divided into a training set (7685 images), a validation set (961 images), and a test set (961 images) in a ratio of 8:1:1. This strictly ensures that the same original image and all its enhanced versions belong to only the same subset of data, thus avoiding data leakage issues.
[0130] III. Model Training Process
[0131] Parameter initialization strategy: The backbone network EPNet is loaded with ResNet18 weights pre-trained on the ImageNet-1K general dataset, the Transformer encoder and decoder are loaded with RT-DETR official pre-trained weights, and the decoder and detector head adopt the Xavier initialization method to ensure gradient stability in the early stage of training.
[0132] Training hyperparameter settings: AdamW optimizer was used, and the initial learning rate was set to 1×10⁻ 4 The weight decay coefficient is 1×10⁻ 4 The batch size is 32, and the total training rounds are set to 300 epochs. A cosine annealing learning rate scheduling strategy is adopted, and the first 5 epochs are used for linear learning rate warm-up. The loss function is a weighted combination of classification loss, L1 coordinate loss and ShapeIoU shape constraint loss, with a weight ratio of 1:0.5:1.
[0133] Training process monitoring and convergence: The validation set mAP@0.5 metric is monitored in real time during training. An early stopping mechanism is triggered when the validation set metric does not improve for 20 consecutive epochs. Experimental results show that the model reaches convergence at about 200 epochs, the validation set mAP@0.5 tends to stabilize, the training loss curve decreases smoothly, and there is no overfitting phenomenon.
[0134] Generalization validation: The five-fold cross-validation method was used to evaluate the generalization ability of the model. The training set was divided into 5 mutually exclusive subsets. In each iteration, 4 subsets were selected for training and the remaining subset was used for testing. After 5 iterations, the mean and standard deviation of each indicator were calculated. The results showed that the fluctuation of mAP@0.5 under different data partitions was less than 0.5%, which proved that the model has good generalization stability.
[0135] Experimental results show that the EPNet backbone network, which adopts the EPBlock structure that integrates PConv and EMA, reduces the number of parameters by 13.4% compared with the benchmark RT-DETR, while improving the small target feature extraction capability by 6.8%, effectively balancing lightweight design and feature representation capability.
[0136] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0137] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A lightweight DETR detection method for small-target transmission lines, characterized in that, Includes the following steps: Step 1: Image preprocessing; Standardize the raw inspection images of arbitrary resolution acquired by the UAV to generate standardized tensors; Step 2: Lightweight multi-scale feature extraction; The standardized image tensor is input into the EPNet backbone network, and through multiple stages of downsampling and feature extraction, a hierarchical multi-scale feature representation system is formed. Step 3: Dynamic adaptive feature fusion; The adaptive fusion of cross-scale features is completed in the hybrid encoder to generate multi-scale enhanced features that fuse global semantics and local details; Step 4: Global semantic modeling and feature decoding; The fused multi-scale enhanced features are modeled globally using the Transformer encoding and decoding structure to generate a prediction set containing the target category and preliminary bounding box parameters. Step 5: Bounding box regression and target detection output based on shape constraint ShapeIoU; The detection head performs final optimization on the preliminary prediction set output by the Transformer decoder to complete the target class probability prediction and bounding box parameter regression. Step 6: Output the detection results of potential hazards in the transmission line; Post-process the original detection results output by the model, filter out low-quality prediction boxes with confidence scores below the preset value, and finally output structured detection data containing hazard category, spatial coordinates, and confidence scores to realize safe distance calculation and risk assessment.
2. The DETR detection method for lightweight transmission lines targeting small targets as described in claim 1, characterized in that, In step 1, the image is first scaled to 640×640 pixels, then the mean and variance are normalized. At the same time, data augmentation strategies that conform to the physical structure constraints of the transmission line are applied, including horizontal flipping, small-angle rotation of ±10° to 15°, and brightness and contrast perturbation. Finally, a standardized tensor that meets the model input requirements is generated.
3. The DETR detection method for lightweight transmission lines targeting small targets as described in claim 1, characterized in that, In step 2, the standardized image tensor is input into the EPNet backbone network. Through four stages of progressive downsampling, feature maps of four scales, namely S2 (160×160), S3 (80×80), S4 (40×40), and S5 (20×20), are generated. In each stage, the EPBlock module completes part of the convolutional reduction calculation and multi-scale attention-enhanced feature extraction. The shallow features retain the spatial details of small targets, while the deep features extract the semantic category information of the targets, forming a hierarchical multi-scale feature representation system.
4. The DETR detection method for lightweight transmission lines targeting small targets as described in claim 3, characterized in that, The EPNet backbone network uses the EPBlock lightweight multi-scale feature extraction module, which includes a channel grouping module, a first feature branch, a second feature branch, a residual connection unit, and a feature output port. The channel grouping module first divides the feature map output by the previous layer into 8 groups along the channel dimension, providing a foundation for subsequent dual-branch parallel computation; The first feature branch is a convolution operation branch, which is responsible for completing the basic feature extraction task. The core adopts partial convolution PConv operation, only performing 3×3 standard convolution operation on 25% of the channels, and maintaining the identity mapping on the remaining 75% of the channels. The theoretical computational cost is only 1 / 16 of that of standard convolution. After the convolution is completed, the operation channels are concatenated with the identity mapping channels to restore the original number of channels. The second feature branch is the attention enhancement branch, which adaptively recalibrates the features output by the convolution branch. First, global average pooling is performed along the horizontal and vertical directions by spatial orientation encoding subunits to extract long-range dependency information across space. Then, the neighborhood structure features extracted by the local 3×3 convolution branch are combined to generate spatial-channel joint attention weights. Finally, the weights are mapped to the 0-1 interval by the Sigmoid function and multiplied element-wise with the original features to enhance the feature response of small target regions and suppress interference information from complex backgrounds. The residual connection unit adds the input features and the attention-enhanced features element by element to construct a residual learning path, which effectively solves the gradient vanishing problem in the deep network training process, ensures that the model can converge stably, and enables the network to learn more refined feature differences, thereby improving the ability to identify minor hidden dangers. The feature output port outputs the enhanced feature map processed by EPBlock to the next EPBlock module or hybrid encoder, ensuring the continuous transmission of the feature flow in the backbone network and providing high-quality feature input for subsequent cross-scale feature fusion and global modeling.
5. The DETR detection method for lightweight transmission lines targeting small targets as described in claim 1, characterized in that, In step 3, the S5 deep feature map output by the backbone is first dynamically upsampled to the S4 size using DySample, and then fused element-wise with the S4 feature. The fused feature is then upsampled to the S3 size using DySample and fused with the S3 feature a second time. Throughout the process, the sampling coordinates are shifted towards the high-response region of the small target by predicting the sampling point offset, thus avoiding the edge smoothing problem of fixed interpolation. Finally, a multi-scale enhanced feature that fuses global semantics and local details is generated.
6. The DETR detection method for lightweight transmission lines targeting small targets as described in claim 5, characterized in that, The original RT-DETR bilinear fixed interpolation upsampling is replaced by the DySample dynamic upsampling module with cross-scale feature fusion. The DySample dynamic upsampling module includes a low-resolution feature input port, a high-resolution feature input port, an offset prediction convolution unit, a local neighborhood coordinate fine-tuning unit, a sampling coordinate generation unit, a content-aware resampling unit, and a cross-scale feature fusion unit. The low-resolution feature input port receives low-resolution feature maps from the deep layers of the trunk, including two scales: S5 (20×20) and S4 (40×40); the high-resolution feature input port receives high-resolution feature maps from the shallow layers of the trunk, including two scales: S4 (40×40) and S3 (80×80). The offset prediction convolutional unit is the core of dynamic upsampling. It processes the input low-resolution feature map through 1×1 convolution to predict the sampling offset corresponding to each pixel. 2×s² offsets are predicted at each position, where s is the upsampling factor. This provides coordinate basis for subsequent adaptive sampling, enabling the sampling points to automatically adjust their positions according to the feature content. The local neighborhood coordinate fine-tuning unit constrains the predicted original offset by limiting it to ±2 pixels to prevent the sampling points from deviating too much from their original positions, which would lead to unstable feature fusion. Then, the PixelShuffle operation rearranges the channel-dimensional offset into the spatial-dimensional sampling coordinates to achieve the mapping of the offset from the channel space to the image space. The sampling coordinate generation unit first generates basic regular grid coordinates to ensure the overall continuity of sampling. Then, it adds the basic grid coordinates to the fine-tuned offset to obtain the final adaptive sampling coordinate set, which enables the sampling points to shift towards the high-response area of small targets, thereby achieving accurate sampling with content awareness. The content-aware resampling unit samples pixel values from the low-resolution feature map through bilinear interpolation based on the generated adaptive sampling coordinates, and generates an upsampled high-resolution feature map. When there is a high-response region of a small target in the low-resolution feature map, the sampling coordinates will automatically converge to that region, thereby preserving clearer edge information and avoiding the edge smoothing effect of fixed interpolation. The cross-scale feature fusion unit adds the upsampled low-resolution feature map to the corresponding high-resolution feature map element by element to complete the cross-scale feature fusion. This allows the fused features to contain both deep semantic information and shallow detail information. Finally, it outputs a multi-scale enhanced feature map to the Transformer encoder, providing a foundation for subsequent global semantic modeling.
7. The DETR detection method for lightweight transmission lines targeting small targets as described in claim 1, characterized in that, In step 4, the fused multi-scale enhanced features are modeled globally using the Transformer encoder-decoder structure. First, the transformer encoder performs global context encoding on the feature map to enhance the semantic association between features in different regions. Then, the transformer decoder uses 300 learnable query vectors to perform cross-attention interaction with the encoded features to generate a prediction set containing the target category and preliminary bounding box parameters, thus achieving end-to-end target set prediction.
8. The DETR detection method for lightweight transmission lines targeting small targets according to claim 7, characterized in that, A complete calculation process for ShapeIoU joint boundary regression loss is adopted to replace the original RT-DETR L1+GIoU loss function; including the input port of predicted bounding box parameters, the input port of true bounding box annotation parameters, the basic calculation unit of intersection-union ratio (IoU), the adaptive weight allocation unit of width-to-height ratio, the calculation unit of orientation-weighted center distance penalty term, the calculation unit of scale consistency constraint term, the ShapeIoU loss value synthesis unit, and the network backpropagation optimization unit; The predicted bounding box parameter input port receives the predicted bounding box parameters output by the detection head, including the target center point coordinates (x, y), width w, and height h. These parameters are the model's preliminary estimate of the target's spatial location and scale, and need to be continuously optimized through the constraints of the loss function to make them approximate the true labeled values. The real bounding box annotation parameter input port receives manually annotated real bounding box parameters, including the real center point coordinates (x_gt, y_gt), the real width w_gt, and the real height h_gt, which serve as the benchmark values for loss calculation and are used to measure the degree of spatial matching between the predicted bounding box and the real target. The Intersection over Union (IoU) basic calculation unit first calculates the IoU between the predicted bounding box and the ground truth bounding box, which serves as the basic term of the loss function and intuitively reflects the degree of spatial overlap of the bounding boxes. However, IoU cannot provide an effective gradient when the two boxes do not overlap, and it is not sensitive to the proportional shift of slender targets. Therefore, subsequent constraint terms are needed to supplement and improve it. The width-to-height ratio adaptive weight allocation unit calculates the directional weighting coefficients α_w and α_h based on the width-to-height ratio of the real bounding box. When the target is slender, the weight of the corresponding geometric principal direction will automatically increase, guiding the model to prioritize optimizing the positioning error in that direction, so that the predicted bounding box can be better aligned with the geometry of the real target. The orientation-weighted center distance penalty calculation unit calculates the weighted distance penalty between the center point of the predicted box and the center point of the real box based on adaptive weights. Compared with the equal-weighted center distance of GIoU, orientation-weighted can more accurately constrain the center position of slender targets, reduce the error in calculating the safe distance caused by center offset, and improve the reliability of risk assessment. The scale consistency constraint calculation unit calculates the difference in the aspect ratio between the predicted box and the real box, and introduces an exponential mapping form of scale consistency penalty. When the aspect ratio deviation is small, it maintains a smooth gradient, and when the deviation is large, it rapidly increases the penalty intensity, accelerates the convergence of the geometric shape, and effectively suppresses the shape deviation caused by the imbalance of aspect ratio. The ShapeIoU loss value synthesis unit weights and synthesizes the IoU base term, the orientation-weighted center distance term, and the scale consistency constraint term to obtain the final ShapeIoU loss value. It comprehensively considers the overlap, center position, and shape ratio of the bounding box to achieve all-round constraints on the bounding box, so that the predicted box can more accurately fit the spatial shape of the real target. The network backpropagation optimization unit performs a weighted summation of ShapeIoU loss, L1 coordinate loss, and classification loss to obtain the total loss value of the model. Then, it updates all parameters of the model through the backpropagation algorithm, continuously iterating and optimizing the detection accuracy and positioning stability of the model, ultimately enabling the model to achieve accurate hazard detection and positioning in complex scenarios.
9. The DETR detection method for lightweight transmission lines targeting small targets as described in claim 1, characterized in that, In step 5, the detection head performs final optimization on the preliminary prediction set output by the Transformer decoder to complete the target category probability prediction and bounding box parameter regression. During the training phase, a joint optimization strategy of L1 coordinate loss and ShapeIoU shape constraint loss is adopted. The prediction box is guided to align with the geometry of the real target through orientation weighting and scale consistency constraints. During the inference phase, the target prediction result with the highest confidence is directly output to improve the localization stability of slender and irregular targets.
10. A lightweight DETR detection system for small-target transmission lines, the system being based on the method of any one of claims 1-9, characterized in that, It includes an image preprocessing module, a lightweight multi-scale feature extraction module, a dynamic adaptive feature fusion module, a global semantic modeling and feature decoding module, a bounding box regression and object detection output module, and a detection result module; The image preprocessing module performs standardization processing on the raw inspection images of arbitrary resolution collected by the UAV to generate a standardized tensor. The lightweight multi-scale feature extraction module inputs the standardized image tensor into the EPNet backbone network, and forms a hierarchical multi-scale feature representation system through multiple stages of downsampling and feature extraction. The dynamic adaptive feature fusion module completes the adaptive fusion of cross-scale features in the hybrid encoder, generating multi-scale enhanced features that fuse global semantics and local details; The global semantic modeling and feature decoding module performs global semantic modeling on the fused multi-scale enhanced features through the Transformer encoding and decoding structure, generating a prediction set containing the target category and preliminary bounding box parameters; The bounding box regression and target detection output module performs final optimization on the preliminary prediction set output by the Transformer decoder through the detection head, and completes the target category probability prediction and bounding box parameter regression. The detection result module performs post-processing on the original detection results output by the model, filters out low-quality prediction boxes with confidence scores below the preset value, and finally outputs structured detection data containing hazard categories, spatial coordinates, and confidence scores, thereby realizing safe distance calculation and risk assessment.
