A freight train container roof foreign matter detection method based on improved RetinexFormer and YOLOv10
Patent Information
- Application Number
- CN202611109450.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-24
- Publication Date
- 2026-10-16
AI Technical Summary
[0007]综上所述,现有技术存在以下技术问题:(1)RetinexFormer的光照估计器感受野有限,难以处理车顶场景的非均匀光照;(2)现有增强方法缺乏对光照不变结构先验的有效利用;(3)增强模块与检测模块之间缺乏面向检测任务的协同优化;(4)车顶小目标异物在低光照条件下检测精度低、漏检率高
(1)本发明在增强阶段采用改进RetinexFormer提取结构先验图,该结构先验图引导增强网络区分光照变化与真实边缘,在光照不均区域仍能保持异物边缘的完整性以及有效识别金属反光区域,并通过光照归一化处理,使得夜间低照度图像经增强后,螺栓、工具等小目标的边缘对比度显著提升,同时背景噪声得到有效抑制,从而能够有效解决光照不均、夜间低照度、金属反光等因素导致的图像质量退化问题,从而避免了因图像质量问题而造成的错检、漏检。同时,本发明利用NMS-free一致性双匹配策略训练YOLOv10目标检测网络,确保小目标在复杂光照下的稳定召回,最终实现夜间、隧道等恶劣环境下车顶异物的可靠检测。
Smart Images

Figure CN122929280A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing and target detection, and in particular to a method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10. Background Technology
[0002] With the rapid development of railway transportation, the volume of container transported by freight trains continues to grow. Foreign objects on the roof of container cars (such as loose tarpaulins, scattered goods, tools left by workers, etc.) are a significant hazard to railway traffic safety. These objects may fall off during operation, strike the overhead contact line or trackside equipment, or even cause serious accidents such as derailment. Therefore, real-time and accurate foreign object detection on the roofs of freight train container cars is of paramount safety importance.
[0003] However, existing methods for detecting foreign objects on the roof mainly rely on manual inspection or fixed-point camera monitoring, which have the following technical problems: (1) Large blind spots: The roof area is located on the top of the train, and traditional monitoring cameras cannot achieve full coverage; (2) Poor lighting conditions: The lighting is severely insufficient in scenarios such as night, inside tunnels, and rainy weather, resulting in serious degradation of image quality, low contrast between foreign objects and background, and difficulty in identification; (3) Large differences in the size of foreign objects: The size of foreign objects on the roof ranges from small parts a few centimeters to large tarpaulins several meters, which places extremely high demands on the multi-scale perception capability of the detection algorithm.
[0004] In the field of low-light image enhancement, RetinexFormer proposes a single-stage Retinex-based Transformer method. It estimates the illuminance map using a lighting estimator and then uses a denoiser for denoising and enhancement. However, RetinexFormer's lighting estimator only uses single-scale depth convolution to extract lighting priors, resulting in a limited receptive field and difficulty in capturing the complex distribution of multiple light sources and non-uniform lighting in rooftop scenes. Furthermore, the original structure lacks a channel / spatial adaptive selection mechanism, is sensitive to enhanced noise, and does not consider lighting invariance features, leading to insufficient generalization ability under drastic changes in day and night lighting conditions.
[0005] It is worth noting that while existing technologies (such as patent application CN120355900A) propose a low-light detection method based on a cascaded Retinexformer and YOLO, their gated adaptive feature fusion module only weights the output of multi-scale parallel convolutions, without introducing structural prior information decoupled from lighting conditions. Furthermore, their use of the YOLOv11 model combined with traditional NMS (Non-Maximum Suppression) post-processing results in high inference latency. More importantly, existing technologies are geared towards general aerial photography scenarios and are not optimized for the unique challenges of railway rooftop scenes, such as metallic reflections and small foreign objects.
[0006] In the field of object detection, YOLOv10 achieves NMS-free training through a dual-assignment strategy, reducing inference latency. However, YOLOv10 lacks a preprocessing mechanism for low-light scenes at its input end. Under uneven lighting conditions, the feature extraction capability of the backbone decreases significantly, leading to missed detections of small targets and low-contrast foreign objects.
[0007] In summary, the existing technologies have the following technical problems: (1) The receptive field of the illumination estimator of RetinexFormer is limited, making it difficult to handle non-uniform illumination in the roof scene; (2) Existing enhancement methods lack effective utilization of illumination-invariant structural priors; (3) There is a lack of collaborative optimization between the enhancement module and the detection module for the detection task; (4) The detection accuracy of small target foreign objects on the roof is low and the false negative rate is high under low illumination conditions. Summary of the Invention
[0008] The purpose of this invention is to provide a foreign object detection method for the roof of a freight train container based on the improved RetinexFormer and YOLOv10, which reduces false detections and false negatives by improving image quality.
[0009] The objective of this invention can be achieved through the following technical solutions: A method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10 includes the following steps: Obtain images of the roof of a freight train container; The roof image is input into the improved RetinexFormer model. First, the structure prior map is extracted. Then, the illumination normalization process is performed based on the structure prior map, and the denoised enhanced image is output. The denoised and enhanced image is input into a pre-trained YOLOv10 object detection network to perform foreign object detection and output the foreign object detection result. The YOLOv10 object detection network is trained using an NMS-free consistency double-matching strategy.
[0010] Furthermore, the CIConv module in the improved RetinexFormer model is used to extract the structural prior graph. The extraction steps of the structural prior graph include: (1) Parameter initialization: Define the learnable parameters that control the Gaussian kernel scale as follows Its initial value is , ,set up , Here is the regularization constant; (2) Transformation of roof image to spectral features: The roof image is reconstructed to obtain a reconstructed image. The reconstructed image is then multiplied by the transpose of the Gaussian color model transformation matrix and reconstructed back to the original spatial dimension to obtain a spectral feature representation. The spectral feature representation includes three components: light intensity, ... First derivative of the spectrum and the second derivative of the spectrum ; (3) Gaussian kernel pre-computation: During each forward propagation, the current learnable parameters are used to pre-compute the Gaussian kernel. Gaussian kernel scale is obtained through exponential mapping. And calculate the 1D Gaussian kernel function value based on the Gaussian kernel scale. and 1D Gaussian derivative kernel function value Then and Reconstructed into convolutional kernels in the X and Y directions respectively, where Updated via backpropagation and gradient descent during training; (4) Spatial derivative calculation: For the light intensity First derivative of the spectrum and the second derivative of the spectrum First use Smooth the surface in both the X and Y directions, then use... Perform Gaussian derivative convolutions in the X and Y directions respectively to obtain the spatial derivative in the X direction and the Gaussian derivative in the Y direction, where the padding in the X direction is set to [0, ..., ... In the Y direction, padding is set to [ [0], where padding is the amount of padding at the convolution edge. The sampling radius of the discrete Gaussian kernel on one side. This represents the total size of the discrete Gaussian kernel; (5) Calculation of W component: based on the first derivative of the spectrum Spectral second derivative And the spatial derivative in the X direction and the Gaussian derivative in the Y direction, in terms of light intensity Normalize based on the baseline: In the formula, for The intensity of normalized spatial variation in the X direction. for Normalized variation intensity in the X direction, for Normalized variation intensity in the X direction, for The intensity of normalized spatial variation in the Y direction, for Normalized variation intensity in the Y direction, for Normalized variation intensity in the Y direction, , , The spatial derivative in the X direction. for The spatial derivative in the X direction, To prevent extremely small constants that are zero, for The spatial derivative in the X direction, for The spatial derivative in the X direction, , , The spatial derivative in the Y direction. for Spatial derivative in the Y direction, for Spatial derivative in the Y direction, for Spatial derivative in the Y direction; Will , , , , , By fusing the data, we obtain the perceived weights of the comprehensive spatial-spectral variation intensity. , is represented as: (6) Normalized output: the normalized output of the perceptual weights A logarithmic transformation is performed to calculate the mean and standard deviation, and then normalization is performed based on the mean and standard deviation to obtain a priori structural diagram independent of illumination conditions. The logarithmic transformation expression is: The normalization expression is: In the formula, The value after logarithmic transformation. The mean, The standard deviation is denoted as .
[0011] Furthermore, illumination normalization is performed using the improved illumination estimator, illuminance decomposer, and denoiser in the improved RetinexFormer model to obtain a denoised enhanced image. The improved illumination estimator is used to perform illumination estimation and output an illuminance map. The illuminance decomposer is used to decompose the illuminance map and the roof image to obtain the enhanced image. The denoiser is used to denoise the enhanced image and output the denoised enhanced image.
[0012] Furthermore, the improved illumination estimator includes an input projection layer, a pre-activation layer, a multi-scale depthwise convolutional unit, a gated attention unit, a residual fusion layer, and an output projection layer. The processing steps of the improved illumination estimator include: A multi-channel input is obtained, which is formed by stitching together the first channel of the structural prior image, the multiple channels of the roof image, and its mean channel. The multi-channel input is projected onto the intermediate feature space using the input projection layer, and then processed by the pre-activation layer to obtain the pre-activated output; Based on the pre-activated output, the multi-scale depth convolutional unit uses multiple parallel depth-separable convolutional branches to perform preliminary multi-scale feature extraction, then concatenates them along the channel dimension, and fuses them back to the original number of channels through convolution to obtain a preliminary fused feature map. Based on the preliminary fused feature map, multi-scale features are extracted again using the gated attention unit, and then spliced along the channel dimension to generate gated weights. The preliminary fused feature map is then adaptively weighted based on the gated weights to obtain the gated weighted feature map. The gated weighted feature map, the pre-activated output, and the output of the input projection layer are fused using the residual fusion layer to obtain the final fused feature map, which is an illumination feature map. Based on the final fused feature map, an illumination map is output through an output projection layer and a Sigmoid activation function.
[0013] Furthermore, the gated attention unit utilizes multiple dilated depthwise convolution branches to extract multi-scale features again. The processing expression of the gated attention unit is as follows: In the formula, For gating weights, It is the Sigmoid activation function. This is a 1×1 convolution transformation operation. Multi-scale features under different void ratios, This is the gated weighted feature map. To initially fuse the feature maps, For learnable residual scaling factor, This is an element-wise multiplication operation. This indicates a channel dimension splicing operation.
[0014] Furthermore, the processing expression of the illuminance resolver is: In the formula, To enhance the image, Image of the car roof. This is an illumination map.
[0015] Furthermore, the denoiser adopts a U-Net structure, including an encoder, a bottleneck layer, and a decoder. The processing steps of the denoiser include: For encoders: The enhanced image is processed through multiple coding layers. and illumination feature map Synchronous downsampling is performed to obtain downsampled multi-scale enhanced image feature maps and downsampled multi-scale illumination feature maps, respectively. In each coding layer, the downsampled corresponding scale enhanced image feature map and downsampled corresponding scale illumination feature map have the same resolution. In each coding layer, the downsampled corresponding scale-enhanced image feature map and the downsampled corresponding scale illumination feature map are jointly input into the illumination-guided attention module to obtain the illumination-guided image features output by each coding layer. For the bottleneck layer: The downsampled illumination feature map of the corresponding scale output of the last coding layer is used to model the global illumination noise, and the modeling result is fused with the image features containing illumination guidance output of the last coding layer to obtain the bottleneck layer features that fuse global illumination noise information. For the decoder: By using multiple decoding layers, the bottleneck layer features are upsampled to restore the image features with illumination guidance from the skip connections of each coding layer at the same resolution, while restoring the illumination feature map at the corresponding scale. In each decoding layer, the upsampled bottleneck layer features / upper decoding layer output features are concatenated with the image features containing illumination guidance from the skip connection of the corresponding coding layer to obtain the concatenated features of each layer. The concatenated features of each layer and the restored illumination feature map of each layer are input into the illumination guidance attention module of that layer to output the image features of each decoding layer. The image features of the highest decoding layer are mapped to obtain the denoised feature map. The processing steps for each layer of the illumination-guided attention module include: The input to each layer of the illumination-guided attention module is set to image features and illumination features. The image features are the corresponding scale-enhanced image feature map after downsampling in the coding layer or the corresponding layer splicing features in the decoding layer. The illumination features are the corresponding scale illumination feature map after downsampling in the coding layer or the illumination feature map after recovery in the corresponding layer in the decoder. Generate queries by projecting image features. ,key ,value And will query ,key ,value Split along the channel dimension Size; The illumination features are transformed linearly to generate a model similar to... Attention modulation terms matching branch space size and head number ; For each head, compute the standard scaled dot product attention: In the formula, For attention output, Channel dimension for each head; Attention output and attention modulation terms Perform element-wise weighted summation to obtain the output of each head. , is represented as: The outputs of all heads are stitched together along the channel dimension, and then linearly projected to obtain the output of each layer of the illumination-guided attention module.
[0016] Furthermore, the training steps of the NMS-free consensus double-matching strategy include: The classification confidence score is calculated for each real foreign object bounding box and the candidate predicted bounding boxes output by the multi-scale decoupled detection head in the YOLOv10 object detection network. and positioning overlap The multi-scale decoupling detection head includes a one-to-many branch and a one-to-one branch; Based on the classification confidence level and positioning overlap Construct task alignment matching degree , of which , These are the classification and positioning weights, respectively. In a one-to-many branching model, for each real foreign object bounding box, the alignment matching degree is determined according to the task. Arrange the candidate prediction boxes in descending order and select the top-ranked candidate boxes as positive samples to form a one-to-many positive sample; In the one-to-one branch, the weight parameters are kept consistent with those in the one-to-many branch, i.e. , For each real foreign object annotation box, only the task alignment matching degree is selected. The highest-ranking unique candidate predicted box is used as a positive sample, forming a one-to-one positive sample, where... , These are the classification and positioning weights used in the one-to-one branch, respectively. , These are the classification and positioning weights used in a one-to-many branch; Based on the one-to-many positive samples, calculate the one-to-many classification loss, one-to-many regression loss, and one-to-many distribution focus loss, and construct the one-to-many branch loss; Based on the one-to-one positive samples, calculate the one-to-one classification loss, one-to-one regression loss, and one-to-one distribution focus loss, and construct the one-to-one branch loss. Joint optimization is performed based on the one-to-many branch loss and the one-to-one branch loss to construct the total loss. The network parameters are then updated via backpropagation. All the above steps are repeated until the iteration termination condition is met, thus completing the training process. The expression for calculating the total loss is as follows: In the formula, The total training loss of the YOLOv10 object detection network is... The total weight of a one-to-many branch. For the total weight of a one-to-one branch, For one-to-many classification loss, For one-to-many regression loss, For a one-to-many distribution focal loss, For classification loss weights, To regress the loss weights, These are the distribution focus loss weights, For one-to-one classification loss, For one-to-one regression loss, It is a one-to-one distribution focal loss.
[0017] Furthermore, the one-to-many regression loss or one-to-one regression loss is constructed using the following steps: Let the candidate prediction box be The actual foreign object label box is The diagonal length of the minimum bounding rectangle of the candidate predicted and the actual foreign object annotation boxes is... The width and height of the minimum bounding rectangle are respectively , ,in, The coordinates of the center point of the candidate prediction box. The width of the candidate prediction box. The height of the candidate predicted bounding box. The coordinates of the center point of the actual foreign object annotation box. The width of the actual foreign object label box. The height of the actual foreign object marking box; For one-to-many or one-to-one branches, construct the basic regression loss, expressed as: In the formula, Based on regression loss, This is the intersection-union ratio (IoU) of the candidate predicted bounding boxes and the ground truth foreign object labeled boxes. Euclidean distance. The normalization constant for the width, It is a highly normalized constant; Based on the aforementioned basic regression loss, Focal weights are introduced to construct the final regression loss for either a one-to-many branch or a one-to-one branch. The one-to-many regression loss and the one-to-one regression loss are respectively expressed as: In the formula, For the intersection-union ratio in a one-to-many branch, The intersection-union ratio in a one-to-one branch. Focal weights For the basic regression loss in a one-to-many branch, The basic regression loss is a one-to-one branch.
[0018] Furthermore, the YOLOv10 object detection network includes a CSP-type backbone network, a PANet-type feature fusion neck network, and a multi-scale decoupled detection head. The PANet-type feature fusion neck network is improved by adding a P2 path in addition to the existing P3, P4, and P5 paths. The multi-scale decoupled detection head includes a newly added small-scale detection head corresponding to the added P2 path and the original scale detection heads corresponding to the existing P3, P4, and P5 paths. During the training phase, each scale is independently equipped with both the one-to-many branch and the one-to-one branch for training. During the inference phase, only the one-to-one branch is retained. Specifically, the processing steps of the YOLOv10 object detection network include: The denoised and enhanced image is downsampled layer by layer through a CSP-type backbone network to output multi-scale features. , , , ; Based on multi-scale features , , By using PANet-style feature fusion, the neck network is fused along a top-down path to... Perform convolution processing to obtain features ,Will After upsampling and By splicing and merging, features are obtained. Then the features After upsampling and By splicing and merging, features are obtained. ; Will The number of channels is adjusted using 1×1 convolution, and then combined with the upsampled features. The concatenation is performed along the channel dimension, and then the concatenated result is processed by a CSP / C2f fusion module or an equivalent convolutional fusion module to obtain the features. ; The PANet-style feature fusion neck network processes downsampled features along a bottom-up path. With features The features are concatenated along the channel dimension and then mechanically fused using a CSP / C2f fusion module or an equivalent convolutional fusion module to obtain the fused features. Then, downsampling and feature extraction layer by layer. , The features are obtained by fusion. , ; The feature Input the newly added small target scale detection head, output the small target detection results, and combine the fused features. , , Input the original scale detection head and output the detection results of medium and large targets.
[0019] Compared with the prior art, the present invention has the following beneficial effects: (1) In the enhancement stage, this invention uses an improved RetinexFormer to extract a structural prior map. This structural prior map guides the enhancement network to distinguish between illumination changes and real edges. It can maintain the integrity of the object's edge and effectively identify metal reflection areas even in areas with uneven illumination. Through illumination normalization processing, the edge contrast of small targets such as bolts and tools is significantly improved after the enhancement of low-light images at night, while background noise is effectively suppressed. This effectively solves the image quality degradation problem caused by uneven illumination, low light at night, and metal reflection, thus avoiding false detections and missed detections caused by image quality problems. At the same time, this invention uses an NMS-free consistency double matching strategy to train the YOLOv10 target detection network to ensure stable recall of small targets under complex lighting conditions, and finally achieves reliable detection of foreign objects on the roof in harsh environments such as night and tunnels.
[0020] (2) The improved RetinexFormer of this invention uses a Gaussian color model to obtain a structural prior map from RGB. This structural prior is concatenated with the RGB image and the mean channel to form a multi-channel input, which drives the gated attention unit to adaptively select enhancement features. Finally, the denoised and enhanced image is output through illumination normalization. This process combines spectral-spatial joint edge perception with deep learning enhancement, which preserves the edge texture details of small targets such as bolts and tools while suppressing noise. It avoids feature loss caused by excessive smoothing in traditional enhancement methods and provides high-quality input for subsequent detection.
[0021] (3) This invention introduces color-invariant convolution CIConv into the improved RetinexFormer illumination estimator, which is concatenated with the RGB image and the mean channel to form a multi-channel input. This provides a structural prior decoupled from illumination conditions for illumination estimation, effectively preventing excessive amplification of noise during the enhancement process and improving the generalization ability under drastic changes in day and night illumination. At the same time, this invention replaces the single-scale depth convolution in the improved RetinexFormer illumination estimator with a multi-scale depth convolution unit, which includes multiple parallel depth-separable convolution branches of different scales. This expands the receptive field and can capture the complex distribution of multiple light sources and non-uniform illumination in the roof scene, thus improving the accuracy of illumination estimation.
[0022] (4) This invention introduces a gated attention mechanism into the improved RetinexFormer illumination estimator, which includes multiple parallel convolutional branches with different hole rates and depths. The multi-scale features are concatenated to generate gated weights, which adaptively weight the input features. This mechanism replaces the traditional channel attention, achieving adaptive enhancement of illumination-related features and suppression of noise and reflective features, thereby improving the quality of the enhanced image.
[0023] (5) By using the small target optimization strategy of YOLOv10, including Focal-EIoU regression loss and small target detection branch, the ability to locate small-scale foreign objects is further enhanced, and the accuracy, real-time performance and intelligence of foreign object detection in low-light environment are comprehensively improved.
[0024] (6) The YOLOv10 of this invention adopts an NMS-free consistency dual-matching strategy, which aligns the matching degree by sharing tasks. The strategy employs a one-to-many assignment (dense supervision) and a one-to-one unique assignment (no redundant output), jointly optimizing the dual branches with the same weight parameters. This strategy eliminates the time overhead of NMS post-processing during the inference phase, while avoiding duplicate detections caused by traditional one-to-many assignment. Combined with Focal-EIoU regression loss, it adaptively adjusts the gradient for easy and difficult samples, making training more focused on difficult-to-detect samples such as small targets. This training mechanism, in conjunction with the enhanced preprocessing of the improved RetinexFormer, results in enhanced images with more consistent brightness distribution and clearer edges, making the positive sample assignment of the dual-matching strategy more stable, the consistency constraint more easily convergent, and ultimately improving the recall and localization accuracy of small targets. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the method flow of the present invention; Figure 2 This is a schematic diagram of the improved illumination estimator processing flow of the present invention; Figure 3 This is a conceptual diagram of the two-stage cascaded training strategy of the present invention. Detailed Implementation
[0026] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.
[0027] This embodiment provides a method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, such as... Figure 1 As shown, the method includes the following steps: Step S1: Obtain an image of the roof of the freight train container.
[0028] Images of the container roof are captured using industrial cameras deployed on gantry cranes or overhead contact line supports alongside the track (RGB images). The shooting angle is 45°-60° downwards, covering the entire width of the roof, and equipped with a light sensor. When the ambient light intensity is below a preset threshold (e.g., 50 lux), the image enhancement module is automatically triggered.
[0029] Step S2: Input the acquired roof image into the improved RetinexFormer model, perform illumination normalization processing, and output the denoised enhanced image.
[0030] This embodiment of the improved RetinexFormer model includes the use of the CIConv (color-invariant convolution) module, an improved illumination estimator, illuminance decomposer, and a denoiser. Specifically, the processing steps of the improved RetinexFormer model include: 2.1 Structural Prior Extraction (Detailed Implementation of CIConv Module) First, the CIConv module extracts prior structural features. Based on the principle of color invariance, the CIConv module converts the RGB image into a spectral feature representation using a Gaussian color model, and then extracts illumination-independent structural edge information using a learnable Gaussian derivative kernel. The specific implementation of the CIConv module is as follows: (1) Parameter initialization: Define the learnable parameters that control the Gaussian kernel scale as follows Its initial value is , ,set up , To prevent numerically unstable regularization constants from occurring in logarithmic, normalization, and division operations.
[0031] (2) RGB to Spectral Feature Conversion: A Gaussian color model is used, and a 3×3 transformation matrix is employed to convert the RGB image into a spectral feature representation. Specifically, the roof image is reconstructed and multiplied by the transpose of the Gaussian color model transformation matrix M, then reconstructed back to the original spatial dimension to obtain the spectral feature representation, which includes three components: light intensity. First derivative of the spectrum Spectral second derivative , means as follows: in, For pixels, For pixels The red passage at that location For pixels The green channel at the location For pixels The blue passage at that location Let M be the transformation matrix.
[0032] (3) Gaussian kernel pre-computation: During each forward propagation, the current learnable parameters are used to pre-compute the Gaussian kernel. Gaussian kernel scale is obtained through exponential mapping. And calculate the 1D Gaussian kernel function value. and 1D Gaussian derivative kernel function value .Will and These are reshaped into convolutional kernels in the X and Y directions, respectively. Updated via backpropagation and gradient descent during training.
[0033] (4) Calculation of spatial derivatives: for , , First use Smooth the surface in both the X and Y directions, then use... Gaussian derivative convolutions are performed in the X and Y directions respectively to obtain the spatial derivative in the X direction and the Gaussian derivative in the Y direction. The X direction uses padding=[0, ], padding=[ in the Y direction [0], where padding is the amount of padding at the convolution edge. Let be the one-sided sampling radius of the discrete Gaussian kernel, and let represent the sampling distance extending from the center of the Gaussian kernel to one side, determined by the 3σ criterion. The total size of the discrete Gaussian kernel is guaranteed to be odd in order to maintain central symmetry.
[0034] (5) Calculation of W component: based on spatial derivative and spectral derivative ( , Calculate the W component. First, use the light intensity... Normalize based on the baseline: In the formula, for The intensity of normalized spatial variation in the X direction. for Normalized variation intensity in the X direction, for Normalized variation intensity in the X direction, for The intensity of normalized spatial variation in the Y direction, for Normalized variation intensity in the Y direction, for Normalized variation intensity in the Y direction, , , The spatial derivative in the X direction. for The spatial derivative in the X direction, To prevent extremely small constants that are zero, for The spatial derivative in the X direction, for The spatial derivative in the X direction, , , The spatial derivative in the Y direction. for Spatial derivative in the Y direction, for Spatial derivative in the Y direction, for Spatial derivative in the Y direction; Then, the above six normalized derivative components , , , , , By fusing the data, we obtain the perceived weights of the comprehensive spatial-spectral variation intensity. , represented as: .
[0035] (6) Normalized output: For Perform logarithmic transformation Calculate the sample mean and sample standard deviation Normalize the samples: The prior structure diagram is obtained.
[0036] (7) Subsequent processing: The prior is processed through a convolutional layer to obtain the structural prior feature prior_feat. In this embodiment, only the first channel of prior is used as the structural prior input illumination estimator, and compared with the RGB image. Mean channel The input channels are concatenated to form a 5-channel input, which is represented as .
[0037] 2.2 Illumination Estimation The 5-channel input is fed into the improved illumination estimator. For example... Figure 2 As shown, the improved illumination estimator includes an input projection layer, a pre-activation layer, multi-scale depth convolutional units, gated attention units, a residual fusion layer, and an output projection layer. Combined with... Figure 2 The processing steps of this improved illumination estimator include: The estimator first projects the 5-channel input to an intermediate feature space through an input projection layer, followed by pre-activation processing to obtain a pre-activated output. This output is then processed sequentially through multi-scale depth convolutional units and gated attention units to obtain a gated weighted feature map. Next, the residual fusion layer performs double residual fusion of the gated weighted feature map's pre-activated output and the input projection layer's output to obtain a final fused feature map, which is an illumination feature map. Finally, this illumination feature map is processed by an output projection layer and a sigmoid activation function to output an illumination map.
[0038] The multi-scale depthwise convolutional unit comprises parallel 3×3, 5×5, and 7×7 depthwise separable convolutional branches, corresponding to local, intermediate, and global receptive fields, respectively. Padding is set to 1, 2, and 3 respectively to maintain spatial resolution. Each branch performs initial multi-scale feature extraction within its respective receptive field, and then the features are concatenated along the channel dimension and fused back to the original number of channels via a 1×1 convolution to obtain a preliminary fused feature map. This structure expands the receptive field, enabling the capture of complex distributions of multiple light sources and non-uniform illumination in rooftop scenes.
[0039] The gated attention unit contains multiple parallel dilated depth convolution branches with dilation rates of 1, 2, and 3. These parallel dilated depth convolution branches extract multi-scale features from the initial fused feature map, then concatenate them along the channel dimension and generate gate weights through a gated network (using 1×1 convolution and the Sigmoid activation function). The input features are then adaptively weighted to obtain the gated weighted feature map.
[0040] Let the input feature map (i.e., the preliminary fused feature map) of the gated attention unit be... The output feature map (i.e., the gated weighted feature map) is The calculation process of the gating attention mechanism is as follows: In the formula, For gating weights, It is the Sigmoid activation function. For learnable residual scaling factor, This represents element-wise multiplication. This indicates a channel-level concatenation operation. This is a 1×1 convolution transformation operation. These represent multi-scale features under different void ratios.
[0041] 2.3 Illuminance Decomposition and Noise Reduction Based on Retinex theory, the illuminance decomposer performs decomposition operations on the original roof image and the illuminance map to obtain the enhanced image: in, To enhance the image, This represents the original roof image. This represents the three-channel illuminance map output by the improved illuminance estimator. For 1×1 convolution, It is the Sigmoid activation function. This is a map showing the characteristics of illumination. and Originating from the same illumination estimation branch, It preserves illuminance distribution, structural priors, and multi-scale illumination context information, which are used to guide the noise suppression intensity at different spatial locations and in different channels during the denoising stage.
[0042] 2.4 Noise Reduction Enhance the image The image input to the denoiser is the illumination feature map. This serves as the guiding input for the denoiser. The denoiser employs a U-Net architecture, comprising an encoder, a bottleneck layer, and a decoder.
[0043] In the encoder: through multiple coding layers Perform downsampling to obtain the downsampled multi-scale enhanced image feature map, and simultaneously... Synchronous downsampling is performed to the same spatial resolution as the corresponding layer's enhanced image features. In each coding layer, the downsampled corresponding scale enhanced image feature map and the downsampled corresponding scale illumination feature map are input together into the illumination-guided attention module (IGAB) to obtain the illumination-guided image features output by each coding layer.
[0044] In the bottleneck layer: the downsampled corresponding scale illumination feature map (with the lowest resolution) output by the last coding layer is used to model the global illumination noise, and the modeling result is fused with the image features containing illumination guidance output by the last coding layer to complete the feature transformation of the bottleneck layer and obtain the bottleneck layer features fused with global illumination noise information. In the decoder: Through multiple decoding layers, the bottleneck layer features are upsampled to restore them to the same resolution as the illumination-guided image features transmitted from the skip connections of each coding layer. Simultaneously, the illumination feature map at the corresponding scale is restored. In each decoding layer, the upsampled bottleneck layer features / the output features of the upper decoding layer are concatenated with the illumination-guided image features transmitted from the skip connections of the corresponding coding layer to obtain the concatenated features of each layer. Each concatenated feature and the restored illumination feature map of each layer are input into the illumination-guided attention module of that layer, and the image features of each decoding layer are output. The image features of the highest decoding layer are mapped to obtain the denoised feature map.
[0045] In this approach, the inputs to the encoding stage are the downsampled scale-enhanced image feature map and the downsampled illumination feature map of the corresponding scale in the encoding layer. The inputs to the decoding stage are the concatenated features of the corresponding layer in the decoding layer and the restored illumination feature map of the corresponding layer in the decoder. Both the downsampled scale-enhanced image feature map and the concatenated features of the corresponding layer in the decoding layer are used as image features, and both the downsampled illumination feature map and the restored illumination feature map of the corresponding layer in the decoder are used as illumination features. Therefore, the illumination-guided attention module in each layer of both the encoding and decoding stages performs the following processing steps: Generate queries by projecting image features. ,key ,value And will query ,key ,value Split along the channel dimension into Size; The illumination features are transformed linearly to generate a model similar to... Attention modulation terms matching branch space size and head number ; For each head, compute the standard scaled dot product attention: In the formula, For attention output, Channel dimension for each head; Attention output and attention modulation terms Perform element-wise weighted summation to obtain the output of each head. , represented as: The outputs of all heads are stitched together along the channel dimension, and then linearly projected to obtain the output of each layer of the illumination-guided attention module.
[0046] IGAB's light-guided multi-head self-attention will The transformation is converted into an attention modulation term, which performs element-wise weighting on the V branch of image features, thereby enhancing the effective structural information in low-light areas and suppressing reflections, dark noise, and enhancing artifacts.
[0047] Step S3: Input the denoised enhanced image into the YOLOv10 object detection network to perform foreign object detection and output the detection box information of the foreign object.
[0048] The denoised and enhanced image is input into the YOLOv10 object detection network. YOLOv10 includes a CSP-type backbone network (CSPNet), a PANet-type feature fusion neck network (Neck layer), and a multi-scale decoupled detection head. The multi-scale decoupled detection head includes a newly added small-scale detection head corresponding to the newly added P2 path and existing scale detection heads corresponding to the existing P3, P4, and P5 paths. During the training phase, each scale is independently trained using both the one-to-many branch and the one-to-one branch simultaneously, employing an NMS-free consistency double-matching strategy. During the inference phase, only the one-to-one branch is retained. The specific training process is as follows: First, the classification confidence score is calculated for each real foreign object bounding box (referred to as the real bounding box) and the candidate predicted bounding boxes (referred to as candidate bounding boxes) output by the detection head. and positioning overlap Secondly, construct the task alignment matching degree. ,in , For classification and localization weights; furthermore, in the one-to-many branch of the detection head, for each ground truth bounding box, according to the task alignment matching degree... The candidate boxes are sorted in descending order, and the top-ranked candidate boxes with the highest matching scores are selected as positive samples to form a one-to-many positive sample group, providing dense supervision. In the one-to-one branch of the detection head, the same matching score parameter as in the one-to-many branch is used. , For each ground truth bounding box, only the candidate bounding box with the highest matching degree is selected as the positive sample, forming a one-to-one positive sample. , These are the classification and positioning weights used in the one-to-one branch, respectively. , The classification and localization weights used in the one-to-many branch are respectively. Finally, both the one-to-many and one-to-one branches are optimized simultaneously to ensure that the classification and regression objectives of the two branches are consistent. Specifically, based on one-to-many positive samples, the one-to-many classification loss, one-to-many regression loss, and one-to-many distribution focus loss are calculated to construct the one-to-many branch loss; based on one-to-one positive samples, the one-to-one classification loss, one-to-one regression loss, and one-to-one distribution focus loss are calculated to construct the one-to-one branch loss. Then, the one-to-many branch loss and the one-to-one branch loss are jointly optimized to construct the total loss. The network parameters are updated through backpropagation, and all the above steps are repeated until the iteration termination condition is met, completing the training process. During the inference phase, only the detection results of the one-to-one branch are retained. Since each target tends to correspond to a unique predicted box, there is no need to perform traditional NMS post-processing.
[0049] The total loss of the YOLOv10 object detection network is: In the formula, The total training loss of the YOLOv10 object detection network is... The total weight of a one-to-many branch. For the total weight of a one-to-one branch, For one-to-many classification loss, For one-to-many regression loss, For a one-to-many distribution focal loss, For classification loss weights, To regress the loss weights, These are the distribution focus loss weights, For one-to-one classification loss, For one-to-one regression loss, It is a one-to-one distribution focal loss.
[0050] Compared to the conventional YOLO loss which only assigns one-to-many branches, this loss introduces additional one-to-one branch supervision; during training, the two branches are jointly backpropagated, and during inference, the one-to-many branches are removed, and only the one-to-one branches are used to obtain NMS-free detection results.
[0051] For small objects on the roof, the YOLOv10 object detection network employs the following optimizations: (1) The regression loss uses Focal-EIoU to enhance the localization accuracy for small targets. Let the candidate predicted bounding box be... The real frame is , The coordinates of the center point of the candidate prediction box. The width of the candidate prediction box. The height of the candidate predicted bounding box. The coordinates of the center point of the actual foreign object annotation box. The width of the actual foreign object label box. The height of the actual foreign object annotation box is given, and the diagonal length of the minimum bounding rectangle between the two boxes is given. The width and height are respectively , The basic regression loss for one-to-many branches or one-to-one branches is: In the formula, Based on regression loss, This is the intersection-union ratio (IoU) of the candidate predicted bounding boxes and the ground truth foreign object labeled boxes. Euclidean distance. The normalization constant for the width, It is a highly normalized constant; After introducing Focal weights, the final regression losses for the one-to-many branch and the one-to-one branch are expressed as follows: in, The focus factor, also known as the Focal weight. For the intersection-union ratio in a one-to-many branch, This is the intersection-union ratio in a one-to-one branch. It is achieved by separately constraining the center point, width, and height errors, and utilizing... , Adjusting the gradient contribution of samples with different quality levels improves the convergence stability of small-sized foreign object bounding boxes.
[0052] (2) Add a small target detection branch to the Neck layer and utilize high-resolution feature maps; Specifically, in the original PANet , , In addition to multi-scale fusion path, new High-resolution branch. Specifically, the processing steps of this YOLOv10 object detection network include: The denoised and enhanced image is downsampled layer by layer using CSPNet to output multi-scale features. , , , ; Based on multi-scale features , , Through PANet along the top-down path Perform convolution processing to obtain features ,Will After upsampling and By splicing and merging, features are obtained. Then the features After upsampling and By splicing and merging, features are obtained. ; Will The number of channels is adjusted using 1×1 convolution, and then combined with the upsampled features. The concatenation is performed along the channel dimension, and then the concatenated result is processed by a CSP / C2f fusion module or an equivalent convolutional fusion module to obtain the features. ; The downsampled features are processed via PANet along a bottom-up path. With features The features are concatenated along the channel dimension and then mechanically fused using a CSP / C2f fusion module or an equivalent convolutional fusion module to obtain the fused features. Then, downsampling and feature extraction layer by layer. , The features are obtained by fusion. , ; feature Maintaining higher spatial resolution preserves the edges and texture details of small objects. These details are then input into a new small-object scale detector head, which outputs small-object detection results (e.g., small foreign objects such as roof bolts, tools, and small tarpaulin fragments). The fused features are then... , , Input the original scale detection head and output the detection results of medium and large targets.
[0053] Step S4: Output the foreign object category, confidence level, and location coordinates.
[0054] Output the foreign object category, confidence score, and bounding box coordinates. When the confidence score exceeds a preset threshold (e.g., 0.7), the alarm module is triggered to send an alarm message to the dispatch center, including the image, category, location, and confidence score.
[0055] In addition, such as Figure 3 As shown, this embodiment also employs a two-stage cascaded training strategy for training: Phase 1: Train the improved RetinexFormer model separately using a low-light roof image dataset, with the loss function being a weighted combination of L1 loss, SSIM loss, and perceptual loss; Phase 2: Freeze the parameters of the improved RetinexFormer model, train the YOLOv10 object detection network, and adopt the NMS-free consistency double matching strategy. The loss function includes classification loss and regression loss, etc.
[0056] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0057] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present invention can be implemented using various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0058] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0059] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0060] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0061] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0062] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, characterized in that, Includes the following steps: Obtain images of the roof of a freight train container; The roof image is input into the improved RetinexFormer model. First, the structure prior map is extracted. Then, the illumination normalization process is performed based on the structure prior map, and the denoised enhanced image is output. The denoised and enhanced image is input into a pre-trained YOLOv10 object detection network to perform foreign object detection and output the foreign object detection result. The YOLOv10 object detection network is trained using an NMS-free consistency double-matching strategy.
2. The method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10 as described in claim 1, characterized in that, The structural prior graph is extracted using the CIConv module in the improved RetinexFormer model. The extraction steps for the structural prior graph include: (1) Parameter initialization: Define the learnable parameters that control the Gaussian kernel scale as follows Its initial value is , ,set up , Here is the regularization constant; (2) Transformation of roof image to spectral features: The roof image is reconstructed to obtain a reconstructed image. The reconstructed image is then multiplied by the transpose of the Gaussian color model transformation matrix and reconstructed back to the original spatial dimension to obtain a spectral feature representation. The spectral feature representation includes three components: light intensity, ... First derivative of the spectrum and the second derivative of the spectrum ; (3) Gaussian kernel pre-computation: During each forward propagation, the current learnable parameters are used to pre-compute the Gaussian kernel. Gaussian kernel scale is obtained through exponential mapping. And calculate the 1D Gaussian kernel function value based on the Gaussian kernel scale. and 1D Gaussian derivative kernel function value Then and Reconstructed into convolutional kernels in the X and Y directions respectively, where Updated via backpropagation and gradient descent during training; (4) Spatial derivative calculation: For the light intensity First derivative of the spectrum and the second derivative of the spectrum First use Smooth the surface in both the X and Y directions, then use... Perform Gaussian derivative convolutions in the X and Y directions respectively to obtain the spatial derivative in the X direction and the Gaussian derivative in the Y direction, where the padding in the X direction is set to [0, ..., ... In the Y direction, padding is set to [ [0], where padding is the amount of padding at the convolution edge. The sampling radius of the discrete Gaussian kernel on one side. This represents the total size of the discrete Gaussian kernel; (5) Calculation of W component: based on the first derivative of the spectrum Spectral second derivative And the spatial derivative in the X direction and the Gaussian derivative in the Y direction, in terms of light intensity Normalize based on the baseline: In the formula, for The intensity of normalized spatial variation in the X direction. for Normalized variation intensity in the X direction, for Normalized variation intensity in the X direction, for The intensity of normalized spatial variation in the Y direction, for Normalized variation intensity in the Y direction, for Normalized variation intensity in the Y direction, , , The spatial derivative in the X direction. for The spatial derivative in the X direction, To prevent extremely small constants that are zero, for The spatial derivative in the X direction, for The spatial derivative in the X direction, , , The spatial derivative in the Y direction. for Spatial derivative in the Y direction, for Spatial derivative in the Y direction, for Spatial derivative in the Y direction; Will , , , , , By fusing the data, we obtain the perceived weights of the comprehensive spatial-spectral variation intensity. , is represented as: (6) Normalized output: the normalized output of the perceptual weights A logarithmic transformation is performed to calculate the mean and standard deviation, and then normalization is performed based on the mean and standard deviation to obtain a priori structural diagram independent of illumination conditions. The logarithmic transformation expression is: The normalization expression is: In the formula, The value after logarithmic transformation. The mean, The standard deviation is denoted as .
3. The method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, as described in claim 1, is characterized in that... The improved illumination estimator, illuminance decomposer, and denoiser in the improved RetinexFormer model are used to perform illumination normalization processing to obtain a denoised enhanced image. The improved illumination estimator is used to perform illumination estimation and output an illuminance map. The illuminance decomposer is used to perform decomposition operations on the illuminance map and the roof image to obtain the enhanced image. The denoiser is used to denoise the enhanced image and output the denoised enhanced image.
4. The method for detecting foreign objects on the roof of a freight train container based on an improved Retinex Former and YOLOv10, as described in claim 3, is characterized in that... The improved illumination estimator includes an input projection layer, a pre-activation layer, a multi-scale depthwise convolutional unit, a gated attention unit, a residual fusion layer, and an output projection layer. The processing steps of the improved illumination estimator include: A multi-channel input is obtained, which is formed by stitching together the first channel of the structural prior image, the multi-channel of the roof image and its mean channel; The multi-channel input is projected onto the intermediate feature space using the input projection layer, and then processed by the pre-activation layer to obtain the pre-activated output; Based on the pre-activated output, the multi-scale depth convolutional unit uses multiple parallel depth-separable convolutional branches to perform preliminary multi-scale feature extraction, then concatenates them along the channel dimension, and fuses them back to the original number of channels through convolution to obtain a preliminary fused feature map. Based on the preliminary fused feature map, multi-scale features are extracted again using the gated attention unit, and then spliced along the channel dimension to generate gated weights. The preliminary fused feature map is then adaptively weighted based on the gated weights to obtain the gated weighted feature map. The gated weighted feature map, the pre-activated output, and the output of the input projection layer are fused using the residual fusion layer to obtain the final fused feature map, which is an illumination feature map. Based on the final fused feature map, an illumination map is output through an output projection layer and a Sigmoid activation function.
5. The method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, as described in claim 4, is characterized in that... The gated attention unit utilizes multiple dilated depthwise convolution branches to extract multi-scale features again. The processing expression of the gated attention unit is as follows: In the formula, For gating weights, It is the Sigmoid activation function. This is a 1×1 convolution transformation operation. Multi-scale features under different void ratios, This is the gated weighted feature map. To initially fuse the feature maps, For learnable residual scaling factor, This is an element-wise multiplication operation. This indicates a channel dimension splicing operation.
6. The method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, as described in claim 3, is characterized in that... The processing expression for the illuminance resolver is: In the formula, To enhance the image, Image of the car roof. This is an illumination map.
7. The method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, as described in claim 4, is characterized in that... The denoiser adopts a U-Net structure, including an encoder, a bottleneck layer, and a decoder. The processing steps of the denoiser include: For encoders: The enhanced image is processed through multiple coding layers. and illumination feature map Synchronous downsampling is performed to obtain downsampled multi-scale enhanced image feature maps and downsampled multi-scale illumination feature maps, respectively. In each coding layer, the downsampled corresponding scale enhanced image feature map and downsampled corresponding scale illumination feature map have the same resolution. In each coding layer, the downsampled corresponding scale-enhanced image feature map and the downsampled corresponding scale illumination feature map are jointly input into the illumination-guided attention module to obtain the illumination-guided image features output by each coding layer. For the bottleneck layer: The downsampled illumination feature map of the corresponding scale output of the last coding layer is used to model the global illumination noise, and the modeling result is fused with the image features containing illumination guidance output of the last coding layer to obtain the bottleneck layer features that fuse global illumination noise information. For the decoder: By using multiple decoding layers, the bottleneck layer features are upsampled to restore the image features with illumination guidance from the skip connections of each coding layer at the same resolution, while restoring the illumination feature map at the corresponding scale. In each decoding layer, the upsampled bottleneck layer features / upper decoding layer output features are concatenated with the image features containing illumination guidance from the skip connection of the corresponding coding layer to obtain the concatenated features of each layer. The concatenated features of each layer and the restored illumination feature map of each layer are input into the illumination guidance attention module of that layer to output the image features of each decoding layer. The image features of the highest decoding layer are mapped to obtain the denoised feature map. The processing steps for each layer of the illumination-guided attention module include: The input to each layer of the illumination-guided attention module is set to image features and illumination features. The image features are the corresponding scale-enhanced image feature map after downsampling in the coding layer or the corresponding layer splicing features in the decoding layer. The illumination features are the corresponding scale illumination feature map after downsampling in the coding layer or the illumination feature map after recovery in the corresponding layer in the decoder. Generate queries by projecting image features. ,key ,value And will query ,key ,value Split along the channel dimension into Size; The illumination features are transformed linearly to generate a model similar to... Attention modulation terms matching branch space size and head number ; For each head, compute the standard scaled dot product attention: In the formula, For attention output, Channel dimension for each head; Attention output and attention modulation terms Perform element-wise weighted summation to obtain the output of each head. , is represented as: The outputs of all heads are stitched together along the channel dimension, and then linearly projected to obtain the output of each layer of the illumination-guided attention module.
8. The method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10 as described in claim 1, characterized in that, The training steps for the NMS-free consensus double-matching strategy include: The classification confidence score is calculated for each real foreign object bounding box and the candidate predicted bounding boxes output by the multi-scale decoupled detection head in the YOLOv10 object detection network. and positioning overlap The multi-scale decoupling detection head includes a one-to-many branch and a one-to-one branch; Based on the classification confidence level and positioning overlap Construct task alignment matching degree , of which , These are the classification and positioning weights, respectively. In a one-to-many branching model, for each real foreign object bounding box, the alignment matching degree is determined according to the task. Arrange the candidate prediction boxes in descending order and select the top-ranked candidate boxes as positive samples to form a one-to-many positive sample; In the one-to-one branch, the weight parameters are kept consistent with those in the one-to-many branch, i.e. , For each real foreign object annotation box, only the task alignment matching degree is selected. The highest-ranking unique candidate predicted box is used as a positive sample, forming a one-to-one positive sample, where... , These are the classification and positioning weights used in the one-to-one branch, respectively. , These are the classification and positioning weights used in a one-to-many branch; Based on the one-to-many positive samples, calculate the one-to-many classification loss, one-to-many regression loss, and one-to-many distribution focus loss, and construct the one-to-many branch loss; Based on the one-to-one positive samples, calculate the one-to-one classification loss, one-to-one regression loss, and one-to-one distribution focus loss, and construct the one-to-one branch loss. Joint optimization is performed based on the one-to-many branch loss and the one-to-one branch loss to construct the total loss. The network parameters are then updated via backpropagation. All the above steps are repeated until the iteration termination condition is met, thus completing the training process. The expression for calculating the total loss is as follows: In the formula, The total training loss of the YOLOv10 object detection network is... The total weight of a one-to-many branch. For the total weight of a one-to-one branch, For one-to-many classification loss, For one-to-many regression loss, For a one-to-many distribution focal loss, For classification loss weights, To regress the loss weights, These are the distribution focus loss weights, For one-to-one classification loss, For one-to-one regression loss, It is a one-to-one distribution focal loss.
9. A method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, as described in claim 8, is characterized in that... The one-to-many regression loss or one-to-one regression loss is constructed using the following steps: Let the candidate prediction box be The actual foreign object label box is The diagonal length of the minimum bounding rectangle of the candidate predicted and the actual foreign object annotation boxes is... The width and height of the minimum bounding rectangle are respectively , ,in, The coordinates of the center point of the candidate prediction box. The width of the candidate prediction box. The height of the candidate predicted bounding box. The coordinates of the center point of the actual foreign object annotation box. The width of the actual foreign object label box. The height of the actual foreign object marking box; For one-to-many or one-to-one branches, construct the basic regression loss, expressed as: In the formula, Based on regression loss, This is the intersection-union ratio (IoU) of the candidate predicted bounding boxes and the ground truth foreign object labeled boxes. Euclidean distance. The normalization constant for the width, It is a highly normalized constant; Based on the aforementioned basic regression loss, Focal weights are introduced to construct the final regression loss for either a one-to-many branch or a one-to-one branch. The one-to-many regression loss and the one-to-one regression loss are respectively expressed as: In the formula, For the intersection-union ratio in a one-to-many branch, The intersection-union ratio in a one-to-one branch. Focal weights For the basic regression loss in a one-to-many branch, The basic regression loss is a one-to-one branch.
10. A method for detecting foreign objects on the roof of a freight train container based on an improved RetinexFormer and YOLOv10, as described in claim 8 or 9, characterized in that... The YOLOv10 object detection network includes a CSP-type backbone network, a PANet-type feature fusion neck network, and a multi-scale decoupled detection head. The PANet-type feature fusion neck network is improved by adding a P2 path in addition to the existing P3, P4, and P5 paths. The multi-scale decoupled detection head includes a newly added small-scale detection head corresponding to the added P2 path and the original scale detection heads corresponding to the existing P3, P4, and P5 paths. During the training phase, each scale is independently trained simultaneously with both the one-to-many branch and the one-to-one branch. During the inference phase, only the one-to-one branch is retained. Specifically, the processing steps of the YOLOv10 object detection network include: The denoised and enhanced image is downsampled layer by layer through a CSP-type backbone network to output multi-scale features. , , , ; Based on multi-scale features , , By using PANet-style feature fusion, the neck network is fused along a top-down path to... Perform convolution processing to obtain features ,Will After upsampling and By splicing and merging, features are obtained. Then the features After upsampling and By splicing and merging, features are obtained. ; Will The number of channels is adjusted using 1×1 convolution, and then combined with the upsampled features. The concatenation is performed along the channel dimension, and then the concatenated result is processed by a CSP / C2f fusion module or an equivalent convolutional fusion module to obtain the features. ; The PANet-style feature fusion neck network processes downsampled features along a bottom-up path. With features The features are concatenated along the channel dimension and then mechanically fused using a CSP / C2f fusion module or an equivalent convolutional fusion module to obtain the fused features. Then, downsampling and feature extraction layer by layer. , The features are obtained by fusion. , ; The feature Input the newly added small target scale detection head, output the small target detection results, and combine the fused features. , , Input the original scale detection head and output the detection results of medium and large targets.
Citation Information
Patent Citations
Low-light environment image enhancement and adaptive feature fusion target detection method
CN120355900A