Lightweight and high-precision power battery pole detection method in complex environments
By optimizing the YOLOX target detection model and combining it with the efficient CSP module, lightweight model neck network, and spatial pyramid pooling module, the high-precision and lightweight detection issues of power battery poles in complex environments are solved, achieving efficient detection with limited hardware resources.
Patent Information
- Application Number
- CN202510120865.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2045-01-24
AI Technical Summary
Existing technologies make it difficult to achieve high-precision detection of power battery poles in complex environments, especially when there are impurities and environmental changes on the pole surface. Traditional methods and deep learning models are unable to achieve lightweight and high-precision detection effects due to hardware resource limitations.
A lightweight and high-precision power battery pole detection model is adopted. By adjusting the basic YOLOX target detection model, the CSP module is replaced with an efficient CSP module, a lightweight model neck network and an optimized spatial pyramid pooling module are introduced, combined with densely connected DenseBottleneck modules and depthwise separable convolution to optimize feature extraction and information fusion.
Lightweight and high-precision power battery pole detection is achieved in complex environments, which reduces the requirements for the welding environment, reduces the demand for hardware resources, and improves the accuracy and robustness of detection.
Smart Images

Figure CN120032226B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision and its application technology, and in particular to a lightweight and high-precision power battery pole detection method in a complex environment. Background Art
[0002] It is proposed to make intelligent manufacturing the main direction of the integration of industrialization and informatization to promote the intelligent manufacturing process. In this context, visual technology, as an advanced technology with non-contact, fast processing speed and large amount of information, has been widely used in the field of welding, such as identification and guidance of the initial welding position before welding, weld tracking, welding quality control and evaluation, weld defect detection, etc. As the core component of new energy vehicles, the connection quality of the poles between battery modules directly affects the stability and utilization efficiency of the final product. In order to ensure the high quality of battery modules and the stable and reliable power supply of the vehicle, it is necessary to adopt an accurate and reliable method for identifying the initial welding position. At present, most companies use the template matching method to locate the battery pole from the captured image. This method performs poorly when there are impurities on the battery surface and has difficulty coping with complex welding environments.
[0003] For example, Chinese invention patent publication number CN 115731165 A introduces a method for determining the size of lithium battery components using a template matching method based on grayscale values.
[0004] Specific methods include:
[0005] Step 1: The image acquisition unit captures the image information of the calibration unit and transmits it to the host computer. Calibration is performed using film sheets with an accuracy of 1 μm and a shape of 5 mm × 5 mm square.
[0006] Step 2: The computing unit in the host computer obtains the regional position of the calibration unit in the calibration unit image information through a template matching method based on gray value.
[0007] Step 3: The computing unit in the host computer obtains the grayscale value in the area position of the calibration unit and calculates the average grayscale value in the area position, compares the deviation with the actual grayscale value of the calibration unit, and determines whether it is NG based on the deviation value.
[0008] Step 4: The computing unit in the host computer obtains the center point coordinates of the calibration unit, and determines the coordinate values of the left, right, upper and lower edges of the calibration unit according to the center point coordinates.
[0009] Step 5: The calculation unit in the host computer calculates the estimated width and height values of the calibration unit according to the horizontal and vertical coordinate differences of the upper and lower edges, and based on this, calculates the deviation between the estimated width and height values and the actual width and height values, and determines whether it is NG according to the deviation value.
[0010] The above technical solution implements a method for calculating the size of lithium battery components. In the image captured by the image acquisition unit, the visual camera stick is black, the product to be inspected is gray, and the tab is white. Different areas have obvious color distinctions, and relatively accurate results can be achieved in target area detection. The above technical solution requires that there is a clear color distinction between the foreground and background, and a clear boundary line can be drawn. If it is applied to pole detection, the performance will be greatly reduced. The surface of the power battery pole is all metallic, and there is no obvious division. Impurities are easily present on the battery surface, and changes in the environment will also affect the presentation of the foreground and background in the imaging results.
[0011] In addition, although deep learning methods are widely used in the field of visual recognition, hardware resources are often limited in industrial applications, making it difficult for deep learning methods to maximize their effectiveness. Therefore, it is necessary to lightweight the model to reduce the demand for hardware and resources, making it possible to deploy target detection models in industrial computers. However, there is currently no lightweight model that matches the pole recognition of power batteries in complex environments. Summary of the Invention
[0012] In view of the shortcomings of the prior art, the object of the present invention is to provide a lightweight and high-precision power battery pole detection method in a complex environment.
[0013] To achieve the aforementioned object of the invention, the technical solutions adopted by the present invention include:
[0014] In a first aspect, the present invention provides a method for training a lightweight, high-precision power battery pole detection model in a complex environment, comprising:
[0015] Providing a training set, the training set including training images and training labels, the training images including photos of power batteries in various environments, and the training labels marking the positions of the power battery poles;
[0016] Providing an initialization model, which is obtained by adjusting the basic YOLOX object detection model. The adjustment includes replacing the CSP module in the basic YOLOX object detection model with an efficient CSP module, introducing a lightweight model neck network, and optimizing the spatial pyramid pooling module in the basic YOLOX object detection model.
[0017] Iteratively training the initialization model using the training set to obtain the lightweight and high-precision power battery pole detection model;
[0018] Among them, the efficient CSP module replaces the Bottleneck submodule in the CSP module with a DenseBottleneck submodule connected in parallel. The DenseBottleneck submodule includes multiple fused convolution layers, and the fused convolution layer includes standard convolution and depth-wise separable convolution. The input features of the fused convolution layer generate a first convolution output after the standard convolution, and the first convolution output generates a second convolution output after the depth-wise separable convolution. The first convolution output and the second convolution output are fused to form a fused output as the output feature of the fused convolution layer. The input features and output features of the adjacent previous fused convolution layer are spliced to form a spliced feature, which serves as the input of the adjacent next fused convolution layer; the lightweight model neck network replaces some standard convolution layers in the original neck network with the fused convolution layers; the spatial pyramid pooling module adds average pooling processing, and the output features of the average pooling processing and the output features of the original maximum pooling processing are fused to replace the output features of the maximum pooling processing.
[0019] In a second aspect, the present invention further provides a lightweight and high-precision power battery pole detection method in a complex environment, which includes:
[0020] Provide a lightweight and high-precision power battery pole detection model trained using the above training method;
[0021] The image to be detected is input into the lightweight and high-precision power battery pole detection model to obtain the pole position mark.
[0022] In a third aspect, the present invention further provides a method for welding a pole of a power battery, comprising:
[0023] An image acquisition device is used to acquire an image of the power battery;
[0024] The above-mentioned lightweight and high-precision power battery pole detection method is used to obtain the pole position mark;
[0025] Based on the pole position mark, a welding device is guided to weld the pole.
[0026] In a fourth aspect, the present invention further provides a training system for a lightweight, high-precision power battery pole detection model in a complex environment, comprising:
[0027] A training set unit, configured to provide a training set, the training set including training images and training marks, the training images including photos of power batteries in a variety of different environments, and the training marks marking the positions of the power battery poles;
[0028] A model initialization unit is used to provide an initialization model, where the initialization model is obtained by adjusting the basic YOLOX object detection model. The adjustment includes replacing the CSP module in the basic YOLOX object detection model with an efficient CSP module, introducing a lightweight model neck network, and optimizing the spatial pyramid pooling module in the basic YOLOX object detection model.
[0029] an iterative training unit, configured to iteratively train the initialization model using the training set to obtain the lightweight and high-precision power battery pole detection model;
[0030] Among them, the efficient CSP module replaces the Bottleneck submodule in the CSP module with a DenseBottleneck submodule connected in parallel. The DenseBottleneck submodule includes multiple fused convolution layers, and the fused convolution layer includes standard convolution and depth-wise separable convolution. The input features of the fused convolution layer generate a first convolution output after the standard convolution, and the first convolution output generates a second convolution output after the depth-wise separable convolution. The first convolution output and the second convolution output are fused to form a fused output as the output feature of the fused convolution layer. The input features and output features of the adjacent previous fused convolution layer are spliced to form a spliced feature, which serves as the input of the adjacent next fused convolution layer; the lightweight model neck network replaces some standard convolution layers in the original neck network with the fused convolution layers; the spatial pyramid pooling module adds average pooling processing, and the output features of the average pooling processing and the output features of the original maximum pooling processing are fused to replace the output features of the maximum pooling processing.
[0031] In a fifth aspect, the present invention further provides a readable storage medium, wherein the readable storage medium stores a computer program, and when the computer program is run, the steps of the above-mentioned training method are executed.
[0032] Based on the above technical solution, compared with the prior art, the beneficial effects of the present invention include at least:
[0033] The present invention applies visual inspection technology to the pre-welding inspection of power battery poles, combines lightweight methods to optimize the parameters and computational complexity of the model while maintaining high precision, uses densely connected DenseBottleneck modules to enhance the guiding role of original features in the feature extraction process, optimizes the simple but poorly performing serial structure into a parallel structure, enriches the feature gradients, and applies residual branches to reduce the probability of gradient explosion and gradient vanishing; introduces a lightweight neck VoV-GSCSP constructed by deep separable convolution, which greatly reduces the parameters and computational complexity of the model by multiples, while maintaining feature extraction and fusion capabilities comparable to the original neck network; also introduces a novel spatial pyramid pooling module (SPP) to consider the information within the convolution kernel from both global and local perspectives, thereby enhancing the feature reuse capability; thus, the optimized YOLOX model is used to realize power battery pole detection, which can effectively avoid the interference of complex welding environments that traditional detection methods are difficult to cope with, and realize lightweight, high-precision pole detection with environmental universality.
[0034] The above description is only an overview of the technical solution of the present invention. In order to enable those skilled in the art to more clearly understand the technical means of this application and implement them according to the contents of the specification, the following is an explanation of the preferred embodiments of the present invention with detailed drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic flow chart of a method for detecting a pole before welding provided in a typical embodiment of the present invention;
[0036] Figure 2 A schematic diagram of data annotation results provided for a typical implementation case of the present invention;
[0037] Figure 3 A schematic diagram of data enhancement results provided for a typical implementation case of the present invention;
[0038] Figure 4 A schematic diagram of the structure of a high-efficiency CSP module constructed using DenseBottleneck, provided as a typical embodiment of the present invention;
[0039] Figure 5 A schematic diagram of the structure of a CSP module of a benchmark model provided for a typical implementation case of the present invention;
[0040] Figure 6 A schematic structural diagram of a lightweight neck VoV-GSCSP provided for a typical embodiment of the present invention;
[0041] Figure 7 A schematic structural diagram of an optimized spatial pyramid pooling module provided for a typical implementation case of the present invention;
[0042] Figure 8 A schematic diagram of the structure of the SPP module of the benchmark model provided for a typical implementation case of the present invention;
[0043] Figure 9 This is a schematic diagram of the pole detection results provided by a typical implementation case of the present invention. DETAILED DESCRIPTION
[0044] In view of the shortcomings of the prior art, the inventors of this case, after long-term research and extensive practice, have proposed the technical solution of the present invention. The following will further explain this technical solution, its implementation process and principles.
[0045] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present invention is not limited to the specific embodiments disclosed below.
[0046] Moreover, relational terms such as “first” and “second” are merely used to distinguish one component or method step from another with the same name, but do not necessarily require or imply any actual relationship or order between these components or method steps.
[0047] The main technical concept of this invention is to address the problem of detecting battery poles before welding in complex environments. A lightweight, high-precision battery pole detection method has been developed for this application, with minimal requirements for both the welding environment and hardware resources. Compared to traditional template matching methods, this invention incorporates a visual inspection model into the pre-weld target detection method, reducing the requirements for the welding environment. It also utilizes a more efficient CSP module to enhance the model's gradient flow, uses a lightweight neck to reduce model parameters and computational complexity, and introduces an optimized SPP module to incorporate global information and minimize information loss.
[0048] Based on the above technical concept, an embodiment of the present invention provides a training method for a lightweight and high-precision power battery pole detection model in a complex environment, which includes the following steps:
[0049] Providing a training set, the training set including training images and training labels, the training images including photos of power batteries in various environments, and the training labels marking the positions of the power battery poles;
[0050] Providing an initialization model, which is obtained by adjusting the basic YOLOX object detection model. The adjustment includes replacing the CSP module in the basic YOLOX object detection model with an efficient CSP module, introducing a lightweight model neck network, and optimizing the spatial pyramid pooling module in the basic YOLOX object detection model.
[0051] Iteratively training the initialization model using the training set to obtain the lightweight and high-precision power battery pole detection model;
[0052] Among them, the efficient CSP module replaces the Bottleneck submodule in the CSP module with a DenseBottleneck submodule connected in parallel. The DenseBottleneck submodule includes multiple fused convolution layers, and the fused convolution layer includes standard convolution and depth-wise separable convolution. The input features of the fused convolution layer generate a first convolution output after the standard convolution, and the first convolution output generates a second convolution output after the depth-wise separable convolution. The first convolution output and the second convolution output are fused to form a fused output as the output feature of the fused convolution layer. The input features and output features of the adjacent previous fused convolution layer are spliced to form a spliced feature, which serves as the input of the adjacent next fused convolution layer; the lightweight model neck network replaces some standard convolution layers in the original neck network with the fused convolution layers; the spatial pyramid pooling module adds average pooling processing, and the output features of the average pooling processing and the output features of the original maximum pooling processing are fused to replace the output features of the maximum pooling processing.
[0053] In the basic YOLOX target detection model, its backbone network is mainly composed of a combination of standard convolution and CSP modules. Network modules of different depths focus on different content. The low-level backbone modules extract the position information of the input image, and the high-level backbone modules extract the semantic information of the input image. The neck of YOLOX mainly adopts the feature transfer structure PAFPN that combines top-down and bottom-up approaches. It still uses standard convolution and CSP stacking to further process the output information of different sizes obtained by the backbone, and mixes feature information of different sizes through upsampling operators and feature splicing methods. The feature extraction ability of the backbone network is very important in the network training process. The input image is processed by the backbone network, and its target and foreground features are separated. Therefore, the present invention retains the original backbone CSP structure and only optimizes the CSP module of the neck. The original CSP module uses the Bottleneck submodule to realize feature extraction, but the serial method has the problem of information loss when the network is deepened. Therefore, the Bottleneck module is optimized. For details, see the structural comparison before and after optimization. Figure 4-Figure 8. For the SPP module, its fundamental role is to divide the input feature map into grids of different sizes, perform pooling operations at different scales to obtain feature representations, and finally splice all features into a feature vector of fixed length, which effectively solves the problem of how to avoid precision loss and computational redundancy caused by image scaling when there are multiple input features of different scales. The SPP module in the original model is applied to the connection between the backbone network and the neck of the model, which can effectively deal with the scale problems caused by different levels of the model. However, it only uses maximum pooling, focusing on the features with the largest weights in the pooling area. Taking the 3×3 convolution kernel as an example, the remaining 8 information within the range are discarded, resulting in information loss. Therefore, the present invention combines maximum pooling and average pooling, and introduces more convolution modules to realize the function of SPP, which can effectively avoid the problem of information loss.
[0054] In some embodiments, the method for obtaining the training set may specifically include the following process:
[0055] Collecting an original power battery image and marking the poles in the original power battery image to form training marks;
[0056] Performing data augmentation on the original power battery image to obtain the training set;
[0057] The data augmentation method includes any one or more combinations of image rotation, partial occlusion, illumination change, and noise addition.
[0058] In some embodiments, the original image is collected in a manner including normal shooting, tilted shooting, shooting with part of the pole out of the camera's field of view, and shooting of the pole image under actual welding conditions.
[0059] As a specific example of the above training method, the training process in actual application may include the following steps:
[0060] S1. Change the welding environment, collect images of the power battery unit, manually annotate the collected images, and save the annotated file information;
[0061] S2. Using data augmentation methods, a dataset containing various welding environments is constructed, and corresponding image labels are obtained. The dataset is then divided according to a certain ratio.
[0062] S3. Optimize the selected YOLOX target detection model, use the densely connected Bottleneck module (DenseBottleneck) to build a more efficient CSP module, introduce the lightweight model neck VoV-GSCSP and the optimized spatial pyramid pooling module (SPP) to improve the YOLOX target detection algorithm;
[0063] S4. The YOLOX network is used to train the data set to obtain a YOLOX algorithm network model. The model performance is evaluated using detection accuracy (Precision) and recall rate (Recall). The optimal model is used to detect the pole image to obtain the region of interest to indicate the position of the pole.
[0064] Regarding the specific process of obtaining the training set, the image acquisition and annotation method in step S1 above specifically includes:
[0065] Use a Daheng Mercury MERCURY2-U3 series camera or other equipment to capture images of power batteries in various welding environments from multiple angles. These images include images of power batteries against a clean and tidy background, images of power batteries placed under a clamping device, images of power batteries with circular background interference, images of power batteries under strong lighting conditions, and images of power batteries under low lighting conditions. Furthermore, the number of power battery poles in the camera's field of view varies during the capture process, ensuring coverage of both single-target and multi-target datasets.
[0066] Use the labelimg tool to annotate battery pole images and create a corresponding label file for each image. The label file uses the Pascal VOC format suitable for the YOLOX target detection model. Specifically, each time a target is annotated, the target's category label is recorded in the XML label file. The category label contains the coordinate information of the battery and the ground truth box (GT).
[0067] Furthermore, the data enhancement method and data set division operation in step S2 specifically include:
[0068] Image rotation: set each existing image to rotate once, with a maximum rotation angle of 25°, to simulate the situation where the relative position of the target and the camera changes;
[0069] The image is partially occluded. Generate a rectangular or circular mask of random size to simulate the situation where the detection target is partially occluded. The mask is required to cover no more than half of the target.
[0070] Lighting changes: the brightness of the existing image is changed by the brightness factor alpha. An alpha value less than 1 simulates the battery pole image under low light conditions, and an alpha value greater than 1 simulates the battery pole image under strong light conditions.
[0071] Add noise. Noise cannot be ignored in the welding environment. Different degrees of Gaussian noise or salt and pepper noise are added through random numbers to simulate the changes in the welding environment.
[0072] The previously labeled image data was then supplemented with images from the four aforementioned conditions in a specific ratio to form the final dataset used for model training. Simulating multiple welding environments effectively enhanced the model's generalization capabilities. The final battery dataset was then divided into training, validation, and test sets in a ratio of 8:1:1.
[0073] Regarding the optimization of the above-mentioned YOLOX target detection model, on the one hand, in some implementation schemes, the CSP module includes a first branch, a second branch and a third branch, the first branch is a direct transmission output, the second branch is sequentially passed through the first standard convolution layer and then passed to multiple parallel connected DenseBottleneck sub-modules and output, the third branch is output after passing through the second standard convolution layer, and the input features of the efficient CSP module pass through the first branch, the second branch and the third branch, and after splicing, continue to pass through the third standard convolution layer as the output features of the efficient CSP module.
[0074] As a typical example, the more efficient CSP module constructed using the densely connected Bottleneck module (DenseBottleneck) in step S3 above specifically includes:
[0075] CSP is constructed by the standard convolution module (Conv) and the Bottleneck module. The specific implementation of the Bottleneck module used by YOLOX is as follows:
[0076] The original features are input and convolved twice, achieving rapid dimensionality reduction and feature extraction, respectively. The convolved features are then summed using a branching structure to create a new feature representation. This implementation suffers from information loss when processing deeper networks, and each layer can only extract features based on the output of the previous layer, limiting feature reuse and sharing.
[0077] The Bottleneck module included in the more efficient CSP module adopts a dense connection method, called DenseBottleneck, and its specific implementation method is as follows:
[0078] The standard convolution is replaced by a lightweight convolution module GSConv that combines feature extraction capabilities with a small size. The output of the first convolution layer is concatenated with the input features as the input of the second convolution layer, ensuring that each layer can directly receive the feature information after all previous convolution processing. The feature information is retained to the maximum extent for subsequent effective feature extraction of the input graphics, greatly enhancing the reusability of the features and further alleviating the problem of gradient disappearance.
[0079] In addition to using DenseBottleneck modules, the more efficient CSP module also optimizes the connection method of multiple DenseBottleneck modules. Specifically:
[0080] Parallel connections are used to enrich the flow of gradient information and reduce the impact of deepening the model layer on gradient information. Parallel module connections can extract features more efficiently. In addition, residual connections are introduced to directly splice the input features with the features processed by multiple DenseBottlenecks through branches, which can maximize the role of input features and effectively avoid gradient explosion and gradient disappearance.
[0081] In a second aspect, in some embodiments, the lightweight model neck network includes a main branch, a first side branch, and a second side branch;
[0082] The main branch passes through the fourth standard convolution layer, the two fused convolution layers, the first sum layer, the first connection layer and the fifth standard convolution layer in sequence; the first side branch passes the output features of the fourth standard convolution layer to the first sum layer after passing through the sixth standard convolution layer; the second side branch passes the input features of the fourth standard convolution layer to the first connection layer after passing through the seventh standard convolution layer.
[0083] As a typical example, the lightweight neck model Vov-GSCSP in step S3 specifically includes:
[0084] The standard convolution module Conv is replaced with an effective combination of standard convolution and depthwise separable convolution (DWConv), called GSConv. For a given input feature map, GSConv first performs standard convolution to obtain a convolution output with half the number of channels. It then uses depthwise separable convolution to obtain a feature map for the other half of the channels. Finally, the two feature maps are concatenated and randomly shuffled along the channel dimension, fusing the feature information from the two convolutions to obtain the final output. Depthwise separable convolution divides the convolution operation into two steps. First, a depthwise convolution is performed on the input features, using the convolution kernel to process each channel of the image separately to achieve a spatial convolution effect. Second, a pointwise convolution is used to increase the dimensionality of the feature map obtained by the depthwise convolution using a 1×1 convolution to extract channel features. For a given input feature map X with a shape of (Cin, H, W), an output feature map with a shape of (Cout, H, W), and a convolution kernel size of K×K, the number of parameters and computation required for standard convolution are expressed as:
[0085] Param Conv =C in ×C out ×K×K
[0086] FLOPSConv =H×W×C in ×C out ×K×K
[0087] The reason why the GSConv module can effectively reduce the number of module parameters when the convolution capability is comparable is that the depthwise separable convolution decouples the channel and space dimensions and extracts features in the two dimensions respectively. The number of parameters and the amount of computation required are expressed as follows:
[0088] Param DWConv =C in ×K×K+C in ×C out
[0089] FLOPS DWConv =H×W×C in ×K×K+H×W×C in ×C out .
[0090] In a third aspect, in some embodiments, the spatial pyramid pooling module includes a main path, a first branch path, a second branch path, and a third branch path;
[0091] The main path passes through the eighth standard convolution layer, the ninth standard convolution layer, the tenth standard convolution layer, two maximum pooling layers, the second sum layer, a maximum pooling layer, the second connection layer, the eleventh standard convolution layer, the twelfth standard convolution layer, the third connection layer, and the thirteenth standard convolution layer in sequence; the first branch directly transfers the input features of the eighth standard convolution layer to the third connection layer; the second branch directly transfers the output features of the tenth standard convolution layer to the second sum layer; the third branch passes the output features of the tenth standard convolution layer to the second connection layer after passing through an average pooling layer.
[0092] As a typical example, the optimization of the spatial pyramid pooling module in step S3 specifically includes:
[0093] YOLOX performs spatial pyramid pooling on the extracted features in the deepest network of the backbone, performs pooling operations at different scales to obtain feature representations, and finally concatenates all features into a feature vector of fixed length, effectively solving the problem of how to avoid accuracy loss and computational redundancy caused by image scaling when there are input features of multiple scales. The SPP module in YOLOX only uses the maximum pooling method for downsampling, focusing only on the maximum weight within the convolution kernel, resulting in information loss and large redundancy in the processing of pooling operation results at multiple scales. Specifically, for the input feature map X, where the local area R contains k×k elements, R={x i,j}, where i, j are the indices of elements in R, then the maximum pooling can be expressed as:
[0094]
[0095] The optimized SPP module introduces average pooling while retaining the maximum pooling. Average pooling uses the average value of all weights in the convolution kernel as an indicator, fully considering all the information in the convolution kernel. Maximum pooling is conducive to focusing on the maximum weight, that is, the most obvious feature. The combination of the two can achieve more fine-grained information combination. In addition, more convolution processing is introduced in the optimized SPP module to enhance the feature extraction capability. Specifically, for the input feature map X, where the local area R contains k×k elements, R={x i,j}, where i, j are the indices of elements in R, then average pooling can be expressed as:
[0096]
[0097] In addition, regarding the training process, various labeled training methods can be used and matched with corresponding loss functions for training. Of course, in the present invention, an exemplary method is selected for training, that is, the model training and evaluation process in step S4, which specifically includes:
[0098] The divided training set images were fed into the optimized YOLOX network model for training. The batch_size parameter was set to 16, and stochastic gradient descent with momentum of 0.9 was used. The initial learning rate was set to 0.01 and continuously adjusted using a cosine learning rate. A reasonable number of training runs was set, and the convergence of the model loss data was used to determine whether the model training was underfitting or overfitting. Furthermore, the model's performance was evaluated by calculating the precision and recall rate at different IoU thresholds. Parameters such as the number of training runs and the learning rate were adjusted accordingly.
[0099] Among them, for each predicted bounding box, the confidence threshold is first used to determine whether the current predicted box is a positive sample Positive or a negative sample Negative. The confidence higher than the threshold is identified as a positive sample, and the confidence lower than the threshold is identified as a negative sample. For positive samples, the predicted value with an IoU value greater than or equal to the set threshold is identified as a true positive TP, and the one that does not meet the above threshold condition is identified as a false positive FP. For negative samples, all detected target boxes with an IoU value less than the threshold and the true target box are called true negative examples TN, and at least one IoU value greater than or equal to the threshold is called a false negative example FN. The precision of the target category measures the accuracy of the model in samples predicted as positive samples, and the recall rate Recall measures the accuracy of the proportion of positive samples correctly detected by the model to all positive samples. The calculation method of the two can be expressed as:
[0100]
[0101] Use the validation set to verify the improved YOLOX network model obtained through training, obtain the validation set results, analyze the differences between the training set results and the validation set results, and focus on observing whether the target is missed and whether the detection rate of the target is not much different from the detection rate on the validation set. If the verification result is not ideal, continue the adjustment strategy in the previous step until the performance of the model on the training set and validation set is balanced.
[0102] The above steps result in a relatively optimal model, which is used to detect the power battery images captured by the camera to obtain the pole images of interest. This achieves a lightweight and high-precision power battery pole detection model in complex environments.
[0103] Based on the above training method, an embodiment of the present invention further provides a lightweight and high-precision power battery pole detection method in a complex environment, which includes the following steps:
[0104] Providing a lightweight, high-precision power battery pole detection model obtained by training using the training method provided in any of the above embodiments;
[0105] The image to be detected is input into the lightweight and high-precision power battery pole detection model to obtain the pole position mark.
[0106] As a further application of the above solution, an embodiment of the present invention further provides a method for welding a pole of a power battery, which includes the following steps:
[0107] An image acquisition device is used to acquire an image of the power battery;
[0108] The above-mentioned lightweight and high-precision power battery pole detection method is used to obtain the pole position mark;
[0109] Based on the pole position mark, a welding device is guided to weld the pole.
[0110] Correspondingly, an embodiment of the present invention further provides a training system for a lightweight, high-precision power battery pole detection model in a complex environment, which includes:
[0111] A training set unit, configured to provide a training set, the training set including training images and training marks, the training images including photos of power batteries in a variety of different environments, and the training marks marking the positions of the power battery poles;
[0112] A model initialization unit is used to provide an initialization model, where the initialization model is obtained by adjusting the basic YOLOX object detection model. The adjustment includes replacing the CSP module in the basic YOLOX object detection model with an efficient CSP module, introducing a lightweight model neck network, and optimizing the spatial pyramid pooling module in the basic YOLOX object detection model.
[0113] an iterative training unit, configured to iteratively train the initialization model using the training set to obtain the lightweight and high-precision power battery pole detection model;
[0114] Among them, the efficient CSP module replaces the Bottleneck submodule in the CSP module with a DenseBottleneck submodule connected in parallel. The DenseBottleneck submodule includes multiple fused convolution layers, and the fused convolution layer includes standard convolution and depth-wise separable convolution. The input features of the fused convolution layer generate a first convolution output after the standard convolution, and the first convolution output generates a second convolution output after the depth-wise separable convolution. The first convolution output and the second convolution output are fused to form a fused output as the output feature of the fused convolution layer. The input features and output features of the adjacent previous fused convolution layer are spliced to form a spliced feature, which serves as the input of the adjacent next fused convolution layer; the lightweight model neck network replaces some standard convolution layers in the original neck network with the fused convolution layers; the spatial pyramid pooling module adds average pooling processing, and the output features of the average pooling processing and the output features of the original maximum pooling processing are fused to replace the output features of the maximum pooling processing.
[0115] In addition, an embodiment of the present invention further provides a readable storage medium, in which a computer program is stored. When the computer program is executed, the steps of the training method provided in any of the above-mentioned embodiments are executed.
[0116] The technical solution of the present invention is further described in detail below through several embodiments and in conjunction with the accompanying drawings. However, the selected embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention.
[0117] Example 1
[0118] This embodiment illustrates the training and specific application process of a pole detection model, which is as follows:
[0119] The specific technical solutions are:
[0120] See also Figure 1 This embodiment provides a lightweight and high-precision power battery pole detection method in a complex environment, comprising the following steps:
[0121] S1. Change the welding environment, collect images of the power battery unit, manually annotate the collected images, and save the annotated file information;
[0122] S2. Using data augmentation methods, a dataset containing various welding environments is constructed, and corresponding image labels are obtained. The dataset is then divided according to a certain ratio.
[0123] S3. Optimize the selected YOLOX target detection model, use the densely connected Bottleneck module (DenseBottleneck) to build a more efficient CSP module, introduce the lightweight model neck VoV-GSCSP and the optimized spatial pyramid pooling module (SPP) to improve the YOLOX target detection algorithm;
[0124] S4. Training the data set with the YOLOX network to obtain a YOLOX algorithm network model through training, evaluating the model performance using detection accuracy and recall, and using the optimal model to detect the polar image to obtain the region of interest;
[0125] It should be noted that, in this embodiment, the division ratio of the data set is not limited to the above-disclosed text ratio. It is sufficient for the data set used to train the model to ensure that it exceeds 70% of the overall data set. The model can be judged whether it has converged based on the evaluation index data of the model training continuously observed as described above. If it has converged, appropriate adjustments can be made.
[0126] As some typical examples of the above technical solutions, the main process of the pole detection method adopted is as follows: Figure 1 As shown, the specific steps include step 1 to step 6.
[0127] Step 1: Image acquisition is shown below.
[0128] One-time training, multiple uses. In order to achieve such a model effect, it is necessary to ensure that a sufficient number of images are collected. During the collection process, full consideration should be given to image collection in all situations, such as when the camera is slightly tilted, some poles are beyond the camera's field of view, and pole images under actual welding conditions, etc. Image collection should be achieved from multiple angles, and the welding environment can be flexibly changed during collection, including improving the environment and deteriorating the environment, to ensure that the target pole can be accurately detected in a variety of situations after one training.
[0129] Step 2: Data annotation, combined with Figure 2 , as shown below.
[0130] The collected image data is manually annotated to select the target area on the image. It should be noted that the selected area should reflect the position of the target on the entire image as accurately as possible, and it is not appropriate to mark too much background information as the target area. Select the polar area on the Labelimg software, and correspond the image data and the annotation data xml file one by one. The xml label file includes the image ID, image path, image name, pixel height and width of the image, and image label name. The pixel height and width of the image are represented by the four coordinates of a rectangular box, including xmin, ymin, xmax, and ymax, which represent the x pixel coordinate of the upper left corner of the real target area, the y pixel coordinate of the upper left corner of the real target area, the x pixel coordinate of the lower right corner of the real target area, and the y pixel coordinate of the lower right corner of the real target area, respectively. Accurate correspondence can help accurately locate the target position during model training and perform feature learning of the target position.
[0131] Step 3: Data enhancement, combined Figure 3 , as shown below.
[0132] After completing the annotation of the collected images in step 2 above, the image data and the corresponding annotation file information are obtained. The data enhancement method is used to enhance the image data according to a certain probability to expand the data set, and the battery pole images under various welding environments and their corresponding annotation file information are obtained, which are used as the final data set for training and verifying the model.
[0133] The data enhancement method used in this embodiment includes:
[0134] Image rotation: set each existing image to rotate once, with a maximum rotation angle of 25°, to simulate the situation where the relative position of the target and the camera changes;
[0135] The image is partially occluded. Generate a rectangular or circular mask of random size to simulate the situation where the detection target is partially occluded. The mask is required to cover no more than half of the target.
[0136] Lighting changes: the brightness of the existing image is changed by the brightness factor alpha. An alpha value less than 1 simulates the battery pole image under low light conditions, and an alpha value greater than 1 simulates the battery pole image under strong light conditions.
[0137] Add noise. Noise cannot be ignored in the welding environment. Different degrees of Gaussian noise or salt and pepper noise are added through random numbers to simulate the changes in the welding environment.
[0138] Step 4: Model construction is as follows.
[0139] CSP is constructed by the standard convolution module (Conv) and the Bottleneck module. The specific implementation of the Bottleneck module used by YOLOX is as follows:
[0140] The original features are input and convolved twice, achieving rapid dimensionality reduction and feature extraction, respectively. The convolved features are then summed using a branching structure to create a new feature representation. This implementation suffers from information loss when processing deeper networks, and each layer can only extract features based on the output of the previous layer, limiting feature reuse and sharing.
[0141] Combine Figure 4 The Bottleneck module included in the more efficient CSP module adopts a dense connection method, called DenseBottleneck, and its specific implementation is as follows:
[0142] The standard convolution is replaced by a lightweight convolution module GSConv that combines feature extraction capabilities with a small size. The output of the first convolution layer is concatenated with the input features as the input of the second convolution layer, ensuring that each layer can directly receive the feature information after all previous convolution processing. The feature information is retained to the maximum extent for subsequent effective feature extraction of the input graphics, greatly enhancing the reusability of the features and further alleviating the problem of gradient disappearance.
[0143] In addition to using DenseBottleneck modules, the more efficient CSP module also optimizes the connection method of multiple DenseBottleneck modules. Specifically:
[0144] Parallel connections are used to enrich the flow of gradient information and reduce the impact of deepening the model layer on gradient information. Parallel module connections can extract features more efficiently. In addition, residual connections are introduced to directly splice the input features with the features processed by multiple DenseBottlenecks through branches, which can maximize the role of input features and effectively avoid gradient explosion and gradient disappearance.
[0145] Further, combined with Figure 6 The lightweight model neck Vov-GSCSP specifically includes:
[0146] The standard convolution module Conv is replaced with an effective combination of standard convolution and depthwise separable convolution (DWConv), called GSConv. For a given input feature map, GSConv first performs standard convolution to obtain a convolution output with half the number of channels. It then uses depthwise separable convolution to obtain a feature map for the other half of the channels. Finally, the two feature maps are concatenated and randomly shuffled along the channel dimension, fusing the feature information from the two convolutions to obtain the final output. Depthwise separable convolution divides the convolution operation into two steps. First, a depthwise convolution is performed on the input features, using the convolution kernel to process each channel of the image separately to achieve a spatial convolution effect. Second, a pointwise convolution is used to increase the dimensionality of the feature map obtained by the depthwise convolution using a 1×1 convolution to extract channel features. For a given input feature map X with a shape of (Cin, H, W), an output feature map with a shape of (Cout, H, W), and a convolution kernel size of K×K, the number of parameters and computation required for standard convolution are expressed as:
[0147] Param Conv =C in ×C Dut ×K×K
[0148] FLOPS Conv =H×W×C in ×C out ×K×K
[0149] The reason why the GSConv module can effectively reduce the number of module parameters when the convolution capability is comparable is that the depthwise separable convolution decouples the channel and space dimensions and extracts features in the two dimensions respectively. The number of parameters and the amount of computation required are expressed as follows:
[0150] Param DWConv =C in ×K×K+C in ×C out
[0151] FLOPS DWConv =H×W×C in ×K×K+H×W×C in ×C out
[0152] Furthermore, the optimization of the spatial pyramid pooling module specifically includes:
[0153] YOLOX performs spatial pyramid pooling on the extracted features in the deepest network of the backbone, performs pooling operations at different scales to obtain feature representations, and finally concatenates all features into a feature vector of fixed length, effectively solving the problem of how to avoid accuracy loss and computational redundancy caused by image scaling when there are input features of multiple scales. The SPP module in YOLOX only uses the maximum pooling method for downsampling, focusing only on the maximum weight within the convolution kernel, resulting in information loss and large redundancy in the processing of pooling operation results at multiple scales. Specifically, for the input feature map X, where the local area R contains k×k elements, R={x i,j}, where i, j are the indices of elements in R, then the maximum pooling can be expressed as:
[0154]
[0155] Combine Figure 7 , the optimized SPP module introduces average pooling while retaining the maximum pooling. Average pooling uses the average value of all weights in the convolution kernel as an indicator, fully considering all the information in the convolution kernel. Maximum pooling is conducive to focusing on the maximum weight, that is, the most obvious feature. The combination of the two can achieve more fine-grained information combination. In addition, more convolution processing is introduced in the optimized SPP module to enhance the feature extraction capability. Specifically, for the input feature map X, where the local area R contains k×k elements, R={x i,j}, where i, j are the indices of elements in R, then average pooling can be expressed as:
[0156]
[0157] For step 5: Training and Validation, the divided training set images were fed into the optimized YOLOX network model for training. The batch_size parameter was set to 16, and stochastic gradient descent with momentum of 0.9 was used. The initial learning rate was set to 0.01 and continuously adjusted using a cosine learning rate. A reasonable number of training runs was set, and the convergence of the model loss data was used to determine whether the model training was underfitting or overfitting. Furthermore, the model's performance was evaluated by calculating the precision and recall at different IoU thresholds. Parameters such as the number of training runs and the learning rate were adjusted accordingly.
[0158] Use the validation set to verify the improved YOLOX network model obtained through training, obtain the validation set results, analyze the differences between the training set results and the validation set results, and focus on observing whether the target is missed and whether the detection rate of the target is not much different from the detection rate on the validation set. If the verification result is not ideal, continue the adjustment strategy in the previous step until the performance of the model on the training set and validation set is balanced.
[0159] Based on the existing training parameter settings, the model is trained for a given number of iterations. After each iteration, the change in the model loss value is used to preliminarily determine whether the current model has converged. After the current model is trained, the changes in precision and recall during the training process are visualized. The curves are observed and the specific values they ultimately converge to are used to determine the model's performance. Precision (target category) measures the accuracy of the model in samples predicted as positive, while recall measures the proportion of positive samples correctly detected by the model out of all positive samples.
[0160] Step 5: Apply, Combine Figure 9 , the specific implementation is as follows.
[0161] The optimized YOLOX model in this embodiment has high detection accuracy while its parameters and computational complexity are relatively reduced, which is conducive to deployment in an industrial computer. Therefore, the model is finally deployed in the industrial computer and used with a camera to capture images to achieve pre-pole welding detection.
[0162] Example 2
[0163] This example uses a series of comparison and knockout experiments to demonstrate the superior performance of the training method and model provided in Example 1, as shown below:
[0164] D0: Example 1;
[0165] D1: Perform the same training and testing directly using the basic YOLOX model;
[0166] D2: Restoring the high-efficiency CSP module in the model provided in Example 1 to the CSP module in the basic YOLOX model;
[0167] D3: Restoring the neck network of the lightweight model in the model provided in Example 1 to the neck network in the basic YOLOX model;
[0168] D4: Remove the average pooling process in the spatial pyramid pooling module in the model provided in Example 1 and restore it to the spatial pyramid pooling module in the basic YOLOX model.
[0169] After conducting the same test experiment, the results are shown in the following table:
[0170]
[0171] Based on the above embodiments, it can be clearly seen that the embodiments of the present invention apply visual inspection technology to the pre-welding inspection of power battery poles, combine lightweight methods to optimize the parameters and computational complexity of the model while maintaining high precision, use densely connected DenseBottleneck modules to enhance the guiding role of the original features in the feature extraction process, optimize the simple but poorly performing serial structure into a parallel structure, enrich the feature gradients while applying residual branches to reduce the probability of gradient explosion and gradient vanishing; introduce a lightweight neck VoV-GSCSP constructed by deep separable convolution, which greatly reduces the parameters and computational complexity of the model by multiples, while maintaining feature extraction and fusion capabilities comparable to the original neck network; also introduce a novel spatial pyramid pooling module (SPP) to consider the information within the convolution kernel from both global and local perspectives, and enhance the feature reuse capability; thereby using the optimized YOLOX model to realize power battery pole detection, which can effectively avoid the interference of complex welding environments that traditional detection methods are difficult to cope with, and realize lightweight, high-precision pole detection with environmental universality.
[0172] It should be understood that the above embodiments are merely illustrative of the technical concepts and features of the present invention. Their purpose is to enable those skilled in the art to understand the contents of the present invention and implement them accordingly. They are not intended to limit the scope of protection of the present invention. Any equivalent variations or modifications made in accordance with the spirit and substance of the present invention are intended to be encompassed within the scope of protection of the present invention.
Claims
1. A training method for a lightweight and high-precision power battery pole detection model in a complex environment, characterized by: include: Providing a training set, the training set including training images and training labels, the training images including photos of power batteries in various environments, and the training labels marking the positions of the power battery poles; Providing an initialization model, which is obtained by adjusting the basic YOLOX object detection model. The adjustment includes replacing the CSP module in the basic YOLOX object detection model with an efficient CSP module, introducing a lightweight model neck network, and optimizing the spatial pyramid pooling module in the basic YOLOX object detection model. Iteratively training the initialization model using the training set to obtain the lightweight and high-precision power battery pole detection model; Among them, the efficient CSP module replaces the Bottleneck submodule in the CSP module with a parallel connected DenseBottleneck submodule, and the DenseBottleneck submodule includes multiple fused convolution layers, and the fused convolution layer includes a standard convolution and a depth-wise separable convolution. The input features of the fused convolution layer generate a first convolution output after the standard convolution, and the first convolution output generates a second convolution output after the depth-wise separable convolution. The first convolution output and the second convolution output are fused to form a fused output as the output feature of the fused convolution layer, and the input features and output features of the adjacent previous fused convolution layer are spliced to form a spliced feature, which serves as the input of the adjacent next fused convolution layer; the lightweight model neck network replaces some standard convolution layers in the original neck network with the fused convolution layers; The spatial pyramid pooling module adds an average pooling process, and the output features of the average pooling process are fused with the output features of the original maximum pooling process to replace the output features of the maximum pooling process.
2. The training method according to claim 1, characterized in that The method of obtaining the training set specifically includes: Collecting an original power battery image and marking the poles in the original power battery image to form training marks; Performing data augmentation on the original power battery image to obtain the training set; The data augmentation method includes any one or more combinations of image rotation, partial occlusion, illumination change, and noise addition.
3. The training method according to claim 2, characterized in that The acquisition methods of the original power battery image include normal shooting, tilted shooting, shooting with some poles out of the camera's field of view, and shooting of pole images under actual welding conditions.
4. The training method according to claim 1, characterized in that The CSP module includes a first branch, a second branch and a third branch. The first branch is a direct transmission output. The second branch is sequentially passed through the first standard convolution layer and then passed to multiple parallel connected DenseBottleneck sub-modules and output. The third branch is output after passing through the second standard convolution layer. The input features of the efficient CSP module pass through the first branch, the second branch and the third branch, and after splicing, continue to pass through the third standard convolution layer as the output features of the efficient CSP module.
5. The training method according to claim 1, wherein: The lightweight model neck network includes a main branch, a first side branch, and a second side branch; The main branch passes through the fourth standard convolution layer, the two fused convolution layers, the first sum layer, the first connection layer and the fifth standard convolution layer in sequence; the first side branch passes the output features of the fourth standard convolution layer to the first sum layer after passing through the sixth standard convolution layer; the second side branch passes the input features of the fourth standard convolution layer to the first connection layer after passing through the seventh standard convolution layer.
6. The training method according to claim 1, characterized in that The spatial pyramid pooling module includes a main path, a first branch path, a second branch path and a third branch path; The main path passes through the eighth standard convolution layer, the ninth standard convolution layer, the tenth standard convolution layer, two maximum pooling layers, the second sum layer, a maximum pooling layer, the second connection layer, the eleventh standard convolution layer, the twelfth standard convolution layer, the third connection layer, and the thirteenth standard convolution layer in sequence; the first branch directly transfers the input features of the eighth standard convolution layer to the third connection layer; the second branch directly transfers the output features of the tenth standard convolution layer to the second sum layer; the third branch passes the output features of the tenth standard convolution layer to the second connection layer after passing through an average pooling layer.
7. A lightweight and high-precision power battery pole detection method in a complex environment, characterized in that: include: Providing a lightweight and high-precision power battery pole detection model obtained by training using the training method according to any one of claims 1 to 6; The image to be detected is input into the lightweight and high-precision power battery pole detection model to obtain the pole position mark.
8. A method for welding a pole of a power battery, characterized in that: include: An image acquisition device is used to acquire an image of the power battery; The lightweight and high-precision power battery pole detection method according to claim 7 is used to obtain the pole position mark; Based on the pole position mark, a welding device is guided to weld the pole.
9. A training system for a lightweight, high-precision power battery pole detection model in a complex environment, characterized by: include: A training set unit, configured to provide a training set, the training set including training images and training marks, the training images including photos of power batteries in a variety of different environments, and the training marks marking the positions of the power battery poles; A model initialization unit is used to provide an initialization model, where the initialization model is obtained by adjusting the basic YOLOX object detection model. The adjustment includes replacing the CSP module in the basic YOLOX object detection model with an efficient CSP module, introducing a lightweight model neck network, and optimizing the spatial pyramid pooling module in the basic YOLOX object detection model. an iterative training unit, configured to iteratively train the initialization model using the training set to obtain the lightweight and high-precision power battery pole detection model; Among them, the efficient CSP module replaces the Bottleneck submodule in the CSP module with a parallel connected DenseBottleneck submodule, and the DenseBottleneck submodule includes multiple fused convolution layers, and the fused convolution layer includes a standard convolution and a depth-wise separable convolution. The input features of the fused convolution layer generate a first convolution output after the standard convolution, and the first convolution output generates a second convolution output after the depth-wise separable convolution. The first convolution output and the second convolution output are fused to form a fused output as the output feature of the fused convolution layer, and the input features and output features of the adjacent previous fused convolution layer are spliced to form a spliced feature, which serves as the input of the adjacent next fused convolution layer; the lightweight model neck network replaces some standard convolution layers in the original neck network with the fused convolution layers; The spatial pyramid pooling module adds an average pooling process, and the output features of the average pooling process are fused with the output features of the original maximum pooling process to replace the output features of the maximum pooling process.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed, the steps of the training method according to any one of claims 1 to 6 are executed.
Citation Information
Patent Citations
Detection system and method for online size spot inspection of lithium battery
CN115731165A
Lightweight SAR ship detection method and system
CN116844055A
Underwater target detection method based on multi-scale feature cross fusion
CN119091286A