Table 1
Fig 1
Fig 2
Fig 3
Fig 4
Fig 5
Fig 6
Fig 7
Fig 8
Fig 9

Cracks on the surface of concrete structures are an obvious indication of their condition. However, traditional visual inspection methods are significantly influenced by human factors. They are accurate for larger cracks. However, they introduce subjective judgment when detecting smaller cracks. They also pose safety risks. Automated detection methods face challenges in achieving lightweight implementation due to limited annotated data and difficulties in complex environments. This paper proposes a method for detecting and measuring concrete cracks. The method uses a generative adversarial network (GAN) to augment data and a U-Net segmentation network. Conditional GAN (cGAN) is proposed to generate high-fidelity crack images using training-set data only, avoiding data leakage and effectively solving insufficient sample issues. A U-Net segmentation network that has been enhanced performs crack segmentation. This network incorporates channel attention modules and dilated residual blocks. A hybrid loss function that combines the Dice coefficient and binary cross-entropy resolves class imbalance. Fractal theory quantifies the geometric features of the detected cracks. The crack segmentation model that was trained on cGAN-augmented datasets achieved an average precision (AP) of 82.03% and an F1 score of 83.24%, as demonstrated by experimental results. The fractal dimension–based crack measurement method achieves an accuracy of ≤4% error for complex crack networks (fractal dimension >1.6). The proposed method provides a reproducible, automated, high-precision solution for concrete crack detection and quantification, with verified stability and engineering applicability.

Citation: Chang Y (2026) Automated concrete crack detection enhanced by deep learning and generative adversarial networks. PLoS One 21(7): e0354018. https://doi.org/10.1371/journal.pone.0354018

Editor: Baohua Guo, Henan Polytechnic University, CHINA

Received: April 7, 2026; Accepted: July 2, 2026; Published: July 20, 2026

Copyright: © 2026 Yue Chang. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.

Data Availability: The minimal data set and accompanying code, where generated is available at ScienceDB via DOI:10.57760/sciencedb.40471.

Funding: The author(s) received no specific funding for this work.

Competing interests: The authors declare there are no competing interests.

As infrastructure’s service life increases and environmental effects accumulate, it inevitably experiences damage such as cracking, corrosion, and fatigue [1,2]. Cracking is one of the most common types of damage to infrastructure. It is an early warning sign of structural safety hazards, and its formation and progression, driven by factors such as design, loading, and environment, can lead to issues like leakage, material degradation, reduced load-bearing capacity, and safety incidents [3,4]. From a mechanical perspective, the shape and location of cracks offer valuable information about structural stress conditions, stiffness degradation, and causes of damage. Accurately determining the position, size, morphology, and development trend of a crack enables inspection personnel to better assess structural health, formulate appropriate maintenance plans, ensure operational safety, and extend service life [5].

Current crack detection relies entirely on manual inspections using ladders, telescopes, and bridge inspection vehicles. Although direct, this method is susceptible to human error and false positives. Inspections are particularly challenging in high-altitude areas, near bodies of water, and at tunnel crowns and waistlines. The mental and physical condition of inspectors can impact results, leading to low efficiency and high costs, as well as the potential for overlooking details and misidentifying defects. Digital image processing technology can replace manual inspections, achieve automation and remote detection and improving efficiency. However, due to its limited generalization capability, the technology’s accuracy significantly decreases in complex backgrounds or environments with high illumination variability (e.g., tunnels). Furthermore, substantial manual calibration is required to achieve acceptable performance levels, which makes its practical application in engineering challenging [6]. Advances in machine vision technology have led to the widespread adoption of digital image processing algorithms for crack detection due to their automation and long-range capabilities. These algorithms can rapidly and accurately isolate cracks from image noise and backgrounds. However, these algorithms perform poorly in tunnel environments. Complex backgrounds and fluctuating lighting conditions compromise their accuracy. In practice, effective detection requires extensive expert analysis and manual parameter adjustments, which fail to meet tunnel lining crack detection requirements. The emergence of deep learning (DL)-based object detection algorithms offers a novel solution for tunnel lining crack detection [7]. These approaches learn crack features directly from the data, bypassing the need for predefined characteristics. Then, they utilize DL techniques and algorithms for crack identification. Current object detection algorithms based on deep learning include the SSD, YOLO, and RCNN families [7]. Many researchers have applied these algorithms to crack detection with significant success. For tunnel lining crack detection, deep learning–based algorithms demonstrate superior generalization capabilities and higher accuracy than traditional digital image processing methods. However, existing DL algorithms have two limitations: insufficient datasets and an imbalanced trade-off between model scale and accuracy. These limitations affect the effectiveness of deep learning algorithms in practical tunnel engineering inspections [8–11].

In recent years, object detection algorithms based on deep learning (DL), such as SSD, YOLO, and the R-CNN series, have demonstrated significant advantages [9,10]. These algorithms use an end-to-end approach that employs forward and backward propagation to autonomously learn optimal weights, eliminating the need for manually designed feature operators. Consequently, they exhibit superior environmental adaptability, detection accuracy, and robustness, while reducing the risks of manual inspection and false alarms. This makes them a key area of research at present. However, two major challenges persist in their practical implementation. (1) Accuracy issues arise because bridge cracks exhibit chaotic textures and varying dimensions. Predefined anchor boxes are not suitable for diverse requirements, resulting in missed detections and false positives. (2) Deployment feasibility: Much current work prioritizes accuracy improvements while neglecting lightweight modeling. This results in large-scale models that are unsuitable for resource-constrained edge devices. Alternative methods, such as radar, laser scanning, infrared, and acoustic sensing, are also excluded due to drawbacks like high cost, low sensitivity, time-consuming processing, significant environmental susceptibility, and noise interference.

This paper proposes a concrete method for detecting and analyzing cracks based on training-set only cGAN data augmentation data augmentation and an enhanced U-Net segmentation network to address these challenges. The paper’s main contributions are threefold:

(1). A cGAN‑based data augmentation module trained exclusively on the training set. Unlike existing GAN augmentation methods that risk data leakage by using validation or test images, our cGAN is trained solely on training‑set samples. It generates high‑fidelity synthetic crack images with realistic textures and diverse backgrounds, effectively solving the small‑sample overfitting problem while strictly preventing information contamination.

(2). An enhanced U‑Net segmentation network with channel attention and dilated residual blocks. We propose a pixel‑level crack segmentation network that integrates channel attention mechanisms into skip connections to dynamically weight important features, and dilated residual blocks to enlarge receptive fields without losing spatial resolution. A dynamic Dice+BCE hybrid loss is designed to handle extreme class imbalance (crack pixels typically <5%), with the Dice weight α adaptively reduced from 0.7 to 0.4 during training to optimize boundary precision.

(3). A fractal box‑counting method for high‑precision geometric quantification. We apply fractal theory to quantify crack geometric parameters (area, length) from the segmented masks. The method achieves measurement error ≤4% for complex crack networks (fractal dimension >1.6) with confidence level >0.9, providing a reliable quantitative tool for structural health assessment. Compared with existing studies that use GAN or U‑Net in isolation, our framework uniquely integrates these three components into an end‑to‑end pipeline, with the training‑set‑only cGAN being a key methodological safeguard often overlooked in prior work.

Early crack detection relied on digital image processing techniques. Edge detection algorithms, such as Sobel, Canny, and Laplacian, identified gray-level gradient changes in images to extract crack edges. Threshold segmentation (e.g., Otsu) automatically separated cracks from the background. Morphological operations (e.g., dilation and erosion) connected the detected cracks. The Hough transform was effective for linear cracks but not for curved or bent cracks within tunnels. When applied to tunnel crack detection in complex environments, these methods exhibited certain limitations. First, edge detection algorithms are sensitive to noise, which often causes discontinuities in crack edges. The Canny operator is a prime example of this issue. Second, threshold segmentation methods are sensitive to lighting conditions, which can lead to crack detection failures in low-contrast backgrounds. Third, morphological operations may smooth connections between some cracks, causing distortion in certain fine features. To enhance detection performance, Talab et al. (2016) integrated Sobel edge detection with threshold segmentation. This approach completes target detection and extraction in a single arithmetic operation, effectively improving noise resistance [12]. Lei et al. (2021b) integrated an adaptive segmentation-edge detection-thresholding framework. This method improved detection accuracy by approximately 15% under high-noise tunnel conditions [13].

In recent years, deep learning methods have become increasingly popular in crack detection. These methods encompass three primary tasks: crack classification, crack segmentation, and object detection. Crack classification treats crack identification as a binary classification problem. Crack segmentation primarily uses encoder-decoder networks, such as U-Net and SegNet, for pixel-level classification. Object detection uses methods like Faster R-CNN and YOLO for crack localization and bounding box detection. Experimental results demonstrate that applying various deep learning methods to crack images yields favorable outcomes and achieves excellent results across diverse public datasets [14].

To address these challenges, many researchers have explored using deep learning to improve traditional digital image processing techniques. For example, Kang et al. used a combination of Faster R-CNN and a tubular flow field method to localize cracks, which enabled them to automatically detect and quantitatively analyze crack regions [15]. Long et al. used a fully convolutional network (FCN) to detect bridge cracks at the pixel level, restoring image details through deconvolution. However, this model struggles with spatial consistency modeling [16]. A pyramid pooling module was integrated into PSPNet by Zhao Xuexiang and colleagues for multi-scale feature fusion, enhancing detection accuracy in complex scenarios [17].

In addition, Jiang et al. (2020) suggested a new Android system based on the SSD algorithm, which was combined with drone-based long-range crack identification methods [18]. Deng et al. (2020) showed that YOLOv2 has better interference resistance and faster processing speed compared to Faster R-CNN [19]. Furthermore, researchers have applied YOLOv4 to detect road surface cracks across multiple locations, achieving satisfactory accuracy.

However, current object detection algorithms are not designed specifically for crack detection and face significant limitations in the identification process. Consequently, experts and scholars are developing optimization techniques. For example, Liu et al. (2020) proposed deepening the network architecture by adding YOLO layers [21], and Gou et al. (2019) introduced bypass connections using faster R-CNN and combined them with squeezed activation networks to improve the representation of crack features [22].

While most current efforts focus on optimizing network architectures and loss functions to improve detection accuracy, results are still heavily dependent on dataset size and quality [23]. When sample images are scarce and crack categories are limited, models struggle to acquire feature representations with strong generalization capabilities [24]. Additionally, since mainstream object detection algorithms require tens of thousands of images for training (e.g., the VOC2007 and COCO datasets), collecting a large number of field crack samples to build massive image datasets in engineering sites is challenging. Furthermore, acquiring a large number of images incurs substantial labor, material, and time costs, which further limits model performance.

After a period of development and iteration, the initial GAN was created. Improvements that incorporated convolutional structures and batch normalization successfully generated high-quality images at approximately 64 × 64 pixels, representing a leap from low-quality images. Enhancing the distance loss in GANs effectively mitigated mode collapse issues and strengthened overall training stability [25].

Regarding the weak texture and irregular morphology of cracks in crack detection tasks, GANs have advanced related research methods in three key aspects [26–28]: (1) data augmentation based on conditional GANs generates realistic synthetic samples of cracks against backgrounds, alleviating the scarcity of annotated crack samples; (2) image restoration models based on pix2pix and attention mechanisms effectively reconstruct cracks with up to 80% occlusion; and (3) style transfer using CycleGan (simulating varying weather conditions, such as rain and fog, and lighting scenarios, such as nighttime) enhances model robustness in complex environments. Table 1 shows that using 30% GAN-generated data to train the UNet segmentation model yields a significantly higher IoU than the other two approaches. Using only 100 original images, the YOLOv4 model improves mAP by 12.3%, and the style-transferred detection model reduces false positive rates by 18% under unseen lighting conditions. However, current GAN methods suffer from issues such as distorted texture generation (PSNR <28 dB) and slow training convergence (exceeding 200 iterations).

https://doi.org/10.1371/journal.pone.0354018.t001

Using Generative Adversarial Networks (GANs) for crack detection is a critical component of infrastructure health monitoring. Traditional manual inspection methods are inefficient, costly, and inaccurate. Deep learning technology has made significant breakthroughs in computer vision and offers a promising approach for automated crack detection. However, the lack of high-quality, annotated crack image databases hinders the practical application of this technology in engineering. This chapter proposes a solution to the scarcity of concrete crack detection data: a combination of GAN-based data augmentation and a hybrid detection model. Synthetic images of real cracks are added to the training dataset. An improved U-Net architecture and a multi-scale feature fusion mechanism enable the precise segmentation and identification of surface cracks in concrete.

Data preprocessing forms the foundation of model performance and comprises two critical steps: normalization and random augmentation. First, input images undergo normalization via the formula , where and represent the dataset’s mean and standard deviation, respectively. This operation eliminates illumination variations and sensor biases, ensuring numerical stability. Second, the random enhancement operation applies geometric transformations (rotation ±30°, scaling 0.8–1.2×), photometric perturbations (brightness/contrast adjustment ±20%), and random cropping. This enhancement strategy dynamically generates diverse samples during training, specifically simulating the tilting, fracturing, and occlusion of cracks in real-world scenarios for crack detection tasks. This significantly enhances the model’s generalization capability to unseen data.

This module uses a conditional GAN (cGAN) trained exclusively on the training set to generate high-realism synthetic crack images, completely avoiding validation/test data leakage. The generator employs a U-Net architecture, taking as inputs the augmented image and a noise vector , and producing a synthetic image . Its loss function comprises two components: an adversarial loss that forces the generated image to deceive the discriminator, and an L1 reconstruction loss that ensures precision in crack location and morphology (λ is typically set to 100). The discriminator adopts a PatchGAN architecture, learning to distinguish real from synthetic samples through the loss . During training, the generator focuses on producing cracks with complex textures, while the discriminator enhances sensitivity to subtle artifacts. Its structural diagram is shown in Fig 1.

The generator G employs a U‑Net structure taking augmented image and noise vector Z as inputs to produce synthetic image . The discriminator D adopts a PatchGAN architecture to distinguish real from synthetic samples. The training uses a combined adversarial and L1 reconstruction loss.

https://doi.org/10.1371/journal.pone.0354018.g001

The proposed segmentation network adopts a standard encoder‑decoder architecture. The encoder consists of five stages, each containing two 3 × 3 convolutional layers with batch normalization and ReLU activation, followed by a 2 × 2 max pooling operation with stride 2 for downsampling. The number of feature channels progressively increases from 64 to 128, 256, 512, and 1024 across the five stages. The decoder employs transposed convolutions for upsampling, with skip connections from corresponding encoder stages to fuse spatial details with semantic information. The final output layer uses a 1 × 1 convolution to reduce the channel dimension to 1, followed by sigmoid activation to produce a pixel‑level probability mask . The complete network architecture is as follows: input size 512 × 512 × 3; encoder stages: 64 → 128 → 256 → 512 → 1024 channels; each stage: two 3 × 3 conv (padding = 1) + BN + ReLU, followed by 2 × 2 max pooling (stride = 2); bottleneck: 1024 channels; decoder stages: 1024 → 512 → 256 → 128 → 64 channels via transposed convolution (kernel = 2 × 2, stride = 2); skip connections via concatenation; output: 1 × 1 conv + sigmoid. Total parameters: 31.2M. Optimizer: Adam (lr = 1e − 4, β1 = 0.9, β2 = 0.999); batch size: 8; epochs: 300; early stopping patience: 50. Framework: PyTorch 1.12.0; hardware: NVIDIA GeForce RTX 3060 (12GB VRAM). Fig 2 shows the architecture. The encoder progressively extracts multi‑scale features through five downsampling stages, while the decoder recovers spatial resolution through transposed convolutions. Skip connections with channel attention modules fuse encoder and decoder features. Dilated residual blocks are inserted at the bottleneck to enlarge receptive fields.

https://doi.org/10.1371/journal.pone.0354018.g002

The decoder module comprises two parts. The first part is the feature extraction structure, consisting of several MLPs that transform the data dimensions to (64, 64, 64, 128). This ultimately yields a 128-dimensional feature vector, followed by max pooling where the maximum value is taken from each dimension. Thus, an n × 2 image is transformed into a 1 × 128 feature vector. The decoder takes two images as input (the original image and the preprocessed image), yielding two 128-dimensional vectors. Combining these results in a 256-dimensional vector, completing the encoding process as shown in Fig 3. The encoder follows the standard U‑Net design. At each stage, two 3 × 3 convolutional layers with batch normalization and ReLU activation are applied, followed by 2 × 2 max pooling with stride 2 for downsampling. This hierarchical structure extracts features at multiple scales: early layers capture fine edges and textures, while deeper layers encode high‑level semantic information about crack topology and context. The encoder outputs feature maps at five resolutions, which are connected to the decoder via skip connections to preserve spatial details. The encoder stages produce feature maps with resolutions of 256 × 256 × 64, 128 × 128 × 128, 64 × 64 × 256, 32 × 32 × 512, and 16 × 16 × 1024 (shown in detail in Fig 3).

https://doi.org/10.1371/journal.pone.0354018.g003

The decoder uses transposed convolution (kernel = 2 × 2, stride = 2) for upsampling, progressively restoring the spatial resolution from 16 × 16 back to 512 × 512. At each decoder stage, the upsampled feature map is concatenated with the corresponding encoder feature map from the same resolution via skip connections, allowing the network to combine high‑level semantic information with fine‑grained spatial details. The concatenated features are then passed through two 3 × 3 convolutional layers with BN and ReLU. The final output is a single‑channel probability mask of size 512 × 512 × 1, produced by a 1 × 1 convolution followed by sigmoid activation. The decoder does not regress length, width, or area; these geometric parameters are computed from the segmentation mask in the post‑processing stage using fractal theory (Section 5). Fig 4 shows the decoder module.

https://doi.org/10.1371/journal.pone.0354018.g004

To enhance small crack detection, the network incorporates a channel attention mechanism to dynamically weight important features in skip connections. As shown in Fig 5 [29], these neural units aggregate regional features. Existing methods using max pooling or average pooling for regional aggregation may result in significant information loss. The attention mechanism enables adaptive learning of crucial neighborhood features through the following steps.

https://doi.org/10.1371/journal.pone.0354018.g005

For local features , the model designs a function g (, W) to learn the attention score for each feature. This function consists of an MLP + softmax, as shown in Equation 1, where w represents the shared weights learned by the MLP.

The learned attention scores serve as a mask matrix to select important features, which are then accumulated using the formula: . This ultimately generates an information-rich feature vector fi.

Due to the progressive downsampling of complex cracks, it is necessary to significantly increase the receptive field of each region to preserve more geometric details even when regions are lost. As shown in Fig 6, multiple LocSE and attention pooling modules are stacked using skip connections and dilated residual blocks to retain more details.

https://doi.org/10.1371/journal.pone.0354018.g006

In deep neural networks, variations in data distribution can cause slow convergence and training speeds. Additionally, large activation outputs in deep networks yield small corresponding gradients, further slowing learning rates. To address this, BN layers are introduced. Through normalization, BN layers transform inputs with varying distributions into a standard normal distribution. This positions activation inputs within regions where nonlinear functions are highly sensitive to input changes, thereby reducing network outputs and generating larger gradients. This accelerates network convergence and training speed. The specific implementation of the BN layer is detailed in Table 1.