An Improved UPAD-YOLO-Based Method for Container Damage Detection

By improving the UPAD-YOLO network, the receptive field of the convolution is dynamically adjusted to enhance feature extraction and fusion, thus solving the problem of insufficient multi-scale feature extraction in traditional convolutional networks and achieving high accuracy and real-time performance in container damage detection.

CN121074053BActive Publication Date: 2026-01-30ZHONGKE INFORMATION IND (SHANDONG) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511631075.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-01-30
Estimated Expiration
2045-11-10

AI Technical Summary

Technical Problem

Existing deep learning-based container damage detection methods have shortcomings in multi-scale feature extraction. The receptive field of traditional convolutional neural networks is fixed, making it difficult to effectively capture the features of both minor damage and large structural deformation at the same time, resulting in low detection accuracy.

Method used

An improved UPAD-YOLO network is adopted, which dynamically adjusts the receptive field of convolution by embedding a dynamically modulated convolution module in the backbone network, introducing a parallelized block-aware attention module and an adaptive spatial feature fusion module, thereby enhancing key defect features, suppressing background noise, and optimizing multi-scale feature fusion.

Benefits of technology

It improves the detection accuracy and practicality of multi-scale defects on container surfaces, and can adaptively adjust the receptive field to capture the characteristics of minute damage and large structural deformation, adapting to the real-time detection needs of large-scale logistics scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121074053B_ABST
    Figure CN121074053B_ABST
Patent Text Reader

Abstract

This invention discloses an improved UPAD-YOLO-based container damage detection method, belonging to the field of container damage detection technology. The method includes the following steps: image acquisition, obtaining an image dataset containing three types of defects: dents, holes, and structural damage; data preprocessing, dividing the dataset and labeling defect information; model construction, embedding a dynamically modulated convolutional module into the backbone network; feature enhancement, introducing a parallelized block-aware attention module; feature fusion, integrating an adaptive spatial feature fusion module into the detection head; and model training, optimizing network parameters to output defect category and location information. This method can effectively extract multi-scale defect features, improve detection accuracy and anti-interference ability, and solve the problems of limited multi-scale defect detection accuracy and poor detection performance in complex backgrounds. It is suitable for real-time container damage detection in large-scale logistics scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of container damage detection technology, specifically to an improved UPAD-YOLO container damage detection method. Background Technology

[0002] As a core carrier of modern international trade and logistics, the structural integrity of shipping containers directly affects cargo safety and transportation efficiency. Over long-term use, container surfaces are prone to defects such as dents, holes, and structural damage due to mechanical impacts and environmental erosion. Traditional manual visual inspection methods are inefficient, subjective, and costly, making them unsuitable for real-time inspection needs in large-scale logistics scenarios.

[0003] In existing technologies, deep learning-based methods for container defect detection have been applied to some extent. For example, some existing technologies enhance multi-scale feature extraction capabilities through improved feature pyramid network structures, but their backbone networks still employ standard convolutional operations with fixed receptive fields, making it difficult to effectively capture features of both minor damage and large structural deformations simultaneously. Other existing technologies improve feature representation capabilities by introducing attention mechanisms into the detection head, but they fail to address the adaptability of the convolutional layers themselves to defects of different scales, resulting in unsatisfactory detection performance for small target defects in complex backgrounds.

[0004] The aforementioned existing technologies demonstrate that current container damage detection methods still suffer from a key problem: the convolutional operations in traditional convolutional neural networks have a fixed receptive field, making it difficult to simultaneously and effectively extract both the subtle features of small holes and the macroscopic features of large-area structural deformations on the container surface. This limitation causes the model to either fail to accurately identify the detailed features of minute damages or fail to fully capture the overall features of large-scale structural deformations when dealing with multi-scale defects, thus affecting detection accuracy.

[0005] In summary, existing deep learning-based methods for container damage detection still have significant shortcomings in multi-scale feature extraction. There is an urgent need for a solution that can adaptively adjust the receptive field and effectively extract multi-scale defect features to improve the accuracy and practicality of container damage detection. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of existing technologies and provide an improved UPAD-YOLO-based container damage detection method. By embedding a dynamically modulated convolutional module into the UPAD-YOLO network backbone, introducing a parallelized block-aware attention module into the feature extraction layer, and integrating an adaptive spatial feature fusion module into the detection head, this method can adaptively adjust the convolutional receptive field, enhance key defect features, suppress background noise, and optimize the multi-scale feature fusion effect. This enables accurate detection of container dents, holes, and structural damage defects, thus overcoming the shortcomings of existing technologies in multi-scale feature extraction capabilities.

[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution: an improved UPAD-YOLO-based method for detecting container damage, comprising the following steps:

[0008] S1. Image acquisition: Use a high-resolution RGB camera to photograph the surface of the container and obtain an image dataset containing three types of defects: dents, holes, and structural damage.

[0009] S2. Data preprocessing: Divide the collected image dataset into training set, validation set and test set, label the location of defect areas and record category information;

[0010] S3. Model building: Design the UPAD-YOLO network architecture, embed dynamic modulation convolution modules in the backbone network, extract multi-scale features through multi-branch parallel convolution, and dynamically adjust the feature fusion weights based on channel-level modulation coefficients.

[0011] S4. Feature enhancement: A parallelized block-aware attention module is introduced into the feature extraction layer. The key feature information of the defect area is captured through the interaction mechanism of local and global multi-branch features, and a dual-path attention weighting strategy is adopted to suppress irrelevant background noise.

[0012] S5. Feature fusion: An adaptive spatial feature fusion module is integrated into the detection head to fuse feature maps of different resolution levels through a dynamic spatial weight allocation strategy.

[0013] S6. Model training: Input the divided dataset into the model for training, optimize the network parameters to output defect category and location information.

[0014] Furthermore, the operation of the dynamically modulated convolution module in S3 includes:

[0015] Three different dilation rates of depthwise separable convolution are performed on the input feature map to generate multi-scale feature maps with different receptive field ranges;

[0016] Learnable channel-level modulation coefficients are introduced for each set of feature maps. The initial values ​​are set using the Xavier initialization method, and the importance of each channel feature is dynamically adjusted according to the task requirements.

[0017] Bilinear interpolation is used to align the spatial dimensions of feature maps, ensuring spatial consistency across multiple scale feature maps.

[0018] The aligned feature maps are concatenated along the channel dimension, and the computation is reduced by a one-to-one convolution operation.

[0019] The reduced feature maps are batch normalized, and the ReLU activation function is used to enhance the nonlinear expressive power.

[0020] The adjustment of the channel-level modulation coefficients is achieved through the following mathematical formula:

[0021]

[0022] In the formula, Indicates the first The modulation coefficients of each channel, Indicates the first The learnable weight vector for each channel, Indicates the first Input feature maps of each channel, This represents the total number of channels in the feature map. Represents an exponential function. This represents the vector dot product operation.

[0023] Furthermore, the structure of the parallelized block-aware attention module in S4 includes:

[0024] The input feature map is divided into several non-overlapping blocks, and local attention weights are generated for each block through a multilayer perceptron.

[0025] In the global branch, calculate the cosine similarity matrix between blocks to measure the correlation of features between blocks;

[0026] The features of local and global branches are fused, and channel attention weighting and spatial attention weighting operations are performed sequentially.

[0027] Channel attention weighting is achieved by performing max pooling and average pooling operations on the feature maps respectively, feeding the pooling results into a shared multilayer perceptron for learning, summing them, and then generating a channel weight matrix through Sigmoid activation.

[0028] Spatial attention weighting generates feature maps through global max pooling and global average pooling operations, and then obtains the spatial weight matrix after concatenation and convolution.

[0029] Finally, the channel and spatial weight matrices are merged to generate the enhanced feature map;

[0030] The calculation of the cosine similarity matrix between blocks is achieved through the following mathematical formula:

[0031]

[0032] In the formula, Indicates the first The first block and the first Cosine similarity between blocks Indicates the first Feature vectors of each block Indicates the first Feature vectors of each block This represents the vector dot product operation. Indicates the first The Euclidean norm of the feature vectors of each block Indicates the first The Euclidean norm of the feature vectors of each block.

[0033] Furthermore, the operation of the adaptive spatial feature fusion module in S5 includes:

[0034] Feature maps at different levels are scaled to a uniform target resolution to fit the input requirements of the detection head;

[0035] For each spatial location, a set of learnable fusion weight parameters is generated, with the weight sum constrained to 1 and the value range being 0 to 1;

[0036] The multi-scale feature maps are linearly weighted and fused according to the generated fusion weights to form the final feature representation.

[0037] The fusion weights are generated using the following mathematical formula:

[0038]

[0039] In the formula, Indicates the first Hierarchical feature maps in spatial location The fusion weight at the point, Indicates the first Hierarchical feature maps in spatial location Learnable parameters at that location This represents the total number of levels in the feature map. Represents an exponential function. Represents the spatial coordinates on the feature map.

[0040] Furthermore, the specific process of model training in S6 includes:

[0041] Set the input image resolution to 640×640, the batch size to 8, and the training epochs to 300.

[0042] The learning rate is adjusted using a cosine learning rate scheduler, with the initial learning rate set to 0.001.

[0043] Enable automatic mixed-precision training to accelerate the convergence process;

[0044] During training, the classification task is optimized using the cross-entropy loss function, and the bounding box regression task is optimized using the CIoU loss function.

[0045] The network parameters were updated using a stochastic gradient descent optimizer, with the momentum parameter set to 0.9 and the weight decay coefficient set to 0.0005.

[0046] The CIoU loss function is calculated using the following mathematical formula:

[0047]

[0048] In the formula, Indicates the CIoU loss value. This represents the intersection-union ratio (IoU) between the predicted bounding box and the ground truth bounding box. This represents the Euclidean distance between the center point of the predicted bounding box and the center point of the ground truth bounding box. Indicates the center coordinates of the prediction box. Represents the center coordinates of the true bounding box. This represents the diagonal length of the smallest bounding rectangle between the predicted bounding box and the ground truth bounding box. Indicates the weighting coefficient. Used to measure the consistency of the aspect ratio between the predicted bounding box and the ground truth bounding box.

[0049] Furthermore, the generation of multi-scale feature maps in the dynamically modulated convolution module specifically includes:

[0050] The input feature map is processed in parallel by three depthwise separable convolutional branches with different dilation rates, where the dilation rates are set to 1, 3 and 6 respectively;

[0051] The output feature map of each branch is weighted by channel-level modulation coefficients, and the dynamic adjustment of the modulation coefficients is based on the backpropagation of the task loss.

[0052] Feature map spatial alignment uses bilinear interpolation to ensure consistency in width and height dimensions of multi-branch feature maps;

[0053] The concatenated feature map is dimensionality reduced by a 1×1 convolutional layer, reducing the number of channels to half the number of input channels.

[0054] Batch normalization is performed after dimensionality reduction to stabilize the training process and accelerate convergence.

[0055] The ReLU activation function is applied to the normalized feature map to introduce a nonlinear transformation;

[0056] The fusion of multi-scale feature maps is achieved through the following mathematical formula:

[0057]

[0058] In the formula, This represents the output feature map. This indicates a batch normalization operation. This represents a 1×1 convolution operation. This demonstrates the splicing operation along the channel dimension. , , These represent the channel-level modulation coefficients of the three branches, respectively. , , These represent the output feature maps of the three branches, respectively. This indicates a channel-by-channel multiplication operation. This represents the modified linear unit activation function.

[0059] Furthermore, the dual-path attention weighting operation in the parallelized block-aware attention module specifically includes:

[0060] The channel attention weighted branch performs global max pooling and global average pooling on the input feature map simultaneously, and inputs the pooling results into a shared multilayer perceptron.

[0061] The shared multilayer perceptron consists of two fully connected layers. The first fully connected layer reduces the number of channels to one-sixteenth of the original number of channels, and the second fully connected layer restores the original number of channels.

[0062] The output feature vectors of the two pooling paths are added element by element, and the channel weight matrix is ​​generated by the Sigmoid function.

[0063] The spatial attention weighted branch performs global max pooling and global average pooling on the channel-weighted feature maps and then concatenates the results along the channel dimension.

[0064] The concatenated feature maps are processed by a 7×7 convolutional layer to generate a spatial weight matrix.

[0065] The final output feature map is obtained by element-wise multiplication of the channel weight matrix and the spatial weight matrix;

[0066] The channel weight matrix is ​​calculated using the following mathematical formula:

[0067]

[0068] In the formula, Represents the channel weight matrix. This represents the Sigmoid activation function. Indicates a shared multilayer perceptron. This indicates a global average pooling operation. This represents the global max pooling operation. This represents the input feature map.

[0069] Furthermore, the linear weighted fusion operation in the adaptive spatial feature fusion module specifically includes:

[0070] In the future, feature maps of different levels of autonomous backbone networks will be unified to the target resolution through upsampling or downsampling operations.

[0071] The target resolution is set to one-eighth, one-sixteenth, and one-thirty-second of the input image resolution;

[0072] A set of fusion weight parameters is generated for each spatial location, and the weight parameters are processed by a 1×1 convolutional layer and a Softmax function.

[0073] The fusion weight parameters are updated during training using a stochastic gradient descent optimizer.

[0074] The linear weighted fusion of multi-scale feature maps is performed independently at each spatial location;

[0075] The final feature representation is used for classification and bounding box regression tasks of the detection head;

[0076] The linear weighted fusion is achieved through the following mathematical formula:

[0077]

[0078] In the formula, Indicates the spatial location after fusion The feature vector at that location, Indicates the first Hierarchical feature maps in spatial location The fusion weight at the point, Indicates the first Hierarchical feature maps in spatial location The feature vector at that location, This represents the total number of levels in the feature map. This represents element-wise multiplication. Represents the spatial coordinates on the feature map.

[0079] Compared with existing technologies, this improved UPAD-YOLO-based container damage detection method has the following advantages:

[0080] I. This invention embeds a dynamically modulated convolutional module into the backbone of the UPAD-YOLO network, employs multi-branch, depth-separable convolutional branches with different dilation rates to extract features in parallel, and dynamically adjusts the fusion weights of each channel feature based on channel-level modulation coefficients. This adaptively adjusts the receptive field of the convolutional operation, effectively capturing both subtle features of minute surface damage and macroscopic features of large structural deformations on the container. This improves the accuracy of feature extraction for multi-scale defects, solving the problem of fixed receptive fields in traditional convolutional neural networks, difficulty in simultaneously adapting to the feature extraction needs of defects at different scales, and limited accuracy in multi-scale defect detection. This provides reliable technical support for the multi-scale adaptability of container damage detection.

[0081] Second, this invention introduces a parallelized block-aware attention module into the feature extraction layer, utilizing a local and global multi-branch feature interaction mechanism and a dual-path attention weighting strategy to enhance key feature information of defect areas and suppress irrelevant background noise. Simultaneously, an adaptive spatial feature fusion module is integrated into the detection head, which optimizes the fusion effect of feature maps at different resolutions through dynamic allocation of spatial weights. Furthermore, the cosine learning rate scheduler and automatic mixed-precision training improve the model's convergence efficiency. Thus, while ensuring detection accuracy, the model's anti-interference ability and real-time detection performance against complex backgrounds are enhanced, making it more suitable for the actual detection needs of large-scale logistics scenarios.

[0082] Other advantages, objectives and features of the invention will be set forth in part in the description which follows, and in part will be apparent to those skilled in the art from the following examination or study, or may be learned from the practice of the invention. Attached Figure Description

[0083] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are merely some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.

[0084] Figure 1 This is a step diagram of the present invention;

[0085] Figure 2 This is a schematic diagram of the core architecture and data flow of the present invention;

[0086] Figure 3 This is a flowchart illustrating the operation of the present invention. Detailed Implementation

[0087] To further illustrate the technical means and effects of the present invention in achieving its intended purpose, the following detailed description of the specific implementation methods, structures, features, and effects of the present invention, in conjunction with the accompanying drawings and preferred embodiments, is provided below.

[0088] Example 1

[0089] like Figure 1 and Figure 2 As shown, this embodiment discloses a specific implementation scheme of an improved UPAD-YOLO container damage detection method, aiming to solve the problems of fixed receptive fields and insufficient multi-scale defect feature extraction capabilities of traditional convolutional neural networks in existing container damage detection technologies. This scheme constructs a detection system including a high-resolution image acquisition unit, a data preprocessing unit, and a UPAD-YOLO network computing unit, sequentially completing image acquisition, data preprocessing, network model construction, model training, and testing, achieving accurate detection of three types of defects in containers: dents, holes, and structural damage. This embodiment effectively improves the detection accuracy and efficiency of defects at different scales by dynamically adjusting the convolutional receptive field, strengthening key feature perception, and optimizing multi-scale feature fusion, making it suitable for the real-time container damage detection needs in large-scale logistics scenarios.

[0090] The hardware configuration of the detection system is implemented as follows:

[0091] The container damage detection system used in this embodiment mainly comprises two parts: an image acquisition unit and a computing processing unit. The image acquisition unit uses a high-resolution RGB camera, which has the resolution and frame rate required for industrial inspection and can clearly capture minute dents, small holes, and large-area structural damage features on the container surface, ensuring complete detail information of the defective areas in the acquired images. The computing processing unit uses a computing device equipped with a high-performance GPU. This device must meet the computing power requirements for training and inference of deep neural network models, ensuring that the model can efficiently update parameters during training and achieve real-time detection during inference.

[0092] The implementation of the container image dataset collection is as follows:

[0093] Using the aforementioned high-resolution RGB camera, images of container surfaces were acquired under various scenarios to construct a dataset covering diverse operating conditions. The acquisition scenarios included indoor storage environments, outdoor dock environments, and temporary stopping points during transportation. Different lighting conditions, shooting angles, and container surface conditions needed to be considered during acquisition to ensure the diversity and representativeness of the dataset.

[0094] The acquired images must include three typical types of defects: first, dent defects, referring to inward dents on the container surface caused by mechanical impact, with dent depths ranging from 1cm to 10cm and dent areas ranging from 5cm² to 500cm²; second, hole defects, referring to through holes on the container surface caused by wear or impact, with hole diameters ranging from 0.5cm to 20cm; and third, structural damage defects, referring to structural deformation or cracking at container corners and welds caused by fatigue or external forces, with damage lengths ranging from 10cm to 500cm. During the acquisition process, the proportion of images for each type of defect must be balanced, with a total dataset of no less than 5000 images. The resolution of each image must be uniformly adjusted to the input resolution required for subsequent model training to ensure complete preservation of information about the defect area and background area in the images.

[0095] The image dataset preprocessing is implemented as follows:

[0096] The acquired image dataset is preprocessed to meet the training and testing requirements of the UPAD-YOLO network model. First, the dataset is divided into training, validation, and test sets according to a preset ratio. Random sampling is used during this division process to avoid data distribution bias affecting the model's generalization ability.

[0097] Subsequently, defect region annotation is performed using industrial-grade image annotation methods to accurately mark the location and category information of defect regions in each image. During annotation, the defect region is selected by bounding a rectangle, which must completely surround the defect edge. Each rectangle is also associated with a corresponding defect category label. After annotation, a corresponding annotation file is generated, containing the image path, the coordinates of the defect rectangle, and the defect category identifier. This ensures that the image and the corresponding annotation information can be read synchronously during model training.

[0098] The implementation of the overall network architecture design is as follows:

[0099] The UPAD-YOLO network model is an improvement on the YOLO series network framework, consisting of three main parts: a backbone network, a feature extraction layer, and a detection head. The backbone network extracts basic features from the input image, achieving multi-scale feature extraction through embedded dynamically modulated convolutional modules. The feature extraction layer, based on the features output by the backbone network, introduces a parallelized block-aware attention module to enhance key features of defect areas and suppress background noise. The detection head integrates an adaptive spatial feature fusion module, fusing feature maps of different resolutions to output defect category and location information, achieving end-to-end container damage detection.

[0100] The implementation of the dynamically modulated convolution module is as follows:

[0101] The dynamically modulated convolutional module is embedded in the backbone network to solve the problem of fixed receptive fields in traditional convolutions, and to achieve adaptive extraction of multi-scale basic features. Its specific operation process is as follows:

[0102] The first step is multi-scale feature map generation. The input feature map of a certain layer of the backbone network is processed using three parallel depthwise separable convolutional branches, each with a different dilation rate: 1, 3, and 6. The branch with a dilation rate of 1 corresponds to a normal receptive field, used to extract local features of subtle defects in the image; the branch with a dilation rate of 3 corresponds to a medium receptive field, used to extract features of medium-scale defects; and the branch with a dilation rate of 6 corresponds to a large receptive field, used to extract macroscopic features of large-scale structural damage. By processing these three branches with different dilation rates in parallel, feature maps covering different scales can be obtained simultaneously, laying the foundation for subsequent multi-scale feature fusion.

[0103] The second step is the calculation of channel-level modulation coefficients. Channel-level modulation coefficients are introduced into the feature maps generated by the three branches mentioned above. These coefficients dynamically adjust the importance of each channel's features, allowing the model to adaptively strengthen effective feature channels and weaken ineffective feature channels during training, based on the needs of the defect detection task. The channel-level modulation coefficients are calculated using the following formula:

[0104]

[0105] In the formula: For the first The modulation coefficient of the i-th channel, whose value ranges from (0,1), with larger values ​​indicating higher values ​​for the i-th channel. The greater the contribution of each channel's features to the defect detection task;

[0106] For the first The learnable weight vector for the nth channel is continuously updated through backpropagation during model training, and its dimension is the same as that of the nth channel. The feature dimensions of the input feature maps for each channel are consistent, which is used to measure the importance of the features in that channel.

[0107] For the first The input feature map of the nth channel, i.e., the nth output feature map of a certain expansion rate branch. Individual channel characteristics;

[0108] This represents the total number of channels in the feature map, i.e., the number of channels in the output feature map of a single dilation rate branch.

[0109] It is an exponential function, used to convert... and The dot product result is mapped to a positive value to avoid the influence of negative values ​​on subsequent calculations;

[0110] This is a vector dot product operation used to calculate... and The higher the similarity, the greater the corresponding similarity. The larger the value, the more attention is paid to the characteristics of this channel.

[0111] During the model initialization phase The Xavier initialization method is used for assignment. This method ensures that the initialized weight vector satisfies the conditions of a mean of 0 and variance matching the input and output dimensions, thus avoiding gradient vanishing or gradient exploding problems in the early stages of model training. During model training, By dynamically adjusting the backpropagation of task loss, the model can optimize the weight allocation of each channel in real time based on the defect characteristics of the current training batch.

[0112] The third step is feature map spatial alignment. Since the feature maps output by the three dilation branches may differ in spatial dimensions, a bilinear interpolation algorithm is used to perform spatial alignment, ensuring that the feature maps of all branches maintain consistency in width and height dimensions. The bilinear interpolation algorithm assigns values ​​to pixels at the target resolution by weighting the grayscale values ​​of the four surrounding pixels of the feature map. This process effectively preserves the spatial structure information of the feature map and avoids feature distortion caused by resolution adjustments.

[0113] The fourth step is feature map concatenation and dimensionality reduction. The three spatially aligned branch feature maps are concatenated along the channel dimension, resulting in a feature map with three times the number of channels of a single branch. To reduce model computation and avoid overfitting, a 1×1 convolution operation is used to reduce the dimensionality of the concatenated feature map. The number of channels after dimensionality reduction is set to half the number of channels of a single branch before concatenation, ensuring effective preservation of feature information while simplifying model computational complexity.

[0114] The fifth step is batch normalization and activation function processing. Batch normalization is performed on the dimensionality-reduced feature maps. This operation stabilizes the feature distribution during model training and accelerates model convergence by standardizing the feature maps in each batch. Subsequently, the batch-normalized feature maps are input into the ReLU activation function. Through the nonlinear transformation of the ReLU function, the model's ability to express nonlinear features is enhanced, enabling the model to better fit the complex features of container damage defects.

[0115] The feature fusion process of the above-mentioned dynamically modulated convolutional module can be represented by the following formula:

[0116]

[0117] In the formula: This is the output feature map of the dynamically modulated convolutional module, which integrates multi-scale features from three branches with different dilation rates. For batch normalization operation; This is a 1×1 convolution operation; This is a splicing operation along the channel dimension; , , These are the channel-level modulation coefficients for the three expansion rate branches; , , These are the output feature maps for the three expansion rate branches; This is a channel-by-channel multiplication operation used to weight and fuse the modulation coefficients with the feature maps of the corresponding branches; To modify the activation function of the linear unit.

[0118] The implementation of the parallelized block-aware attention module is as follows:

[0119] The parallelized block-aware attention module is set in the feature extraction layer to enhance key feature information of defective regions and suppress irrelevant background noise. Its specific operation process is as follows:

[0120] The first step is feature map block partitioning. The feature map output by the backbone network is divided into several non-overlapping rectangular blocks. The size of the blocks is determined based on the resolution of the feature map and the defect scale, ensuring that each block can completely contain local features of at least one defect region or background region features. During the partitioning process, it is necessary to ensure that there is no overlap between blocks and that they cover the entire feature map to avoid missing feature information.

[0121] The second step is the generation of local attention weights. For each partitioned block, a multilayer perceptron is used to generate local attention weights for that block. The multilayer perceptron consists of two fully connected layers. The first fully connected layer compresses the dimension of the block features to a preset dimension, and the second fully connected layer restores the dimension to the original block feature dimension. Through this process, the correlation between features within the block is learned. The generated local attention weights can characterize the importance of features within the block. The higher the weight value, the more likely the feature at the corresponding location belongs to a defective region.

[0122] The third step is the calculation of cosine similarity in the global branch. In the global branch, the cosine similarity between all blocks is calculated to measure the correlation between features of different blocks. This process helps the model capture global feature associations across blocks, and is particularly suitable for extracting defect features across multiple blocks, such as those related to large structural damage. The cosine similarity is calculated using the following formula:

[0123]

[0124] In the formula: For the first The first block and the first The cosine similarity between blocks ranges from [-1, 1]. The closer the value is to 1, the stronger the feature correlation between the two blocks. The closer the value is to -1, the weaker the correlation.

[0125] For the first The feature vector of the nth block is obtained by... The feature map of each block is flattened to obtain the block height × block width × number of channels.

[0126] For the first The feature vectors of each block are generated in the same way as... Consistent;

[0127] This is a vector dot product operation used to calculate... and The inner product of two vectors reflects the similarity of the two vectors in a direction.

[0128] For the first The Euclidean norm of each block's feature vector is used to normalize the feature vectors and avoid the similarity calculation results being affected by differences in vector magnitude.

[0129] For the first The Euclidean norm of the feature vectors of each block, and its effect on... Consistent.

[0130] The fourth step is the fusion of local and global features. The local attention weights generated by the local branches are fused with the cosine similarity matrix calculated by the global branches. The fusion method is to embed the global association information corresponding to the cosine similarity matrix into the local attention weights, so that the attention weights of each block contain both local feature importance information and global association information with other blocks, thereby achieving collaborative perception of local and global features.

[0131] Step 5: Dual-path attention weighting. A dual-path strategy of channel attention weighting and spatial attention weighting is adopted to further enhance the fused features:

[0132] Channel attention weighting: Global average pooling and global max pooling are performed simultaneously on the fused feature map. Global average pooling calculates the average value of all pixels in each channel to obtain the global average feature of that channel; global max pooling calculates the maximum value of all pixels in each channel to obtain the global maximum feature of that channel. The results of the two pooling operations are then fed into a shared multilayer perceptron, which consists of two fully connected layers. The first fully connected layer reduces the number of channels to one-sixteenth of the original number to reduce computation, while the second fully connected layer restores the number of channels to the original number. Subsequently, the output feature vectors from the two pooling paths processed by the multilayer perceptron are summed element-wise, and then a channel weight matrix is ​​generated by passing a sigmoid activation function. The formula for calculating the channel weight matrix is ​​as follows:

[0133]

[0134] In the formula: This is the channel weight matrix, whose dimension is the same as the number of channels in the input feature map. Each element takes a value in the range of (0,1). The larger the value, the more important the feature of the corresponding channel is for defect detection. The Sigmoid activation function is used to map input values ​​to the (0,1) interval, thereby normalizing the channel weights. To share the multilayer sensor; This is a global average pooling operation; This is a global max pooling operation; This is the feature map after fusing local and global features.

[0135] Spatial attention weighting: Global max pooling and global average pooling operations are performed on the channel attention-weighted feature map. The results of the two pooling operations are concatenated along the channel dimension to obtain a dual-channel feature map. Then, the dual-channel feature map is input into a 7×7 convolutional layer. The spatial dimension correlation information is extracted through the convolution operation to generate a spatial weight matrix with the same spatial resolution as the original feature map. This matrix can characterize the importance of each spatial location in the feature map. The more likely a spatial location is to belong to a defect region, the larger the corresponding weight value.

[0136] Step 6: Enhanced Feature Map Generation. The channel weight matrix and spatial weight matrix are multiplied element-wise with the channel attention-weighted feature map to obtain the final enhanced feature map. This enhanced feature map highlights the channel features crucial for defect detection, strengthens the spatial features of the defect region, and suppresses background noise interference.

[0137] The implementation of the adaptive spatial feature fusion module is as follows:

[0138] The adaptive spatial feature fusion module is integrated into the detection head and is used to fuse feature maps at different levels to achieve accurate localization and classification of multi-scale defects. Its specific operation process is as follows:

[0139] The first step is to unify the feature map resolution. Enhanced feature maps from different layers are obtained from the feature extraction layer. These feature maps have different resolutions depending on the network layer. Upsampling or downsampling operations are used to uniformly scale all feature maps to a preset target resolution. The target resolution is set to 1 / 8, 1 / 16, and 1 / 32 of the input image resolution, corresponding to the detection requirements of large-scale, medium-scale, and small-scale defects, respectively. Upsampling uses a bilinear interpolation algorithm, and downsampling uses a convolution operation with a stride of 2 to ensure effective preservation of feature information during resolution adjustment.

[0140] The second step is weight fusion generation. For each target resolution feature map, weights are generated at each spatial location. A set of learnable fusion weights is generated, which measures the contribution of feature maps from different layers to a given spatial location. The fusion weights are generated using a 1×1 convolutional layer and a Softmax function: first, the feature maps with uniform resolution are input into the 1×1 convolutional layer to compress the number of channels to match the number of layers; then, the Softmax function is used to normalize the convolutional output to generate the fusion weights. The formula for calculating the fusion weight is as follows:

[0141]

[0142] In the formula: For the first Hierarchical feature maps in spatial location The fusion weight at each location has a value range of (0,1), and the sum of the weights of all levels at the same spatial location is 1, ensuring the rationality of weight allocation. For the first Hierarchical feature maps in spatial location The learnable parameter at position 1, which is updated through backpropagation during model training, is used to represent the learning parameter at position 2. The importance of the hierarchical feature map in this spatial location; The total number of feature maps participating in the fusion; It is an exponential function; These are the spatial coordinates on the feature map, used to locate the specific pixel position in the feature map.

[0143] The third step is linear weighted fusion. Based on the generated fusion weights, feature maps from different levels but with the same resolution are fused at each spatial location. Linear weighted fusion is performed at each spatial location, with the fusion process conducted independently to ensure that each location can adaptively select different levels of feature contribution based on its own feature requirements. The formula for linear weighted fusion is as follows:

[0144]

[0145] In the formula: In order to integrate in spatial position The feature vector at that location integrates the effective information of feature maps from different levels at that position; For the first Hierarchical feature maps in spatial location The fusion weight at the location; For the first Hierarchical feature maps in spatial location The eigenvector at that location; This represents the total number of levels in the feature map; This is an element-wise multiplication operation.

[0146] The fourth step is the detection head output. The fused feature map is input into the classification and regression branches of the detection head: the classification branch outputs the defect category probability corresponding to each predicted box through convolution operations and the Softmax activation function; the regression branch outputs the coordinate parameters of each predicted box through convolution operations, realizing the location of the defect area, and finally obtaining the container damage detection result.

[0147] The training parameters for the UPAD-YOLO model are set as follows:

[0148] After the model was built, it was trained using the preprocessed training and validation sets. The training parameters were set as follows: the input image resolution was set to a fixed value to ensure consistent input data dimensionality during training; the batch size was set to a fixed value to balance training efficiency and memory usage; the number of training epochs was set to a fixed value to ensure the model could converge fully; the initial learning rate was set to 0.001, and a cosine learning rate scheduler was used to dynamically adjust the learning rate. The cosine learning rate scheduler reduces the learning rate according to the cosine function during training, achieving rapid convergence in the early stage and fine optimization in the later stage; automatic mixed precision training was enabled, which uses half-precision floating-point numbers for calculations to improve training speed while ensuring training accuracy.

[0149] The implementation of the loss function design is as follows:

[0150] The model training uses a joint loss function that combines classification loss and regression loss, where:

[0151] Classification loss: The cross-entropy loss function is used to optimize the prediction accuracy of defect categories. This function measures the error of category prediction by calculating the cross-entropy between the predicted category probability and the true category label. The smaller the cross-entropy loss value, the more accurate the category prediction.

[0152] Regression Loss: The CIoU loss function is used to optimize the positional deviation between the predicted and ground truth boxes. Based on IoU, this function further considers the distance between the center points of the predicted and ground truth boxes and aspect ratio consistency, providing a more comprehensive measure of bounding box regression accuracy. The formula for the CIoU loss function is as follows:

[0153]

[0154] In the formula: The CIoU loss value indicates that the predicted bounding box is closer to the ground truth bounding box in terms of overlap, position, and shape. The intersection-union ratio (IUU) of the predicted bounding box and the ground truth bounding box is calculated by dividing the intersection area of ​​the predicted bounding box and the union area, and is used to measure the degree of overlap between the two boxes. The Euclidean distance between the center point of the predicted bounding box and the center point of the actual bounding box is used to measure the positional deviation between the center points of the two boxes. The center coordinates of the prediction box are calculated from the coordinates of the top left and bottom right corners of the prediction box. These are the center coordinates of the true bounding box, calculated from the true bounding box coordinates in the annotation file; The diagonal length of the minimum bounding rectangle between the predicted bounding box and the ground truth bounding box is used to normalize the distance between the center points and avoid the loss calculation being affected by differences in image scale. This is a weighting coefficient used to balance the contributions of the center point distance term and the aspect ratio term; its value is adaptively adjusted according to the training process. This parameter, used to measure the consistency of the aspect ratio between the predicted and ground truth bounding boxes, is obtained by calculating the difference in aspect ratios between the two boxes. The smaller the value, the closer the shapes of the two boxes are.

[0155] The model training process is implemented as follows:

[0156] The training set images are input into the UPAD-YOLO model in batches. The model calculates the predicted class and predicted bounding box through forward propagation. Then, the loss value between the predicted result and the ground truth label is calculated according to the joint loss function. A stochastic gradient descent optimizer is used, with the momentum parameter set to 0.9 and the weight decay coefficient set to 0.0005. All learnable parameters of the model are updated through the backpropagation algorithm. After a certain number of training batches, the model performance is evaluated using a validation set. The training strategy is adjusted according to the detection accuracy of the validation set. If the accuracy of the validation set does not improve for several consecutive rounds, an early stopping strategy is used to terminate the training to avoid model overfitting.

[0157] The model testing and result verification are implemented as follows:

[0158] The preprocessed test set was used to test the performance of the trained UPAD-YOLO model. During the test, the test set images were input into the model, and the model output the defect detection results for each image. The detection metrics of the test set, including accuracy, recall, and mean precision, were statistically analyzed to comprehensively evaluate the detection performance of the model.

[0159] Test results show that the UPAD-YOLO model in this embodiment can accurately identify three types of defects on the container surface: dents, holes, and structural damage. The recall rate for small-scale holes is no less than 90%, the accuracy rate for large-scale structural damage is no less than 92%, and the mAP value is no less than 93%. Moreover, the detection speed can meet the requirements of real-time detection, proving that the method has good practicality and reliability in container damage detection tasks.

[0160] In summary, this embodiment details the entire process of container damage detection, from image acquisition and data preprocessing to network model construction, training, and testing, by building a complete container damage detection system based on the improved UPAD-YOLO. Specifically, the dynamic modulation convolution module addresses the fixed receptive field issue of traditional convolution through multi-rate branches and channel-level modulation coefficients; the parallelized block-aware attention module enhances defect feature perception capabilities through local-global feature fusion and dual-path attention weighting; and the adaptive spatial feature fusion module optimizes multi-scale feature fusion effects through dynamic weight allocation. The collaborative work of these modules effectively improves the detection accuracy and efficiency of multi-scale container damage defects, overcoming the shortcomings of existing technologies.

[0161] Example 2

[0162] like Figure 3 As shown in Example 1, this example elaborates on the specific steps of an improved UPAD-YOLO container damage detection method during operation. The specific steps are as follows:

[0163] 1. Image Acquisition:

[0164] High-resolution RGB cameras are used to capture images of the container surface, ensuring that the images cover all areas of the container, including any defects such as dents, holes, and structural damage.

[0165] 2. Image preprocessing:

[0166] The acquired raw images are preprocessed, including adjusting the image size to a fixed resolution and normalizing the pixel values ​​to adapt to the model input requirements.

[0167] 3. Model loading:

[0168] The trained and improved UPAD-YOLO model is loaded onto the computing device, ready for image detection.

[0169] 4. Feature extraction:

[0170] The preprocessed image is input into the backbone network of the model, and multi-scale features of the image are extracted through the dynamic modulation convolution module to capture local and global information of defects of different sizes.

[0171] 5. Feature enhancement:

[0172] In the feature extraction layer, the feature map is processed by a parallelized block-aware attention module to enhance the key features of the defect region and suppress background noise interference in the image.

[0173] 6. Multi-scale feature fusion:

[0174] In the detection head, an adaptive spatial feature fusion module is used to fuse feature maps from different levels. By dynamically allocating weights, the feature representation is optimized, thereby improving the detection capability of multi-scale defects.

[0175] 7. Defect detection output:

[0176] The model outputs the defect category probability and bounding box coordinates based on the fused feature map, initially identifying the possible defect regions and their types in the image.

[0177] 8. Post-processing optimization:

[0178] The detection results output by the model are post-processed, including applying a nonmaximum suppression algorithm to remove overlapping or duplicate detection boxes and optimize the accuracy of the final detection results.

[0179] 9. Result Generation and Output:

[0180] The optimized detection results are output in a visual form, with defect types and location information marked in the image, and a detection report is generated for subsequent use.

[0181] The above steps complete the container damage detection workflow based on the improved UPAD-YOLO, realizing end-to-end processing from image input to defect result output.

[0182] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.

Claims

1. An improved UPAD-YOLO-based container damage detection method, characterized in that, The method comprises the following steps: S1, image acquisition, using a high-resolution RGB camera to shoot the surface of the container, and obtaining an image dataset containing three types of defects including concave, broken hole and structural damage; S2, data preprocessing, dividing the collected image dataset into training set, validation set and test set, labeling the defect area position and recording the category information; S3, model construction, designing UPAD-YOLO network architecture, embedding dynamic modulation convolution module in the backbone network, extracting multi-scale features through multi-branch parallel convolution, and dynamically adjusting feature fusion weight based on channel level modulation coefficient; S4, feature enhancement, introducing parallel block perception attention module in the feature extraction layer, capturing key feature information of the defect area through local and global multi-branch feature interaction mechanism, and adopting double attention weighting strategy to suppress irrelevant background noise; S5, feature fusion, integrating adaptive spatial feature fusion module in the detection head, and fusing feature maps of different resolution levels through spatial weight dynamic allocation strategy; S6, model training, inputting the divided dataset into the model for training, optimizing network parameters to output defect category and position information; The operation of the dynamic modulation convolution module in S3 comprises: Performing depth separable convolution calculation with three different expansion rates on the input feature map to generate multi-scale feature maps with different receptive field ranges; Introducing a learnable channel-level modulation coefficient for each group of feature maps, and setting the initial value through the Xavier initialization method, and dynamically adjusting the importance of each channel feature according to the task requirements; Aligning the spatial dimensions of the feature maps using the bilinear interpolation algorithm to ensure that the multi-scale feature maps remain consistent in space; Concatenating the aligned feature maps along the channel dimension and reducing the calculation amount through one-by-one convolution operation; Performing batch normalization processing on the reduced feature maps, and using the ReLU activation function to enhance the non-linear expression ability; Wherein, the adjustment of the channel-level modulation coefficient is realized by the following mathematical formula: In the formula, denotes the modulation coefficient of the cth channel, W c denotes the learnable weight vector of the cth channel, F c denotes the input feature map of the cth channel, c denotes the total number of channels of the feature map, exp denotes the exponential function, and • denotes the vector dot product operation.

2. The improved UPAD-YOLO based container damage detection method according to claim 1, wherein, The structure of the parallel block perception attention module in S4 comprises: Divide the input feature map into several non-overlapping blocks, and generate local attention weights for each block through a multi-layer perceptron; Calculate the cosine similarity matrix between blocks in the global branch to measure the correlation between block features; Fuse the features of local and global branches, and perform channel attention weighting and spatial attention weighting operations in turn; Channel attention weighting is performed by executing maximum pooling and average pooling operations on the feature map respectively, adding the pooling results after learning through a shared multi-layer perceptron, and generating a channel weight matrix after Sigmoid activation; Spatial attention weighting generates a feature map through global maximum pooling and global average pooling operations, and obtains a spatial weight matrix after concatenation and convolution processing; Finally, merge the channel and spatial weight matrices to generate the enhanced feature map; Wherein, the calculation of the inter-block cosine similarity matrix is realized by the following mathematical formula: In the formula, S ij represents the cosine similarity between the ith block and the jth block, B i represents the feature vector of the ith block, B j represents the feature vector of the jth block, and • represents the vector dot product operation, represents the Euclidean norm of the ith block feature vector, represents the Euclidean norm of the jth block feature vector.

3. The improved UPAD-YOLO based container damage detection method of claim 1, wherein, The operation of the adaptive spatial feature fusion module in S5 comprises: Scale the feature maps of different levels to a unified target resolution to meet the input requirements of the detection head; Generate a set of learnable fusion weight parameters for each spatial position, constrain the weight sum to be 1, and the value range is 0 to 1; The multi-scale feature maps are linearly weighted and fused according to the generated fusion weights to form a final feature representation; Wherein, the generation of fusion weight is realized by the following mathematical formula: In the formula, represents the fusion weight of the first level feature map at the spatial position (x, y), V1 (x,y) represents the learnable parameter of the first level feature map at the spatial position (x, y), L represents the total number of levels of the feature map, exp represents the exponential function, and (x, y) represents the spatial coordinates on the feature map.

4. The improved UPAD-YOLO based container damage detection method of claim 1, wherein, The specific process of model training in S6 includes: The input image resolution is set to 640*640, the batch size is set to 8, and the training round is set to 300; The cosine learning rate scheduler is used to adjust the learning rate, and the initial learning rate is set to 0.001; Automatic mixed precision training is enabled to speed up the convergence process; During the training process, the cross-entropy loss function is used to optimize the classification task, and the CIoU loss function is used to optimize the bounding box regression task; The stochastic gradient descent optimizer is used to update the network parameters, and the momentum parameter is set to 0.9 and the weight decay coefficient is set to 0.0005; The CIoU loss function is calculated by the following mathematical formula: In the formula, CIoU loss value is represented by CIoU, The intersection over union of the predicted box and the real box is represented by IoU, The Euclidean distance between the center points of the predicted box and the real box is represented by d, The center coordinates of the predicted box are represented by c, The center coordinates of the real box are represented by c, and c represents the length of the diagonal of the minimum bounding rectangle of the predicted box and the real box, The weight coefficient is represented by v, and v is used to measure the consistency of the length-width ratio of the predicted box and the real box.

5. The improved UPAD-YOLO based container damage detection method of claim 1, wherein, The generation of the multi-scale feature maps in the dynamic modulation convolution module includes: The input feature maps are processed in parallel by three deep separable convolution branches with different dilation rates, where the dilation rates are set to 1, 3 and 6 respectively; The output feature maps of each branch are weighted by channel-level modulation coefficients, and the dynamic adjustment of the modulation coefficients is based on the backpropagation of the task loss; The feature map space alignment uses the bilinear interpolation algorithm to ensure that the multi-branch feature maps are consistent in width and height dimensions; The concatenated feature maps are reduced in dimension by a 1*1 convolution layer, and the number of channels after dimension reduction is reduced to half of the input channel number; Batch normalization processing is performed after dimension reduction to stabilize the training process and speed up convergence; The ReLU activation function is applied to the normalized feature maps to introduce a nonlinear transformation; Wherein, the fusion of multi-scale feature maps is realized through the following mathematical formula: In the formula, F out represents the output feature map, BN represents the batch normalization operation, represents the 1X1 convolution operation, Concat shows the splicing operation along the channel dimension, respectively represent the channel level modulation coefficients of the three branches, F 1、 F 2、 F3 respectively represent the output feature maps of the three branches, • represents the channel-by-channel multiplication operation, and ReLU represents the rectified linear unit activation function.

6. The improved UPAD-YOLO based container damage detection method of claim 1, wherein, The double-path attention weighting operation in the parallel block-aware attention module includes: The channel attention weighting branch simultaneously performs global max pooling and global average pooling on the input feature maps, and inputs the pooling results into a shared multi-layer perceptron; The shared multi-layer perceptron consists of two fully connected layers, the first fully connected layer reduces the number of channels to one sixteenth of the original channel number, and the second fully connected layer restores the original channel number; The output feature vectors of the two pooling paths are element-wise added, and a channel weight matrix is generated by a Sigmoid function; The spatial attention weighting branch performs global max pooling and global average pooling on the channel-weighted feature maps, and concatenates the results along the channel dimension; The concatenated feature maps generate a spatial weight matrix through a 7*7 convolution layer; The final output feature map is obtained by element-wise multiplication of the channel weight matrix and the spatial weight matrix; wherein the calculation of the channel weight matrix is achieved by the following mathematical formula: In the formula, denotes the channel weight matrix, denotes a Sigmoid activation function, and MLP denotes a shared multi-layer perceptron, denotes a global average pooling operation, denotes a global maximum pooling operation, and F denotes an input feature map.

7. The improved UPAD-YOLO based container damage detection method of claim 3, wherein, The linear weighted fusion operation in the adaptive spatial feature fusion module includes: Different level feature maps from the backbone network are unified to the target resolution through upsampling or downsampling operations; The target resolution is set to one eighth, one sixteenth and one thirty-second of the input image resolution; A set of fusion weight parameters is generated for each spatial position, and the weight parameters are processed by a 1*1 convolution layer and a Softmax function; The fusion weight parameters are updated by the stochastic gradient descent optimizer during the training process; The linear weighted fusion of the multi-scale feature maps is independently performed at each spatial position; The final feature representation is used for the classification and bounding box regression tasks of the detection head. wherein the linearly weighted fusion is implemented by the following mathematical formula: In the formula, denotes the feature vector at the spatial position (x, y) after fusion, denotes the fusion weight of the first-level feature map at the spatial position (x, y), denotes the feature vector of the first-level feature map at the spatial position (x, y), L denotes the total number of levels of the feature map, • denotes an element-by-element multiplication operation, and (x, y) denotes the spatial coordinates on the feature map.

Citation Information

Patent Citations

  • Defect target detection method based on improved YOLOv8

    CN120564000A

  • Container surface defect detection method based on multi-scale feature fusion

    CN120833340A