A method and system for detecting surface defects in battery cover plates based on an improved YOLOv8

By improving the feature enhancement module and loss function of the YOLOv8 model, the problems of missed detection and false detection in the detection of surface defects of battery cover plates were solved, and higher detection accuracy and positioning stability were achieved.

CN123118467APending Publication Date: 2026-11-17NANJING UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611175200.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-04
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

The existing YOLOv8 model has insufficient sensitivity to small-scale, low-contrast, and weak-edge defects in the detection of surface defects on battery cover plates. It is difficult to distinguish between real defects and surface processing textures and reflective interference. In addition, the positioning is unstable, resulting in a high rate of missed detections and false detections.

Method used

We employ the WED-C2f wavelet-edge dual-domain feature enhancement module, the DBSPPF dual-branch decoupled spatial pyramid pooling module, the SCA-BiFPN multi-scale feature fusion structure, and the WIoU v3-NWD composite bounding box regression loss function to enhance the feature representation capability of battery cover surface defects and improve detection accuracy and positioning stability.

Benefits of technology

It improves the accuracy and recall rate of surface defect detection for battery cover plates, reduces the false detection rate, enhances the ability to express the features of small-scale, low-contrast, and weak-edge defects, and improves the accuracy and robustness of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123118467A_ABST
    Figure CN123118467A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for detecting surface defects on battery cover plates based on an improved YOLOv8. Specifically, it includes: acquiring battery cover plate surface images and performing preprocessing and defect annotation to construct a defect dataset; constructing an improved detection model based on YOLOv8, wherein the improved detection model includes a WED-C2f wavelet-edge dual-domain feature enhancement module, a DBSPPF dual-branch decoupled spatial pyramid pooling module, and an SCA-BiFPN multi-scale feature fusion structure in the neck network, and is trained using the WIoU v3-NWD composite bounding box regression loss function; using the trained model to detect defects in the image to be detected, and outputting the defect category, confidence level, and bounding box coordinates. This invention enhances the model's feature representation ability for small-scale, low-contrast, weak-edge, and irregular battery cover plate surface defects, improves defect detection accuracy and localization stability, and is applicable to image, batch image, video, and real-time camera detection scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of industrial machine vision and deep learning target detection technology, specifically relating to a method and system for detecting surface defects on battery cover plates based on an improved YOLOv8. Background Technology

[0002] The battery cover is a critical structural component of a power battery, and its surface quality directly affects the battery's sealing performance, insulation performance, and overall lifespan. During the stamping, surface treatment, terminal assembly, and transportation processes of the battery cover, various surface defects such as scratches, dents, dents, dirt, and terminal damage are inevitably generated. If these defects are not detected in time, they can lead to serious safety hazards such as leakage, short circuits, and even thermal runaway during subsequent charging and discharging.

[0003] Currently, defect detection on battery cover surfaces mainly relies on manual visual inspection and traditional machine vision methods. Manual visual inspection suffers from low efficiency, high false negative rates, inconsistent inspection standards, and operator fatigue, making it difficult to meet the speed and accuracy requirements of large-scale industrial production. Traditional machine vision methods typically employ image preprocessing combined with manually designed features (such as edge detection, morphological processing, and threshold segmentation) for defect identification. However, battery cover surfaces have a highly reflective metallic texture and complex processing patterns, and different defect types vary significantly in shape, size, and contrast. Traditional methods struggle to simultaneously handle the detection performance of multiple defect types, especially for minor scratches, low-contrast pits, and weak edge damage, leading to frequent false negatives and false negatives.

[0004] In recent years, deep learning-based target detection methods, especially the YOLO series of target detection algorithms, have gained widespread attention and application in the field of industrial defect detection. However, the standard YOLOv8 model still has the following shortcomings when facing the task of detecting defects on the surface of battery cover: (1) The C2f module of the backbone network of the standard YOLOv8 extracts spatial domain features based on ordinary convolution, which is not sensitive enough to defects with low contrast, weak edges and irregular shapes. Small-scale defects are easy to lose detailed information due to downsampling in deep networks; (2) The spatial pyramid pooling module of the standard YOLOv8 only captures contextual semantic features through multi-scale max pooling, and lacks explicit modeling of local texture details, making it difficult for the model to distinguish between real defects and surface processing textures and reflective interference; (3) The PAN-FPN feature fusion structure of the neck network of the standard YOLOv8 simply adds or splices the features of each layer, without considering the different contributions of features of different scales to the detection task, and is not capable of expressing the feature continuity of directional defects such as thin scratches; (4) The CIoU bounding box regression loss function of the standard YOLOv8 is too sensitive to the localization of small targets, and pixel-level offset may lead to significant localization errors.

[0005] Therefore, it is necessary to develop a method for detecting surface defects on battery cover plates that can enhance the model's ability to represent features of small-scale, low-contrast, and weak-edge defects, thereby improving defect detection accuracy and positioning stability. Summary of the Invention

[0006] The purpose of this invention is to provide a method and system for detecting surface defects of battery cover plates based on an improved YOLOv8, in order to solve the problems of missed detection, false detection and unstable positioning of existing detection methods in scenarios with small scale, low contrast, weak edges, blurred boundaries and complex background interference, and to improve the detection accuracy, recall rate and positioning stability of surface defects of battery cover plates.

[0007] The technical solution to achieve the purpose of this invention is: a method for detecting surface defects in battery cover plates based on an improved YOLOv8, comprising:

[0008] Step S1: Obtain a surface image of the battery cover plate, and perform preprocessing, data augmentation, and defect annotation on the surface image of the battery cover plate to form a battery cover plate surface defect dataset.

[0009] Step S2: Construct a battery cover surface defect detection model based on YOLOv8. The battery cover surface defect detection model includes a backbone network, a neck network, and a detection head.

[0010] Step S3: Replace at least one C2f module in the backbone network with a WED-C2f wavelet-edge dual-domain feature enhancement module to jointly enhance the surface defect features of the battery cover in the spatial domain, frequency domain and edge domain.

[0011] Step S4: Replace the spatial pyramid pooling module in YOLOv8 with the DBSPPF dual-branch decoupled spatial pyramid pooling module, so as to extract global contextual semantic features and local texture detail features through multi-scale pooling branches and depthwise separable convolution branches respectively.

[0012] Step S5: Replace the original PAN-FPN feature fusion structure in the YOLOv8 neck network with the SCA-BiFPN multi-scale feature fusion structure to perform bidirectional weighted fusion of features at different scales, and enhance directional defect features through strip contextual attention.

[0013] Step S6: Construct the WIoU v3-NWD composite bounding box regression loss function, which includes the WIoU v3 loss term and the NWD loss term;

[0014] Step S7: Using the battery cover surface defect dataset, and based on the WIoU v3-NWD composite bounding box regression loss function, train the battery cover surface defect detection model to obtain the trained detection model.

[0015] Step S8: Input the surface image of the battery cover to be detected, video frame, or real-time image from the camera into the trained detection model, and output the defect category, confidence level, and bounding box coordinates.

[0016] Step S9: Generate detection results based on the defect category, confidence level, and bounding box coordinates, and display and save the detection results.

[0017] Further, in step S1, the defect categories in the battery cover surface defect dataset include at least one of scratches, dents, bumps, dirt, and terminal damage; the defect annotation includes annotating the defect category and the bounding box position of the defect in the image.

[0018] In step S1, the preprocessing includes at least one of image size adjustment, image format conversion, noise suppression, brightness adjustment, contrast adjustment, and normalization; the data augmentation includes at least one of horizontal flipping, vertical flipping, rotation, cropping, brightness perturbation, contrast perturbation, color perturbation, noise addition, and scaling.

[0019] Furthermore, in step S3, the WED-C2f wavelet-edge dual-domain feature enhancement module includes a channel adjustment layer, a spatial feature branch, a wavelet feature branch, an edge enhancement branch, and a feature fusion layer;

[0020] The channel adjustment layer is used to perform 1×1 convolution channel adjustment on the input feature X to obtain the adjusted feature X′.

[0021] The spatial feature branch is used to extract the spatial structure information of the adjusted feature X′ based on the C2f structure;

[0022] The wavelet feature branch decomposes the adjusted feature X′ into low-frequency components, horizontal high-frequency components, vertical high-frequency components, and diagonal high-frequency components, and performs convolution mapping on at least one of the horizontal high-frequency components, vertical high-frequency components, and diagonal high-frequency components; the edge convolution kernel is a Sobel convolution kernel, which is set to fixed parameters during training and does not participate in backpropagation updates;

[0023] The edge enhancement branch is used to extract the edge response of the adjusted feature X′ through the edge convolution kernel, and to map the edge response to the fusion feature space through learnable convolution;

[0024] The feature fusion layer is used to concatenate the spatial structure information, frequency domain high-frequency detail features and edge response features in the channel dimension, and fuse them through convolution to obtain the output features of the WED-C2f wavelet-edge dual-domain feature enhancement module.

[0025] The WED-C2f wavelet-edge dual-domain feature enhancement module is set in the P2 and P3 stages of the YOLOv8 backbone network; the number of output channels of the wavelet feature branch and the edge enhancement branch is less than the number of output channels of the spatial feature branch.

[0026] Further, in step S4, the DBSPPF dual-branch decoupled spatial pyramid pooling module includes a multi-scale pooling main branch, a depthwise separable convolution auxiliary branch, and a fused output layer;

[0027] The multi-scale pooling main branch is used to extract contextual semantic features under different receptive fields through continuous or parallel multi-scale pooling operations.

[0028] The depthwise separable convolution auxiliary branch is used to extract local texture detail features without reducing the feature map spatial resolution; the depthwise separable convolution auxiliary branch includes at least two cascaded depthwise separable convolution modules, and residual fusion connections are set between the depthwise separable convolution modules; the depthwise separable convolution module includes channel-wise depthwise convolution and 1×1 pointwise convolution;

[0029] The fusion output layer is used to perform channel fusion of the contextual semantic features and the local texture detail features to obtain context-enhanced features.

[0030] Furthermore, in step S5, the SCA-BiFPN multi-scale feature fusion structure includes a top-down feature fusion path, a bottom-up feature fusion path, same-scale lateral skip connections, and a fast normalization fusion unit.

[0031] The fast normalization fusion unit is used to assign learnable non-negative weights to features of different scales input to the same fusion node, and to perform weighted fusion after normalizing the learnable non-negative weights.

[0032] The SCA-BiFPN multi-scale feature fusion structure also includes a CAA strip context attention module; the CAA strip context attention module is used to aggregate strip context information along at least one of the horizontal and vertical directions, and apply the aggregated attention weights to the fused features to enhance the continuous expression of slender scratches, edge damage and directional defects.

[0033] Further, in step S6, the WIoU v3-NWD composite bounding box regression loss function satisfies:

[0034]

[0035] in, This represents the regression loss of the composite bounding box. This represents the WIoU v3 loss term. Represents the NWD loss term; and These represent the preset weighting coefficients, and , , The WIoU v3 loss term is used to dynamically adjust the bounding box regression gradient weights based on the quality of the predicted box samples, and the NWD loss term is used to reduce the sensitivity of small target bounding boxes to pixel-level positional offsets.

[0036] Further, step S7 includes: inputting the training set images into the battery cover surface defect detection model for forward propagation to obtain the predicted defect category, predicted confidence, and predicted bounding box; calculating the classification loss, confidence loss, and WIoU v3-NWD composite bounding box regression loss based on the predicted defect category, predicted confidence, predicted bounding box, and corresponding annotation information; and performing backpropagation based on the total loss and updating the model parameters until the total loss converges or reaches a preset number of training rounds.

[0037] Further, step S9 includes: drawing a detection box corresponding to the bounding box coordinates on the image to be detected, video frame, or real-time image from the camera, and displaying the defect category and confidence level; and simultaneously writing at least one of the defect category, confidence level, bounding box coordinates, detection time, and result saving path into a detection result table or detection log.

[0038] This invention also provides a battery cover surface defect detection system based on an improved YOLOv8, comprising:

[0039] The image acquisition module is used to acquire images of the surface of the battery cover to be inspected, video streams, or real-time images from a camera.

[0040] The model weight loading module is used to load the model weight file of the pre-trained battery cover surface defect detection model. The battery cover surface defect detection model includes a WED-C2f wavelet-edge dual-domain feature enhancement module, a DBSPPF dual-branch decoupled spatial pyramid pooling module, and an SCA-BiFPN multi-scale feature fusion structure. The battery cover surface defect detection model is trained using the WIoU v3-NWD composite bounding box regression loss function during the training phase.

[0041] The input source selection module is used to select a single image, image folder, video file, or live camera feed as the detection input source;

[0042] The detection parameter setting module is used to set the confidence threshold, intersection-over-union (IoU) threshold, and input image size;

[0043] The detection module is used to call the loaded battery cover surface defect detection model, perform defect detection on the surface image, video frame or real-time image of the battery cover to be detected, and output the defect category, confidence level and bounding box coordinates.

[0044] The display module is used to display the detected image with the detection box, defect category and confidence level, and to display at least one of the following detection information: defect category, confidence level, bounding box coordinates and detection time;

[0045] The storage module is used to store at least one of the following: detection image, detection video frame, detection result table, detection log, and result storage path.

[0046] Furthermore, the system also includes a user management module, an operation control module, and a camera control module;

[0047] The user management module is used for user login, user registration, and user authentication; the operation control module is used to control the start, pause, stop, and exit of detection tasks.

[0048] The camera control module is used to control the camera to turn on, preview in real time, detect in real time, and turn off.

[0049] The display module includes an image display unit and a result table display unit. The result table display unit is used to display the defect category, confidence level, bounding box coordinates, and result saving path.

[0050] Compared with the prior art, the significant advantages of this invention are:

[0051] (1) This invention uses the WED-C2f wavelet-edge dual-domain feature enhancement module to simultaneously extract spatial domain structural information, frequency domain wavelet decomposition and edge domain gradient response of input features in the shallow and mid-shallow stages of the backbone network. It also uses channel splicing and 1×1 convolution to fuse multi-domain features, enabling the model to utilize spatial structural information, frequency domain detail information and explicit edge response information at the same time. This effectively enhances the feature expression ability of small-scale, low-contrast, weak edge and irregular battery cover surface defects and improves detection accuracy.

[0052] (2) This invention decouples the spatial pyramid pooling module through DBSPPF dual branches, and uses multi-scale pooling branches and depthwise separable convolution branches to decouple and extract global context semantic features and local texture detail features respectively. This avoids the loss of local detail information by a single pooling operation, so that the model can still maintain sensitivity to defect texture details in deep networks. This is beneficial to distinguish between real defects and the surface processing texture and reflective interference of the battery cover, and reduces the false detection rate.

[0053] (3) This invention introduces learnable non-negative weights to adaptively adjust the contribution of features at different scales through the SCA-BiFPN multi-scale feature fusion structure, and combines the CAA strip context attention module to aggregate strip context information along the horizontal and / or vertical directions, thereby enhancing the feature continuity expression ability of directional defects such as slender scratches and edge damage, while suppressing the response of irrelevant background areas, thus improving the accuracy and robustness of detection.

[0054] (4) The present invention adopts the WIoU v3-NWD composite bounding box regression loss function, which combines the dynamic non-monotonic focusing mechanism of the WIoU v3 loss term with the Gaussian distribution normalized distance metric of the NWD loss term, effectively reducing the sensitivity of small defect targets to pixel-level positional offset, improving the localization stability and accuracy of bounding box regression, and enhancing the stability and convergence efficiency of the training process.

[0055] (5) The battery cover surface defect detection system constructed by the present invention integrates user management, model loading, multi-input source selection, detection parameter setting, detection result display and saving and other functional modules. It supports multiple input methods such as single image, batch image, video file and real-time camera image. Users can complete the defect detection task without writing or running code directly. It has good engineering practicality and operability. Attached Figure Description

[0056] Figure 1 This is a flowchart of the battery cover surface defect detection method based on the improved YOLOv8 of this invention.

[0057] Figure 2 This is a schematic diagram of the overall network structure of the improved detection model of the present invention.

[0058] Figure 3 This is a schematic diagram of the WED-C2f wavelet-edge dual-domain feature enhancement module structure of the present invention.

[0059] Figure 4 This is a schematic diagram of the DBSPPF dual-branch decoupled spatial pyramid pooling module structure of the present invention.

[0060] Figure 5 This is a schematic diagram of the SCA-BiFPN multi-scale feature fusion structure of the present invention.

[0061] Figure 6 This is a schematic diagram of the calculation process for the regression loss function of the WIoU v3-NWD composite bounding box in this invention.

[0062] Figure 7 This is a schematic diagram of the overall architecture of the battery cover surface defect detection system of the present invention.

[0063] Figure 8 This is a schematic diagram of the working process of the battery cover surface defect detection system of the present invention.

[0064] Figure 9 This is a schematic diagram of the login interface of the battery cover surface defect detection system of the present invention.

[0065] Figure 10 This is a schematic diagram of the detection result interface of the battery cover surface defect detection system of the present invention. Detailed Implementation

[0066] The present invention will be further described below with reference to embodiments. It should be understood that the following embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. Where there is no conflict, the following embodiments and the technical features therein can be combined with each other.

[0067] Combination Figures 1-2This invention provides a method for detecting surface defects in battery cover plates based on an improved YOLOv8, comprising:

[0068] Step S1: Obtain a surface image of the battery cover plate, and perform preprocessing, data augmentation, and defect annotation on the surface image of the battery cover plate to form a battery cover plate surface defect dataset.

[0069] Step S2: Construct a battery cover surface defect detection model based on YOLOv8. The battery cover surface defect detection model includes a backbone network, a neck network, and a detection head.

[0070] Step S3: Replace at least one C2f module in the backbone network with a WED-C2f wavelet-edge dual-domain feature enhancement module to jointly enhance the surface defect features of the battery cover in the spatial domain, frequency domain and edge domain.

[0071] Step S4: Replace the spatial pyramid pooling module in YOLOv8 with the DBSPPF dual-branch decoupled spatial pyramid pooling module, so as to extract global contextual semantic features and local texture detail features through multi-scale pooling branches and depthwise separable convolution branches respectively.

[0072] Step S5: Replace the original PAN-FPN feature fusion structure in the YOLOv8 neck network with the SCA-BiFPN multi-scale feature fusion structure to perform bidirectional weighted fusion of features at different scales, and enhance directional defect features through strip contextual attention.

[0073] Step S6: Construct the WIoU v3-NWD composite bounding box regression loss function, which includes the WIoU v3 loss term and the NWD loss term;

[0074] Step S7: Using the battery cover surface defect dataset, and based on the WIoU v3-NWD composite bounding box regression loss function, train the battery cover surface defect detection model to obtain the trained detection model.

[0075] Step S8: Input the surface image of the battery cover to be detected, video frame, or real-time image from the camera into the trained detection model, and output the defect category, confidence level, and bounding box coordinates.

[0076] Step S9: Generate detection results based on the defect category, confidence level, and bounding box coordinates, and display and save the detection results.

[0077] As a specific example, in step S1, the defect categories in the battery cover surface defect dataset include at least one of scratches, dents, bumps, dirt, and terminal damage; the defect annotation includes annotating the defect category and the bounding box position of the defect in the image.

[0078] In step S1, the preprocessing includes at least one of image size adjustment, image format conversion, noise suppression, brightness adjustment, contrast adjustment, and normalization; the data augmentation includes at least one of horizontal flipping, vertical flipping, rotation, cropping, brightness perturbation, contrast perturbation, color perturbation, noise addition, and scaling.

[0079] As a concrete example, combined with Figure 3 In step S3, the WED-C2f wavelet-edge dual-domain feature enhancement module includes a channel adjustment layer, a spatial feature branch, a wavelet feature branch, an edge enhancement branch, and a feature fusion layer.

[0080] The channel adjustment layer is used to perform 1×1 convolution channel adjustment on the input feature X to obtain the adjusted feature X′.

[0081] The spatial feature branch is used to extract the spatial structure information of the adjusted feature X′ based on the C2f structure;

[0082] The wavelet feature branch decomposes the adjusted feature X′ into low-frequency components, horizontal high-frequency components, vertical high-frequency components, and diagonal high-frequency components, and performs convolution mapping on at least one of the horizontal high-frequency components, vertical high-frequency components, and diagonal high-frequency components; the edge convolution kernel is a Sobel convolution kernel, which is set to fixed parameters during training and does not participate in backpropagation updates;

[0083] The edge enhancement branch is used to extract the edge response of the adjusted feature X′ through the edge convolution kernel, and to map the edge response to the fusion feature space through learnable convolution;

[0084] The feature fusion layer is used to concatenate the spatial structure information, frequency domain high-frequency detail features and edge response features in the channel dimension, and fuse them through convolution to obtain the output features of the WED-C2f wavelet-edge dual-domain feature enhancement module.

[0085] The WED-C2f wavelet-edge dual-domain feature enhancement module is set in the P2 and P3 stages of the YOLOv8 backbone network; the number of output channels of the wavelet feature branch and the edge enhancement branch is less than the number of output channels of the spatial feature branch.

[0086] As a concrete example, combined with Figure 4Step S4, the DBSPPF dual-branch decoupled spatial pyramid pooling module includes a multi-scale pooling main branch, a depthwise separable convolution auxiliary branch, and a fused output layer;

[0087] The multi-scale pooling main branch is used to extract contextual semantic features under different receptive fields through continuous or parallel multi-scale pooling operations.

[0088] The depthwise separable convolution auxiliary branch is used to extract local texture detail features without reducing the feature map spatial resolution; the depthwise separable convolution auxiliary branch includes at least two cascaded depthwise separable convolution modules, and residual fusion connections are set between the depthwise separable convolution modules; the depthwise separable convolution module includes channel-wise depthwise convolution and 1×1 pointwise convolution;

[0089] The fusion output layer is used to perform channel fusion of the contextual semantic features and the local texture detail features to obtain context-enhanced features.

[0090] As a concrete example, combined with Figure 5 In step S5, the SCA-BiFPN multi-scale feature fusion structure includes a top-down feature fusion path, a bottom-up feature fusion path, a same-scale lateral skip connection, and a fast normalization fusion unit.

[0091] The fast normalization fusion unit is used to assign learnable non-negative weights to features of different scales input to the same fusion node, and to perform weighted fusion after normalizing the learnable non-negative weights.

[0092] The SCA-BiFPN multi-scale feature fusion structure also includes a CAA strip context attention module; the CAA strip context attention module is used to aggregate strip context information along at least one of the horizontal and vertical directions, and apply the aggregated attention weights to the fused features to enhance the continuous expression of slender scratches, edge damage and directional defects.

[0093] As a concrete example, combined with Figure 6 In step S6, the WIoU v3-NWD composite bounding box regression loss function satisfies:

[0094]

[0095] in, This represents the regression loss of the composite bounding box. This represents the WIoU v3 loss term. Represents the NWD loss term; and These represent the preset weighting coefficients, and , , The WIoU v3 loss term is used to dynamically adjust the bounding box regression gradient weights based on the quality of the predicted box samples, and the NWD loss term is used to reduce the sensitivity of small target bounding boxes to pixel-level positional offsets.

[0096] As a specific example, step S7 includes: inputting the training set images into the battery cover surface defect detection model for forward propagation to obtain the predicted defect category, predicted confidence, and predicted bounding box; calculating the classification loss, confidence loss, and the WIoU v3-NWD composite bounding box regression loss based on the predicted defect category, predicted confidence, predicted bounding box, and corresponding annotation information; and performing backpropagation based on the total loss and updating the model parameters until the total loss converges or reaches a preset number of training rounds.

[0097] As a specific example, step S9 includes: drawing a detection box corresponding to the bounding box coordinates on the image to be detected, video frame, or real-time image from the camera, and displaying the defect category and confidence level; and simultaneously writing at least one of the defect category, confidence level, bounding box coordinates, detection time, and result saving path into a detection result table or detection log.

[0098] This invention also provides a battery cover surface defect detection system based on an improved YOLOv8, comprising:

[0099] The image acquisition module is used to acquire images of the surface of the battery cover to be inspected, video streams, or real-time images from a camera.

[0100] The model weight loading module is used to load the model weight file of the pre-trained battery cover surface defect detection model. The battery cover surface defect detection model includes a WED-C2f wavelet-edge dual-domain feature enhancement module, a DBSPPF dual-branch decoupled spatial pyramid pooling module, and an SCA-BiFPN multi-scale feature fusion structure. The battery cover surface defect detection model is trained using the WIoU v3-NWD composite bounding box regression loss function during the training phase.

[0101] The input source selection module is used to select a single image, image folder, video file, or live camera feed as the detection input source;

[0102] The detection parameter setting module is used to set the confidence threshold, intersection-over-union (IoU) threshold, and input image size;

[0103] The detection module is used to call the loaded battery cover surface defect detection model, perform defect detection on the surface image, video frame or real-time image of the battery cover to be detected, and output the defect category, confidence level and bounding box coordinates.

[0104] The display module is used to display the detected image with the detection box, defect category and confidence level, and to display at least one of the following detection information: defect category, confidence level, bounding box coordinates and detection time;

[0105] The storage module is used to store at least one of the following: detection image, detection video frame, detection result table, detection log, and result storage path.

[0106] As a specific example, the system also includes a user management module, an operation control module, and a camera control module;

[0107] The user management module is used for user login, user registration, and user authentication; the operation control module is used to control the start, pause, stop, and exit of detection tasks.

[0108] The camera control module is used to control the camera to turn on, preview in real time, detect in real time, and turn off.

[0109] The display module includes an image display unit and a result table display unit. The result table display unit is used to display the defect category, confidence level, bounding box coordinates, and result saving path.

[0110] Figure 7 This is a schematic diagram of the overall architecture of the battery cover surface defect detection system of the present invention. Figure 8 This is a schematic diagram of the working process of the battery cover surface defect detection system of the present invention. Figure 9 This is a schematic diagram of the login interface of the battery cover surface defect detection system of the present invention. Figure 10 This is a schematic diagram of the detection result interface of the battery cover surface defect detection system of the present invention.

[0111] Example 1

[0112] This example describes the construction of a dataset of surface defects on a battery cover plate.

[0113] In this embodiment, an industrial camera or webcam is used to capture images of the battery cover surface. During acquisition, the battery cover is kept in the center of the imaging field of view, and the lighting conditions are controlled to ensure that the surface structure, edge areas, and electrode areas of the cover are clearly visible.

[0114] After acquisition, the images are preprocessed. Preprocessing may include at least one of image resizing, format conversion, noise suppression, brightness adjustment, contrast adjustment, and normalization. Subsequently, data augmentation is performed on the images. Data augmentation may include at least one of horizontal flipping, vertical flipping, rotation, cropping, brightness perturbation, contrast perturbation, noise addition, and scaling to improve the model's adaptability to different imaging conditions and defect morphologies.

[0115] Image annotation tools were used to label defect areas with rectangular bounding boxes, with annotation information including the defect category and bounding box coordinates. Defect categories included scratches, dents, dents, dirt, and pole piece damage. The labeled data was then divided into training, validation, and test sets according to a preset ratio for model training, parameter tuning, and performance testing.

[0116] Example 2

[0117] This embodiment introduces the WED-C2f wavelet-edge dual-domain feature enhancement module:

[0118] In this embodiment, the original C2f module is replaced with the WED-C2f module in the P2 and P3 stages of the YOLOv8 backbone network. For the input feature X, the channels are first adjusted by 1×1 convolution to obtain the adjusted feature X′; then the adjusted feature X′ is input into the spatial feature branch, wavelet feature branch and edge enhancement branch respectively.

[0119] The spatial feature branch follows the cross-stage feature reuse concept in the C2f structure, extracting the spatial domain structure information of the adjusted feature X′ through convolution and bottleneck units to obtain the spatial feature F. C2f .

[0120] The wavelet feature branch performs a two-dimensional discrete wavelet transform on the adjusted feature X′, decomposing it into a low-frequency component LL, a horizontal high-frequency component LH, a vertical high-frequency component HL, and a diagonal high-frequency component HH. The low-frequency component characterizes the main structure and gradually changing regions of the battery cover surface, while the high-frequency component characterizes edges, abrupt texture changes, and local detail variations. Low-frequency convolution is performed on the low-frequency component, and high-frequency convolution is performed on at least one of the horizontal, vertical, and diagonal high-frequency components. Finally, a 1×1 convolution is used to fuse the low-frequency and high-frequency features to obtain the wavelet frequency domain feature F. WT .

[0121] The edge enhancement branch extracts gradients or edge responses from the adjusted feature X′ to obtain edge response features. Specifically, it extracts the edge responses of the adjusted feature X′ in the horizontal and vertical directions using a Sobel convolution kernel with fixed parameters. This Sobel convolution kernel is fixed during training and does not participate in backpropagation updates. Subsequently, a learnable convolution maps the edge responses to a feature space suitable for feature fusion, resulting in the edge enhancement feature F. E .

[0122] To control computational load, the number of auxiliary channels output by the wavelet feature branch and the edge enhancement branch can be set to a preset ratio of the number of channels output by the spatial feature branch, for example, 1 / 4. This will allow the spatial features to... Wavelet frequency domain features and edge enhancement features After concatenation along the channel dimension, a 1×1 convolution is input for channel fusion and compression to obtain the output features of the WED-C2f module. .

[0123] The feature fusion process of the WED-C2f module can be represented as follows:

[0124]

[0125] Wherein, Concat represents concatenation along the channel dimension. This represents a 1×1 convolution operation. The output feature simultaneously contains spatial structure information, wavelet frequency domain details, and explicit edge response information, thereby enhancing the model's ability to represent small-scale, low-contrast, and weak edge defects.

[0126] Example 3

[0127] This embodiment introduces the DBSPPF dual-branch decoupled spatial pyramid pooling module:

[0128] In this embodiment, the original YOLOv8 SPPF module is replaced with a DBSPPF module. The DBSPPF module includes a multi-scale pooling main branch, a depthwise separable convolution auxiliary branch, and a fused output layer.

[0129] The multi-scale pooling main branch performs pooling operations on the input features at multiple scales to obtain contextual semantic features under different receptive fields. The depthwise separable convolution auxiliary branch performs local convolution modeling on the input features to supplement local details and texture information that may be lost during pooling. Subsequently, the outputs of the multi-scale pooling main branch and the depthwise separable convolution auxiliary branch are concatenated along the channel dimension, and contextual enhancement features are output through convolutional layers.

[0130] Through the above structure, the DBSPPF module can simultaneously model global semantic information and local detail information in deep networks, which is beneficial for distinguishing real defects from the surface texture, reflection and structural edges of the battery cover.

[0131] Example 4

[0132] This embodiment introduces the SCA-BiFPN multi-scale feature fusion structure:

[0133] In this embodiment, the SCA-BiFPN multi-scale feature fusion structure is adopted in the YOLOv8 neck network. This structure is built based on a bidirectional feature pyramid network, establishing a bidirectional fusion path from top to bottom and from bottom to top between shallow features, mid-level features, and deep features.

[0134] During feature fusion, learnable weights are assigned to each input feature, and these weights are normalized. This allows features at different scales to adaptively participate in the fusion process based on their contribution to the current detection task. Shallow features primarily provide edge, texture, and location information, while deep features mainly provide semantic discrimination information. Weighted fusion reduces feature redundancy and improves the effectiveness of feature responses.

[0135] Furthermore, a strip contextual attention module is introduced into the fusion node. This module aggregates contextual information along the horizontal and / or vertical directions to enhance the continuous representation of directional defects such as fine scratches and edge damage, and suppress responses from irrelevant background regions.

[0136] Example 5

[0137] This example introduces the WIoU v3-NWD composite bounding box regression loss function:

[0138] In this embodiment, the improved detection model is trained using the WIoU v3-NWD composite bounding box regression loss function. The composite loss function consists of a WIoU v3 loss term and an NWD loss term.

[0139] The WIoU v3 loss term is based on a dynamic non-monotonic focusing mechanism, which adjusts the gradient weights of different predicted bounding boxes according to the sample quality. This reduces the model's overemphasis on extremely high-quality samples and low-quality outliers, improving training stability. The NWD loss term models the predicted and ground truth boxes as two-dimensional Gaussian distributions and uses normalized distance to measure the difference between the predicted and ground truth boxes, reducing the sensitivity of small target predicted boxes to small pixel offsets.

[0140] The WIoU v3 loss term and the NWD loss term are combined according to preset weights to obtain the composite bounding box regression loss. The total model loss may include classification loss, confidence loss, and composite bounding box regression loss.

[0141] Example 6

[0142] This embodiment describes a battery cover plate surface defect detection system:

[0143] In this embodiment, a battery cover surface defect detection system is constructed based on a trained improved YOLOv8 detection model. The system includes a user management module, a model weight loading module, an input source selection module, a detection parameter setting module, a detection module, a result display module, a result saving module, and a camera control module.

[0144] The user management module is used to complete user login and registration. After starting the system, users are taken to the login interface, where they enter their username and password; after successful verification, they are taken to the main detection interface.

[0145] The model weight loading module is used to load the weight files of the trained model. Users select the model weight file through the interface, and the system completes the model initialization.

[0146] The input source selection module is used to select the detection input source. Input sources include single images, image folders, video files, and live camera feeds. For single images, the system reads the image, performs inference, and displays the detection results; for image folders, the system reads the images in the folder sequentially and performs batch detection; for video files, the system reads the video frame by frame and performs detection; for live camera feeds, the system calls the camera to acquire real-time frames and performs online detection.

[0147] The detection parameter setting module is used to set parameters such as confidence threshold, IoU threshold, and input image size. The system performs model inference based on the user-defined parameters.

[0148] The detection module is used to call the trained improved YOLOv8 detection model to perform defect detection on the input image, video frame or real-time camera frame, and output the defect category, confidence score and bounding box coordinates.

[0149] The results display module shows the original and detected images on the interface, and draws bounding boxes, category names, and confidence levels on the detected images. The system can also display defect categories, confidence levels, bounding box coordinates, detection time, and save paths in a table.

[0150] The results saving module is used to save the detected images, video frames, detection result tables or detection logs to a specified directory, which facilitates subsequent quality traceability, result verification and production statistics.

[0151] The camera control module is used to control the camera's activation, preview, detection, and deactivation. When the user selects a camera input source, the system calls up the camera and displays a real-time preview; after detection is initiated, the system performs real-time inference on the camera frames; and after the camera is deactivated, camera resources are released.

[0152] Example 7

[0153] In this embodiment, the operation flow of the battery cover surface defect detection system is as follows:

[0154] Step 1: Start the system and enter the login screen;

[0155] Step 2: Verify user identity. After successful verification, you will enter the main detection interface.

[0156] Step 3: Select the weight file of the trained improved YOLOv8 model;

[0157] Step 4: Set the confidence threshold, IoU threshold, and input image size;

[0158] Step 5: Select the input source type, which includes images, folders, videos, and webcam images;

[0159] Step 6: The system reads the input source data and calls the improved YOLOv8 model for inference;

[0160] Step 7: The system outputs the defect category, confidence level, and bounding box coordinates;

[0161] Step 8: The system displays the detection results on the interface and saves the results to the local directory.

[0162] Through the above process, users can complete the task of detecting defects on the surface of the battery cover without directly writing or running code.

[0163] Example 8

[0164] In an alternative implementation, the improved detection model can be selected as either a high-precision model or a lightweight model based on the computing power of the deployed devices. For servers or industrial control computers with sufficient computing power, a high-precision detection model including WED-C2f, DBSPPF, SCA-BiFPN, and WIoU v3-NWD can be used; for edge devices, lightweight replacements can be made to the backbone network, neck network, or detection head while keeping the core detection process unchanged.

[0165] In another alternative implementation, the input source can be connected to an industrial production line camera, line scan camera, area scan camera or other image acquisition equipment, and the detection results can be further sent to a host computer, database, quality traceability system or rejection execution mechanism.

[0166] The above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention. Equivalent substitutions, modifications, or combinations made by those skilled in the art without departing from the concept of the present invention should all fall within the scope of protection of the present invention.

Claims

1. A method for detecting surface defects in battery cover plates based on an improved YOLOv8, characterized in that, include: Step S1: Obtain a surface image of the battery cover plate, and perform preprocessing, data augmentation, and defect annotation on the surface image of the battery cover plate to form a battery cover plate surface defect dataset. Step S2: Construct a battery cover surface defect detection model based on YOLOv8. The battery cover surface defect detection model includes a backbone network, a neck network, and a detection head. Step S3: Replace at least one C2f module in the backbone network with a WED-C2f wavelet-edge dual-domain feature enhancement module to jointly enhance the surface defect features of the battery cover in the spatial domain, frequency domain and edge domain. Step S4: Replace the spatial pyramid pooling module in YOLOv8 with the DBSPPF dual-branch decoupled spatial pyramid pooling module, so as to extract global contextual semantic features and local texture detail features through multi-scale pooling branches and depthwise separable convolution branches respectively. Step S5: Replace the original PAN-FPN feature fusion structure in the YOLOv8 neck network with the SCA-BiFPN multi-scale feature fusion structure to perform bidirectional weighted fusion of features at different scales, and enhance directional defect features through strip contextual attention. Step S6: Construct the WIoU v3-NWD composite bounding box regression loss function, which includes the WIoU v3 loss term and the NWD loss term; Step S7: Using the battery cover surface defect dataset, and based on the WIoU v3-NWD composite bounding box regression loss function, train the battery cover surface defect detection model to obtain the trained detection model. Step S8: Input the surface image of the battery cover to be detected, video frame, or real-time image from the camera into the trained detection model, and output the defect category, confidence level, and bounding box coordinates. Step S9: Generate detection results based on the defect category, confidence level, and bounding box coordinates, and display and save the detection results.

2. The battery cover surface defect detection method based on improved YOLOv8 according to claim 1, characterized in that, In step S1, the defect categories in the battery cover surface defect dataset include at least one of scratches, dents, bumps, dirt, and terminal damage; the defect annotation includes annotating the defect category and the bounding box position of the defect in the image. In step S1, the preprocessing includes at least one of image size adjustment, image format conversion, noise suppression, brightness adjustment, contrast adjustment, and normalization; the data augmentation includes at least one of horizontal flipping, vertical flipping, rotation, cropping, brightness perturbation, contrast perturbation, color perturbation, noise addition, and scaling.

3. The method for detecting surface defects of battery cover plates based on improved YOLOv8 according to claim 1, characterized in that, In step S3, the WED-C2f wavelet-edge dual-domain feature enhancement module includes a channel adjustment layer, a spatial feature branch, a wavelet feature branch, an edge enhancement branch, and a feature fusion layer; The channel adjustment layer is used to perform 1×1 convolution channel adjustment on the input feature X to obtain the adjusted feature X′. The spatial feature branch is used to extract the spatial structure information of the adjusted feature X′ based on the C2f structure; The wavelet feature branch decomposes the adjusted feature X′ into low-frequency components, horizontal high-frequency components, vertical high-frequency components, and diagonal high-frequency components, and performs convolution mapping on at least one of the horizontal high-frequency components, vertical high-frequency components, and diagonal high-frequency components; the edge convolution kernel is a Sobel convolution kernel, which is set to fixed parameters during training and does not participate in backpropagation updates; The edge enhancement branch is used to extract the edge response of the adjusted feature X′ through the edge convolution kernel, and to map the edge response to the fusion feature space through learnable convolution; The feature fusion layer is used to concatenate the spatial structure information, frequency domain high-frequency detail features and edge response features in the channel dimension, and fuse them through convolution to obtain the output features of the WED-C2f wavelet-edge dual-domain feature enhancement module. The WED-C2f wavelet-edge dual-domain feature enhancement module is set in the P2 and P3 stages of the YOLOv8 backbone network; the number of output channels of the wavelet feature branch and the edge enhancement branch is less than the number of output channels of the spatial feature branch.

4. The battery cover surface defect detection method based on improved YOLOv8 according to claim 1, characterized in that, Step S4, the DBSPPF dual-branch decoupled spatial pyramid pooling module includes a multi-scale pooling main branch, a depthwise separable convolution auxiliary branch, and a fused output layer; The multi-scale pooling main branch is used to extract contextual semantic features under different receptive fields through continuous or parallel multi-scale pooling operations. The depthwise separable convolution auxiliary branch is used to extract local texture detail features without reducing the feature map spatial resolution; the depthwise separable convolution auxiliary branch includes at least two cascaded depthwise separable convolution modules, and residual fusion connections are set between the depthwise separable convolution modules; the depthwise separable convolution module includes channel-wise depthwise convolution and 1×1 pointwise convolution; The fusion output layer is used to perform channel fusion of the contextual semantic features and the local texture detail features to obtain contextual enhancement features.

5. The battery cover surface defect detection method based on improved YOLOv8 according to claim 4, characterized in that, In step S5, the SCA-BiFPN multi-scale feature fusion structure includes a top-down feature fusion path, a bottom-up feature fusion path, same-scale lateral skip connections, and fast normalization fusion units. The fast normalization fusion unit is used to assign learnable non-negative weights to features of different scales input to the same fusion node, and to perform weighted fusion after normalizing the learnable non-negative weights. The SCA-BiFPN multi-scale feature fusion structure also includes a CAA strip context attention module; The CAA strip context attention module is used to aggregate strip context information along at least one of the horizontal and vertical directions, and apply the aggregated attention weights to the fused features to enhance the continuous representation of slender scratches, edge damage and directional defects.

6. The method for detecting surface defects of battery cover plates based on improved YOLOv8 according to claim 1, characterized in that, In step S6, the WIoU v3-NWD composite bounding box regression loss function satisfies: in, This represents the regression loss of the composite bounding box. This represents the WIoU v3 loss term. Represents the NWD loss term; and These represent the preset weighting coefficients, and , , The WIoU v3 loss term is used to dynamically adjust the bounding box regression gradient weights based on the quality of the predicted box samples, and the NWD loss term is used to reduce the sensitivity of small target bounding boxes to pixel-level positional offsets.

7. The method for detecting surface defects of battery cover plates based on improved YOLOv8 according to claim 1, characterized in that, Step S7 includes: inputting the training set images into the battery cover surface defect detection model for forward propagation to obtain the predicted defect category, predicted confidence, and predicted bounding box; calculating the classification loss, confidence loss, and WIoU v3-NWD composite bounding box regression loss based on the predicted defect category, predicted confidence, predicted bounding box, and corresponding annotation information; and performing backpropagation based on the total loss and updating the model parameters until the total loss converges or reaches the preset number of training rounds.

8. The method for detecting surface defects of battery cover plates based on improved YOLOv8 according to claim 1, characterized in that, Step S9 includes: drawing a detection box corresponding to the bounding box coordinates on the image to be detected, video frame, or real-time image from the camera, and displaying the defect category and confidence level; simultaneously writing at least one of the defect category, confidence level, bounding box coordinates, detection time, and result saving path into the detection result table or detection log.

9. A battery cover surface defect detection system based on an improved YOLOv8, characterized in that, include: The image acquisition module is used to acquire images of the surface of the battery cover to be inspected, video streams, or real-time images from a camera. The model weight loading module is used to load the model weight file of the pre-trained battery cover surface defect detection model. The battery cover surface defect detection model includes a WED-C2f wavelet-edge dual-domain feature enhancement module, a DBSPPF dual-branch decoupled spatial pyramid pooling module, and an SCA-BiFPN multi-scale feature fusion structure. The battery cover surface defect detection model is trained using the WIoU v3-NWD composite bounding box regression loss function during the training phase. The input source selection module is used to select a single image, image folder, video file, or live camera feed as the detection input source; The detection parameter setting module is used to set the confidence threshold, intersection-over-union (IoU) threshold, and input image size; The detection module is used to call the loaded battery cover surface defect detection model, perform defect detection on the surface image, video frame or real-time image of the battery cover to be detected, and output the defect category, confidence level and bounding box coordinates. The display module is used to display the detected image with the detection box, defect category and confidence level, and to display at least one of the following detection information: defect category, confidence level, bounding box coordinates and detection time; The storage module is used to store at least one of the following: detection image, detection video frame, detection result table, detection log, and result storage path.

10. The battery cover surface defect detection system based on improved YOLOv8 according to claim 9, characterized in that, The system also includes a user management module, an operation control module, and a camera control module; The user management module is used for user login, user registration, and user authentication; the operation control module is used to control the start, pause, stop, and exit of detection tasks. The camera control module is used to control the camera to turn on, preview in real time, detect in real time, and turn off. The display module includes an image display unit and a result table display unit. The result table display unit is used to display the defect category, confidence level, bounding box coordinates, and result saving path.