1. Introduction
Aluminum profiles have become a critical foundational material for modern industries such as aerospace and automotive manufacturing due to their excellent properties of lightweight, high strength, corrosion resistance, and ease of processing [
1]. Their surface quality directly determines product safety and aesthetic integrity, serving as a core indicator that affects product grade and market competitiveness. In mass production, influenced by multiple factors, including environmental conditions and transport friction, aluminum profiles are prone to surface defects such as scratches, dents, and paint bubbles. Even micrometer-scale defects can lead to severe consequences, including product rejection and significant economic losses [
2]. Therefore, developing accurate and efficient defect detection technology is essential to ensuring product quality and production efficiency.
Traditional aluminum defect detection methods, including magnetic particle testing, penetrant testing [
3], X-ray testing [
4], ultrasonic testing [
5], eddy current testing [
6], and magnetic flux leakage testing [
7], all exhibit significant limitations. For instance, magnetic particle and penetrant testing rely on manual interpretation, resulting in low efficiency, high subjective error, and elevated rates of false negatives and false positives. X-ray testing shows insufficient sensitivity to shallow defects, such as surface microcracks, and poses radiation hazards. Ultrasonic and eddy current testing are susceptible to environmental factors such as temperature, humidity, and surface contamination with oil, which degrade detection accuracy. Even though related studies have attempted to improve these traditional methods through simulation modeling for parameter optimization and multi-modal fusion for integrating multi-source data, it remains challenging to ensure generalization capability under complex industrial conditions or meet the real-time detection requirements of modern production lines [
8,
9,
10]. With the rapid development of deep learning technology in computer vision, deep learning-based object detection methods, leveraging their powerful feature extraction and self-learning capabilities, are gradually replacing traditional detection techniques and have become a research hotspot in aluminum surface defect detection [
11]. These methods are primarily divided into two-stage and one-stage detection architectures based on differences in their detection pipelines. The two-stage architecture is represented by the Region-based Convolutional Neural Network (R-CNN) series. This type of algorithm employs a stepwise process of region proposal generation followed by object classification and localization. While capable of achieving high detection accuracy, it suffers from high computational complexity due to the sequential extraction of candidate regions and subsequent fine-grained classification, making it difficult to meet the demands of industrial real-time detection. In contrast, the one-stage architecture is represented by the YOLO [
12] series, SSD [
13], and Transformer [
14]-enhanced models, among others. These algorithms simultaneously perform object localization and classification via a unified network, significantly reducing computational complexity and making them better suited to the efficiency requirements of industrial scenarios [
15,
16].
However, existing deep learning-based methods for aluminum defect detection still face critical challenges. Firstly, current models exhibit insufficient capability in multi-scale defect detection. Aluminum defects vary widely in scale, ranging from micrometer-sized paint bubbles to centimeter-scale stains. Traditional single-stage detection models, which rely solely on fixed-size convolutional kernels, often have limited receptive fields within individual layers, making it difficult to simultaneously capture the fine details of extremely small defects and the global contours of larger ones within a single layer. To overcome this limitation, existing methods commonly adopt multi-scale feature fusion strategies such as multi-layer stacking, feature pyramids, dilated convolutions, or kernel pyramids, enabling single-stage network models to integrate both detailed and global information effectively. Although feature fusion structures like FPN [
17] and PANet [
18] attempt to alleviate this issue through multi-level feature interaction, FPN may weaken shallow small-defect features due to its unidirectional top-down pathway, while PANet alleviates this issue through bidirectional fusion at the cost of increased computational redundancy, which is unfavorable for lightweight industrial deployment.
Secondly, there is a low recognition rate for small defects against complex textured backgrounds. Moreover, in detection tasks, background noise formed by inherent textures on aluminum surfaces, such as brushed or frosted patterns, often interferes with the detection process. Existing attention mechanisms, such as SE [
19] and CBAM [
20], struggle to effectively focus on subtle small-defect signals, leading to a high rate of missed detections. While specialized techniques like passive acoustic tomography [
21] and dedicated visual artifact analysis [
22] have shown effectiveness in specific crack characterization tasks, their reliance on specialized sensors, intrusive setups, or customized calibration limits their scalability and generalizability for inline industrial inspection.Furthermore, it is challenging to balance model lightweighting with detection accuracy. Mainstream single-stage networks suffer from large parameter counts and high computational costs, making them difficult to deploy on embedded detection terminals or mobile inspection robots in industrial settings. Simply reducing parameters, however, tends to degrade detection accuracy significantly [
16].
To address the aforementioned challenges, this study proposes an improved aluminum defect detection network named BFI-YOLO, based on the YOLOv8n baseline model. Specifically, a Multi-Scale Residual Convolution (MSRConv) module is designed within the backbone network to enhance feature extraction. This module effectively reduces parameter count and computational load by leveraging depthwise separable convolutions, while simultaneously incorporating convolutional kernels of varying sizes to adapt to the multi-scale characteristics of surface defects in aluminum. Through residual connections, shallow-level detailed information is preserved, significantly improving the model’s ability to represent fine defects. Furthermore, a Bidirectional Multi-scale Feature Pyramid and the SimAM attention mechanism are introduced to address the insufficient multi-scale feature fusion in the original network while maintaining model lightweightness, thereby enhancing the detection accuracy of aluminum defects.
The main contributions of this study are as follows:
- (1)
We propose a lightweight bidirectional multi-scale fusion neck called BM-FPN that enhances cross-scale feature interaction and preserves fine-grained defect cues for small targets under complex textures.
- (2)
We introduce MSRConv as a building block for the feature extraction network. MSRConv adopts a dual-branch depthwise separable convolutional structure, reducing computational complexity while enhancing resistance to interference from complex aluminum textures. It also improves the efficiency of synergistic extraction of local details and global contextual features.
- (3)
Experimental validation is conducted on the public dataset TAPSDD. Compared to the baseline network, BFI-YOLO achieves significant improvements in detection accuracy while reducing parameter count and achieving greater lightweightness.
3. Method
As shown in
Figure 1, we propose an improved bidirectional multi-scale residual network based on YOLOv8 for aluminum surface defect detection. Specifically, we upgrade the PANet structure in the neck network layer to a BM-FPN structure to achieve multi-scale feature fusion and enhance the representation of small target information in deep features. To further improve the model’s feature extraction for small-scale aluminum defects, we introduce MSRConv into the backbone network. By combining depthwise separable convolution with a parallel design of multi-sized convolutional kernels, this module effectively captures defect features at different scales while reducing computational complexity, thereby significantly enhancing the model’s detection accuracy for small target defects.
3.1. BM-FPN
In aluminum defect detection tasks, multi-scale feature pyramids enhance the ability to identify minute defects by extracting and fusing features in parallel at different resolution levels, thereby capturing both fine-grained details and global information. However, traditional feature fusion networks often suffer from inefficient computational resource utilization, and interference from complex background textures with subtle defect features results in insufficient detection accuracy. To address these issues, we have designed BMFPN, a bidirectional multi-scale feature pyramid network. It strengthens feature interaction through bidirectional information flow and leverages SimAM to deeply capture the detailed textures on aluminum surfaces.
As shown in
Figure 2, the traditional FPN employs a top-down, unidirectional feature-propagation path (
Figure 2a), leading to the gradual loss of detailed features of underlying minor defects during hierarchical transmission. Although PANet introduces a bottom-up supplementary path (
Figure 2b), redundant node connections significantly increase the network’s computational load, thereby affecting detection efficiency. In
Figure 2c, BiFPN simplifies the bidirectional network by removing nodes with a single input edge. Since such nodes contribute minimally to feature fusion, this operation effectively reduces the network’s computational load without compromising its feature fusion performance or hindering the effective extraction of aluminum defect features. However, it still falls short in adequately representing minute features.
To enhance perception of subtle features, BM-FPN adapts the BiFPN structure by adding additional pathways between the original input nodes and the original output nodes residing on the same layer. This modification enables the fusion of more effective features from different hierarchical levels without significantly increasing computational costs.
Furthermore, unlike the traditional approach to feature fusion, which treats all input features equally, BM-FPN introduces learnable weights to determine the importance of different input features. By assigning weights to each input feature, BM-FPN can place greater emphasis on more informative features, thereby improving the accuracy and effectiveness of feature fusion. The weighted fusion formula Equation (
1) is as follows:
In the formula,
O denotes the fused feature, I represents the
Ii-th input feature, and
wi is the corresponding learnable weight. Since
wi may be a scalar or a vector, such an inconsistency can lead to unstable training results. Therefore, we employ weight normalization to constrain each weight’s value range. The final implementation is shown in Equation (
2):
where
, and the ReLU activation function is applied to each
wi, with
introduced to avoid numerical instability. Ultimately, each normalized weight falls within the range [0,1].
In aluminum defect detection, existing attention mechanisms, such as SE and CBAM, exhibit significant limitations in disentangling interference from complex surface textures and in enhancing the representation of subtle defect features. These mechanisms either focus solely on single-dimensional optimization or require additional parameters, making it difficult to precisely capture weak defect signals while also conflicting with lightweight objectives. To address this, this study integrates SimAM into the Bottleneck unit of the C2F module within BM-FPN, as illustrated in
Figure 3.
SimAM is a parameter-free, lightweight three-dimensional attention module. Unlike traditional attention mechanisms that focus solely on either channel or spatial dimensions, SimAM can simultaneously address both dimensions by assigning unique attention weights to each neuron, thereby forming a three-dimensional attention perception. The spatial inhibition phenomenon inspires its design in neuroscience, where an energy function is defined to quantify differences between neurons. Lower energy values indicate a higher information value of the neuron, enabling weight allocation that enhances defects and suppresses backgrounds. Specifically, neurons in defect regions are assigned higher weights due to their significant differences from the background, while those in textured background regions are suppressed.
SimAM operates without parameters, eliminating the need for additional convolutional or fully connected layers to learn parameters. This avoids model expansion and reduces training complexity. The importance of neuron information is quantified by the energy function, where lower energy values indicate a higher likelihood that the neuron contains effective defect information, corresponding to higher assigned attention weights. Its mathematical definition is shown in Equation (
3).
where
M is the total number of neurons in a single channel, i is the index of non-target neurons,
xi represents other neurons except the current one,
wt and
bt are linear transformation parameters, and
is the regularization constant. Through this function, SimAM can accurately identify defect regions and enhance their feature responses, effectively improving the detection rate of subtle defects. Intuitively, SimAM operates by comparing each neuron with its neighboring neurons. Neurons that exhibit substantial differences from their adjacent neurons, for example those located at defect edges or interior defect regions, are assigned higher attention weights. In contrast, neurons within homogeneous background regions are suppressed. This mechanism enables the model to automatically focus on anomaly regions without introducing additional learnable parameters. In this work, we assume that aluminum surface defects exhibit distinct intensity or structural differences from their backgrounds. The target defects are primarily small-to-medium in scale (>10 pixels), with regular surface textures considered as the main interference.
BM-FPN adopts structural optimization strategies, including bidirectional feature propagation, redundant node pruning, and the addition of supplementary connection pathways. Combined with a dynamic weighted fusion mechanism, it efficiently integrates multi-scale features while simplifying the network architecture and reducing computational costs. Integrated into this structure, the parameter-free three-dimensional attention mechanism, SimAM, is specifically designed for aluminum defect detection. It effectively isolates interference from complex background textures and enhances the representation of subtle defect features, thereby significantly improving the identification of small target defects. Through their synergistic interaction, BM-FPN and SimAM achieve efficient multi-scale feature integration, streamlined network architecture, and reduced computational overhead. Ultimately, this results in balanced improvements in both detection accuracy and inference efficiency, meeting the real-time detection requirements of industrial production lines.
3.2. MSRConv
To address the YOLOv8n base convolutional module’s insufficient feature extraction for detecting subtle defects in aluminum materials, we propose MSRConv. This module adopts a dual-branch structure and leverages depthwise separable convolution to enhance feature extraction efficiency. As illustrated in
Figure 4, in depthwise convolution each channel is convolved with a single filter, unlike traditional convolution, where each channel is convolved with all filters. This approach reduces both computational load and parameter count while improving the model’s efficiency and speed. Furthermore, the module collaboratively integrates max-pooling operations and residual connections, significantly enhancing the model’s ability to represent features of small targets.
As shown in
Figure 5, MSRConv adopts a parallel dual-branch architecture to achieve multi-scale feature extraction. The depthwise convolution branch with a kernel size of 3 × 3 utilizes a smaller receptive field to effectively focus on local detailed features, capturing fine-grained information such as edges and textures with precision. In contrast, the depthwise convolution branch with a kernel size of 5 × 5 leverages a larger receptive field to extract broader contextual information, thereby modeling long-range spatial dependencies. Through this parallel design with differentiated kernel sizes, the two branches complement each other effectively in feature extraction: the 3 × 3 branch excels at preserving detailed texture features of targets. In contrast, the 5 × 5 branch captures broader target information. This structure maintains high computational efficiency while achieving richer feature representations.
The output features of the two branches are concatenated and then enhanced through a max-pooling layer. Max-pooling further emphasizes locally salient small target features, enabling multi-scale feature extraction that helps capture targets of varying sizes. This approach ensures robust feature processing capabilities for diverse targets.
Finally, to preserve feature integrity and optimize gradient propagation, MSRConv incorporates a residual connection mechanism. This mechanism fuses the original input features with the processed features, effectively mitigating feature degradation issues in deep networks. The residual connection not only retains original feature information, preventing the loss of small target features in deep layers, but also significantly improves gradient flow, enhancing the training stability of the model.
The specific computational flow of MSRConv is shown in Equation (
4):
In the formula, X represents the input feature map of the module,
denotes the max-pooling operation,
represents the depthwise separable convolution operation,
indicates the convolution operation with a kernel size of
, and
indicates the convolution operation with a kernel size of
. The output is shown in Equation (
4):
MSRConv is specifically designed for detection scenarios where minute defects coexist with complex textures on aluminum surfaces, achieving a precise balance between fine-grained feature extraction and anti-interference requirements. By combining parallel multi-kernel depthwise convolutions with residual connections, MSRConv expands effective receptive fields while maintaining a lightweight design. Its applicability is precisely tailored to the deployment conditions of industrial edge devices, enabling efficient detection of minute defects under low computational overhead.
3.3. NWD
In aluminum defect detection tasks, small targets often exhibit limited edge information and blurred boundaries, making feature extraction challenging for models and leading to significant localization errors. To address this issue, this study introduces the Normalized Wasserstein Distance (NWD) into the regression loss function of the YOLOv8n model to measure the similarity between predicted bounding boxes and ground truth bounding boxes. Given a bounding box
, where
denotes the center coordinates and
h and
w denote height and width, respectively.The expression for the inscribed ellipse equation within the bounding box is shown in Equation (
5):
In the formula, represents the semi-axis length along the x-axis, represents the semi-axis length along the y-axis, and denotes the coordinates of the center point. Correspondingly, , , , .
Then, the bounding box is modeled as a two-dimensional Gaussian distribution
, where the parameter values of
and ∑ are shown in Equation (
6):
The Wasserstein distance between two two-dimensional Gaussian distributions
and
can be expressed as Equation (
7):
In the formula,
and
are mean vectors, ∑ is the covariance matrix, and
denotes the Frobenius norm. By combining the above formulas, the Wasserstein distance between the two-dimensional Gaussian distributions of bounding box
and bounding box
can be expressed as Equation (
8):
Then, normalization is performed using an exponential form to derive a new metric, NWD. The Equation is shown in (
9):
In the Equation, C is a constant. In the detection of small target defects on aluminum surfaces, NWD can better capture the geometric relationships between bounding boxes, particularly performing more effectively when there is minimal overlap between target boxes. Within complex defect backgrounds, NWD contributes to improving the precision of defect localization. CIOU primarily focuses on the overlapping regions of bounding boxes and incorporates constraints on center point distance and aspect ratio, thereby optimizing bounding box regression more effectively. During training, the CIOU loss function enables faster convergence and reduces the drift of predicted boxes. We have adopted a combined metric approach integrating NWD and CIOU, which helps comprehensively address the issue of bounding box overlap in object detection, thereby reducing sensitivity to positional deviations in small targets.
4. Experiments
4.1. Experimental Settings
The experimental environment consists of a Windows 11 64-bit operating system, with a hardware platform equipped with an NVIDIA GeForce RTX 4060 Laptop GPU and an Intel Core i9-14900HX processor. The software environment is based on Python 3.8, PyTorch 2.4.0 framework, and CUDA 12.4 drivers. All comparative experiments adopt uniform training parameters and data augmentation strategies: the initial learning rate is set to 0.01, momentum to 0.937, weight decay to 0.0005, training is conducted for 300 epochs, batch size is configured as 16, and the SGD optimizer is employed. The data augmentation strategy follows the default settings of YOLOv8, including Mosaic augmentation, MixUp augmentation, random geometric transformations, and HSV color space adjustments.All images are resized to 640 × 640, and FPS is tested on the aforementioned hardware platform.
4.2. Evaluation Metrics
To ensure a more precise evaluation of object detection performance, six fundamental metrics [
36] are introduced: P, R, mAP, Params, FPS, and GFLOPs. The specific calculation formulas for these metrics are as follows (Equations (
10)–(
13)):
In the formula, TP represents the number of samples correctly classified by the model; FP represents the number of samples incorrectly classified by the model; FN represents the number of samples missed by the model.
In the formula, AP measures the detection accuracy of the model for each category; K represents the total number of categories, and the mean is the average of the summed AP values across all categories.
mAP refers to the average precision of all targets detected by the model on the test set. A larger mAP value indicates higher detection accuracy. In this study, when the IoU threshold is set to 0.5, mAP@0.5 represents the mAP value under this threshold. A higher mAP@0.5 value indicates better detection performance for different types of target objects.
The number of parameters (Params) is a metric for evaluating model complexity. A smaller parameter count typically indicates a simpler model structure and faster processing speed.
FPS refers to the number of image frames the model can process per second. A higher FPS value indicates faster detection speed.
Computational complexity (GFLOPs) refers to the number of floating-point operations of the model, which is used to measure its computational efficiency.
4.3. Experimental Dataset
This study employs two datasets, namely TAPSDD [
37] and NEU-DET [
38]. The TAPSDD dataset consists of 6008 aluminum surface images. These images are divided into training, test, and validation sets with 4866, 601, and 541 samples respectively. The partition ratio is 8:1:1. All images are collected at a resolution of 2560 × 1920. This dataset covers ten defect categories, including non-conduct, scratch, orange peel, reveal, paint bubble, pit, flow, mottle, corner reveal, and dirty. It provides diverse surface textures including rolled, polished, and ground surfaces, as well as multiple lighting conditions including uniform illumination, directional lighting, and low-contrast environments. However, the dataset presents limited samples of tiny defects smaller than 10 pixels and contains no defect examples on curved surfaces. The original TAPSDD images have a high resolution of 2560 × 1920, which is much larger than the common input size of modern object detectors. In our experiments, all images are resized to 640 × 640 before being fed into the network. This operation maintains the relative scale of defects and enables efficient batch inference. For industrial deployment involving large-format images, a sliding window inference strategy can be adopted, in which the large image is split into overlapping 640 × 640 patches for independent detection and the results are merged afterward. Benefiting from its lightweight architecture with only 1.8 M parameters, BFI-YOLO supports real-time multi-patch processing on embedded devices, enabling reliable and efficient detection for large-scale images commonly encountered in industrial production lines. Example images of the TAPSDD dataset are illustrated in
Figure 6.
The NEU-DET dataset contains six types of steel surface defects, specifically crazing, inclusion, patches, pitted surface, rolled-in scale, and scratches. Each defect class includes 300 samples with an original image size of 200 × 200 pixels. This dataset is also split at a ratio of 8:1:1, generating 1440 training images, 180 test images, and 180 validation images.
4.4. Comparative Experiments
To evaluate the superiority of the BFI-YOLO model compared to existing algorithms, this study systematically compares it with current mainstream and representative detection models. The selected models for comparison encompass a variety of typical detectors, including single-stage, two-stage, and Transformer-based architectures. Specifically, the models include: SSD, YOLOv5s, YOLOv7, Faster-RCNN, DETR, RT-DETR, YOLOv8n, YOLOv10n, YOLOv11n, and YOLOv12n. These models each exhibit distinct characteristics in detection accuracy, inference speed, and architectural design, and all serve as widely applied backbone frameworks in practical scenarios such as industrial inspection. To comprehensively validate the generalization ability of the proposed method, experiments were conducted on two datasets: the TAPSDD dataset and the publicly available NEU-DET dataset. The NEU-DET dataset serves as an additional benchmark to assess model performance under different data distributions and surface defect scenarios, addressing the reviewer’s suggestion for broader validation. By conducting comparisons under a unified experimental environment, the applicability and comprehensive advantages of the proposed method in real-world tasks can be more objectively assessed.All experiments were repeated five times with different random seeds, and the average results are reported throughout this section. The comparison results are shown in
Table 1.
As shown in
Table 1, the BFI-YOLO model proposed in this study demonstrates superior comprehensive performance in aluminum defect detection tasks, exhibiting significant competitive advantages in detection precision, recall rate, and lightweight design. A detailed comparative analysis is outlined below:
Among mainstream comparative models, YOLO series models such as YOLOv5 and YOLOv8n hold certain performance advantages due to their mature feature fusion architectures. However, they still exhibit notable limitations: YOLOv5 relies on a unidirectional FPN structure, while YOLOv8n employs PANet for feature interaction. Both models suffer from fixed feature propagation pathways, which easily lead to information loss, especially for the detailed features of minor defects that tend to be diluted in deeper network layers, thereby constraining their detection performance. In contrast, BFI-YOLO achieves an mAP@0.5 of 92.1%, representing improvements of 4.6% over YOLOv5 and 4.2% over YOLOv8n. The recall rate is also optimized simultaneously, fully validating the multi-scale fusion advantages of BM-FPN.
DETR series models, such as DETR [
31], introduce Transformer encoder-decoder architectures and global attention mechanisms, eliminating the constraints of manually designed anchor boxes. However, DETR suffers from high computational complexity, slow convergence, and high demands on GPU memory and training data scale. RT-DETR [
32] further optimizes real-time performance but still lacks sensitivity to local subtle features. Preliminary experiments show that DETR and RT-DETR achieve mAP@0.5 values of 76.7% and 77.5%, respectively, both lower than BFI-YOLO. Additionally, their parameter counts and computational costs are significantly higher than BFI-YOLO, indicating a clear gap in comprehensive detection efficiency.
Both the C3 module in YOLOv5 and the C2f module in YOLOv8n are designed based on stacked standard convolutions, resulting in large parameter counts and limited receptive fields, making it difficult to balance detailed and global information. In contrast, the MSRConv module designed in this study integrates depthwise separable convolutions and dilated convolutions in parallel, reducing parameter counts while covering richer scale information, thereby successfully balancing detection efficiency and precision.
Compared to YOLOv11n and YOLOv12n, BFI-YOLO reduces the parameter count by 0.7 M, demonstrating better balance between lightweight design and detection precision. By combining the depthwise separable convolutions of MSRConv and the shared weight mechanism of BM-FPN, BFI-YOLO compresses the parameter count to an ultra-lightweight level of 1.8 M while maintaining a detection precision of 91.3%, significantly outperforming YOLOv11.
In summary, through the synergistic optimization of the BM-FPN and MSRConv modules, BFI-YOLO achieves the optimal balance between detection precision and efficiency under an ultra-light parameter count (1.8 M). Its comprehensive performance surpasses that of existing mainstream models, making it more suitable for deployment in industrial scenarios requiring real-time detection of aluminum defects.
On the newly introduced NEU-DET dataset, our method achieves 79.8% Precision, 78.5% Recall, and 78.4% mAP@0.5, consistently surpassing other detectors. Notably, YOLOv8n performs best among existing methods on NEU-DET with 75.3% mAP, while our method exceeds it by 3.1 percentage points. The results demonstrate that BFI-YOLO achieves 78.4% mAP@0.5 on NEU-DET, outperforming the best existing method by 3.1 percentage points while maintaining low parameters and high inference speed. This confirms the model’s strong effectiveness and generalization capability across different metal surface defect detection tasks.
To evaluate the lightweight advantage of BFI-YOLO, we select two representative lightweight backbone networks for comparison: the classic lightweight model MobileNetv3 and the recent extremely simple architecture VanillaNet. The experimental results are shown in
Table 2.
As shown in
Table 2, BFI-YOLO achieves 92.1% mAP@0.5, greatly surpassing MobileNetv3 and VanillaNet. Although these lightweight models have smaller model sizes, they suffer from severe accuracy degradation. Meanwhile, BFI-YOLO reduces parameters by 40% relative to the baseline and achieves the fastest inference speed of 243 FPS. These results demonstrate that BFI-YOLO achieves a more superior accuracy-efficiency trade-off than existing lightweight detectors.
4.5. Ablation Study
To validate the individual contributions and combined effects of each improved module on detection performance, we designed a series of ablation experiments. We incrementally introduced each module into the original YOLOv8 and analyzed its effectiveness through performance comparisons. The experiments used the original YOLOv8 as the baseline and separately incorporated the BM-FPN, MSRConv, and NWD modules. We maintained consistent training strategies and datasets, introducing only structural modifications to ensure the fairness of the experiments. The experimental results are shown in
Table 3.
The model with only BM-FPN introduced reduces the parameter count by 36.7% while increasing mAP@0.5 from 87.9% to 91.0%, with the recall rate improving by 2.6 percentage points. This indicates that BM-FPN significantly enhances the efficiency of multi-scale feature fusion by streamlining redundant connections and strengthening bidirectional feature interaction. It particularly aids in preserving and transmitting features of minute defects, laying a crucial foundation for model lightweighting and performance improvement.
The model with only MSRConv introduced achieves a 1.8% increase in mAP@0.5, a 2.1% rise in recall rate, and a 16.7% reduction in parameter count. This module enhances the model’s ability to represent features of defects of varying sizes through parallel multi-scale depthwise convolution and residual connections. Its lightweight structural design also contributes to optimizing overall computational efficiency.
After introducing NWD, the model achieves comprehensive, albeit modest, improvements in precision, recall rate, and mAP@0.5 without increasing any parameters or computational overhead. This validates the effectiveness of NWD in optimizing bounding box regression for small targets and mitigating scale sensitivity issues, providing an important foundation for localization optimization in subsequent multi-module collaboration.
The final model, which incorporates NWD loss on top of BM-FPN and MSRConv, effectively aligns the feature optimization directions of BM-FPN and MSRConv through the refined calculation of the NWD loss for bounding box regression. This fully leverages the synergistic benefits among the modules, achieving optimal levels in core metrics such as precision, recall rate, and mAP@0.5. Moreover, it maintains extremely low parameter count and computational cost, with only 1.8 M parameters-a 40% reduction compared to the baseline A0 ultimately achieving the best balance among detection accuracy, parameter count, and computational efficiency.
The above ablation results are visually presented in
Figure 7: Comparison of aluminum defect detection performance under different module configurations. As can be observed from
Figure 7, although the problem of missed detection has been resolved for some typical tiny and dirty defects, their confidence scores are still only around 0.3–0.4, which are significantly lower than those of defects with clear features and distinct contours. This phenomenon is mainly attributed to the low contrast between tiny defects and the complex aluminum surface texture, the lack of prominent and representative features of the defects themselves, as well as the interference from background noise and texture.
4.6. Heatmap Analysis
To more intuitively demonstrate the effectiveness of the improved model, we randomly selected four typical aluminum surface defect images from the test set of the dataset. We employed the Grad-CAM method to generate heatmaps [
38] and visualized them.
Figure 8 compares the heatmap visualization results of YOLOv8n and BFI-YOLO:
Figure 8 displays the heatmaps generated by the original YOLOv8n model and the BFI-YOLO model proposed in this study, revealing several typical detection challenges. The first category involves significant offsets in detection boxes, which directly lead to increased localization errors. The second category pertains to shallow defects, such as minor scratches, which produce almost no effective activation in the heatmaps, ultimately resulting in missed detections. The third category involves small targets in sparse scenes, where heatmap responses appear as weak and scattered peaks. The third category also includes missed detections of small targets, a problem that encompasses both feature attenuation caused by repeated downsampling in sparse scenes and the mutual interference of adjacent target features in dense scenes, where heatmap responses overlap and are erroneously merged or suppressed.
The primary cause of detection box offsets lies in the feature pyramid’s insufficient fusion of multi-scale information. In the original network, deep semantic features often overshadow shallow texture details, resulting in low-amplitude, discrete heatmap responses at defect edges. After threshold processing, detection boxes are prone to deviating from the true contours. To address this, this study introduces an optimized BiFPN structure integrated with the SimAM attention mechanism into the feature fusion pathway. This module achieves effective feature interaction across different scales through dynamic weighting, enhancing detailed information in deep networks and producing sharp, high-amplitude heatmap activations at defect edges. As a result, detection boxes can more closely align with the actual boundaries of defects.
Shallow features have limited receptive fields and low contrast, making them susceptible to suppression as noise during traditional convolution operations, leading to missed detections of shallow defects. To tackle this issue, the MSRConv module we designed constructs feature extraction branches with differentiated receptive fields. The dilated convolution expands the receptive field without adding extra parameters, while depthwise separable convolution enhances the efficiency of the response to subtle textures. After fusion via residual connections, the features of shallow defects are significantly enhanced, producing distinct bright patches in the corresponding heatmap regions, thereby effectively reducing the missed-detection rate for these defects.
For small target detection in sparse scenes, the gradual attenuation of features during repeated downsampling is a key factor leading to missed detections. To maintain sensitivity to tiny targets, our method retains high-resolution feature layers in the BiFPN structure. It leverages the multi-receptive field characteristics of the MSRConv module, enabling even extremely small targets to be fully represented on higher-resolution feature maps. The result is sharper, more concentrated, and higher-amplitude heatmap peaks at small target locations, allowing detection boxes to capture these targets accurately.
In dense scenes, missed detections of small targets primarily stem from feature interference between adjacent targets, manifested as overlapping heatmap responses. To address this, we further incorporate a self-attention mechanism based on cross-scale interactions in BiFPN, decoupling the features of adjacent targets to ensure each target obtains an independent activation region in the heatmap. Additionally, a weighted NWD-CIoU loss function is employed during the regression stage to balance the model’s sensitivity to positional errors, encouraging the network to focus more on learning overall shape matching rather than over-optimizing pixel-level offsets. This strategy significantly suppresses erroneous merging caused by boundary overlap, allowing the heatmap to clearly distinguish each small target even in dense areas, thereby substantially reducing the missed detection rate.
In summary, the synergistic effect of BiFPN’s dynamic weighted cross-scale fusion mechanism, MSRConv’s differentiated receptive field design, and the weighted NWD-CIOU regression strategy enables BFI-YOLO to achieve more concentrated response distributions, higher peak intensities, and lower background noise in heatmaps. The improvement in heatmap quality is directly reflected in enhanced detection performance: bounding boxes align more closely with defect boundaries, the recall rate for shallow defects is improved, and the detection completeness for small targets, whether sparsely or densely distributed, is significantly elevated. These experimental results validate the effectiveness of the bidirectional multi-scale residual network proposed in this study for industrial defect detection tasks.
4.7. Detection Performance Analysis
To more intuitively demonstrate the effectiveness of the improved model, we randomly selected representative surface defect images from the test set for each defect category-namely, Pit, Scratch, Paint Bubble, and Flow. The detection results of the original YOLOv8n and the enhanced BFI-YOLO proposed in this study are compared, as shown in
Figure 9.
The detection results demonstrate that the improved BFI-YOLO significantly outperforms the YOLOv8n baseline model, effectively addressing issues present in the baseline model for aluminum defect detection. The original input images preserve the true texture of the aluminum surface. Subsequently, the baseline model YOLOv8n detects the same images, revealing frequent missed detections or low confidence in subtle, low-contrast defects such as pits and paint bubbles. The detection boxes for scratches are overly large and exhibit positioning offsets, while flow marks suffer from fragmented detections. BFI-YOLO, which incorporates bidirectional multi-scale feature fusion, efficient local attention mechanisms, and a lightweight shared detection head, achieves significant improvements across all four defect categories: detection boxes for pits tightly adhere to defect edges, with confidence rising from approximately 0.5 to 0.6; repeated false detection boxes for scratches are effectively suppressed, with confidence increasing to 0.8; faint textures of paint bubbles are enhanced, transitioning from missed detection to effective identification; and detection confidence for flow marks improves from 0.8 to 0.9, with detection boxes fully covering defect regions and coverage completeness markedly enhanced. Overall, BFI-YOLO significantly surpasses the baseline model in three key metrics: detection completeness, localisation accuracy, and confidence. This validates that the proposed improvements in this study enable efficient, accurate detection of aluminum surface defects in industrial settings, meeting the stringent quality-control demands of production lines.
5. Limitation and Future Work
Compared to the current mainstream methods in the field of metal surface defect detection, BFI-YOLO achieves a comprehensive balance among detection accuracy, real-time performance, and model lightweighting, demonstrating significant competitiveness. However, this study still has certain limitations that need to be addressed: the scalability of the model has not been fully explored, as the experimental validation is primarily conducted on the TAPSDD dataset, which focuses on aluminum surface defects. Its generalization capability on larger-scale datasets and its adaptability to different types of defects on other materials, such as metals and composites, have yet to be thoroughly validated, which restricts its applicability in a broader range of industrial scenarios. It is worth mentioning that all datasets used in this study are publicly available datasets commonly adopted in the industry, and the improvement in detection accuracy is attributed to algorithmic enhancements. However, in practical metal surface defect detection tasks, detection accuracy is primarily influenced by the quantity and quality of datasets, which are, to a large extent, constrained by objective conditions such as lighting and viewing angles.
In future deployment efforts, we will focus on further research: integrating the proposed vision-based detection method with robotics technology, embedding the model into robotic inspection systems to expand its practical application scenarios and achieve automated, large-scale, and high-efficiency defect detection in industrial production, aligning with the Industry 4.0 development framework. Additionally, we will expand the dataset by incorporating more tiny defect samples smaller than 10 pixels and refine the feature extraction module to enhance its sensitivity to subtle defect features, thereby optimizing the model’s detection performance for extremely small defects and further improving detection accuracy for such cases.