Dam crack detection method based on dual-channel multi-scale attention mechanism
Patent Information
- Application Number
- CN202511515877.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-22
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2045-10-22
AI Technical Summary
[0007]本发明提供了基于双通道多尺度自适应增强机制的大坝裂缝检测方法,在解决现有技术在处理大坝复杂多变背景图像时,裂缝检测精度和鲁棒性不足,以及处理高分辨率大尺寸图像时计算效率低下的问题
1、本申请通过构建全局语义与背景噪声抑制通道(第一通道)和局部细节与裂缝增强通道(第二通道),本发明实现了对大坝复杂背景和细微裂缝特征的有效处理。第一通道在较低分辨率下捕获全局语义信息并利用全局上下文感知注意力模块抑制背景噪声,而第二通道通过可变形卷积块和局部特征自适应增强模块,在高分辨率下精细提取和增强裂缝细节特征,从而解决了现有技术在复杂背景下裂缝与噪声难以区分的问题,显著提升了检测的鲁棒性和准确性。
Smart Images

Figure CN121685364B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology, and more specifically, relates to a method for detecting cracks in dams based on a dual-channel multi-scale attention mechanism. Background Technology
[0002] With the continuous expansion and aging of modern industrial infrastructure, the early and accurate identification of structural defects has become crucial to ensuring its safe and stable operation. Dams, as vital water conservancy infrastructure, play an irreplaceable strategic role in crack detection for national economic and social development, including flood control, power generation, and water supply. Traditional crack detection methods often rely on manual inspections, which are not only inefficient and costly but also susceptible to subjective factors, making it difficult to accurately identify minute cracks. Therefore, crack detection methods using deep learning technology have rapidly become a research hotspot in this field. This technology utilizes the powerful feature learning capabilities of convolutional neural networks (CNNs) to automatically extract crack features from images, greatly improving the automation and objectivity of detection.
[0003] With the continuous evolution of image processing technology, deep learning-based crack detection methods have been increasingly widely applied in various industrial scenarios such as photovoltaic panels and dams. Among them, CN116402761A, titled "A Photovoltaic Panel Crack Detection Method Based on a Dual-Channel Multi-Scale Attention Mechanism," focuses on constructing a dual-channel neural network model. Specifically, this model captures high-level semantic information and fine spatial detail features of the image through separate semantic branch channels and spatial detail branch channels. Building upon this, the scheme cleverly introduces a multi-scale attention mechanism module, enabling it to dynamically adjust the weights of information at different scales based on the importance of features. Combined with a multi-channel dilated convolutional fusion module, the features extracted from the two branch channels are effectively fused. Through this design, the technical solution successfully solves the problem of detail feature loss during feature extraction in traditional convolutional networks, thus significantly improving the accuracy of photovoltaic panel crack detection. It demonstrates excellent performance when processing photovoltaic panel electroluminescent (EL) images with a simple background and relatively regular crack morphology.
[0004] However, with the continuous development of related technologies and the increasingly stringent performance requirements for dam safety monitoring, some inherent characteristics of the aforementioned technical solutions for photovoltaic panel crack detection are gradually revealing their limitations in addressing the more complex and variable challenges of dam crack detection. The relatively simple visual environment of photovoltaic panels allows models to effectively learn the unique patterns of photovoltaic panel cracks. However, the surface environment of dams is drastically different. Their image data backgrounds are complex and varied, often accompanied by complex and non-uniform backgrounds. Dam cracks often appear as fine, discontinuous lines, and their visual features are easily confused with background noise. They may even be difficult to distinguish due to their small size, insufficient contrast, or obstruction. Therefore, these solutions cannot meet the stringent requirements of high robustness and high precision for dam detection.
[0005] Furthermore, this method may suffer from high computational complexity when processing large images. The consumption of computational resources (such as GPU memory and processing time) is enormous when processing high-resolution or large-scale image data. When a dam detection system needs to process a large number of high-resolution images in real-time or near real-time, the high computational complexity will directly lead to slow detection speed and system response delays, severely impacting detection efficiency in practical applications.
[0006] The above analysis shows that existing crack detection technologies designed for specific scenarios (such as photovoltaic panel EL images) have significant shortcomings in terms of model running efficiency when applied to scenarios such as dams, which have complex and variable backgrounds and extremely high requirements for detection efficiency. Summary of the Invention
[0007] This invention provides a dam crack detection method based on a dual-channel, multi-scale adaptive enhancement mechanism. It addresses the shortcomings of existing technologies in crack detection accuracy and robustness when processing complex and variable background images of dams, as well as their low computational efficiency when processing high-resolution, large-size images. To achieve the above-mentioned objectives, this invention provides the following technical solution: The present invention provides a dam crack detection method based on a dual-channel multi-scale adaptive enhancement mechanism, comprising the following steps: First, high-resolution digital image data of the dam surface to be inspected is acquired, and the digital image data is preprocessed to standardize the brightness and contrast of the image and remove preliminary image noise.
[0008] Preprocessing operations specifically include: The digital image data is converted into a grayscale image, adaptive histogram equalization is performed to enhance local contrast, and a nonlocal mean filtering algorithm is applied for preliminary denoising. The processed digital image data is used as the input to the method of this invention.
[0009] Second, a dual-channel feature extraction network is constructed and run. The dual-channel feature extraction network includes a first channel and a second channel. The first channel is designed as a global semantic and background noise suppression channel, and the second channel is designed as a local detail and crack enhancement channel.
[0010] The first channel receives downsampled input digital image data. The downsampling operation reduces the resolution of the input digital image data to one-quarter of the original resolution in order to extract global context information at a lower computational cost.
[0011] The first channel consists of a deep convolutional neural network containing multiple cascaded convolutional blocks. Each convolutional block comprises a convolutional layer, a batch normalization layer, and an activation function layer. The convolutional layers use standard 3x3 convolutional kernels with a stride of 1 and padding of 1. The batch normalization layer accelerates model training and stabilizes the feature distribution. The activation function layer uses the ReLU activation function.
[0012] During the feature extraction process of the first channel, a global context-aware attention module is integrated. This module receives the feature map output from the intermediate layer of the first channel and generates a channel descriptor through an average pooling operation and a max pooling operation. The two channel descriptors are then input into a shared multilayer perceptron to learn the dependencies between channels, thereby generating channel attention weights. Simultaneously, spatial attention weights are generated through convolution. The channel attention weights and spatial attention weights are multiplied and normalized using a sigmoid function to generate a gated attention map. This gated attention map is then multiplied element-wise with the feature map of the first channel to enhance global semantic features and suppress background noise features. The first channel outputs a set of global semantic and background noise-suppressed features.
[0013] The second channel receives unsampled, raw-resolution input digital image data or digital image data that has been slightly downsampled (e.g., reduced to half the original resolution) to preserve high-resolution local spatial details. The second channel also consists of a deep convolutional neural network containing multiple sets of cascaded deformable convolutional blocks, each consisting of a deformable convolutional layer, a batch normalization layer, and an activation function layer.
[0014] The deformable convolutional layer employs a 3x3 deformable convolutional kernel, which dynamically adjusts the shape of the receptive field based on the learned offset on the feature map to better adapt to the non-rigid morphology and irregular geometry of the crack. The batch normalization layer and activation function layer are configured the same as in the first channel. During feature extraction in the second channel, a local feature adaptive enhancement module is integrated. This module receives the feature map output from the intermediate layer of the second channel and processes it in parallel through a multi-scale convolutional filter bank consisting of multiple scale branches. Each branch uses a convolutional kernel of different sizes (e.g., 1x1, 3x3, 5x5) to capture local information at different scales, and the multi-scale convolution results are concatenated. The concatenated feature map then passes through a hybrid attention unit consisting of channel attention and spatial attention mechanisms. This hybrid attention unit adaptively enhances local detail features related to the crack and suppresses local noise. The second channel outputs a set of local detail and crack enhancement features.
[0015] Third, implement cross-channel information fusion and guidance, and effectively integrate the characteristics of the two channels.
[0016] The cross-channel information fusion and guidance module specifically includes: constructing a gated attention modulation unit and an adaptive multi-scale feature fusion unit.
[0017] The gated attention modulation unit receives the global semantic and background noise suppression features from the first channel output, as well as the local detail and crack enhancement features from the second channel output.
[0018] The global semantic and background noise suppression features are first upsampled to increase their spatial resolution to the same size as the local detail and crack enhancement features. Then, the upsampled global semantic and background noise suppression features are fed into a modulation network consisting of convolutional layers and a sigmoid activation function to generate a gated modulation map. Each pixel value in the gated modulation map is between 0 and 1, representing the background noise intensity of the corresponding local region or the degree of suppression in non-crack regions. The gated modulation map is then multiplied element-wise with the local detail and crack enhancement features, thereby guiding and modulating the features of the second channel with the global background suppression information from the first channel.
[0019] Specifically, in regions with low gating modulation map values (representing high background noise or non-crack areas), local details and crack enhancement features are weakened; in regions with high gating modulation map values (representing low background noise or potential crack areas), local details and crack enhancement features are preserved or enhanced. Through the gating attention modulation unit, the global background suppression capability of the first channel effectively guides the local feature extraction of the second channel, reducing the sensitivity of the second channel to complex background noise and improving the recognizability of crack features.
[0020] The adaptive multi-scale feature fusion unit receives local detail and crack enhancement features modulated by the gated attention modulation unit, as well as global semantic and background noise suppression features upsampled from the first channel. The adaptive multi-scale feature fusion unit employs a hierarchical attention aggregation mechanism and a hybrid mechanism of channel attention and spatial attention.
[0021] Specifically, the two feature maps are first concatenated along the channel dimension. The concatenated feature map is then fed into a fusion network consisting of multiple parallel branches. Each branch contains a convolutional layer and a dilated convolutional layer of a specific scale (e.g., dilated convolutions with dilation rates of 2, 4, and 8) to capture fusion features across different receptive fields. The output features of the parallel branches are concatenated and passed through a global average pooling layer and a global max pooling layer to generate two channel descriptors, respectively. The two channel descriptors are then fed into a shared convolutional layer and a sigmoid activation function to generate channel attention weight vectors. These channel attention weight vectors are element-wise multiplied with the concatenated multi-scale fusion features to adaptively adjust the importance of different channel features. Furthermore, the fusion network includes a spatial attention module, which compresses the fusion features along the channel dimension using average pooling and max pooling operations, generating two two-dimensional spatial descriptors. These two spatial descriptors are then concatenated and passed through a convolutional layer and a sigmoid activation function to generate a spatial attention weight map. The spatial attention weight map is multiplied element-wise with the fusion features after channel attention weighting to further refine the spatial distribution of the fusion features.
[0022] Through a hierarchical attention aggregation mechanism, this invention can dynamically allocate weights based on the semantic and spatial importance of features, ensuring the synergistic complementarity between global semantic information and local detailed information, and effectively avoiding feature redundancy. The adaptive multi-scale feature fusion unit outputs the fused high-level feature representation.
[0023] Fourth, the crack segmentation and output are performed. The fused high-level feature representation is gradually restored to the same spatial resolution as the original input image through a series of upsampling and convolutional layers. The upsampling operation uses bilinear interpolation or transposed convolution.
[0024] The convolutional layer uses a 1x1 convolutional kernel to convert the number of channels in the feature map to the required number of output channels (e.g., 1 in a binary classification task). Finally, a sigmoid activation function maps the output value of each pixel to between 0 and 1, generating a pixel-level crack probability map. Each pixel value in the crack probability map represents the probability that the pixel belongs to a crack. By setting a preset threshold, the probability map is binarized into the final crack segmentation result map.
[0025] Furthermore, to further enhance the model's ability to detect minute cracks and improve the convergence speed of the training process, this invention introduces auxiliary loss functions into multiple intermediate layers of the dual-channel feature extraction network. These auxiliary loss functions, together with the loss function of the final output layer, constitute a deep supervision strategy. The loss function can be either the binary cross-entropy loss function or the Dice loss function.
[0026] In summary, this invention, through the aforementioned technical solutions, proposes a detection method with high robustness, high accuracy, and high computational efficiency to address the complexity and efficiency requirements of dam crack detection. The method features systematic innovations in feature extraction, information fusion, and guidance, effectively addressing the diverse crack characteristics under complex dam conditions. Furthermore, it significantly improves the efficiency of processing large-size images while maintaining detection accuracy, thus comprehensively resolving the deep-seated contradictions in existing technologies.
[0027] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This application constructs a global semantic and background noise suppression channel (first channel) and a local detail and crack enhancement channel (second channel), thereby achieving effective processing of complex background and fine crack features of dams. The first channel captures global semantic information at a lower resolution and uses a global context-aware attention module to suppress background noise, while the second channel, through deformable convolutional blocks and a local feature adaptive enhancement module, finely extracts and enhances crack detail features at high resolution. This solves the problem of existing technologies making it difficult to distinguish cracks from noise in complex backgrounds, significantly improving the robustness and accuracy of detection.
[0028] 2. The gated attention modulation unit introduced in this invention enables the global background suppression information of the first channel to effectively guide and modulate the local feature extraction process of the second channel. This mechanism allows the model to dynamically weaken the feature response of background noise regions and enhance the feature representation of potential crack regions, thereby improving the model's ability to identify crack features without significantly increasing computational complexity. In particular, it can effectively reduce the false detection rate when facing diverse interference factors such as textures, water stains, and moss on the dam surface.
[0029] 3. The adaptive multi-scale feature fusion unit designed in this invention achieves deep fusion of different scales and semantic information from two channels through a hierarchical attention aggregation mechanism and a hybrid mechanism of channel attention and spatial attention. The fusion unit can dynamically allocate weights according to the importance of features and refine the fused features, effectively solving the problems of feature redundancy and information loss that may be caused by traditional fusion methods, and ensuring that the model can comprehensively utilize global context and local detail information for accurate crack identification.
[0030] 4. The asynchronous resolution processing strategy employed in this invention involves the first channel operating at a lower resolution to capture the global context, while the second channel operates at a higher resolution to preserve details. Simultaneously, cross-channel guidance is achieved through gated attention modulation, effectively balancing detection accuracy and computational efficiency. Compared to traditional designs where both channels perform complex calculations at high resolution, this invention significantly reduces the computational resources and time required to process high-resolution, large-size dam images, thereby improving the system's response speed and detection efficiency in practical applications. Attached Figure Description
[0031] Figure 1 This is a system flowchart of the present invention. Detailed Implementation
[0032] Example 1: As Figure 1 As shown, this invention provides a dam crack detection method based on a dual-channel multi-scale attention mechanism. The aim is to improve the accuracy, robustness, and computational efficiency of dam crack detection through refined feature extraction, adaptive cross-channel information fusion and guidance, and an efficient end-to-end learning strategy. This invention fully considers the complexity of dam surface images, including diverse textures, uneven illumination, environmental noise, and the subtlety and irregularity of the cracks themselves. The following will elaborate on the various components and their operating mechanisms of this invention in detail, with specific technical details provided.
[0033] The dam crack detection method based on dual-channel multi-scale attention mechanism of the present invention includes the following core steps.
[0034] First, this invention preprocesses the high-resolution digital image data of the dam surface to be inspected. The digital image data typically originates from visual information collected by drones, ground robots, or fixed cameras, ensuring that the details of the original scene are fully preserved.
[0035] Specifically, the preprocessing procedure first converts the RGB three-channel color image data into a single-channel grayscale image. After the grayscale image is generated, an adaptive histogram equalization (AHE) operation is performed. To avoid excessive noise amplification and limit contrast magnification, this invention preferably employs the contrast-limited adaptive histogram equalization (CLAHE) algorithm. The CLAHE algorithm divides the image into multiple non-overlapping small regions (e.g., 8x8 or 16x16 pixel patches) and performs histogram equalization independently on each region. By setting a contrast limiting factor, excessive noise amplification can be effectively suppressed, while enhancing the contrast of local areas, making the boundary between the crack and the background clearer.
[0036] Subsequently, to further reduce image noise, this invention applies a Non-Local Means (NLM) filtering algorithm for preliminary denoising. The core idea of NLM is that the estimated value of a pixel is obtained by weighted averaging of pixels in its surrounding similar regions, with the weights depending on the similarity between regions. In a typical configuration, the algorithm uses a large search window (e.g., 21x21 pixels) to find similar regions and a small patch size (e.g., 7x7 pixels) to calculate the similarity between regions, while controlling the sensitivity of similarity to the weights through a decay parameter h (e.g., 5.0 to 10.0). Compared to traditional local filters such as Gaussian blur, NLM effectively removes random noise while better preserving image edge and texture details, which is crucial for subsequent fine crack detection. After the above preprocessing steps, the resulting digital image data serves as the normalized input for the method of this invention.
[0037] Secondly, this invention constructs and runs a dual-channel feature extraction network. The dual-channel feature extraction network includes a first channel and a second channel, which are designed to perform different functional roles and work together to achieve comprehensive capture of crack features.
[0038] The first channel is designed as a global semantic and background noise suppression channel. This channel receives downsampled input digital image data. To significantly reduce computational cost and memory consumption while maintaining global contextual information capture capabilities, the downsampling operation reduces the resolution of the input digital image data to one-quarter of the original resolution. For example, an image with an original resolution of 2048x1024 pixels will become 512x256 pixels after downsampling. This downsampling process is typically implemented by consecutively applying two max-pooling layers with a stride of 2 and a kernel size of 2x2 (nn.MaxPool2d(kernel_size=2, stride=2)) or two convolutional layers with a stride of 2. The first channel consists of a deep convolutional neural network containing multiple sets of cascaded convolutional blocks. In a typical implementation, this channel can contain 4 to 5 convolutional blocks, each responsible for extracting features at different levels of abstraction. Each convolutional block consists of a convolutional layer, a batch normalization layer, and an activation function layer. The convolutional layers use a standard 3x3 convolutional kernel with a stride of 1 and padding of 1, ensuring that the spatial dimensions of the feature map remain unchanged after the convolution operation while capturing local spatial information of neighboring pixels. For example, the first convolutional block might map the number of input channels (e.g., 1 grayscale channel) to 32 feature channels, with subsequent blocks progressively increasing the number of channels to 64, 128, and 256 to extract richer feature representations. Batch normalization layers normalize the features of each mini-batch of input, accelerating model training convergence and stabilizing the feature distribution across different layers. Default parameters typically include a small ε value (e.g., 1e-5) to avoid division by zero errors and a momentum parameter (e.g., 0.1) to update the running mean and variance. The activation function layer uses the ReLU (Rectified LinearUnit) activation function, f(x) = max(0, x), which is computationally simple and effectively alleviates the vanishing gradient problem in deep networks, while introducing non-linearity to enhance the model's expressive power.
[0039] During the feature extraction process of the first channel, a Global Context-Aware Attention Module (GCAM) is specifically integrated. The GCAM receives the feature map output from the intermediate layer of the first channel, for example, the output from the intermediate layer with 128 or 256 channels.
[0040] This module first generates a channel descriptor through an average pooling operation (nn.AdaptiveAvgPool2d(1)), which reflects the average feature response of each channel. Simultaneously, it generates another channel descriptor through a max pooling operation (nn.AdaptiveMaxPool2d(1)), which captures the most salient feature information of each channel. The two channel descriptors are then concatenated and fed into a shared Multi-Layer Perceptron (MLP). The MLP contains two fully connected layers sandwiched by a ReLU activation function, which learns the dependencies between channels. For example, the first fully connected layer compresses the concatenated feature dimension (e.g., by a factor of 16) and then activates it with ReLU; the second fully connected layer restores the dimension to the original number of channels. The output of the MLP is processed by a Sigmoid activation function to generate a set of channel attention weight vectors, which indicate the importance of each feature channel. Simultaneously, to capture attention in the spatial dimension, the module processes the feature maps aggregated along the channel dimension (typically concatenated after average pooling and max pooling) through a convolutional operation (e.g., a convolutional layer with a kernel size of 7x7, stride of 1, and padding of 3) to generate a spatial attention weight map. The channel attention weight vector and the spatial attention weight map are then multiplied element-wise, and the result is normalized using the sigmoid function to finally generate a gated attention map. Each pixel value in the gated attention map is between 0 and 1, representing the importance of that spatial location and feature channel. The gated attention map is then multiplied element-wise with the original feature map of the first channel, allowing the model to adaptively enhance global semantic features (such as the overall structure of a dam, the macroscopic distribution of crack areas) and suppress background noise features (such as large-area texture interference, uneven illumination). This mechanism enables the first channel to understand image content at a high level and provides a "clean" global semantic background for subsequent local detail processing. The first channel ultimately outputs a set of global semantic and background noise suppression features.
[0041] Furthermore, the second channel is designed as a local detail and crack enhancement channel. This channel receives unsampled, original-resolution input digital image data or digital image data that has only been slightly downsampled (e.g., reduced to half the original resolution). In practical applications, to balance computational resources and detail preservation, a single max-pooling operation is often used to reduce the resolution to half the original resolution, maximizing the preservation of high-resolution local spatial details at a reasonable computational cost. The second channel also consists of a deep convolutional neural network containing multiple sets of cascaded deformable convolutional blocks. Similar to the first channel, it can also contain 4 to 5 deformable convolutional blocks, with the number of channels gradually increasing (e.g., from 64 to 512). Each deformable convolutional block consists of a deformable convolutional layer, a batch normalization layer, and an activation function layer.
[0042] The deformable convolutional layer employs a 3x3 deformable convolutional kernel. Its core feature lies in its ability to dynamically adjust the shape of the receptive field and the sampling position based on learned offsets on the feature map. Specifically, in addition to the traditional convolutional kernel parameters, this layer additionally learns a set of two-dimensional offset maps with the same size as the input feature map. These offsets are predicted through a separate convolutional layer (e.g., a 3x3 kernel with 2*K output channels, where K is the number of sampling points in the convolutional kernel; for a 3x3 kernel, K=9, hence 18 output channels). During convolution operations, these offsets are added to the standard grid sampling points, allowing the convolutional kernel to sample features more flexibly, thus better adapting to the non-rigid morphology, irregular geometry, and varied topological features of cracks. This adaptive sampling mechanism greatly enhances the network's ability to capture local crack details and reduces feature mismatch caused by changes in crack shape. The batch normalization layer and activation function layer are configured the same as the first channel, used to stabilize the training process and introduce nonlinearity, respectively.
[0043] In the feature extraction process of the second channel, a Local Feature Adaptive Enhancement Module (LFAEM) is integrated. The LFAEM receives the feature map output from the intermediate layer of the second channel, for example, in an intermediate layer with 256 or 512 channels. This module first processes the feature map in parallel through a multi-scale convolutional filter bank consisting of multiple scale branches to capture local information at different scales. For example, it can contain three parallel branches, using convolutional kernels of 1x1, 3x3, and 5x5 sizes, respectively. The 1x1 convolutional kernel is mainly used to adjust the number of channels and introduce non-linearity without changing the receptive field; the 3x3 convolutional kernel (usually with padding=1) is used to capture medium-scale local context; and the 5x5 convolutional kernel (usually with padding=2) is used to capture slightly larger-scale local context information. These parallel convolutional operations enable the module to simultaneously perceive local features of different crack widths and their surrounding environment. The multi-scale convolutional results are then concatenated along the channel dimensions (using the `torch.cat` operation) to form a feature map that incorporates multi-scale local information. The concatenated feature maps are further processed by a hybrid attention unit consisting of channel attention and spatial attention mechanisms. The channel attention mechanism generates channel weights through global average pooling and global max pooling, followed by a shared MLP and sigmoid function, to adaptively enhance specific channel features associated with cracks. The spatial attention mechanism performs average pooling and max pooling separately along the channel dimensions, and after concatenation, passes the concatenation through a convolutional layer (e.g., with a 7x7 kernel) and a sigmoid function to generate a spatial weight map, focusing on crack regions in the feature map.
[0044] The cascading or parallel application of these two attention mechanisms (e.g., applying channel attention first and then inputting the result into spatial attention) can adaptively enhance local detail features associated with cracks and suppress local noise (such as small stains and bubbles), thereby enabling the second channel to output a set of highly refined local detail and crack enhancement features.
[0045] Third, this invention performs cross-channel information fusion and guidance to guide the extraction of local detailed features from global semantic information and effectively fuse the features of the two channels.
[0046] The cross-channel information fusion and guidance module specifically includes: constructing a Gated Attention Modulation Unit (GAMU) and an Adaptive Multi-Scale Feature Fusion Unit (AMFU).
[0047] The gated attention modulation unit receives the global semantic and background noise suppression features from the first channel output, and the local detail and crack enhancement features from the second channel output. Since the features in the first channel are typically at a lower resolution (e.g., one-quarter of the original resolution), while the features in the second channel are at a higher resolution (e.g., half the original resolution), the global semantic and background noise suppression features are first upsampled to increase their spatial resolution to the same size as the local detail and crack enhancement features. This upsampling operation is typically implemented using bilinear interpolation or transposed convolution (kernel size 2, stride 2), where X is the corresponding scaling factor, such as 2x or 4x. Subsequently, the upsampled global semantic and background noise suppression features are fed into a modulation network consisting of convolutional layers and a sigmoid activation function. The modulation network typically contains a 1x1 convolutional layer to convert the feature channel count to a single channel, followed by a sigmoid activation function. The sigmoid function constrains the output value between 0 and 1, thus generating a gated modulation map. Each pixel value in the gated modulation map ranges from 0 to 1, representing the intensity of background noise in the corresponding local area or the degree of suppression in non-crack areas. For example, pixel values near the dam background area may be lower, indicating a need for strong suppression; while pixel values near potential crack areas may be higher, indicating preservation or enhancement. The gated modulation map is then multiplied element-wise with local detail and crack enhancement features. Specifically, in areas with lower gated modulation map values (indicating high background noise or non-crack areas), local details and crack enhancement features are weakened; in areas with higher gated modulation map values (indicating low background noise or potential crack areas), local details and crack enhancement features are preserved or enhanced. Through the gated attention modulation unit, the global background suppression capability extracted by the first channel effectively guides the local feature extraction of the second channel, dynamically adjusting the attention of the second channel to different areas, reducing the sensitivity of the second channel to complex background noise, and improving the recognition of crack features, thus avoiding misidentification of background noise as cracks.
[0048] The adaptive multi-scale feature fusion unit receives local detail and crack enhancement features modulated by the gated attention modulation unit, as well as global semantic and background noise suppression features upsampled from the first channel. The adaptive multi-scale feature fusion unit employs a hierarchical attention aggregation mechanism and a hybrid mechanism of channel attention and spatial attention to achieve deep fusion of two different types of features.
[0049] Specifically, the two feature maps are first concatenated along the channel dimension. The concatenated feature map is then input into a fusion network consisting of multiple parallel branches. Each branch contains a convolutional layer and a dilated convolutional layer of a specific scale. For example, four parallel branches can be set up, each employing a 3x3 kernel with dilated convolutions of 1, 2, 4, and 8 dilation rates. Dilated convolutions can effectively expand the receptive field of the convolutional kernel without increasing the number of parameters or computational cost, thereby capturing fusion features under different receptive fields. This parallel structure of multi-scale dilated convolutions helps the fusion unit perceive contextual information of different widths and scales of the cracks. The output features of the parallel branches are then concatenated to form a feature map containing rich multi-scale fusion information. To further refine these fusion features, this invention introduces a channel attention mechanism and a spatial attention mechanism. Channel attention generates two channel descriptors through a global average pooling layer and a global max pooling layer, respectively. Two channel descriptors are fed into a shared convolutional layer (e.g., first compressing the number of channels to 1 / 16 and then restoring it) and a sigmoid activation function to generate channel attention weight vectors. These channel attention weight vectors are element-wise multiplied with the concatenated multi-scale fusion features to adaptively adjust the importance of different channel features, making the model focus more on feature channels relevant to crack detection. Furthermore, the fusion network includes a spatial attention module, which compresses the fusion features along the channel dimension using average pooling and max pooling operations, generating two two-dimensional spatial descriptors. These two spatial descriptors are concatenated and passed through a convolutional layer (e.g., 7x7 kernel size, 3 padding) and a sigmoid activation function to generate a spatial attention weight map. This spatial attention weight map is element-wise multiplied with the channel-weighted fusion features to further refine the spatial distribution of the fusion features, allowing the model to focus on crack regions in the feature map. By employing a hierarchical attention aggregation mechanism, this invention dynamically allocates weights based on the semantic and spatial importance of features, ensuring the synergistic complementarity between global semantic information (from the first channel) and local detail information (from the second channel), and effectively avoiding feature redundancy and information loss that may occur with traditional fusion methods. The adaptive multi-scale feature fusion unit ultimately outputs the fused high-level feature representation.
[0050] Finally, this invention performs crack segmentation and output. The fused high-level feature representation is progressively restored to the same spatial resolution as the original input image through a series of upsampling and convolutional layers. Upsampling operations can employ bilinear interpolation or transposed convolution to progressively increase the resolution of the feature map. For example, if the fused feature resolution is half that of the original image, two levels of 2x upsampling or one level of 4x upsampling are required. After each upsampling step, a convolutional layer (e.g., with a kernel size of 3x3) is typically used to refine the upsampled features. Finally, a convolutional layer with a 1x1 kernel converts the number of channels in the feature map to the desired number of output channels. For a binary classification task (crack / non-crack), the number of output channels is 1. Finally, a sigmoid activation function maps the output value of each pixel to between 0 and 1, generating a pixel-level crack probability map. Each pixel value in the crack probability map represents the probability that the pixel belongs to a crack; the higher the probability value, the greater the likelihood of belonging to a crack. To obtain the final binarized crack segmentation result image, the probability map is binarized by setting a preset threshold (e.g., 0.5): pixels with values greater than or equal to the threshold are judged as cracks (set to 1), otherwise they are background (set to 0).
[0051] Furthermore, to further enhance the model's ability to detect subtle cracks and improve the convergence speed of the training process, this invention introduces auxiliary loss functions into multiple intermediate layers of the dual-channel feature extraction network, which, together with the loss function of the final output layer, constitute a deep supervision strategy. For example, after the intermediate layers of the first and second channels (e.g., output layers with 128 or 256 channels), a 1x1 convolutional layer and an upsampling layer can be added respectively to make their output resolution the same as the final output layer, and auxiliary losses can be calculated. The loss function can be either the binary cross-entropy loss function or the Dice loss function. The binary cross-entropy loss function measures the pixel-level difference between the predicted probability and the true label, while the Dice loss function measures the degree of overlap between the predicted segmentation result and the true segmentation result, and has better robustness to class imbalance problems (crack pixels are usually much smaller than background pixels). During training, the total loss function is a weighted sum of the loss function of the final output layer and each auxiliary loss function, used to balance the contributions of different loss terms.
[0052] Example 2 This embodiment aims to verify the effectiveness, accuracy, and robustness of the dam crack detection method based on the dual-channel multi-scale attention mechanism of the present invention.
[0053] 1. Experimental Dataset This embodiment uses a large-scale dam surface crack image dataset (DCD - Dam CrackDataset), which contains 1200 high-resolution images collected from the surfaces of multiple dams in Southwest China. These images have a resolution of 2048x1024 pixels and cover various dam materials, different lighting conditions (sunny, cloudy, evening), and various environmental disturbances (such as water stains, moss, dust, surface textures, construction joints, etc.). Each image was manually annotated with pixel-level crack regions by professionals, generating corresponding binary mask images as ground truth labels. The dataset was divided into a training set (960 images), a validation set (120 images), and a test set (120 images) in an 8:1:1 ratio. To enhance the model's generalization ability, the training set images underwent various data augmentation operations before training, including random horizontal flipping, random vertical flipping, random rotation (±10 degrees), random brightness adjustment (±0.1), random contrast adjustment (±0.1), and Gaussian blur.
[0054] 2. Experimental Environment All experiments were conducted on a workstation equipped with an NVIDIA A100 GPU (40GB VRAM), an Intel Xeon Platinum 8380 CPU (2.3GHz, 64 cores), and 256GB of RAM. The software environment consisted of Ubuntu 20.04 operating system, Python 3.8, PyTorch 1.10.1 deep learning framework, CUDA 11.3, and cuDNN 8.2.
[0055] 3. Network Configuration and Training Parameters The core network configuration of the method of this invention is as follows: First channel (Global semantics and background noise suppression channel): Input: The original image is subjected to two 2x2 max pooling operations, reducing the resolution to 1 / 4 of the original image (e.g., 512x256 pixels).
[0056] Number of convolutional blocks: 4 groups.
[0057] The number of channels is 32, 64, 128, and 256, respectively. Each convolutional block contains a 3x3 convolutional layer (stride 1, padding 1), a batch normalization layer, and a ReLU activation function.
[0058] Global context-aware attention module: Deployed after the output of the third convolutional block. The shared MLP has a channel reduction ratio of 16. The spatial attention convolutional kernel size is 7x7.
[0059] Second channel (local details and crack enhancement channel): Input: The original image is subjected to a 2x2 max pooling operation, reducing the resolution to half of the original image (e.g., 1024x512 pixels).
[0060] Number of deformable convolutional blocks: 4 groups.
[0061] The number of channels is 64, 128, 256, and 512, respectively. Each deformable convolutional block contains a 3x3 deformable convolutional layer (learning the offset through additional convolutional layers), a batch normalization layer, and a ReLU activation function.
[0062] Local Feature Adaptive Enhancement Module: Deployed after the output of the third deformable convolutional block. The multi-scale convolutional filter bank contains 1x1, 3x3 (padding 1), and 5x5 (padding 2) convolutional kernels. In the hybrid attention unit, the channel attention MLP has a channel reduction ratio of 16, and the spatial attention convolutional kernel size is 7x7.
[0063] Gated attention modulation unit: The first channel output is upsampled by 4 times, and the second channel output is upsampled by 2 times, so that their resolution is 1024x512 pixels. The modulation network uses a 1x1 convolution followed by a sigmoid function.
[0064] The adaptive multi-scale feature fusion unit, after concatenating the channel dimensions, contains four parallel dilated convolutional branches, each with a kernel size of 3x3 and dilation rates of 1, 2, 4, and 8, respectively. In the hierarchical attention aggregation mechanism, the channel attention MLP has a channel reduction rate of 16, and the spatial attention convolutional kernel size is 7x7.
[0065] Slit segmentation and output: The fused high-level feature representation is gradually restored to the original resolution (2048x1024 pixels) through two transposed convolutional layers (kernel size 2, stride 2) and a convolutional layer. The final output layer is a 1x1 convolution followed by a Sigmoid activation function.
[0066] Deep supervision: Auxiliary losses are introduced after the output of the second convolutional block in the first channel (upsampled to 1 / 2 resolution), after the output of the second deformable convolutional block in the second channel (maintaining 1 / 2 resolution), and before the final fused feature output.
[0067] Loss Function: The total loss function is the weighted sum of the loss function of the final output layer and the three auxiliary loss functions. The final loss is a combination of the BCE loss and the Dice loss (weighted at a ratio of 0.5:0.5), while all auxiliary losses are BCE losses. The weights of the auxiliary losses are 0.4, 0.3, and 0.2, respectively.
[0068] Optimizer: AdamW optimizer, with an initial learning rate of 1e-4.
[0069] Learning rate scheduling: A polynomial learning rate decay strategy is adopted, with a power of 0.9.
[0070] Batch size: 8 images.
[0071] Training cycles: 300 epochs.
[0072] 4. Evaluation Indicators The following standard indicators are used in this embodiment to evaluate the model performance: IoU (Intersection over Union): The intersection-over-union ratio measures the degree of overlap between the predicted segmented region and the actual region.
[0073] F1-Score: The harmonic mean of precision and recall, which comprehensively evaluates the accuracy and completeness of the model.
[0074] Precision: The proportion of predicted cracks that are actually cracks.
[0075] Recall: The proportion of true cracks that are correctly predicted as cracks.
[0076] Average inference time: The average time (milliseconds) required for the model to process a single image, measuring computational efficiency.
[0077] 5. Experimental Results On the DCD test set, the embodiments of this invention achieved significant crack detection performance. After 300 epochs of training, the model achieved optimal performance on the validation set. The average performance metrics on the test set are as follows: IoU: 88.7% F1-Score: 90.2% Precision: 91.5% Recall: 89.0% Average inference time: 165 ms / image This invention provides a dam crack detection method based on a dual-channel multi-scale attention mechanism. Through refined feature extraction, adaptive cross-channel information fusion and guidance, and an efficient end-to-end learning strategy, it improves the accuracy, robustness, and computational efficiency of dam crack detection. This invention fully considers the complexity of dam surface images, including diverse textures, uneven illumination, environmental noise, and the subtlety and irregularity of the cracks themselves.
Claims
1. A dam crack detection method based on a dual-channel multi-scale attention mechanism, characterized in that: Acquire high-resolution digital image data of the surface of the dam to be inspected, and perform preprocessing operations on the digital image data to obtain preprocessed digital image data; A dual-channel feature extraction network is constructed and run. The dual-channel feature extraction network includes a first channel and a second channel. The first channel is used to receive the preprocessed digital image data after downsampling, and the second channel is used to receive the preprocessed digital image data that has not been downsampled or has been slightly downsampled. The first channel outputs global semantic and background noise suppression features, and the second channel outputs local details and crack enhancement features. Perform cross-channel information fusion and guidance, which includes: A gated attention modulation unit is constructed. The gated attention modulation unit upsamples the global semantic and background noise suppression features output from the first channel to the same size as the local details and crack enhancement features output from the second channel. Then, a gated modulation map is generated through a modulation network composed of convolutional layers and a sigmoid activation function. The gated modulation map is multiplied element-wise with the local details and crack enhancement features to guide and modulate the local details and crack enhancement features using the global semantic and background noise suppression features. An adaptive multi-scale feature fusion unit is constructed. The adaptive multi-scale feature fusion unit receives the local detail and crack enhancement features modulated by the gated attention modulation unit, as well as the global semantic and background noise suppression features upsampled by the first channel, and fuses the features to output the fused high-level feature representation. Crack segmentation and output are performed. The crack segmentation and output generate a pixel-level crack probability map based on the fused high-level feature representation, and obtain the crack segmentation result map by binarization through a preset threshold.
2. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 1, characterized in that: The digital image data is converted into a grayscale image, adaptive histogram equalization is performed, and a nonlocal mean filtering algorithm is applied for initial denoising.
3. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 1, characterized in that: The first channel is composed of a deep convolutional neural network, which contains multiple sets of concatenated convolutional blocks. Each convolutional block consists of a convolutional layer, a batch normalization layer, and an activation function layer.
4. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 1, characterized in that: The first channel further includes a global context-aware attention module. The global context-aware attention module receives the feature map output by the intermediate layer of the first channel and generates a channel descriptor through average pooling and max pooling operations. The channel descriptor is input to a shared multilayer perceptron to generate channel attention weights and generates spatial attention weights through convolution operations. The channel attention weights and spatial attention weights are multiplied and then normalized by the Sigmoid function to generate a gated attention map. The gated attention map is then multiplied element-wise with the feature map of the first channel.
5. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 1, characterized in that, The second channel is composed of a deep convolutional neural network, which contains multiple sets of cascaded deformable convolutional blocks. Each deformable convolutional block consists of a deformable convolutional layer, a batch normalization layer, and an activation function layer.
6. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 5, characterized in that, The deformable convolutional layer employs a 3x3 deformable convolutional kernel that can dynamically adjust the shape of the receptive field based on the learned offset on the feature map.
7. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 6, characterized in that, The second channel also includes a local feature adaptive enhancement module. The local feature adaptive enhancement module receives the feature map output by the intermediate layer of the second channel and processes the feature map in parallel through a multi-scale convolutional filter bank composed of multiple scale branches. Each branch in the multi-scale convolutional filter bank uses a convolutional kernel of different size to capture local information at different scales and concatenates the multi-scale convolution results. The concatenated feature map then passes through a hybrid attention unit composed of channel attention mechanism and spatial attention mechanism.
8. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 1, characterized in that, In the adaptive multi-scale feature fusion unit, the modulated local details and crack enhancement features, as well as the upsampled global semantics and background noise suppression features, are concatenated along the channel dimension. The concatenated feature map is input into a fusion network composed of multiple parallel branches. Each branch contains a convolutional layer and a dilated convolutional layer. The dilation rates of each branch are 2, 4, and 8, respectively. The output features of the parallel branches are concatenated and fused through a hierarchical attention aggregation mechanism and a hybrid mechanism of channel attention and spatial attention.
9. The dam crack detection method based on a dual-channel multi-scale attention mechanism according to claim 1, characterized in that, In the crack segmentation and output, the fused high-level feature representation is gradually restored to the same spatial resolution as the original input image through a series of upsampling layers and convolutional layers. The convolutional layers use 1x1 convolutional kernels, and finally the output value of each pixel is mapped to between 0 and 1 through the Sigmoid activation function to generate the pixel-level crack probability map.
Citation Information
Patent Citations
Photovoltaic panel crack detection method based on dual-channel multi-scale attention mechanism
CN116402761A
External facade crack detection method and device based on multi-scale feature fusion, equipment and medium
CN120635015A
