A vehicle component surface defect detection method

By improving the YOLOv11 algorithm and combining the VDEMA attention mechanism and Focal Loss loss function, the problems of low efficiency and insufficient accuracy in the detection of surface defects of vehicle parts are solved, achieving high-precision and robust detection results, which are suitable for complex industrial scenarios.

CN122176398APending Publication Date: 2026-06-09JINLING INST OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JINLING INST OF TECH
Filing Date
2026-03-19
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing technologies are inefficient, susceptible to subjective factors, and lack sufficient detection accuracy in the detection of surface defects of vehicle parts. In particular, their generalization ability is limited under varying lighting conditions and complex backgrounds. Furthermore, algorithms such as YOLOv11 cannot effectively capture minute defects and suffer from class imbalance, resulting in a high rate of missed detections.

Method used

An improved YOLOv11 algorithm is adopted, which introduces the VDEMA attention mechanism and Focal Loss loss function. Through the feature pyramid network and dynamic upsampling module, the multi-scale feature capture capability is enhanced, the class imbalance problem is solved, and the detection accuracy and robustness are improved.

Benefits of technology

It significantly improves the accuracy and recall rate of surface defect detection for vehicle parts, reduces the false negative rate, and enhances the stability and real-time detection capability of the model in complex industrial environments, meeting the needs of high-speed and high-reliability production lines.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176398A_ABST
    Figure CN122176398A_ABST
Patent Text Reader

Abstract

A vehicle part surface defect detection method, a vehicle part surface defect dataset is made, the dataset is assigned to a training set, a validation set, a test set, the vehicle part surface defect attributes are labeled, the dataset is preprocessed to form a training sample for supervised learning; based on the improved YOLOv11 model, VDEMA attention mechanism is introduced and Focal Loss loss function is used instead of the original loss function; a vehicle part surface defect detection model is built, a dynamic upsampling or lightweight convolution module is embedded, back propagation and gradient descent are used to optimize the model parameters, the vehicle part surface defect dataset is trained, the features of the vehicle part surface defect are automatically learned to extract, and the vehicle part surface defect detection model weight is output; load the model weight, input the test set for reasoning, identify the category and position of the vehicle part surface defect, and quantitatively analyze the recognition effect of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of defect detection technology, specifically involving a YOLO11 algorithm, VDEMA attention mechanism, and Focal Loss loss function technique. Background Technology

[0002] Existing technologies for detecting surface defects in vehicle parts rely on manual visual inspection or machine vision systems based on traditional image processing. Manual inspection is inefficient, susceptible to subjective factors, and has high rates of missed and false detections, failing to meet the high-precision and high-efficiency inspection requirements of modern automotive production lines. Traditional machine vision systems, based on manually designed features such as edges, textures, and grayscale statistics, have limited generalization capabilities and insufficient feature representation under conditions of varying lighting, complex backgrounds, and diverse defect morphologies, thus limiting improvements in detection accuracy.

[0003] Existing deep learning-based detection methods include YOLOv3-tiny, YOLOv5, and YOLOv8. While these methods improve detection performance, they cannot capture the multi-scale features of minute defects. Furthermore, these methods cannot address the class imbalance problem caused by the uneven distribution of normal and defective component samples, leading to predictions that tend to favor normal samples, resulting in missed detections and low accuracy.

[0004] YOLOv11 is an improved object detection algorithm based on the YOLO series, developed by the Ultralytics team. It supports various computer vision tasks, including object detection, instance segmentation, image classification, pose estimation, and OBB (Object-Based Box) detection. Compared to its predecessor, YOLOv11 offers significant improvements in architecture, efficiency, and accuracy.

[0005] YOLO11 employs a deeply optimized cross-stage partial network variant of CSPNet as its backbone for efficient extraction of multi-level features. It utilizes modules such as the Fast Spatial Pyramid Pooling (SPPF) module to enhance the receptive field, effectively handling targets of varying scales, from large-scale texture anomalies to minute point defects. The model's backbone-neck-head structure is clear, with the neck integrating an optimized feature pyramid network (FPN) and a path aggregation network (PAN) fusion strategy. Bidirectional multi-scale feature fusion paths, both top-down and bottom-up, enable full interaction between deep semantic information and shallow localization information, providing a solid architectural foundation for detecting defects in vehicle parts with drastically varying sizes. It offers multiple preset configurations for different scales, flexibly balancing inference speed and detection accuracy, providing a high-performance starting point for the real-time requirements of industrial visual inspection.

[0006] The Focal Loss function improves upon the standard cross-entropy loss by introducing a modulating factor and a balancing factor. This reduces the contribution of easily classified samples to the total loss and increases the weight of difficult-to-classify samples to account for their scarcity. The mathematical expression is FL(p_t) = -α_t * (1 - p_t)^γ * log(p_t), where p_t is the model's predicted probability for each class, γ is the modulating factor (reducing the loss contribution of easily classified samples), and α_t is the balancing factor (adjusting the loss ratio between positive and negative samples).

[0007] When implementing the focus loss function, a sigmoid activation is applied to the model output, ensuring the predicted probability p_t lies within the [0,1] interval. The loss for each sample is calculated based on the true label and the predicted probability, with modulation and balancing factors applied. When the model is confident in its prediction of a sample (i.e., p_t is close to 1), the modulation factor reduces the loss contribution of that sample. When the model is unconfident in its prediction of a sample (i.e., p_t is small), the modulation factor increases the loss contribution of that sample. Since the number of positive samples is typically much smaller than the number of negative samples, α_t is adjusted to emphasize positive samples. Depending on the specific task and dataset, γ and α_t are adjusted to achieve the optimal training effect.

[0008] The VDEMA attention mechanism uses a weighted averaging approach to process the model's feature maps and extract feature information. Weight factors are introduced to adjust the importance of each location in the feature map, allowing the model to focus on key features. The feature map is divided into multiple sub-feature groups, employing a parallel sub-network structure to capture spatial information at different scales. For each sub-feature group, global information encoding and cross-dimensional interaction are used to recalibrate channel weights and capture pixel-level pairwise relationships. On multiple benchmark datasets, such as CIFAR-100, ImageNet-1k, and MS COCO, it outperforms traditional attention modules like CA and CBAM while maintaining computational efficiency. Summary of the Invention

[0009] This invention is based on the improved YOLO11 algorithm, introduces the EMA attention mechanism to enhance the ability to capture multi-scale features of small defects, and uses the Focal Loss loss function to optimize the original loss function, solving the problems of class imbalance and insufficient bounding box regression accuracy, thereby improving the detection efficiency of the model.

[0010] This invention proposes a method for detecting surface defects in vehicle parts. A dataset of surface defects in vehicle parts is created and allocated to training, validation, and test sets. The surface defect attributes are labeled, and the dataset is preprocessed to form training samples for supervised learning. Based on an improved YOLOv11 model, a VDEMA attention mechanism is introduced, and a Focal Loss loss function is used instead of the original loss function, allowing the model to focus on defect regions and alleviate the imbalance between positive and negative samples. A surface defect detection model for vehicle parts is built, embedding dynamic upsampling or lightweight convolutional modules to improve the detection capability for small defects or inference speed. Backpropagation and gradient descent are used to optimize model parameters. The model is trained on the surface defect dataset and automatically learns to extract features of surface defects in vehicle parts, outputting the weights of the surface defect detection model. The model weights are loaded and input into the test set for inference to identify the category and location of surface defects in vehicle parts. The confusion matrix, precision-recall curve, and F1 score are used as indicators to quantitatively analyze the model's recognition performance.

[0011] To create a dataset of surface defects for vehicle parts: images of surface defects of vehicle parts were collected, including those with varying lighting conditions, complex backgrounds, and defect morphologies. The images were standardized, and data augmentation techniques were used to expand data diversity and improve the model's generalization ability. The bounding boxes and categories of defects were labeled. The NEU-DET and GC10-DET datasets were used as the dataset for surface defects of vehicle parts, including multiple images containing defect types such as cracks, inclusions, spots, pitting, rolled-in oxide scale, and scratches.

[0012] The dataset is preprocessed by removing low-quality data samples, shuffling the image order, and dividing it into training, validation, and test sets in an 8:1:1 ratio to improve the model's generalization ability, balance the influence of samples, and improve training efficiency. Defect types are labeled using labelImg for subsequent model training and evaluation.

[0013] Based on the improved YOLOv11 model, the VDEMA attention mechanism is introduced and the Focal Loss loss function is used to replace the original loss function: The code for designing the VDEMA attention mechanism and the Focal Loss loss function is integrated into the core file of YOLOv11. The configuration file of YOLOv11 is modified and embedded into the detection head of the feature pyramid network of the model. The original binary cross-entropy loss function is replaced with the Focal Loss loss function. After the feature pyramid network completes multi-scale feature fusion, the VDEMA attention mechanism adaptively filters and enhances the fused high-level features, driving the detection network to allocate attention resources to regions in the image with minor defects.

[0014] Furthermore, the VDEMA attention mechanism employs channel grouping and dual-path fusion to enhance the model's ability to perceive and distinguish multi-scale features of surface defects on small vehicle parts. Based on parallel processing of feature maps, the input features are divided into two subgroups along the channel dimension. One group extracts local detail features through a 3×3 depth-separable convolutional layer, while the other group retains the global information of the original features through identity mapping. The two groups of features are fused across paths, and residual connections are used to maintain gradient flow.

[0015] The VDEMA attention mechanism outputs from the SPPF layer, constructs a multi-branch structure, recalibrates spatial weights, focuses on potential defect areas in the image, dynamically adjusts weights along the channel dimension, adaptively enhances key feature responses, and suppresses background noise and irrelevant information interference.

[0016] Furthermore, the Focal Loss function dynamically adjusts sample weights during training, reducing the weight of simple negative samples and causing the model to focus on samples that are difficult to classify. This is achieved using the formula... Let p represent the cross-entropy loss function, where p represents the probability of predicting a sample as 1, and y represents the label, which corresponds to [0,1] in binary classification. The Focal Loss function is expressed by the formula... The formula is denoted as α, where α represents the balancing factor and γ represents the adjustment factor. When the model predicts a sample with a high probability and it is easy to classify, the Focal Loss function reduces the weight of that sample. When the model predicts a sample with a low probability and it is difficult to classify, the Focal Loss function increases the weight of that sample, so that the model focuses on learning the defective features that are difficult to classify.

[0017] Output vehicle component surface defect detection model weights: monitor loss curve, accuracy, and recall, adjust parameters based on validation set performance to prevent overfitting, introduce focusing parameters and balancing factors to dynamically adjust the contribution of each sample to the loss, reduce the loss weight of a large number of easily classified background samples, increase the loss weight of difficult-to-classify defect samples, and enable the model to focus on learning a few key defect features during training.

[0018] Identify the type and location of surface defects on vehicle parts: Use PyCharm to build a YOLOv11 model, use an improved YOLOv11 model to extract features from the surface defect images of vehicle parts, train iteratively multiple times to obtain the weight file of the surface defect detection model for vehicle parts, iteratively update the feature weights, and evaluate the model based on the validation set.

[0019] The number of normal and defective samples in vehicle component defect detection tasks is severely imbalanced, with normal component samples far outnumbering defective samples. Traditional cross-entropy loss functions cause model training to favor the background class, correctly classifying most qualified products while under-learning the few defective component samples, leading to a high false negative rate. This invention addresses the learning bias that may occur when training YOLO11 with tens of thousands of normal samples and hundreds of defective samples by replacing the original classification loss function of YOLO11 with the FocalLoss loss function, adjusting the loss calculation method. This guides the YOLO11 model to focus on learning difficult examples and minority class defects during training, optimizing the learning objective of YOLO11. It dynamically reduces the loss weight of easily classified background samples during training, focusing model training on difficult-to-classify defect samples, improving the model's sensitivity and accuracy in identifying rare defect classes. This solves the model training bias problem caused by extreme sample imbalance, improving the model's recall and detection accuracy for rare defect classes such as cracks and scratches.

[0020] YOLO11 is a general-purpose detection framework, not specifically designed for industrial detection of extreme class imbalances and minute, low-contrast defects. This invention does not directly apply YOLO11, but rather, based on an efficient and robust architecture, embeds a VDEMA attention module in the "neck" or "head" of YOLO11. This module acts on the multi-scale fusion features of YOLO11, essentially equipping the model with a smart spotlight. It dynamically focuses on key regions of the feature map that may contain minute, blurry defects, enhancing YOLO11's feature extraction and fusion capabilities and strengthening its internal perception.

[0021] Vehicle component surface defects are small in size, have low contrast with the background, and vary in shape. In complex industrial environments, general target detection frameworks struggle to effectively capture and distinguish weak defect signals from complex background noise. This invention introduces an improved VDEMA attention mechanism into the core feature fusion layer of the YOLO11 model, enhancing the model's ability to perceive and focus on multi-scale defect features, especially small defects, and improving feature capture and discrimination capabilities. The input feature map is divided into two independent subgroups along the channel dimension and processed in parallel. One subgroup is processed through a 3×3 depthwise separable convolutional layer, efficiently extracting fine local features and spatial context information of defects with low computational cost, capturing edge and texture details of defects such as scratches and cracks. The other subgroup is directly passed through an identity mapping, fully preserving the global information and original semantics of the input features, preventing the loss of the overall structure and positional information of the target when focusing on local details. The feature maps output from the two paths are fused using element-wise addition. Cross-path fusion of local details and global information enables the model to take into account both the microscopic morphology of defects and the macroscopic context, thereby improving the feature representation capability of low-contrast, small-scale targets.

[0022] After feature fusion, the VDEMA attention mechanism module generates a spatially and channel-adaptive attention weight map through a lightweight gating unit, recalibrating features, strengthening feature channel responses related to potential defect regions, and suppressing noise interference from cluttered backgrounds or irrelevant regions. Integration with the backbone network via residual connections enables smooth gradient propagation during training without increasing model complexity, significantly improving performance.

[0023] Real-world industrial inspection environments are subject to interference factors such as uneven lighting, component reflections, and complex background textures. Existing feature representation technologies are easily affected by these factors, resulting in decreased generalization ability, false detections in variable scenarios, and low detection stability. This invention, based on the high-efficiency, high-precision YOLO11 model, employs the VDEMA attention mechanism and Focal Loss loss function to maintain real-time inference speed and improve model stability and detection accuracy under non-ideal conditions. It addresses the issues of insufficient robustness and real-time detection capability of the model in complex industrial scenarios, meeting the high-speed, high-reliability inspection requirements of production lines.

[0024] This invention inherits the high efficiency and high precision of YOLO11. Through the orderly combination and synergistic optimization of three key technologies, it endows the system with stronger environmental robustness, solves the shortcomings of existing methods in terms of accuracy, robustness and practicality, and achieves a dual leap in detection accuracy and stability in variable and harsh industrial environments. It provides an innovative technical method for building a highly reliable and efficient intelligent system for detecting surface defects in vehicle parts. Attached Figure Description

[0025] Figure 1 This is the algorithm flowchart.

[0026] Figure 2 This is a structural diagram of the VDEMA attention mechanism.

[0027] Figure 3 This is a diagram of the improved YOLOv11 model structure. Detailed Implementation

[0028] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings.

[0029] The process of surface defect detection method for vehicle parts is as follows: Figure 1As shown, a dataset of surface defects in vehicle parts was created, and the dataset was allocated to training, validation, and test sets. The surface defect attributes of the vehicle parts were labeled, and the dataset was preprocessed to form training samples for supervised learning. Based on the improved YOLOv11 model, a VDEMA attention mechanism was introduced, and the Focal Loss loss function was used instead of the original loss function, allowing the model to focus on defect regions and alleviate the imbalance between positive and negative samples. A vehicle part surface defect detection model was built, embedding dynamic upsampling or lightweight convolutional modules to improve the detection capability of small defects or inference speed. Backpropagation and gradient descent were used to optimize the model parameters, and the model was trained on the vehicle part surface defect dataset. The model automatically learned to extract features of vehicle part surface defects and output the weights of the vehicle part surface defect detection model. The model weights were loaded, input into the test set for inference, and the categories and locations of vehicle part surface defects were identified. The confusion matrix, precision-recall curve, and F1 score were used as indicators to quantitatively analyze the model's recognition performance.

[0030] To create a dataset of surface defects for vehicle parts: images of surface defects of vehicle parts were collected, including those with varying lighting conditions, complex backgrounds, and defect morphologies. The images were standardized, and data augmentation techniques were used to expand data diversity and improve the model's generalization ability. The bounding boxes and categories of defects were labeled. The NEU-DET and GC10-DET datasets were used as the dataset for surface defects of vehicle parts, consisting of 5370 images including defects such as cracks, inclusions, spots, pitting, rolled-in oxide scale, and scratches.

[0031] The dataset is preprocessed by removing low-quality data samples, shuffling the image order, and dividing it into training, validation, and test sets in an 8:1:1 ratio to improve the model's generalization ability, balance the influence of samples, and improve training efficiency. Defect types are labeled using labelImg for subsequent model training and evaluation.

[0032] Based on the improved YOLOv11 model, the VDEMA attention mechanism is introduced and the Focal Loss loss function is used to replace the original loss function: The code for designing the VDEMA attention mechanism and the Focal Loss loss function is integrated into the core files of YOLOv11. The yolo11.yaml configuration file of YOLOv11 is modified to embed the detection head of the feature pyramid network of the model. In train.py, the original binary cross-entropy loss function is replaced with the Focal Loss loss function.

[0033] After the feature pyramid network completes multi-scale feature fusion, the VDEMA attention mechanism adaptively filters and enhances the fused high-level features, driving the detection network to accurately allocate attention resources to areas in the image with minute defects. This solves the problem of high false negative rate of minute defects in complex industrial scenarios, enabling the model to achieve stable improvements in comprehensive evaluation metrics such as mAP50 and mAP50-95.

[0034] The VDEMA attention mechanism employs channel grouping and dual-path fusion to enhance the model's ability to perceive and distinguish multi-scale features of surface defects on minute vehicle parts. It utilizes parallel processing based on feature map grouping. The input features are divided into two subgroups along the channel dimension. One subgroup extracts local detail features through a 3×3 depthwise separable convolutional layer, while the other subgroup retains global information from the original features through an identity mapping. The two subgroups are then fused across paths, reducing the number of parameters while using residual connections to maintain gradient flow, thus balancing the model's computational efficiency and expressive power.

[0035] The structure of the VDEMA attention mechanism is as follows: Figure 2 As shown, a multi-branch structure is constructed in the SPPF layer output, and spatial weight recalibration is adopted to focus on potential defect areas in the image. It is suitable for enhancing the extraction of low-contrast targets such as fine scratches and pores. Dynamic weight adjustment is performed in the channel dimension to adaptively enhance the response of key features, suppress background noise and irrelevant information interference, and improve the detection robustness and localization accuracy in complex scenes.

[0036] In vehicle component defect detection tasks, the ratio of normal component samples to defective component samples is unbalanced. Models trained using the traditional cross-entropy loss function tend to predict all samples as normal. To address this, the Focal Loss function is employed, dynamically adjusting sample weights during training to reduce the weight of simple negative samples, thus focusing the model on samples that are difficult to classify.

[0037] The cross-entropy loss function is expressed by the formula. Let p represent the probability that the predicted sample belongs to 1, and y represent the label, which corresponds to [0,1] in binary classification. The Focal Loss function is expressed by the formula... It is represented by α, where α represents the balance factor and γ represents the regulation factor.

[0038] When the model predicts a high probability for a sample, meaning the sample is easy to classify, the Focal Loss function reduces the weight of that sample. Conversely, when the model predicts a low probability for a sample, meaning the sample is difficult to classify, the Focal Loss function increases the weight of that sample, prompting the model to focus on learning the difficult-to-classify features.

[0039] Output vehicle component surface defect detection model weights: monitor loss curve, accuracy, and recall, adjust parameters based on validation set performance to prevent overfitting, introduce focusing parameters and balance factors to dynamically adjust the contribution of each sample to the loss, reduce the loss weight of a large number of easily classified background samples, increase the loss weight of difficult-to-classify defect samples, so that the model focuses on learning a few key defect features during training and corrects the learning bias caused by sample imbalance.

[0040] Identifying the type and location of surface defects on vehicle parts: A YOLOv11 model was built using PyCharm. An improved YOLOv11 model was used to extract features from images of surface defects on vehicle parts. Multiple iterations of training were performed to obtain the weight file for the vehicle part surface defect detection model. The feature weights were iteratively updated, and the model was evaluated using a validation set. The network structure is as follows: Figure 3 As shown.

[0041] The mainstream target detection models were selected as the comparison benchmark, including seven types: YOLOv3-tiny, YOLOv5, YOLOv6, YOLOv8, YOLOv9, YOLOv10, and YOLO11. The performance of these models was compared with the improved YOLO11 vehicle component surface defect detection model of this invention, as shown in the table below.

[0042]

[0043] The above experimental results confirm the superiority of this invention in the detection of surface defects in vehicle parts. In terms of accuracy, it achieves performance improvements of 9.3%, 7.7%, 7.3%, 4.4%, 4.1%, 3.6%, and 2.4% compared to YOLOv3-tiny, YOLOv5, YOLOv6, YOLOv8, YOLOv9s, YOLOv10s, and YOLO11, respectively. In terms of recall rate, it improves by 9.9%, 7.9%, 7.4%, 3.7%, 3.3%, 2.7%, and 1.1%, respectively. The mAP50 index improves by 13.3%, 11.7%, 5%, 3.5%, 2.7%, 2.8%, and 1.7%, respectively, and the mAP50-95 index improves by 8.2%, 6.8%, 5.3%, 3.9%, 2.6%, 2.0%, and 0.4%, respectively.

[0044] Compared with YOLOv11 and its separate addition of the VDEMA attention machine Focal Loss loss function, this invention improves precision by 2.4%, 0.8%, and 2.0%, respectively; recall by 1.1%, 0.6%, and 0.8%, respectively; mAP50 index by 1.7%, 0.3%, and 1.5%, respectively; and mAP50-95 index by 0.4%, 0.3%, and 0.9%, respectively. It is applicable to vehicle component surface defect datasets, as shown in the table below.

[0045]

[0046] By embedding the VDEMA attention mechanism in front of the detection head of the YOLO11 model feature pyramid network, the fused features from different scales are adaptively recalibrated, automatically enhancing the response of feature channels and spatial locations related to potential defect areas, effectively suppressing noise interference from complex backgrounds, and significantly improving the model's perception sensitivity and feature discrimination for targets such as fine scratches and micropores.

[0047] By replacing the original binary cross-entropy loss function of YOLO11 with the Focal Loss function, the model can focus more attention on learning a few key defect features during training. This fundamentally corrects the learning bias caused by sample imbalance, effectively improves the model's recall rate for defect categories, and reduces the risk of missed detections.

[0048] We constructed and validated a model robustness enhancement paradigm for open industrial scenarios. We built a hybrid dataset that integrates multiple light sources, multiple angles, and multiple backgrounds, and designed validation experiments that include degradation scenarios such as illumination changes and background interference. This provides a reproducible methodological paradigm for the robustness evaluation and enhancement of YOLO series models in real and open industrial environments.

[0049] The above are embodiments of the present invention and do not limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention are included within the protection scope of the present invention.

Claims

1. A method for detecting surface defects in vehicle parts, characterized in that, include: A dataset of surface defects of vehicle parts is created, and the dataset is allocated to training, validation and test sets. The surface defect attributes of vehicle parts are labeled, and the dataset is preprocessed to form training samples for supervised learning. Based on the improved YOLOv11 model, a VDEMA attention mechanism is introduced and the Focal Loss loss function is used to replace the original loss function, so that the model focuses on the defect region and alleviates the imbalance between positive and negative samples. A vehicle component surface defect detection model is built, embedding dynamic upsampling or lightweight convolution modules to improve the detection capability of small defects or inference speed. Backpropagation and gradient descent are used to optimize the model parameters, train the vehicle component surface defect dataset, automatically learn to extract the features of vehicle component surface defects, and output the weights of the vehicle component surface defect detection model. The model weights are loaded and input into the test set for inference to identify the category and location of surface defects on vehicle parts. The confusion matrix, precision-recall curve, and F1 score are used as indicators to quantitatively analyze the model's recognition performance.

2. The method for detecting surface defects of vehicle parts according to claim 1, characterized in that, The process of creating the vehicle component surface defect dataset includes: collecting images of vehicle component surface defects, including those with varying lighting conditions, complex backgrounds, and defect morphologies; standardizing the images; using data augmentation techniques to expand data diversity and improve model generalization ability; labeling the bounding boxes and categories of defects; and using the NEU-DET and GC10-DET datasets as the vehicle component surface defect dataset, which includes multiple images containing defect types such as cracks, inclusions, spots, pitting, rolled-in oxide scale, and scratches.

3. The method for detecting surface defects of vehicle parts according to claim 1, characterized in that, The preprocessing of the dataset includes: removing low-quality data samples, shuffling the image order, dividing it into training, validation, and test sets in an 8:1:1 ratio to improve the model's generalization ability, balance the influence of samples, improve training efficiency, and using labelImg to label defect types for subsequent model training and evaluation.

4. The method for detecting surface defects of vehicle parts according to claim 1, characterized in that, The improved YOLOv11 model introduces the VDEMA attention mechanism and replaces the original loss function with the Focal Loss loss function. This includes: designing the code for the VDEMA attention mechanism and the Focal Loss loss function, integrating it into the core files of YOLOv11, modifying the YOLOv11 configuration file, embedding it into the detection head of the model's feature pyramid network, replacing the original binary cross-entropy loss function with the Focal Loss loss function, and after the feature pyramid network completes multi-scale feature fusion, the VDEMA attention mechanism adaptively filters and enhances the fused high-level features, driving the detection network to allocate attention resources to regions in the image with minor defects.

5. The method for detecting surface defects of vehicle parts according to claim 1, characterized in that, The output vehicle component surface defect detection model weights include: monitoring loss curves, accuracy, and recall; adjusting parameters based on validation set performance to prevent overfitting; introducing focusing parameters and balancing factors to dynamically adjust the contribution of each sample to the loss; reducing the loss weight of a large number of easily classified background samples; increasing the loss weight of difficult-to-classify defect samples; and enabling the model to focus on learning a few key defect features during training.

6. The method for detecting surface defects of vehicle parts according to claim 1, characterized in that, The process of identifying the type and location of surface defects on vehicle parts includes: building a YOLOv11 model using PyCharm, extracting features from the surface defect images of vehicle parts using an improved YOLOv11 model, iterating through the training multiple times to obtain a weight file for the surface defect detection model of vehicle parts, iteratively updating the feature weights, and evaluating the model based on the validation set.

7. The method for detecting surface defects of vehicle parts according to claim 4, characterized in that, The VDEMA attention mechanism employs channel grouping and dual-path fusion to enhance the model's ability to perceive and distinguish multi-scale features of surface defects on small vehicle parts. Based on parallel processing of feature maps, the input features are divided into two subgroups along the channel dimension. One group extracts local detail features through a 3×3 depth-separable convolutional layer, while the other group retains the global information of the original features through identity mapping. The two groups of features are fused across paths, and residual connections are used to maintain gradient flow.

8. The method for detecting surface defects of vehicle parts according to claim 4, characterized in that, The VDEMA attention mechanism outputs at the SPPF layer, constructs a multi-branch structure, recalibrates spatial weights, focuses on potential defect areas in the image, dynamically adjusts weights in the channel dimension, adaptively enhances key feature responses, and suppresses background noise and irrelevant information interference.

9. The method for detecting surface defects of vehicle parts according to claim 4, characterized in that, The Focal Loss function dynamically adjusts sample weights during training, reducing the weight of simple negative samples and causing the model to focus on samples that are difficult to classify. This is achieved using the formula... Let p represent the cross-entropy loss function, where p represents the probability of predicting a sample as 1, and y represents the label, which corresponds to [0,1] in binary classification. The Focal Loss function is expressed by the formula... The formula is denoted as α, where α represents the balancing factor and γ represents the adjustment factor. When the model predicts a sample with a high probability and it is easy to classify, the Focal Loss function reduces the weight of that sample. When the model predicts a sample with a low probability and it is difficult to classify, the Focal Loss function increases the weight of that sample, so that the model focuses on learning the defective features that are difficult to classify.