Abstract
Underwater crack detection is critical for the structural health monitoring of concrete dams; however, complex turbid environments and limited computational resources on underwater robots pose significant challenges. This study proposes HAIS-SegFormer, a lightweight segmentation network utilizing a Mix Transformer backbone. We introduce a tandem Hybrid Attention mechanism—cascading Coordinate Attention (CoordAtt) and Convolutional Block Attention Modules (CBAM)—to preserve long-range topological connectivity and refine local edge details. Furthermore, a Feature Inhibition Module (FIM), modeled after biological lateral inhibition, is designed to actively suppress high-frequency background noise such as water plants. Experimental results on an underwater crack dataset demonstrate that HAIS-SegFormer achieves a favorable trade-off between segmentation accuracy (71.66% mIoU) and computational efficiency (73 FPS, 3.80 M parameters). The proposed framework provides a robust and resource-efficient solution for automated underwater inspections.
1. Introduction
With the rapid expansion of global hydraulic infrastructure, maintaining the structural integrity of large concrete facilities—such as dams, sea-crossing bridge piers, and underwater tunnels—has emerged as a critical priority in marine engineering [1,2,3]. During long-term service, these structures inevitably develop surface cracks due to sustained water pressure, chemical erosion, and geological activity. Cracks frequently serve as early indicators of structural degradation; if left unaddressed, minute surface fissures can rapidly propagate into penetrating damage, potentially leading to catastrophic failure.
Historically, underwater inspections have relied heavily on human divers. This approach is not only inefficient and cost-prohibitive but also entails significant occupational hazards. Furthermore, manual inspection results are highly susceptible to subjective interpretation and physiological fatigue, increasing the likelihood of missed defects. Consequently, deploying Autonomous Underwater Vehicles (AUVs) and Remotely Operated Vehicles (ROVs) for automated visual inspection has become the standard practice in modern structural health monitoring.
However, underwater crack detection presents unique optical and algorithmic challenges compared to terrestrial environments [4]. First, light absorption and scattering in water cause severe image degradation, including low contrast, color distortion, and uneven illumination. Second, suspended particles, biological fouling (e.g., algae), and lighting artifacts create complex mimicry noise that segmentation algorithms frequently misclassify as structural damage [5]. Finally, early-stage cracks are inherently subtle and possess complex topologies. During the downsampling process of standard deep learning networks, these high-frequency topological details are easily lost, resulting in fragmented or blurred segmentation masks [6].
Although deep learning has advanced computer vision significantly, deploying these models in underwater engineering requires navigating a strict trade-off between detection accuracy and computational efficiency [7]. This constraint is dictated by the hardware limitations of underwater mobile platforms. AUVs and ROVs possess restricted internal space and battery capacity, precluding the use of high-power desktop-class GPUs. Because onboard computing units must simultaneously manage navigation, control, and perception tasks, the computational budget remaining for visual algorithms is severely constrained. As a result, traditional semantic segmentation networks with massive parameter counts—such as DeepLabV3+ and PSPNet—struggle to achieve real-time inference on these edge devices [8].
To address this hardware constraint, some researchers have explored one-stage object detection algorithms like the YOLO [9] series. While YOLO achieves exceptional inference speeds, its bounding-box regression paradigm is fundamentally unsuitable for crack detection. Cracks are characteristically slender, meandering, and irregular; a rectangular bounding box often encapsulates more than 80% invalid background pixels. More importantly, structural safety assessments require precise quantification of geometric parameters (e.g., width, length, and orientation), which object detection cannot provide. Therefore, generating fine, pixel-level binarized masks through semantic segmentation remains a strict prerequisite for quantitative structural analysis [10].
To overcome the limitations of CNNs in capturing global context information, Vision Transformer (ViT) and its variants have been introduced into segmentation tasks. Although Transformers surpass CNNs in performance by virtue of the Self-Attention mechanism, the computational complexity of standard ViT is quadratically related to the image resolution () [11], resulting in excessive video memory usage when processing high-resolution crack images. SegFormer successfully reduced the complexity to linear by introducing a hierarchical Mix Transformer (MiT) encoder and an efficient self-attention mechanism, achieving a breakthrough in lightweighting [12]. However, the decoder head design of the original SegFormer is relatively simple (only MLP aggregation) and lacks feature enhancement mechanisms for fine-grained targets. When facing complex background interference underwater, it is often difficult to effectively inhibit noise, leading to the disconnection of subtle cracks.
To solve the above challenges, this paper proposes a lightweight underwater crack segmentation network that balances accuracy and efficiency—HAIS-SegFormer (Hybrid Attention and Inhibition SegFormer). We utilize SegFormer-B0 as the backbone and design a new decoding strategy specifically for underwater scenarios.
The main contributions of this paper are summarized as follows:
- We propose a Hybrid Attention mechanism: Aiming at the characteristics of cracks being slender and prone to breakage, we innovatively cascade Coordinate Attention (CoordAtt) and the Convolutional Block Attention Module (CBAM). CoordAtt is responsible for capturing the long-range positional dependence of cracks in horizontal and vertical directions, while CBAM focuses on the refinement of local texture features. The combination of the two achieves feature enhancement of “global positioning first, then local sharpening”, significantly improving the connectivity of cracks.
- We design a Feature Inhibition Module (FIM): Inspired by the lateral inhibition mechanism of biological vision, we designed a lightweight gating module. This module can adaptively learn the feature distribution of background noise and perform weighted inhibition on high-frequency interference areas such as water plants and light spots, thereby significantly reducing the false detection rate in complex underwater environments.
- We achieve a favorable accuracy-efficiency trade-off: Experimental results show that HAIS-SegFormer achieved 71.66% mIoU and 82.84% mPA on the underwater crack dataset. Compared with other lightweight segmentation networks, this method provides robust pixel-level segmentation accuracy while maintaining real-time inference speed (73 FPS), making it highly suitable for deployment on resource-constrained underwater robot platforms.
Furthermore, a critical research gap remains in the current literature: existing lightweight models lack specific mechanisms to handle underwater mimicry noise, often leading to severe false positive rates. To address this, we conceptually shift the design paradigm. Unlike conventional enhanced variants that exclusively focus on positive feature amplification (e.g., adding attention modules to highlight cracks), HAIS-SegFormer introduces a dual-logic approach. Our primary novelty lies in the Feature Inhibition Module (FIM), which applies active negative-feature suppression to penalize mimicry noise—a fundamental architectural shift tailored for complex underwater structural health monitoring.
2. Related Work
2.1. Traditional Crack Detection Methods
Prior to the widespread adoption of deep learning, crack detection relied primarily on traditional digital image processing techniques. These methods generally assume that crack pixels exhibit lower intensity values than the background or that crack boundaries display pronounced gradient variations. Thresholding serves as a foundational technique; for example, the Otsu algorithm [13] automatically determines an optimal binarization threshold by maximizing inter-class variance. However, concrete dam surfaces frequently present interference from water stains and biological growth. Under complex underwater lighting conditions, global thresholding methods struggle to adapt, often resulting in fragmented segmentations or substantial noise. Other classical approaches include Contrast Limited Adaptive Histogram Equalization (CLAHE) for global contrast enhancement and Wavelet-transform-based multi-scale spatial filtering. While these non-AI spatial and morphological methods are computationally efficient and do not require extensive annotated datasets, they rely heavily on hard-coded heuristics and rigid prior knowledge. Consequently, their performance degrades severely in underwater environments, where uneven illumination and mimicry noise dynamically alter local image contrast.
Similarly, edge detection operators (e.g., Sobel and Canny) extract structural boundaries by calculating image gradients [14]. Yet, these operators cannot reliably distinguish genuine cracks from pseudo-edges—such as formwork joints or surface scratches—and remain highly sensitive to salt-and-pepper noise induced by suspended particles. To mitigate these limitations, filtering and morphological methods were introduced. For instance, Gabor filters [15] have been utilized to extract multi-directional texture features, often followed by morphological closing operations to bridge disconnected crack segments. Although effective on constrained datasets, these approaches depend heavily on hand-crafted features, resulting in poor generalization and limited robustness when deployed in complex, dynamically changing underwater scenes [16].
2.2. Deep Learning-Based Crack Segmentation Methods
In the initial application of deep learning to structural health monitoring, Convolutional Neural Networks (CNNs) emerged as the dominant paradigm. Early research primarily utilized architectures such as FCN, SegNet, U-Net, and their variants to achieve end-to-end, pixel-level classification of structural cracks. Fully Convolutional Networks (FCNs) [17] pioneered semantic segmentation by replacing fully connected layers with convolutions and employing deconvolution to recover spatial resolution. However, FCNs exhibit limited capacity for fine detail recovery. To address this, SegNet [18] introduced a symmetric encoder–decoder structure that utilizes max-pooling indices from the encoding stage during upsampling, thereby improving edge localization. U-Net [19] further advanced the field by introducing skip connections, which concatenate shallow, high-resolution features from the encoder with deep, semantic features from the decoder. This design effectively preserves spatial details, establishing U-Net as a benchmark model for crack segmentation.
Subsequently, to accommodate highly variable crack morphologies, researchers leveraged the DeepLab series. For instance, Fu et al. [20] proposed an enhanced algorithm based on DeepLabV3+, utilizing Atrous Spatial Pyramid Pooling (ASPP) to expand the receptive field. In pursuit of computational efficiency, Zim et al. [21] introduced EfficientCrackNet, a lightweight model designed to balance segmentation accuracy with reduced computational overhead. Despite these successes, standard CNN architectures possess inherent limitations. The local inductive bias of convolution kernels restricts their ability to model long-range contextual dependencies. When detecting slender, large-span cracks on underwater dams or bridge piers, CNNs frequently fail to perceive the overarching topological structure, resulting in fragmented or discontinuous segmentation masks. Furthermore, to achieve a sufficiently large receptive field, high-accuracy CNNs (e.g., DeepLabV3+ with a ResNet-101 backbone) require massive parameter counts. This computational burden renders them unsuitable for deployment in resource-constrained edge computing environments, such as underwater ROVs.
2.3. Transformer-Based Segmentation Networks
To overcome the global modeling deficiencies of CNNs, the Vision Transformer (ViT) and its variants have been adapted for crack segmentation [22,23]. Transformers leverage self-attention mechanisms to capture dependencies between arbitrary pixel pairs, significantly enhancing the network’s capacity to identify complex structures and highly irregular cracks. For example, the Swin Transformer [24] reduces computational costs while maintaining a broad receptive field via a shifted-window attention mechanism. Building on this, Cao et al. [25] integrated Swin Transformer blocks into a U-Net architecture to develop ST-UNet. Despite the robust representational power of Transformers, the computational complexity of standard self-attention scales quadratically with image resolution (). This results in prohibitive memory consumption and slow inference speeds when processing high-resolution images. To alleviate this bottleneck, Xie et al. [12] proposed SegFormer. By eliminating complex positional encodings, SegFormer employs a hierarchical Mix Transformer (MiT) encoder coupled with a lightweight All-MLP decoder. This design significantly accelerates inference speed while preserving the global modeling advantages inherent to Transformers.
However, the original SegFormer decoder is relatively simplistic and lacks targeted feature enhancement mechanisms for subtle targets. In extreme underwater envir2ments characterized by high turbidity and low contrast, relying solely on linear MLP layers for feature aggregation frequently leads to the missed detection of micro-cracks. Consequently, this study adopts SegFormer as the foundational backbone and strategically re-engineers its decoding architecture to address these specific environmental challenges.
2.4. Attention Mechanisms and Feature Inhibition
Attention mechanisms simulate human visual cognition, enabling neural networks to selectively focus on salient regions while suppressing irrelevant background noise [26]. Standard channel attention mechanisms (e.g., the SE module) successfully recalibrate feature responses but inherently discard critical spatial positional information. To resolve this, Hou et al. [27] proposed Coordinate Attention (CA), which embeds precise coordinate information into channel attention maps, thereby capturing long-range spatial dependencies. Recently, Zhang et al. [28] introduced CA-SegFormer, which further refines the CA module through diagonal pooling to better capture irregular crack morphologies.
While individual attention modules (such as CA or CBAM) have proven effective, underwater crack detection requires simultaneously resolving both macroscopic localization and microscopic edge refinement. To complement attention-based enhancement, we introduce a Feature Inhibition Module (FIM). Inspired by the lateral inhibition phenomenon in biological nervous systems, feature inhibition serves as an active mechanism to suppress irrelevant or distracting signals. Similar gating mechanisms have been successfully applied in medical image analysis to filter background noise and heterogeneous tissue interference; for instance, Xie et al. [29] proposed the SMOFFI module for ovarian tumor segmentation. Furthermore, integrating principles from biological vision helps mitigate the “black box” nature of deep neural networks, improving the interpretability and rationale of the feature extraction process [30]. Applying analogous inhibitory principles to underwater crack detection can effectively suppress the high-frequency texture noise generated by aquatic plants and suspended matter.
Existing frameworks rarely concatenate distinct types of attention mechanisms to leverage their complementary strengths. Moreover, conventional attention modules lack the active inhibition mechanisms required to combat the specific high-frequency mimicry noise endemic to underwater environments. To address these deficiencies, this paper proposes a tandem Hybrid Attention strategy—synergizing the long-range positioning capabilities of CA with the local texture refinement of CBAM—and introduces a dedicated Feature Inhibition Module (FIM) to formulate a robust, highly accurate underwater crack segmentation framework.
3. Methodology
This chapter details the network architecture of HAIS-SegFormer. The system consists of a SegFormer-B0 encoder, a Hybrid Attention module, a Feature Inhibition Module, and a final prediction head.
3.1. Overall Architecture
To address the three core challenges in detecting cracks on underwater concrete dam surfaces—“feature blurring caused by high turbidity”, “mimicry noise interference from water plants and suspended matter”, and “limited edge-side computing power of underwater robots (ROVs)”—this paper proposes a lightweight and highly robust semantic segmentation network: HAIS-SegFormer.
As shown in Figure 1, the system does not adopt the traditional “heavy backbone + simple decoder” pattern, but instead follows an architectural philosophy of “lightweight encoding + cascaded refined decoding + active noise inhibition.” The overall data flow consists of four continuous and progressive processing phases:
Figure 1.
The overall architecture of the proposed HAIS-SegFormer network. Note: The arrow indicates the transfer and fusion of features between layers.
- Feature Extraction Phase: Undertaken by the Mix Transformer (MiT-B0), leveraging the global modeling capability of Transformers to overcome the limited receptive field of CNNs. It is responsible for extracting multi-scale feature representations with global receptive fields from raw underwater images.
- Global Positioning Phase: Features flow through the Coordinate Attention (CoordAtt) module. Aiming to solve the problem that underwater cracks are “slender and prone to breakage”, it locks onto the topological skeleton of the crack by capturing long-range spatial dependencies.
- Local Refinement Phase: Features enter the Convolutional Block Attention Module (CBAM). Utilizing dual weighting of channel and space, this phase sharpens blurred crack edges to solve the “unclear boundary” problem.
- Noise Inhibition Phase: Finally, the Feature Inhibition Module (FIM) is employed. Using an adaptive gating mechanism, it actively filters out high-frequency texture noise such as water plants, solving the “false positive misdetection” problem.
These four modules are not simply stacked; rather, they form a complete feature processing chain ranging from “macro extraction” to “global positioning”, then to “micro refinement”, and finally “eliminating the false and preserving the true.”
3.2. Backbone: Mix Transformer-B0
To achieve real-time crack detection under the limited computing resources of underwater robots (ROVs) without sacrificing the ability to capture multi-scale features, this study selects the most lightweight variant of the SegFormer architecture, MiT-B0 (Mix Transformer-B0), as the feature extraction backbone. Unlike traditional Vision Transformers (ViT), MiT-B0 adopts a hierarchical structure design and introduces key features optimized for semantic segmentation while maintaining an extremely low parameter count (only 3.7 M). The specific architecture is shown in Figure 2.
Figure 2.
Architecture of the SegFormer-B0 (MiT-B0) encoder.
3.2.1. Hierarchical Feature Representation
Traditional ViTs typically generate feature maps of a single resolution (usually 1/16), which is extremely disadvantageous for positioning subtle dam cracks. MiT-B0 adopts a pyramid structure similar to CNNs, containing four stages, which generate feature maps with different resolutions respectively.
For an input image with a resolution of , the outputs of each stage are defined by the default hyperparameter configurations of the original MiT-B0 architecture [12] as follows:
- Stage 1: Resolution , Channel count = 32.
- Stage 2: Resolution , Channel count = 64.
- Stage 3: Resolution , Channel count = 160.
- Stage 4: Resolution , Channel count = 256.
This multi-scale design enables the network to capture high-resolution crack texture details in shallow layers and low-resolution global context information in deep layers, providing a rich foundation for subsequent decoder feature fusion. (A quantitative justification for selecting the B0 variant over heavier models like B1 is detailed in Section 4.8, demonstrating its optimal accuracy-efficiency trade-off for ROV deployment).
3.2.2. Overlap Patch Merging
ViT divides the image into non-overlapping patches, which leads to the loss of local continuity at patch boundaries. For crack targets with strong connectivity, this severance is fatal. MiT-B0 introduces an Overlap Patch Merging mechanism.
Essentially, this is a 2D convolution operation (Conv2d) where the stride () is smaller than the kernel size (). Assuming the input feature is , the output is calculated as follows:
where denotes the zero-padding size along the spatial boundaries. In MiT-B0, the specific spatial parameters for each stage are set as:
In MiT-B0, the specific parameters for each stage are set as:
- Stage 1: , ,
- Stage 2–4: , ,
This overlapping design (e.g., , ) ensures pixel overlap between adjacent patches, thereby preserving the spatial smooth transition and local continuity of cracks.
3.2.3. Efficient Self-Attention
The computational complexity of standard Multi-head Self-Attention is , where . To reduce computational load while maintaining the global receptive field, MiT-B0 introduces a Sequence Reduction strategy.
ESA reduces the spatial dimensions of Key () and Value () by a reduction ratio (), while keeping the Query () unchanged. The specific process is as follows:
where represents the original spatial sequence length, is the channel dimension, and is the reduction ratio. The () operation flattens the spatial dimensions, and () denotes a linear projection layer utilized to restore the channel dimension. represent the Query, Key, and Value matrices, respectively, and is the dimension of each attention head. In the B0 version, the reduction ratios for the four stages are set to [64, 16, 4, 1] respectively. This improvement reduces the complexity from to , allowing the model to process high-resolution crack images smoothly.
3.2.4. Mix-FFN
Traditional Transformers rely on Positional Encoding (PE), requiring the inference resolution to be consistent with the training resolution, which limits flexibility. MiT-B0 removes PE and adopts Mix-FFN instead. It inserts a 3×3 Depth-wise Convolution () into the feed-forward network to implicitly encode positional information:
where and are the input and output feature maps, respectively. () represents a Multi-Layer Perceptron comprising two fully connected layers, and () denotes the Gaussian Error Linear Unit activation function. Leveraging the zero-padding property of the convolution operation, positional information is implicitly leaked and encoded into the features.
3.3. Global Positioning with CoordAtt
3.3.1. Design Motivation: Solving the “Crack Fracture” Problem
In turbid water bodies, uneven lighting often causes long cracks to appear visually as fractured segments. If their topological connectivity cannot be recovered in the early stages of decoding, subsequent refinement will be meaningless. Traditional channel attention (such as SE Blocks) [31] compresses spatial features into a single scalar 1 × 1 through Global Average Pooling (GAP). While this process preserves channel importance, it completely discards the positional information of the crack. The network knows “there is a crack”, but does not know “where” the crack is or “how it runs.” Therefore, we introduced Coordinate Attention (CoordAtt) at the entrance of the decoder. It decomposes 2D global pooling into two 1D feature encodings along orthogonal directions, acting as a “global compass” for the system. The specific architecture is shown in Figure 3.
Figure 3.
Diagram of the Coordinate Attention Module. Note: The module decomposes channel attention into two parallel 1D feature encoding processes using X-AvgPool and Y-AvgPool. These features are concatenated and processed to capture long-range dependencies along one spatial direction while preserving precise positional information along the other. In this diagram, solid arrows indicate the main feature processing flow, while dashed arrows represent the direct routing of the original input tensor. The special symbol “⊗” denotes element-wise multiplication, and different colors are utilized to visually distinguish distinct feature tensors at various processing stages.
3.3.2. Mathematical Formulation of CoordAtt
CoordAtt does not directly compress all spatial information but aggregates features along the horizontal direction (X-axis) and vertical direction (Y-axis) respectively.
- Step 1: Coordinate Information Embedding
Given the input feature tensor , for the -th channel with spatial dimensions , its output along the vertical direction (height ) is computed by 1D global average pooling:
Similarly, for the -th channel with width , its output is:
where denotes the feature value at the corresponding spatial coordinates within the -th channel. This step generates a pair of direction-aware feature maps , capturing long-range dependencies of the crack in vertical and horizontal directions, respectively.
- Step 2: Coordinate Attention Generation
To utilize the above information, we concatenate the two feature maps spatially (denoted by the operation) and feed them into a shared 1 × 1 convolution transformation function for channel dimensionality reduction (reduction ratio ) and non-linear activation :
where is the intermediate feature map, and represents the non-linear activation function (typically Swish). Subsequently, we split along the spatial dimension into and , which then pass through convolutional transformations , and the Sigmoid activation function , generating attention weights and :
- Step 3: Feature Re-weighting
The final output is obtained by multiplying the original input feature with the generated coordinate weights:
where the multiplication () is performed element-wise.
3.3.3. Performance Analysis
Through this orthogonal decomposition strategy, CoordAtt enables the network to perceive that “there is a strong crack feature response in a certain interval on the X-axis and a certain interval on the Y-axis.” When the responses of these two intervals intersect spatially, the precise location of the crack is locked. Experiments demonstrate that this effectively reconnects broken crack segments at the feature level, significantly improving the connectivity metrics in mIoU.
3.4. Local Refinement with CBAM
3.4.1. Design Motivation: Solving the “Blurred Edge” Problem
After processing by CoordAtt, the “skeleton” of the crack has been located. However, under the influence of the scattering effect of the water body, crack edges are often accompanied by a Halo Effect, causing boundary pixels to be blurred and unclear. Mere positioning cannot solve the pixel-level classification problem of edges.
Furthermore, although the Transformer encoder of SegFormer excels at capturing global context, it is less sensitive than CNNs in extracting local texture details. Therefore, we cascaded the Convolutional Block Attention Module (CBAM) [32] after CoordAtt. If CoordAtt is a telescope, then CBAM acts as a microscope. We adopt a “Channel-first, Spatial-second” tandem strategy to progressively refine feature responses. The specific architecture is shown in Figure 4.
Figure 4.
Diagram of the Convolutional Block Attention Module (CBAM). Note: The module consists of two sequential sub-modules: the Channel Attention Module (Part A), which utilizes Global AvgPool and MaxPool to refine channel features, and the Spatial Attention Module (Part B), which focuses on informative spatial regions. In this diagram, solid arrows indicate the main feature processing flow. The special symbol “⊗” denotes element-wise multiplication, and “⊕” denotes element-wise addition. Different colors are utilized to visually distinguish between distinct feature tensors and operational blocks at various processing stages.
3.4.2. Channel Attention Module
When processing crack images, crack features often exist only in specific feature channels, while other channels may be filled with water body background noise. The role of CAM is feature selection, answering the question of “What to focus on”.
Traditional CAM uses only Global Average Pooling (AvgPool). However, this is not ideal for underwater crack detection. Cracks are typical High-frequency Features, while the water background corresponds to low-frequency features. Average pooling tends to smooth out the saliency of cracks. Therefore, we introduce Global Max Pooling (GMP) to work in parallel with average pooling.
The mathematical expression is as follows. Let the input feature be .
- Feature Aggregation: Generate the average pooling descriptor and the max pooling descriptor respectively. MaxPool is more sensitive to texture features, helping to preserve high-frequency edge information of cracks, while AvgPool provides smooth background information.
- 2.
- Weight Sharing Perception: Both descriptors are fed into a Shared MLP (Multi-Layer Perceptron), which contains a hidden layer with a compression ratio (set to in experiments).
- 3.
- Fusion and Activation: The output features are summed element-wise and then passed through a Sigmoid activation function to generate channel weights . The final output feature is obtained by multiplying the original feature with the weight element-wise ().
can keenly capture the strong response of crack pixels, preventing them from being “averaged” out by the background, while provides statistical information about the background. The combination of the two enables the network to more robustly select key channels containing crack information.
3.4.3. Spatial Attention Module (SAM)
After channel selection, the feature map enters SAM. The role of SAM is position focusing, answering the question of “Where to focus”. Unlike CoordAtt which focuses on long-range dependencies, SAM utilizes a large convolution kernel to focus on local neighborhood contrast, which is crucial for sharpening crack edges.
- Channel Compression: We perform aggregation along the channel dimension, applying average pooling and max pooling respectively to generate two 2D feature maps: and .
- Spatial Convolution: These two feature maps are concatenated (Concat) and processed by a 7 × 7 convolution layer. 7 × 7 is chosen over 3 × 3 to obtain a larger local receptive field, covering the crack and its surrounding background area to better calculate local contrast.
- Attention Generation:
3.5. Feature Inhibition Module (FIM)
3.5.1. Design Motivation: Combating “Mimicry Noise” and Bio-Inspired Vision
This is the most innovative design of HAIS-SegFormer. The surface of underwater dams not only has cracks but is also often attached with strip-like water plants and dark algae bands, or has shadow stripes caused by uneven lighting. These interferences are extremely similar to real cracks in morphology (slender, curved) and grayscale (dark), constituting Hard Negative Samples.
Existing attention mechanisms are essentially Feature Enhancers. They generate weights via the Sigmoid function. If the feature response of a water plant area is inherently strong (because it looks like a crack), the attention mechanism often erroneously assigns it a high weight, leading to “False Positive” misdetection.
Rather than serving as a mere conceptual analogy, the biological Lateral Inhibition mechanism acts as the core modeling principle for the Feature Inhibition Module (FIM) [33]. Just as activated biological neurons suppress the excitation of neighboring neurons to enhance edge contrast, FIM algorithmically translates this by constructing a reverse gating mask to mathematically penalize the activation of high-frequency background features. The design philosophy of FIM is: instead of enhancing the target, it is better to actively suppress the noise. The specific architecture is shown in Figure 5.
Figure 5.
The architecture of the proposed Feature Inhibition Module (FIM). Note: In this diagram, solid arrows indicate the direction of the data and feature processing flow. The special symbol “⊗” denotes element-wise multiplication, which is utilized to apply the generated reverse gating mask to the features. Different colors are employed to visually distinguish between the distinct operational blocks and feature tensors within the dual-path structure.
3.5.2. Mathematical Derivation of the Reverse Gating Mask
FIM adopts a dual-path parallel structure, utilizing a lightweight Gating Network to learn “what looks like noise” and generating a reverse mask for filtering. Let the input feature be (i.e., the output refined by CBAM).
- Path 1: Noise Perception Gating: The goal of this branch is to fit the texture distribution of noise. First, Global Average Pooling (GAP) is used to obtain overall environmental information of the image (such as turbidity and light intensity), generating vector . Then, through 1 × 1 convolution and non-linear activation, the spatial structure of the original feature is preserved. Afterward, global information is fused with local features, noise patterns are learned through a 3 × 3 convolution layer, and finally, a Soft Noise Mask () is generated via Sigmoid activation.
In this definition:
: Indicates the pixel highly likely belongs to high-frequency noise (e.g., water plant texture).
: Indicates the pixel belongs to a flat background or a real crack.
- Path 2: Inhibition Operation: Unlike the direct multiplication in attention mechanisms, we construct a reverse inhibition weight .
Physical Meaning Analysis: When the network detects typical water plant texture in a certain area, the gating branch outputs a high response . Assuming = 1, the inhibition weight becomes 1 − 0.9 = 0.1. This is equivalent to multiplying the feature signal in that area by 0.1, greatly attenuating its backward propagation intensity, thereby making it “invisible” in the final prediction map. This is a Soft Gating mechanism; compared to hard threshold truncation, it preserves the differentiability of the gradient flow, which is more conducive to training, effectively eliminating false positive misdetections common in traditional models and significantly improving the Precision metric.
3.6. System Synergy and Gradient Flow
3.6.1. Cognitive Interpretation of Tandem Logic
HAIS-SegFormer adopts a specific tandem order of . This is not a random combination, but strictly follows the processing logic of human visual cognition: “Coarse to Fine, Positive to Negative”. The motivation for this specific cascade stems from the individual limitations of each attention module. Individually, CoordAtt excels at capturing long-range spatial dependencies to preserve the global topology of slender cracks; however, it lacks the ability to refine local pixel-level boundaries, often resulting in edge blurring. Conversely, while CBAM’s spatial attention excels at sharpening local textures, its relatively narrow receptive field struggles to perceive the overarching structural continuity, which can lead to disconnected crack segments if applied in isolation. Synergistically, they address each other’s deficiencies: CoordAtt first establishes a reliable global Region of Interest (ROI) to prevent topological breakage, effectively providing a solid structural skeleton. Building upon this, CBAM is then deployed to focus exclusively on sharpening the local boundaries within the ROI, ensuring clear edge delineation without losing the global structural trend.
- Global Positioning via CoordAtt: The task is to establish the topological structure of the crack in the initial stage where features are blurred. Logic: CoordAtt acts like a Radar, utilizing X/Y axis aggregation capabilities to lock onto the “general trend” and “skeletal connection” of the crack at a macro level, preventing crack breakage. At this point, edge details are not the focus, only connectivity is.
- Local Refinement via CBAM: The task is to refine boundaries based on the established skeleton. Logic: CBAM acts like a Magnifying Glass. Within the Region of Interest (ROI) determined by CoordAtt, it utilizes the local perception capability of 7 × 7 convolution to sharpen crack edges and distinguish crack pixels from adjacent water halo pixels.
- Noise Rejection via FIM: The task is to perform a final quality check before outputting the result. Logic: FIM acts like a Filter. After the enhancement in the first two steps, some water plants resembling cracks may also have been enhanced. FIM utilizes its learned texture priors to perform targeted inhibition on these “pseudo-cracks”, ensuring the purity of the final output.
As shown in Figure 6, although CBAM (Convolutional Block Attention Module) enhances edge sharpness, it inadvertently amplifies background noise (see column 3). In contrast, CoordAtt (Coordinate Attention) helps recover topological structure but lacks edge clarity. The proposed FIM (column 4) effectively combines these features, filtering out the noise introduced by CBAM while preserving structural integrity, thereby resulting in a clean and precise detection output.
Figure 6.
Visual comparison of feature maps processed by CoordAtt, CBAM, and the proposed FIM. Note: While CoordAtt recovers topology and CBAM sharpens edges, the proposed FIM effectively removes noise and preserves a clean crack structure.
3.6.2. Optimization of Gradient Flow
Deep stacking of modules can easily lead to Gradient Vanishing. To ensure that the SegFormer backbone can be effectively updated, we focused on the smoothness of gradient flow in the system design:
- Residual Connections: Each Transformer Block in SegFormer contains internal residual connections.
- Combination of Addition and Multiplication: In CBAM and CoordAtt, attention maps are multiplied onto the original features (), forming a gated gradient structure during backpropagation.
- Identity Mapping Property of FIM: The formula of FIM, , is essentially a residual structure. When , the gradient can be back-propagated to losslessly. This means the FIM does not obstruct gradient flow, ensuring the model is easy to train and converges quickly.
3.6.3. Analysis of Lightweight Characteristics
Despite introducing three additional modules, HAIS-SegFormer maintains its lightweight characteristics:
- CoordAtt: Only involves 1D pooling and 1 × 1 convolution; parameter count is minimal.
- CBAM: Although it contains 7 × 7 convolution, it is performed only on single-channel attention maps; the increase in FLOPs is negligible.
- FIM: Mainly composed of 1 × 1 convolutions.
- Overall Parameters: Compared to the original SegFormer-B0 (3.71 M), the total parameter count of HAIS-SegFormer increases by only about 0.1 M (reaching 3.80 M). The inference speed (FPS) on an RTX 3090 decreases only from 80.8 FPS to 73.3 FPS, still exceeding the real-time requirement of 30 FPS.
4. Experimental Section
4.1. Dataset Acquisition and Preprocessing
To validate the crack detection performance of HAIS-SegFormer in real-world underwater environments, this study did not use synthetic data but instead selected the public “Underwater Crack Detection” dataset provided by the open-source community Roboflow Universe [34]. This dataset is specifically collected for surface defects of underwater concrete structures, containing crack images under various lighting conditions, water turbidity levels, and background noise (such as water plants and sediments), which fits perfectly with the research goals of “anti-noise and subtle crack repair” in this paper.
4.1.1. Dataset Overview
We selected a total of 7435 high-resolution underwater crack images from the original dataset. All images are equipped with fine pixel-level or Bounding Box annotations, focusing mainly on a single category: crack.
To meet the training requirements of deep learning models and ensure the reproducibility of experiments, the dataset was randomly divided according to a ratio of 7:2:1:
- Training Set: Contains 5204 images (70%), used for iterative model weight updates.
- Validation Set: Contains 1487 images (20%), used for hyperparameter tuning and Early Stopping monitoring during training to prevent overfitting.
- Testing Set: Contains 744 images (10%), used only for the final model performance evaluation to ensure the objectivity of the metrics.
4.1.2. Data Preprocessing and Augmentation
Considering the specific degradation problems of underwater images (such as blue-green color cast and low contrast) and the input requirements of the SegFormer-B0 backbone, we implemented the following standardized preprocessing workflow:
- Resolution Standardization: Due to inconsistent specifications of the original acquisition equipment, all images were unified (Resized) to 768 × 768 pixels. The Bilinear Interpolation algorithm was used for scaling to reduce computational load while preserving crack texture details.
- Adaptive Augmentation: To improve the generalization capability (Robustness) of HAIS-SegFormer in complex underwater environments, we introduced an online data augmentation strategy during the training phase. In addition to basic Random Flip and Rotation, the following transformations were introduced specifically for underwater scenes:
- (1)
- Brightness and Contrast Adjustment: To simulate uneven underwater lighting and strong light spot interference.
- (2)
- Gaussian Noise Injection: To simulate the granularity caused by water turbidity, forcing the model to rely more on structural features rather than pure grayscale values, thereby validating the effectiveness of the proposed FIM (Feature Inhibition Module) in suppressing high-frequency noise.
- Format Conversion: Since the labels provided by the dataset were not in the required format, we used “SAM model” to convert the label format from YOLOv11 to standard COCO JSON format (for detection) and Mask PNG format (for segmentation). We also performed normalization, scaling pixel values to the corresponding interval to accelerate model convergence.
Through the above processing, we constructed a high-quality and challenging underwater crack benchmark library (UDC-Roboflow), providing a solid data foundation for subsequent verification of the effectiveness of the Hybrid Attention (HA) mechanism and Feature Inhibition Module (FIM). An overview of the relevant dataset is shown in Figure 7.
Figure 7.
Overview of the Underwater Crack Detection Computer Vision Dataset. (a) Annotated Dataset Samples (4 × 4 Grid); (b) Data Split Distribution.
4.2. Experimental Setup and Evaluation Metrics
The experiments were conducted on a dedicated deep learning workstation running the Windows 11 operating system. The hardware specifications included an Intel Core i9-10900X processor (3.70 GHz), 64 GB of system RAM, and an NVIDIA GeForce RTX 3090 Graphics Processing Unit (GPU) equipped with 24 GB of VRAM to ensure sufficient memory for high-resolution feature maps. The software environment was built on Python 3.8, utilizing the PyTorch 1.12.1 framework [35] and the CUDA 11.3 library for hardware acceleration.
As detailed in Section 4.1, the network was trained and evaluated on a diverse underwater crack dataset comprising 7435 high-resolution images, which inherently exhibit complex characteristics such as uneven illumination and varying turbidity. To mitigate the effects of underwater color distortion and improve model generalization, online data augmentation strategies—including random flipping, dynamic brightness/contrast adjustments, and Gaussian noise injection—were systematically applied during the training phase. All comparison models were trained, validated, and tested under these consistent hardware and data configurations to ensure a fair benchmark.
During the training process, to determine the optimal training cycle, we monitored the loss convergence and mIoU changes in the model, as shown in Figure 8. As seen from the figure, the model learned features rapidly in the first 10 Epochs, with significant mIoU improvement; the subsequent 50 Epochs entered a fine-tuning stage where performance grew steadily. After 80 Epochs, the Validation Set Loss tended to stabilize, and the mIoU metric entered a saturation zone without obvious overfitting. Therefore, to achieve the best balance between computational efficiency and model performance, we set the total training epochs to 100.
Figure 8.
Curves of the Loss function and mIoU during the training process. (a) The decreasing trend of the loss on both training and validation sets; (b) The increasing trend of mIoU.
The optimizer selected was AdamW [36], with an initial learning rate set to 1 × 10−4, and a Cosine Annealing strategy was adopted for learning rate decay. To prevent overfitting, we used ImageNet pretrained weights for initialization. Key training parameters are summarized in Table 1.
Table 1.
Experimental Parameter Configuration.
To comprehensively and objectively evaluate the model’s detection performance on underwater cracks, we selected multiple evaluation metrics: mIoU, mPA, Accuracy, F1-score, model Parameter count, and computational complexity (measured in FLOPs) [36,37,38,39]. These metrics allow for a comprehensive analysis of the model’s accuracy and efficiency. Specifically, mIoU, mPA, Accuracy, and F1-score mainly reflect detection precision, while Parameters and GFLOPs quantify computational overhead and deployment suitability.
The specific definitions of the metrics are as follows:
Parameters (M): The total number of trainable parameters in the model, measuring model complexity.
GFLOPs: Represents the computational amount required by the model to process a single image, measured in billions of floating-point operations.
- where TP is True Positive, TN is True Negative, FP is False Positive, FN is False Negative, and k is the number of categories (including the background class).
4.3. Ablation Studies
To evaluate the impact of individual modules in the HAIS-SegFormer improvements, comprehensive ablation experiments were conducted on the dataset under consistent hyperparameter settings. These experiments quantified the contribution of each module and evaluated their combined effects. Evaluation metrics included mIoU, mPA, Accuracy, F1-score, Parameters, and GFLOPs. The results are shown in Table 2.
Table 2.
Ablation Study Results. Note: Bold values indicate the best performance.
As shown in Table 2, although the baseline SegFormer-B0 model is extremely advantageous in terms of parameter count, its mIoU is only 70.53%. This is mainly because the Transformer backbone easily loses local high-frequency details of cracks during feature extraction and struggles to capture the global connectivity of slender cracks.
Using SegFormer-B0 as the benchmark, the three modules—CoordAtt, CBAM, and Feature Inhibition Module (FIM)—were introduced progressively. The design of each module aims to maximize feature extraction capability and segmentation accuracy while keeping computational efficiency within a controllable range.
CoordAtt increased mIoU from 70.53% to 70.92% with only a 0.02 M increase in parameters and unchanged GFLOPs (15.23), indicating its extremely high structural efficiency in capturing spatial location information. Although FIM introduced a small computational increment, it effectively increased mPA from 81.60% to 82.72%, confirming its ability to suppress irrelevant background noise and enhance specific category features. While the effect of the CBAM alone was not as prominent as the other two, it is the most lightweight module (adding only 0.01 M parameters) and provided more robust performance gains when combined with other modules.
The ablation results reveal distinct metric contributions from each module. CoordAtt primarily drives the mIoU improvement because its spatial dependency modeling successfully reconnects broken crack segments, thereby significantly reducing False Negatives. Conversely, the FIM contributes most directly to the mPA (Precision) improvement, as its reverse gating mechanism effectively suppresses background water plants and shadows, drastically reducing False Positives.
The final HAIS-SegFormer model integrates all modules, achieving 71.66% mIoU and 82.84% mPA using only 3.80 M parameters and 17.7 GFLOPs. These results demonstrate that carefully designed attention and inhibition mechanisms can significantly improve detection performance with minimal parameter growth, highlighting their strong potential in the actual deployment of underwater crack detection. As shown in Figure 9, the HAIS model accomplished the detection of tiny cracks better than other models.
Figure 9.
Qualitative comparison of ablation studies regarding different module combinations for underwater crack detection. Note: From left to right: original image, baseline model B0, addition of individual modules, pairwise combinations, and the detection results of the final HAIS model. The red boxes (or lines) are utilized to highlight specific fine crack regions for detailed visual comparison. As observed in these highlighted areas, the baseline model (B0) suffers from severe topological disconnection. The addition of CoordAtt reconnects the global structure, but introduces edge blurring. The final HAIS model successfully resolves both defects, demonstrating sharp, continuous boundaries even against complex underwater backgrounds.
4.4. Impact of Loss Functions and Input Resolution
To establish a strong baseline for underwater crack detection, we investigated the impact of different loss functions and input configurations on the SegFormer-B0 backbone.
We introduced Dice Loss to optimize the overlap of fine cracks. As shown in Figure 10, it is evident that the inclusion of Dice Loss makes crack detection finer. We also introduced Focal Loss to force the model to focus on hard-to-classify samples. Evaluation metrics included mIoU, mPA, Accuracy, and F1-score. The results are shown in Table 3.
Figure 10.
Visual comparison of segmentation results with and without Dice Loss. (a) Visualization of Segmentation Results without Dice Loss; (b) Visualization of Segmentation Results with Dice Loss.
Table 3.
Experimental Results of Loss Functions. Note: Bold values indicate the best performance.
The baseline model using standard loss achieved an mIoU of 69.70%. After adding Dice Loss, the mIoU significantly improved to 70.33%, indicating better boundary delineation. Further adding Focal Loss fine-tuned the performance to 70.53%. Therefore, we adopted the combination of in all subsequent experiments.
Meanwhile, input resolution significantly affects the detection accuracy of tiny cracks and computational costs. We evaluated model performance under different input sizes. Although higher resolution provides richer spatial details for detecting tiny cracks, it also causes a further drop in operation speed. Evaluation metrics included mIoU, mPA, Accuracy, F1-score, and FPS. The results are shown in Table 4.
Table 4.
Experimental Results under Different Resolutions. Note: Bold values indicate the best performance.
At 512 × 512 resolution, the running speed and mIoU values are excellent, but it is prone to missing subtle cracks (lower mPA). The 1024 × 1024 resolution is too large, causing a drastic drop in detection rate. Considering the trade-off between speed and accuracy for underwater robots, we selected 768 × 768 as the optimal setting. It achieves balanced performance at an acceptable inference speed.
Given the extreme quantity difference between crack pixels (foreground) and the concrete surface (background), assigning higher weight to positive samples is crucial for guiding model optimization. We conducted sensitivity experiments by setting the positive sample weight () to 3.0, 5.0, and 10.0, respectively. Evaluation metrics included mIoU, mPA, Accuracy, and F1-score. The results are shown in Table 5.
Table 5.
Experimental Results under Different Weight Ratios. Note: Bold values indicate the best performance.
When = 3.0, the model tends to be conservative, leading to missed detection of subtle cracks (lower mPA). When = 10.0, although the model captures more crack details, it also introduces excessive background noise, causing a decrease in Precision and overall mIoU. The optimal setting ( = 5.0) achieves the best balance between suppressing background noise and preserving crack integrity.
4.5. Comparison of Different Lightweight Attention Modules
To further justify the selection of the Coordinate Attention (CoordAtt) module, we conducted a comprehensive quantitative comparison with other advanced lightweight attention mechanisms, including SE [40], ECA [41], Triplet [42], and Shuffle Attention [43]. All modules were integrated into the SegFormer-B0 baseline under identical experimental settings. Evaluation metrics included mIoU, mPA, Accuracy, F1-score, Parameters, and GFLOPs. The results are shown in Table 6.
Table 6.
Comparison Results of Different Lightweight Attention Modules. Note: Bold values indicate the best performance.
All introduced modules are extremely lightweight. SE, Triplet, and Shuffle Attention bring almost no parameter overhead (total parameters remain at 3.71 M) and have no impact on GFLOPs. ECA and CoordAtt introduce negligible parameter increases (only +0.02 M), maintaining the model’s compact characteristics suitable for underwater robots.
Although SE, ECA, Triplet, and Shuffle are computationally efficient, their performance gains are limited. In contrast, CoordAtt achieved a significant increase in mIoU with only a 0.02 M increase in parameters. Although its mPA is slightly lower, its mIoU is the highest (70.92%), and when combined with other modules eventually, the mPA reached the optimum. This indicates that CoordAtt provides the best trade-off between segmentation accuracy and computational cost, making it the optimal choice for our specific task.
4.6. Comparison of Different Context-Aware Hybrid Modules
In the second branch of HAIS, our goal is to enhance global context and feature refinement capabilities. We compared the selected CBAM with other advanced hybrid or context modeling modules, including BAM [44], SimAM [45], SK Net [46], and GCNet [47]. Evaluation metrics included mIoU, mPA, Accuracy, F1-score, Parameters, and GFLOPs. The results are shown in Table 7.
Table 7.
Comparison Results of Different Context-Aware Hybrid Modules. Note: Bold values indicate the best performance.
SK Net performed best in mIoU, but its multi-branch or transform structure introduced significant parameter overhead, reaching 3.80 M. Similarly, GCNet also increased parameter overhead significantly to achieve high accuracy (97.81%), but its mPA was the lowest among all modules (82.09%). Although SimAM’s parameters remained basically unchanged, the lack of learnable parameters limited its ability to adapt to complex underwater noise, resulting in the lowest mIoU of 70.48%.
In comparison, the CBAM used in this study achieved the best balance. Compared with BAM (+0.03 M), it adds negligible parameters (+0.02 M) and maintains the same GFLOPs (15.23 G) as the baseline. The mPA of the CBAM remains the highest among all context-aware hybrid modules (82.56%). This confirms that CBAM provides an efficient and effective method to refine features without burdening the lightweight SegFormer encoder, while complementing the CoordAtt module mentioned above, thereby bringing higher overall performance.
4.7. Comparison of Different Feature Inhibition and Filtering Modules
To validate the effectiveness of the proposed FIM in suppressing underwater background noise (such as water plants and suspended particles), we compared it with several mainstream regularization and thresholding mechanisms, including Spatial Dropout [48], DropBlock [49], and Soft Thresholding [50]. Evaluation metrics included mIoU, mPA, Accuracy, F1-score, Parameters, and GFLOPs. The results are shown in Table 8.
Table 8.
Comparison Results of Different Feature Inhibition and Filtering Modules. Note: Bold values indicate the best performance.
Stochastic regularization methods like Spatial Dropout and DropBlock actually led to performance degradation. This is mainly because underwater cracks are extremely subtle; randomly dropping feature channels or spatial blocks easily “accidentally injures” the already weak crack features, causing segmentation fractures. Soft Thresholding achieved some improvement; however, it applies channel-level thresholds based on global statistical information. When “dark cracks” and “dark water plants” have similar channel responses but different spatial patterns, this global method struggles to distinguish them effectively.
In contrast, FIM outperforms all comparison methods. The computational cost it introduces is negligible (Params only increased by 0.03 M, GFLOPs by 0.01 G). Unlike random dropping, FIM learns to generate spatially adaptive masks. It uses a soft inhibition strategy to specifically target background areas for attenuation while preserving weak crack signals. This mechanism effectively filters high-frequency noise without destroying the topological continuity of cracks, achieving the best mIoU and mPA among all comparison modules, making it the optimal choice for our task.
4.8. Comparison of SegFormer Series Models
To verify parameter efficiency, we compared HAIS with the larger-scale SegFormer-B1. Evaluation metrics included mIoU, mPA, Accuracy, F1-score, Parameters, and GFLOPs. The results are shown in Table 9.
Table 9.
Comparison Results of SegFormer Series Models. Note: Bold values indicate the best performance.
Although SegFormer-B1 achieved a 72.13% mIoU result due to its deeper network structure and larger feature channel count (parameters reaching 13.7 M), our HAIS model achieved 71.66% mIoU with only 3.80 M parameters (about 27% of B1), with a performance gap of less than 0.5%. This indicates that by introducing efficient Hybrid Attention mechanisms (CoordAtt + CBAM) and the Feature Inhibition Module (FIM), HAIS successfully compensates for the insufficient feature extraction capability of the lightweight backbone (MiT-B0), achieving a better balance between computational efficiency and detection accuracy than SegFormer-B1, making it more suitable for deployment on resource-constrained underwater robots.
4.9. Comparison with Classical Traditional Methods
To comprehensively evaluate the overall performance of the proposed method, we compared HAIS-SegFormer with three representative semantic segmentation models: PSPNet, U-Net, and DeepLabV3+. Evaluation metrics included mIoU, mPA, Accuracy, F1-score, Parameters, and GFLOPs. The results are shown in Table 10.
Table 10.
Comparison Results with Classical Traditional Methods. Note: Bold values indicate the best performance.
HAIS-SegFormer achieved the highest levels in various tests. PSPNet performed the worst in various data, as its Pyramid Pooling Module (PPM) tends to lose details of subtle cracks during down sampling. U-Net achieved a competitive mPA (83.10%) by preserving spatial information through skip connections. However, its lower mIoU (69.81%) indicates a higher false detection rate, suggesting it struggles to distinguish cracks from water plants or shadows without strong context filtering mechanisms. DeepLabV3+ performed robustly but was still slightly inferior to HAIS, proving that our proposed attention mechanisms (CoordAtt + CBAM) are more effective at capturing underwater crack features than standard dilated convolutions
The greatest advantage of HAIS lies in its efficiency. Our model has only 3.80 M parameters, which is about 1/3 the size of DeepLabV3+ and 1/7 of U-Net. In terms of GFLOPs, HAIS requires 39% less computational resources than DeepLabV3+ and only 1/6 of U-Net.
In summary, HAIS-SegFormer does not rely on heavy backbones to obtain high accuracy. Instead, it utilizes an efficient Transformer architecture and targeted modules to achieve the optimal accuracy-efficiency trade-off. This makes it an ideal solution for deploying and performing real-time dam inspection tasks on resource-constrained underwater robots (ROVs).
5. Discussion
In this study, we introduced a lightweight semantic segmentation framework based on SegFormer-B0, HAIS-SegFormer, aiming to solve the difficulty of crack detection in complex underwater environments while effectively balancing pixel-level segmentation accuracy with the inference efficiency of edge-side models. Our method focuses on three key innovations tailored to the characteristics of underwater scenarios: introducing Coordinate Attention (CoordAtt) to address long-range dependencies and crack topology fracture issues; cascading the Convolutional Block Attention Module (CBAM) to refine blurred crack edges within a local range; and designing a Feature Inhibition Module (FIM) inspired by biological vision to actively suppress mimicry noise such as water plants and suspended matter via a gating mechanism. Experimental results indicate that this method outperforms the original SegFormer and other lightweight networks in underwater crack segmentation tasks, particularly excelling in maintaining the connectivity of subtle cracks and suppressing high-frequency background noise.
It is worth emphasizing that the improvement strategy adopted in this work is not merely a simple stacking of attention modules, but follows a collaborative processing logic consistent with human visual cognition: “Coarse to Fine, Positive to Negative”. CoordAtt first acts as a “radar”, locking onto the global skeleton and topological structure of the crack during the initial stage where features are blurred; subsequently, CBAM serves as a “microscope”, sharpening edge details within the identified region of interest; finally, FIM functions as a “filter”, utilizing an adaptive gating mechanism to filter out erroneously enhanced texture noise. This tandem design not only compensates for the Transformer backbone’s deficiency in capturing local details but also effectively solves the false positive misdetection problem easily caused by traditional feature enhancement methods through an active inhibition mechanism.
From a deployment perspective, the proposed model exhibits strong engineering adaptability. Despite the introduction of three additional modules, the total parameter count of the model is controlled at around 3.80 M. Furthermore, it maintains an inference speed of 73 FPS on an RTX 3090, which is only a 9.2% decrease compared to the baseline’s 80.8 FPS, exceeding the real-time requirement of 30 FPS. This validates its potential in resource-constrained environments, making it particularly suitable for automated inspection tasks of dams or bridge piers carried out by underwater robots (ROVs) with limited computing power.
Despite achieving a favorable trade-off between accuracy and efficiency, there is still potential for further optimization. Future work will explore advanced model compression techniques, including channel pruning strategies to eliminate redundant feature channels in the decoder head, combined with knowledge distillation techniques to transfer the knowledge of HAIS-SegFormer to shallower networks, aiming to achieve higher frame rate detection on ultra-low-power embedded chips. Additionally, addressing extremely turbid underwater scenarios, we will also consider introducing self-supervised learning pre-training to further reduce dependence on large amounts of annotated data.
Despite the favorable trade-off achieved, certain limitations remain in the current study. Firstly, HAIS-SegFormer may struggle in extremely low-light deep-sea environments without auxiliary lighting, where structural features are completely absent. Secondly, while mIoU effectively evaluates pixel-level accuracy, the absence of direct topology-aware evaluation metrics (e.g., clDice) limits the quantitative assessment of precise structural continuity. Generalizing to highly divergent marine conditions may require the integration of domain adaptation preprocessing in future deployments.
6. Conclusions
This study addressed the specificity of crack detection in underwater concrete structures by proposing a lightweight improvement framework based on SegFormer-B0, HAIS-SegFormer. From the three dimensions of global topology recovery, local edge refinement, and active noise inhibition, we designed the Hybrid Attention mechanism (CoordAtt + CBAM) and the Feature Inhibition Module (FIM) respectively.
This study provides a semantic segmentation solution integrating high accuracy, low latency, and strong anti-interference capabilities for resource-constrained underwater robot platforms. It is particularly suitable for automated inspection applications of critical infrastructure such as dam safety monitoring and underwater tunnel maintenance. Future work will focus on integrating autonomous ROV navigation control loops with our real-time segmentation model. Additionally, we will explore unsupervised domain adaptation and topology-preserving loss functions to further reduce the reliance on annotated datasets and enhance structural continuity assessment in extreme marine environments.
Author Contributions
G.L.: writing—review and editing, supervision, conceptualization, funding acquisition, project administration. J.Z.: methodology, software, validation, formal analysis, investigation, resources, data curation, writing—original draft preparation, visualization, software. K.H.: methodology, supervision, writing—review & editing. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Data Availability Statement
The publicly available dataset analyzed in this study can be found at Roboflow Universe: [https://universe.roboflow.com/arjun-elh2g/underwater-crack-detection-owcch] (accessed on 6 January 2026).
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Golding, V.P.; Gharineiat, Z.; Munawar, H.S.; Ullah, F. Crack detection in concrete structures using deep learning. Sustainability 2022, 14, 8117. [Google Scholar] [CrossRef] [Scilit]
- Mohan, A.; Poobal, S. Crack detection using image processing: A critical review and analysis. Alex. Eng. J. 2018, 57, 787–798. [Google Scholar] [CrossRef] [Scilit]
- Li, G.; Zhao, X. LCS-Net: Learnable Color Correction and Selective Multi-Scale Fusion for Underwater Image Enhancement. Sensors 2026, 26, 1323. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Chen, D.; Huang, B.; Kang, F. A review of detection technologies for underwater cracks on concrete dam surfaces. Appl. Sci. 2023, 13, 3564. [Google Scholar] [CrossRef] [Scilit]
- Li, Y.; Bao, T.; Huang, X.; Chen, H.; Xu, B.; Shu, X.; Zhou, Y.; Cao, Q.; Tu, J.; Wang, R.; et al. Underwater crack pixel-wise identification and quantification for dams via lightweight semantic segmentation and transfer learning. Autom. Constr. 2022, 144, 104600. [Google Scholar] [CrossRef] [Scilit]
- Orinaitė, U.; Pal, M.; Palevicius, P.; Ragulskis, M. Deep Learning Based Detection of Concrete Cracks in Critical Underwater Infrastructure. Adv. Signal Process. Artif. Intell. 2024, 89, 89–90. [Google Scholar]
- Jing, J.; Wang, Z.; Rätsch, M.; Zhang, H. Mobile-Unet: An efficient convolutional neural network for fabric defect detection. Text. Res. J. 2022, 92, 30–42. [Google Scholar] [CrossRef] [Scilit]
- Su, G.; Qin, Y.; Xu, H.; Liang, J. Automatic real-time crack detection using lightweight deep learning models. Eng. Appl. Artif. Intell. 2024, 138, 109340. [Google Scholar] [CrossRef] [Scilit]
- Li, G.; Fang, J. LCW-YOLO: A Lightweight Multi-Scale Object Detection Method Based on YOLOv11 and Its Performance Evaluation in Complex Natural Scenes. Sensors 2025, 25, 6209. [Google Scholar] [CrossRef] [Scilit]
- Zhang, X.; Rajan, D.; Story, B. Concrete crack detection using context-aware deep semantic segmentation network. Comput.-Aided Civ. Infrastruct. Eng. 2019, 34, 951–971. [Google Scholar] [CrossRef] [Scilit]
- Alipour, M.; Harris, D.K. Increasing the Robustness of Deep Learning-Based Crack Detection for Bridge Inspections. Sensors 2020, 20, 2069. [Google Scholar]
- Xie, E.; Wang, W.; Yu, Z.; Anandkumar, A.; Alvarez, J.M.; Luo, P. SegFormer: Simple and efficient design for semantic segmentation with transformers. Adv. Neural Inf. Process. Syst. 2021, 34, 12077–12090. [Google Scholar]
- Otsu, N. A threshold selection method from gray-level histograms. Automatica 1975, 11, 23–27. [Google Scholar] [CrossRef] [Scilit]
- Canny, J. A computational approach to edge detection. IEEE Trans. Pattern Anal. Mach. Intell. 2009, PAMI-8, 679–698. [Google Scholar] [CrossRef] [Scilit]
- Salman, M.; Mathavan, S.; Kamal, K.; Rahman, M. Pavement crack detection using the Gabor filter. In 16th International IEEE Conference on Intelligent Transportation Systems (ITSC 2013); IEEE: New York, NY, USA, 2013; pp. 2039–2044. [Google Scholar]
- Munawar, H.S.; Hammad, A.W.A.; Haddad, A.; Soares, C.A.P.; Waller, S.T. Image-based crack detection methods: A review. Infrastructures 2021, 6, 115. [Google Scholar] [CrossRef] [Scilit]
- Long, J.; Shelhamer, E.; Darrell, T. Fully convolutional networks for semantic segmentation. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Boston, MA, USA, 7–12 June 2015; pp. 3431–3440. [Google Scholar]
- Badrinarayanan, V.; Kendall, A.; Cipolla, R. Segnet: A deep convolutional encoder-decoder architecture for image segmentation. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 2481–2495. [Google Scholar] [CrossRef] [Scilit]
- Ronneberger, O.; Fischer, P.; Brox, T. U-net: Convolutional networks for biomedical image segmentation. In International Conference on Medical Image Computing and Computer-Assisted Intervention; Springer International Publishing: Cham, Switzerland, 2015; pp. 234–241. [Google Scholar]
- Fu, H.; Meng, D.; Li, W.; Wang, Y. Bridge crack semantic segmentation based on improved Deeplabv3+. J. Mar. Sci. Eng. 2021, 9, 671. [Google Scholar] [CrossRef] [Scilit]
- Zim, A.H.; Iqbal, A.; Al-Huda, Z.; Malik, A.; Kuribayashi, M. EfficientCrackNet: A lightweight model for crack segmentation. In 2025 IEEE/CVF Winter Conference on Applications of Computer Vision (WACV); IEEE: New York, NY, USA, 2025; pp. 6279–6289. [Google Scholar]
- Raghu, M.; Unterthiner, T.; Kornblith, S.; Zhang, C.; Dosovitskiy, A. Do vision transformers see like convolutional neural networks? Adv. Neural Inf. Process. Syst. 2021, 34, 12116–12128. [Google Scholar]
- Han, K.; Xiao, A.; Wu, E.; Guo, J.; Xu, C.; Wang, Y. Transformer in transformer. Adv. Neural Inf. Process. Syst. 2021, 34, 15908–15919. [Google Scholar]
- Liu, Z.; Lin, Y.; Cao, Y.; Hu, H.; Wei, Y.; Zhang, Z.; Lin, S.; Guo, B. Swin transformer: Hierarchical vision transformer using shifted windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision, Virtual, 11–17 October 2021; pp. 10012–10022. [Google Scholar]
- Cao, H.; Wang, Y.; Chen, J.; Jiang, D.; Zhang, X.; Tian, Q.; Wang, M. Swin-unet: Unet-like pure transformer for medical image segmentation. In European Conference on Computer Vision; Springer Nature Switzerland: Cham, Switzerland, 2022; pp. 205–218. [Google Scholar]
- Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need. Adv. Neural Inf. Process. Syst. 2017, 30, 1–11. [Google Scholar]
- Hou, Q.; Zhou, D.; Feng, J. Coordinate attention for efficient mobile network design. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Virtual, 19–25 June 2021; pp. 13713–13722. [Google Scholar]
- Zhang, H.; Ullah, N.; Sharhan, A.; Duan, Y. CA-SegFormer: An improved coordinate attention-enhanced model for crack segmentation in concrete structures. Case Stud. Constr. Mater. 2025, 23, e05492. [Google Scholar] [CrossRef] [Scilit]
- Xie, Q.; Huang, J.; Sun, J.; Huang, C.; Xu, C. SMoFFI-SegFormer: A novel approach for ovarian tumor segmentation based on an improved SegFormer architecture. Front. Oncol. 2025, 15, 1555585. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Rudin, C. Stop Explaining Black Box Machine Learning Models for High Stakes Decisions and Use Interpretable Models Instead. Nat. Mach. Intell. 2019, 1, 206–215. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Gholamalinejad, H.; Khosravi, H. Vehicle classification using a real-time convolutional structure based on DWT pooling layer and SE blocks. Expert Syst. Appl. 2021, 183, 115420. [Google Scholar] [CrossRef] [Scilit]
- Woo, S.; Park, J.; Lee, J.Y.; Kweon, I.S. Cbam: Convolutional block attention module. In Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany, 8–14 September 2018; pp. 3–19. [Google Scholar]
- Hartline, H.K. The effects of spatial summation in the retina on the excitation of the fibers of the optic nerve. Am. J. Physiol.-Leg. Content 1940, 130, 700–711. [Google Scholar] [CrossRef] [Scilit]
- Arjun. Underwater Crack Detection Object Detection Dataset [DS/OL]. Roboflow Universe. 2025. Available online: https://universe.roboflow.com/arjun-elh2g/underwater-crack-detection-owcch (accessed on 6 January 2026).
- Paszke, A.; Gross, S.; Massa, F.; Lerer, A.; Bradbury, J.; Chanan, G.; Killeen, T.; Lin, Z.; Gimelshein, N.; Antiga, L.; et al. Pytorch: An imperative style, high-performance deep learning library. Adv. Neural Inf. Process. Syst. 2019, 32, 1–12. [Google Scholar]
- Loshchilov, I.; Hutter, F. Decoupled Weight Decay Regularization. arXiv 2017, arXiv:1711.05101. [Google Scholar]
- Everingham, M.; Van Gool, L.; Williams, C.K.; Winn, J.; Zisserman, A. The pascal visual object classes (voc) challenge. Int. J. Comput. Vis. 2010, 88, 303–338. [Google Scholar] [CrossRef] [Scilit]
- Ramli, A.A.; Liu, X.; Berndt, K.; Goude, E.; Hou, J.; Kaethler, L.B.; Liu, R.; Lopez, A.; Nicorici, A.; Owens, C.; et al. Gait characterization in Duchenne muscular dystrophy (DMD) using a single-sensor accelerometer: Classical machine learning and deep learning approaches. Sensors 2024, 24, 1123. [Google Scholar] [CrossRef] [Scilit]
- Cui, W.; Meng, G.; Gou, T.; Wang, A.; Xiao, R.; Zhang, X. Intelligent rolling bearing fault diagnosis method using symmetrized dot pattern images and CBAM-DRN. Sensors 2022, 22, 9954. [Google Scholar] [CrossRef] [Scilit]
- Hu, J.; Shen, L.; Sun, G. Squeeze-and-excitation networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–22 June 2018; pp. 7132–7141. [Google Scholar]
- Wang, Q.; Wu, B.; Zhu, P.; Li, P.; Zuo, W.; Hu, Q. ECA-Net: Efficient channel attention for deep convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020; pp. 11534–11542. [Google Scholar]
- Misra, D.; Nalamada, T.; Arasanipalai, A.U.; Hou, Q. Rotate to attend: Convolutional triplet attention module. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, Waikoloa, HI, USA, 3–8 January 2021; pp. 3139–3148. [Google Scholar]
- Zhang, Q.L.; Yang, Y.B. Sa-net: Shuffle attention for deep convolutional neural networks. In ICASSP 2021—2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP); IEEE: New York, NY, USA, 2021; pp. 2235–2239. [Google Scholar]
- Park, J.; Woo, S.; Lee, J.Y.; Kweon, I.S. Bam: Bottleneck Attention Module. arXiv 2018, arXiv:1807.06514. [Google Scholar] [CrossRef] [Scilit]
- Yang, L.; Zhang, R.Y.; Li, L.; Xie, X. Simam: A simple, parameter-free attention module for convolutional neural networks. In International Conference on Machine Learning; PMLR: Cambridge, MA, USA, 2021; pp. 11863–11874. [Google Scholar]
- Li, X.; Wang, W.; Hu, X.; Yang, J. Selective kernel networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Long Beach, CA, USA, 15–20 June 2019; pp. 510–519. [Google Scholar]
- Cao, Y.; Xu, J.; Lin, S.; Wei, F.; Hu, H. Gcnet: Non-local networks meet squeeze-excitation networks and beyond. In Proceedings of the IEEE/CVF International Conference on Computer Vision Workshops, Seoul, Republic of Korea, 27–28 October 2019. [Google Scholar]
- Tompson, J.; Goroshin, R.; Jain, A.; LeCun, Y.; Bregler, C. Efficient object localization using convolutional networks. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Boston, MA, USA, 7–12 June 2015; pp. 648–656. [Google Scholar]
- Ghiasi, G.; Lin, T.Y.; Le, Q.V. Dropblock: A regularization method for convolutional networks. Adv. Neural Inf. Process. Syst. 2018, 31, 1–11. [Google Scholar]
- Zhao, M.; Zhong, S.; Fu, X.; Tang, B.; Pecht, M. Deep residual shrinkage networks for fault diagnosis. IEEE Trans. Ind. Inform. 2019, 16, 4681–4690. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.









