Battery shell welding position defect detection method and device based on data expansion
By performing data expansion and model training on the battery casing welding image data, and using the Transformer encoder and multi-layer perceptron MLP module, the problem of small data volume in the industrial environment is solved and the accuracy of defect detection is improved.
Patent Information
- Application Number
- CN202410752781.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-27
AI Technical Summary
The existing battery casing welding defect detection method in an industrial environment has a small amount of data due to difficulty in data collection and a small sample size, which is not conducive to the training of deep learning network models, resulting in low accuracy of defect types and defect locations.
By data expansion of the battery casing welding image sample data, the expanded data and labels are generated, and the Transformer encoder and multi-layer perceptron MLP module are used to train the model to improve the accuracy of defect detection.
It is possible to improve the accuracy of defect detection at battery casing welds in an industrial environment with a small amount of data, ensuring accurate identification of defect types and defect locations.
Smart Images

Figure CN118710600A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of battery shell welding defect detection, and in particular to a battery shell welding defect detection method and device based on data expansion. Background Art
[0002] The existing battery shell welding defect detection methods generally use deep learning or machine vision methods with RGB images or grayscale images. The deep learning method is generally used in the field of defect detection. The method uses the Backbone+Neck+Head framework structure, where the Backbone is the feature extraction module, generally using CNN, ResNet, Swin-Transformer, VGG network. Neck is used to connect the Backbone and the Head for feature fusion learning. Neck generally uses FPN, PANet, Transformer models. Head is the output head, which is used to process the Neck output data to predict the defect type and location. Head generally uses Yolo, Faster R-CNN, NMS, FFN and other models. The use of the Backbone+Neck+Head structure results in an overly large model, more data parameters, and a large amount of calculation. A large amount of data is required to achieve a better effect. In addition, when collecting RGB images or grayscale images, it is necessary to take into account multiple factors such as lighting and angle, and the useless features of the collected images are much higher than the part to be detected. However, due to the difficulty in data collection in industrial environments and the small sample size, the cost of collecting large amounts of data is high. Combined with the defects of existing technologies, existing battery casing weld defect detection methods are difficult to apply to industrial environments with small data volumes and small features. Summary of the invention
[0003] The present invention provides a battery shell welding defect detection method based on data expansion, which can perform data expansion on the collected sample data and increase the data volume so as to train a battery shell welding defect detection model, further obtain a battery shell welding defect detection model with high accuracy, and then obtain defect types and defect positions with high accuracy.
[0004] In order to solve the above technical problems, an embodiment of the present invention provides a battery casing welding defect detection method based on data expansion, comprising:
[0005] Acquire image data of the welding part of the battery shell to be inspected;
[0006] Input the image data of the welding part of the battery shell to be detected into the trained defect detection model of the welding part of the battery shell, so that the defect detection model of the welding part of the battery shell can detect the image data of the welding part of the battery shell to be detected, and obtain the defect type and defect position of the welding part of the battery shell;
[0007] The training of the battery casing welding defect detection model includes:
[0008] Obtain image sample data of the welding part of the battery shell;
[0009] Performing grayscale processing on the image sample data of the welding portion of the battery shell to generate a grayscale image;
[0010] Labeling the defect position of the grayscale image with label information, calculating the row range of the defect position, and using the calculated row range value as the defect category in the label information to generate a first label;
[0011] The grayscale image and the first label are spliced in the column direction, and a plurality of random intervals are set for sampling to generate a plurality of sampled data and labels;
[0012] The data and labels sampled from multiple different random intervals are combined and spliced in the row direction to generate expanded data and labels;
[0013] The expanded data and labels are input into the battery shell welding defect detection model for model training to obtain a trained battery shell welding defect detection model.
[0014] Furthermore, before grayscale processing is performed on the image sample data of the battery shell welding position to generate a grayscale image, the method further includes: performing a Binning transformation on each row of the image sample data of the battery shell welding position.
[0015] Furthermore, after generating the expanded data and labels, the method further includes: performing a padding fixation operation on the expanded data and labels.
[0016] Furthermore, the grayscale processing of the image sample of the welding point of the battery shell to generate a grayscale image includes: generating a grayscale image matrix using a grayscale image matrix formula combined with a relu function, and generating a grayscale image according to the grayscale image matrix.
[0017] Further, the labeling of the defect position of the grayscale image with label information, calculating the row range of the defect position, and using the calculated row range value as the defect category in the label information to generate a first label includes:
[0018] Label the defect position of the grayscale image with label information to obtain a label Y; wherein the label information of the label Y includes the number of label boxes and the label box information, and the label box information includes the defect category, the x-coordinate of the box center, the y-coordinate of the box center, the box width ratio, and the box height ratio;
[0019] According to the y coordinate of the frame center, the frame width ratio and the frame height ratio, the row range value is calculated by using the row range formula for calculating the defect position, and the calculated row range value is used as the defect category in the label information to generate the first label.
[0020] Furthermore, the row range formula for calculating the defect position is specifically:
[0021]
[0022] Among them, i represents the i-th defect box, i height It represents the height ratio of the i-th defect box, and n is the number of rows.
[0023] Furthermore, after splicing the grayscale image and the first label in the column direction and setting a plurality of random intervals for sampling to generate a plurality of sampled data and labels, it also includes: using a One_hot encoding method to convert the decimal code of the generated plurality of sampled labels into a binary code.
[0024] Furthermore, the battery shell welding defect detection model includes a data acquisition module, a one-dimensional feature extraction module, a Transformer encoder, a multi-layer perceptron MLP module and a prediction output module;
[0025] When training the battery casing welding defect detection model, the expanded data and labels are obtained through the data acquisition module;
[0026] The expanded data is subjected to feature extraction and position coding calculation through a one-dimensional feature extraction module and a position coding formula, and feature extraction data and position coding are obtained;
[0027] The feature extraction data and the position code are added and input into the Transformer encoder for encoder encoding and decoder learning position information to obtain the encoding learning data;
[0028] The predicted value is calculated for the encoded learning data through the multi-layer perceptron MLP module to obtain the predicted value, the cross-entropy loss value is calculated according to the predicted value, the expanded label and the cross-entropy loss function, and the defect detection model of the battery shell welding is optimized by back-propagation according to the cross-entropy loss value;
[0029] The defect category and defect location of the battery casing welding are determined based on the FFN network of the prediction value and prediction output module.
[0030] Furthermore, the formula for calculating the cross entropy loss value of the cross entropy loss function is specifically:
[0031]
[0032] Where M = num_cls represents the number of defect categories; y ic Represents 0 or 1, when sample i is equal to defect category c, y ic Take 1, when sample i is not equal to defect category c, y ic Take 0; p ic represents the probability that sample i belongs to defect category c.
[0033] Based on the above method embodiment, the present invention provides a corresponding device embodiment;
[0034] An embodiment of the present invention provides a battery casing welding defect detection device based on data expansion, comprising: an image data acquisition module, a defect detection model module and a model training module; wherein the model training module comprises an image sample acquisition unit, a grayscale image unit, a first label unit, a sampling unit, a splicing unit and a model generation unit;
[0035] The image data acquisition module is used to acquire image data of the welding part of the battery shell to be inspected;
[0036] The defect detection model module is used to input the image data of the battery shell welding position to be detected into the trained battery shell welding position defect detection model, so that the battery shell welding position defect detection model detects the image data of the battery shell welding position to be detected, and obtains the defect type and defect position of the battery shell welding position;
[0037] The image sample acquisition unit is used to obtain image sample data of the welding part of the battery shell;
[0038] The grayscale image unit is used to perform grayscale processing on the image sample data of the welding part of the battery shell to generate a grayscale image;
[0039] The first label unit is used to label the defect position of the grayscale image, calculate the row range of the defect position, use the calculated row range value as the defect category in the label information, and generate a first label;
[0040] The sampling unit is used to splice the grayscale image and the first label in the column direction, and set a plurality of random intervals for sampling to generate a plurality of sampled data and labels;
[0041] The splicing unit is used to combine and splice the data and labels sampled from multiple different random intervals in the row direction to generate expanded data and labels;
[0042] The model generation unit is used to input the expanded data and labels into the battery shell welding defect detection model for model training to obtain a trained battery shell welding defect detection model.
[0043] Furthermore, before the grayscale image unit, it also includes: a Binning transformation unit for performing Binning transformation on each row of the battery casing welding position image sample data acquired by the image sample acquisition unit.
[0044] Furthermore, after the sampling unit, it also includes: a label coding conversion unit for converting the decimal coding of the labels for generating the multiple samples into binary coding by a One-hot coding method.
[0045] Furthermore, after the splicing unit, it also includes: a Padding fixing unit for performing a Padding fixing operation on the expanded data and labels.
[0046] Furthermore, the grayscale image unit includes: a grayscale matrix calculator and a grayscale image generator; wherein the grayscale matrix calculator is used to generate a grayscale image matrix using a grayscale image matrix formula combined with a relu function; and the grayscale image generator is used to generate a grayscale image based on the grayscale image matrix.
[0047] Furthermore, the first label unit includes: a label information labeling unit and a first label calculation unit; wherein the label information labeling unit is used to label the defect position of the grayscale image to obtain a label Y; wherein the label information of label Y includes the number of labeled boxes and the labeled box information, and the labeled box information includes the defect category, the x-coordinate of the box center, the y-coordinate of the box center, the frame width ratio and the frame height ratio; the first label calculation unit is used to calculate the row range value according to the y-coordinate of the box center, the frame width ratio and the frame height ratio by calculating the row range formula of the defect position, and use the calculated row range value as the defect category in the label information to generate the first label.
[0048] Furthermore, the model generation unit includes: a data acquisition module, a one-dimensional feature extraction module, a Transformer encoder, a multi-layer perceptron MLP module and a prediction output module; wherein the data acquisition module is used to obtain expanded data and labels; the one-dimensional feature extraction module is used to perform feature extraction and calculate position coding on the expanded data according to the position coding formula to obtain feature extraction data and position coding; the Transformer encoder is used to perform encoder coding and decoder learning position information according to the feature extraction data and position coding to obtain coding learning data; the multi-layer perceptron MLP module calculates the predicted value of the coding learning data to obtain the predicted value, calculates the cross entropy loss value according to the predicted value, the expanded label and the cross entropy loss function, and back-propagates and optimizes the defect detection model of the battery shell welding according to the cross entropy loss value; the prediction output module is used to determine the defect category and defect position of the battery shell welding according to the predicted value and the FFN network of the prediction output module.
[0049] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0050] The technical solution of the present invention expands the data of the image sample data of the battery shell welding point, and inputs the expanded data as training data into the battery shell welding point image defect detection model for model training, thereby further obtaining a battery shell welding point image defect detection model with high accuracy, and then obtaining defect types and defect locations with high accuracy, thereby solving the problem that the prior art has a small amount of data due to difficulties in data collection and a small amount of samples in an industrial environment, which is not conducive to the training of a deep learning network model, and further cannot obtain a deep learning network model with high accuracy, which leads to low accuracy in the final determination of the defect type and defect location of the battery shell welding point. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 : A flow chart of the steps of a battery casing welding defect detection method based on data expansion provided by an embodiment of the present invention;
[0052] Figure 2 : A device structure diagram of a device for detecting defects at welding points of a battery casing with data expansion provided by an embodiment of the present invention;
[0053] Figure 3 : is a structural diagram of a battery casing welding defect detection model in an embodiment of the present invention. DETAILED DESCRIPTION
[0054] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0055] Please refer to Figure 1 , is a flow chart of the steps of a battery casing welding defect detection method based on data expansion provided by an embodiment of the present invention; the method includes steps S1 to S2, each step is specifically as follows:
[0056] Step S1, obtaining image data of the welding part of the battery shell to be inspected;
[0057] Step S2, input the image data of the battery shell weld to be detected into the trained battery shell weld defect detection model, so that the battery shell weld defect detection model detects the image data of the battery shell weld to be detected, and obtains the defect type and defect position of the battery shell weld; wherein, the training of the battery shell weld defect detection model includes: obtaining sample image data of the battery shell weld; grayscale processing the sample image data of the battery shell weld to generate a grayscale image; labeling the defect position of the grayscale image with label information, and calculating the row range of the defect position, using the calculated row range value as the defect category in the label information, and generating a first label; splicing the grayscale image and the first label in the column direction, and setting multiple random intervals for sampling to generate multiple sampled data and labels; combining and splicing the data and labels sampled by multiple different random intervals in the row direction to generate expanded data and labels; inputting the expanded data and labels into the battery shell weld defect detection model for model training to obtain a trained battery shell weld defect detection model.
[0058] In this embodiment, the obtaining of the image sample data of the battery casing welding portion is specifically to use a Keyence laser profile measuring instrument and a mobile platform to collect the image sample data of the battery casing welding portion, wherein the dimension of the image sample data of the battery casing welding portion is 800.
[0059] In this embodiment, before grayscale processing is performed on the image sample data of the battery shell welding position to generate a grayscale image, the method further includes: performing a Binning transformation on each row of the image sample data of the battery shell welding position to reduce the dimension to 400. The calculation formula of the Binning transformation is specifically:
[0060]
[0061] In this embodiment, the image sample data of the battery shell welding position is gray-processed to generate a gray-scale image, specifically: a gray-scale image matrix is generated using a gray-scale image matrix formula combined with a relu function, and a gray-scale image is generated according to the gray-scale image matrix, wherein the gray-scale image matrix formula combined with the relu function is specifically:
[0062]
[0063] X is the dimensionally reduced image data, X grey Represents the grayscale image matrix, X max and X min They represent the maximum and minimum values in the dimensionally reduced image data respectively. α is an empirical value. The value of α is selected according to the original data in order to retain the effective features. For this data set, α = 1.5.
[0064] In this embodiment, the defect position of the grayscale image is annotated with label information, and the row range of the defect position is calculated, and the value of the calculated row range is used as the defect category in the label information to generate a first label, specifically: the defect position of the grayscale image is annotated with label information to obtain a label Y; wherein the label information of the label Y includes the number of annotated boxes and the annotated box information, and the annotated box information includes the defect category, the x-coordinate of the box center, the y-coordinate of the box center, the box width ratio, and the box height ratio;
[0065] According to the y coordinate of the center of the frame, the frame width ratio and the frame height ratio, the row range value is calculated by the row range formula of the defect position, and the calculated row range value is used as the defect category in the label information to generate the first label. The row range formula for calculating the defect position is specifically:
[0066]
[0067] i represents the i-th defect box, i height It represents the height ratio of the i-th defect box, and n is the number of rows.
[0068] In this embodiment, the grayscale image and the first label are spliced in the column direction, and a plurality of random intervals are set for sampling to generate a plurality of sampled data and labels. Specifically, the grayscale image and the first label are spliced in the column direction to become Z′, and then a random interval [s1, s2] is generated to sample the original data to generate sampled data and labels; wherein the sampled data and labels are specifically:
[0069] X new =Z′[s1:s2,1:400]
[0070] Y new =Z′[s1:s2,401]
[0071] 0≤s1<s2≤400, Z′[s1:s2,1:400] means rows s1 to s2 and columns 1 to 400 of Z′, Represent the sampled data and labels respectively, and num_cls represents the number of defect categories.
[0072] In this embodiment, after splicing the grayscale image and the first label in the column direction and setting a plurality of random intervals for sampling to generate a plurality of sampled data and labels, it also includes: using a One_hot encoding method to convert the decimal code of the generated plurality of sampled labels into a binary code.
[0073] In this embodiment, the data and labels sampled from multiple different random intervals are combined and spliced in the row direction to generate extended data and labels, specifically: the data and labels sampled from multiple different random intervals are combined and spliced in the row direction by using the Concatenate function to generate extended data and labels; wherein the Concatenate function combines and splices the data and labels sampled from multiple different random intervals in the row direction, specifically:
[0074]
[0075] In the formula and Represents the data and labels sampled in the pth random interval, X′ new and Y′ new Represent the expanded data and labels respectively.
[0076] In this embodiment, after the expanded data and labels are generated, the method further includes: performing a Padding fixation operation on the expanded data and labels.
[0077] In this embodiment, combined with Figure 3 , input the expanded data and labels into the battery shell welding defect detection model for model training, and obtain a trained battery shell welding defect detection model, specifically: the battery shell welding defect detection model includes a data acquisition module, a one-dimensional feature extraction module, a Transformer encoder, a multi-layer perceptron MLP module and a prediction output module;
[0078] When training the battery casing welding defect detection model, the expanded data and labels are obtained through the data acquisition module;
[0079] The expanded data is subjected to feature extraction and position coding calculation through a one-dimensional feature extraction module and a position coding formula to obtain feature extraction data and position coding; wherein the position coding formula is specifically:
[0080] PE pos,2i =sin(pos / 10000 2i / d )
[0081] PE pos,2i+1 =cos(pos / 10000 2i / d )
[0082] pos represents the position of a row in the entire sequence, d represents the dimension of PE, and also represents the feature dimension of each row after one-dimensional feature extraction;
[0083] The feature extraction data and the position code are added and input into the Transformer encoder for encoder encoding and decoder learning position information to obtain the encoding learning data;
[0084] The predicted value is calculated for the encoded learning data through the multi-layer perceptron MLP module to obtain the predicted value, the cross entropy loss value is calculated according to the predicted value, the expanded label and the cross entropy loss function, and the battery casing welding defect detection model is back-propagated according to the cross entropy loss value; wherein the formula for calculating the cross entropy loss value of the cross entropy loss function is specifically:
[0085]
[0086] Where M = num_cls represents the number of categories; y ic Represents 0 or 1, when sample i is equal to defect category c, y ic Take 1, when sample i is not equal to defect category c, y ic Take 0; p ic represents the probability that sample i belongs to defect category c;
[0087] The defect category and defect location of the battery casing welding are determined based on the FFN network of the prediction value and prediction output module.
[0088] Please refer to Figure 2 , which is a device structure diagram of a data-expanded battery casing welding defect detection device provided by an embodiment of the present invention; the device includes: an image data acquisition module, a defect detection model module and a model training module; wherein the model training module includes an image sample acquisition unit, a grayscale image unit, a first label unit, a sampling unit, a splicing unit and a model generation unit;
[0089] In this embodiment, the image data acquisition module is used to acquire image data of the welding part of the battery shell to be inspected;
[0090] In this embodiment, the defect detection model module is used to input the image data of the battery shell welding position to be detected into the trained battery shell welding position defect detection model, so that the battery shell welding position defect detection model detects the image data of the battery shell welding position to be detected, and obtains the defect type and defect position of the battery shell welding position;
[0091] In this embodiment, the model training module includes an image sample acquisition unit, a Binning transformation unit, a grayscale image unit, a first label unit, a sampling unit, a label encoding conversion unit, a splicing unit, a Padding fixing unit and a model generation unit.
[0092] In this embodiment, the image sample acquisition unit is used to acquire image sample data of the welding part of the battery casing using a Keyence laser profile measuring instrument and a mobile platform, wherein the dimension of the image sample data of the welding part of the battery casing is 800.
[0093] In this embodiment, the Binning transformation unit is used to perform Binning transformation on each row of the battery shell welding image sample data acquired by the image sample acquisition unit to reduce the dimension to 400. The calculation formula of the Binning transformation is specifically:
[0094]
[0095] In this embodiment, the grayscale image unit is used to perform grayscale processing on the image sample data of the welding part of the battery shell to generate a grayscale image, specifically: the grayscale image unit includes a grayscale matrix calculator and a grayscale image generator; wherein, the grayscale matrix calculator is used to generate a grayscale image matrix using a grayscale image matrix formula combined with a relu function; the grayscale image generator is used to generate a grayscale image according to the grayscale image matrix; the grayscale image matrix formula combined with the relu function is specifically:
[0096]
[0097] X is the dimensionally reduced image data, X grey Represents the grayscale image matrix, X max and X min They represent the maximum and minimum values in the dimensionally reduced image data respectively. α is an empirical value. The value of α is selected according to the original data in order to retain the effective features. For this data set, α = 1.5.
[0098] In this embodiment, the first label unit is used to annotate the defect position of the grayscale image with label information, and calculate the row range of the defect position, and use the calculated value of the row range as the defect category in the label information to generate a first label. Specifically, the first label unit includes a label information annotating unit and a first label calculating unit.
[0099] The label information labeling unit is used to label the defect position of the grayscale image to obtain a label Y; wherein the label information of the label Y includes the number of label boxes and the label box information, and the label box information includes the defect category, the x-coordinate of the box center, the y-coordinate of the box center, the box width ratio and the box height ratio;
[0100] The first label calculation unit is used to calculate the value of the row range according to the y coordinate of the frame center, the frame width ratio and the frame height ratio by using the row range formula for calculating the defect position, and use the calculated row range value as the defect category in the label information to generate the first label;
[0101] The row range formula for calculating the defect position is specifically:
[0102]
[0103] i represents the i-th defect box, i height It represents the height ratio of the i-th defect box, and n is the number of rows.
[0104] In this embodiment, the sampling unit is used to splice the grayscale image and the first label in the column direction, and set multiple random intervals for sampling to generate multiple sampled data and labels, specifically: splice the grayscale image and the first label in the column direction to become z′, and then generate a random interval [s1, s2] to sample the original data to generate sampled data and labels; wherein the sampled data and labels are specifically:
[0105] X new =Z′[s1:s2,1:400]
[0106] Y new =Z'[s1:s2,401]
[0107] 0≤s1<s2≤400, Z′[s1:s 2, 1∶4000] represents rows s1 to s2 and columns 1 to 400 of z′, Represent the sampled data and labels respectively, and num_cls represents the number of defect categories.
[0108] In this embodiment, the label coding conversion unit is used to convert the decimal coding of the labels for generating the multiple samples into binary coding by using a One-hot coding method.
[0109] In this embodiment, the concatenation unit is used to combine and concatenate the data and labels sampled from multiple different random intervals in the row direction to generate extended data and labels, specifically: using the Concatenate function to combine and concatenate the data and labels sampled from multiple different random intervals in the row direction to generate extended data and labels; wherein the Concatenate function combines and concatenates the data and labels sampled from multiple different random intervals in the row direction, specifically:
[0110]
[0111] In the formula and Represents the data and labels sampled in the pth random interval, X′ new and Y′ new Represent the expanded data and labels respectively.
[0112] In this embodiment, the padding fixing unit is used to perform a padding fixing operation on the expanded data and the label.
[0113] In this embodiment, combined with Figure 3 The model generation unit is used to input the expanded data and labels into the battery shell welding defect detection model for model training to obtain a trained battery shell welding defect detection model. The model generation unit includes a data acquisition module, a one-dimensional feature extraction module, a Transformer encoder, a multi-layer perceptron MLP module and a prediction output module;
[0114] The data acquisition module is used to obtain the expanded data and labels;
[0115] The one-dimensional feature extraction module is used to extract features and calculate position codes for the expanded data according to the position coding formula to obtain feature extraction data and position codes; the position coding formula is specifically:
[0116] PE pos,2i =sin(pos / 10000 2i / d)
[0117] PE pos,2i+1 =cos((pos / 10000 2i / d )
[0118] pos represents the position of a row in the entire sequence, d represents the dimension of PE, and also represents the feature dimension of each row after one-dimensional feature extraction;
[0119] The Transformer encoder is used to perform encoder encoding and decoder learning position information according to feature extraction data and position encoding to obtain encoding learning data;
[0120] The multi-layer perceptron MLP module calculates the predicted value of the encoded learning data to obtain the predicted value, calculates the cross entropy loss value according to the predicted value, the expanded label and the cross entropy loss function, and back-propagates and optimizes the battery casing welding defect detection model according to the cross entropy loss value; the formula for calculating the cross entropy loss value of the cross entropy loss function is specifically:
[0121]
[0122] Where M = num_cls represents the number of categories; y ic Represents 0 or 1, when sample i is equal to defect category c, y ic Take 1, when sample i is not equal to defect category c, y ic Take 0; p ic represents the probability that sample i belongs to defect category c;
[0123] The prediction output module is used to determine the defect category and defect location of the battery casing welding part according to the prediction value and the FFN network of the prediction output module.
[0124] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0125] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
[0126] Those skilled in the art can understand that all or part of the processes in the above embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes in the above embodiments. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
Claims
1. A battery casing welding defect detection method based on data expansion, characterized in that: include: Acquire image data of the welding part of the battery shell to be inspected; Input the image data of the welding part of the battery shell to be detected into the trained defect detection model of the welding part of the battery shell, so that the defect detection model of the welding part of the battery shell can detect the image data of the welding part of the battery shell to be detected, and obtain the defect type and defect position of the welding part of the battery shell; The training of the battery casing welding defect detection model includes: Obtain image sample data of the welding part of the battery shell; Performing grayscale processing on the image sample data of the welding portion of the battery shell to generate a grayscale image; Labeling the defect position of the grayscale image with label information, calculating the row range of the defect position, and using the calculated row range value as the defect category in the label information to generate a first label; The grayscale image and the first label are spliced in the column direction, and a plurality of random intervals are set for sampling to generate a plurality of sampled data and labels; The data and labels sampled from multiple different random intervals are combined and spliced in the row direction to generate expanded data and labels; The expanded data and labels are input into the battery shell welding defect detection model for model training to obtain a trained battery shell welding defect detection model.
2. A battery casing welding defect detection method based on data expansion according to claim 1, characterized in that: Before grayscale processing is performed on the image sample data of the battery shell welding position to generate a grayscale image, the method further includes: performing Binning transformation on each row of the image sample data of the battery shell welding position.
3. A battery casing welding defect detection method based on data expansion according to claim 1, characterized in that: After the expanded data and labels are generated, the method further includes: performing a Padding fixation operation on the expanded data and labels.
4. A battery casing welding defect detection method based on data expansion according to claim 1, characterized in that: The grayscale processing of the image sample of the welding portion of the battery shell to generate a grayscale image includes: A grayscale image matrix is generated using the grayscale image matrix formula combined with the relu function, and a grayscale image is generated based on the grayscale image matrix.
5. A battery casing welding defect detection method based on data expansion according to claim 1, characterized in that: The step of labeling the defect position of the grayscale image with label information, calculating the row range of the defect position, and using the calculated row range value as the defect category in the label information to generate a first label includes: Label the defect position of the grayscale image with label information to obtain a label Y; wherein the label information of the label Y includes the number of label boxes and the label box information, and the label box information includes the defect category, the x-coordinate of the box center, the y-coordinate of the box center, the box width ratio, and the box height ratio; According to the y coordinate of the frame center, the frame width ratio and the frame height ratio, the row range value is calculated by using the row range formula for calculating the defect position, and the calculated row range value is used as the defect category in the label information to generate the first label.
6. A battery casing welding defect detection method based on data expansion according to claim 5, characterized in that: The row range formula for calculating the defect position is specifically: Among them, i represents the i-th defect box, i height It represents the height ratio of the i-th defect box, and n is the number of rows.
7. A battery casing welding defect detection method based on data expansion according to claim 1, characterized in that: After the grayscale image and the first label are spliced in the column direction and a plurality of random intervals are set for sampling to generate a plurality of sampled data and labels, the method further includes: converting the decimal code of the generated plurality of sampled labels into a binary code using a One_hot encoding method.
8. A battery casing welding defect detection method based on data expansion according to claim 1, characterized in that: The battery shell welding defect detection model includes a data acquisition module, a one-dimensional feature extraction module, a Transformer encoder, a multi-layer perceptron MLP module and a prediction output module; When training the battery casing welding defect detection model, the expanded data and labels are obtained through the data acquisition module; The expanded data is subjected to feature extraction and position coding calculation through a one-dimensional feature extraction module and a position coding formula, and feature extraction data and position coding are obtained; The feature extraction data and the position code are added and input into the Transformer encoder for encoder encoding and decoder learning position information to obtain the encoding learning data; The predicted value is calculated for the encoded learning data through the multi-layer perceptron MLP module to obtain the predicted value, the cross-entropy loss value is calculated according to the predicted value, the expanded label and the cross-entropy loss function, and the defect detection model of the battery shell welding is optimized by back-propagation according to the cross-entropy loss value; The defect category and defect location of the battery casing welding are determined based on the FFN network of the prediction value and prediction output module.
9. A battery casing welding defect detection method based on data expansion according to claim 8, characterized in that: The cross entropy loss function is calculated using the cross entropy loss value formula, specifically: Where M = num_cls represents the number of categories; y ic Represents 0 or 1, when sample i is equal to defect category c, y ic Take 1, when sample i is not equal to defect category c, y ic Take 0; p ic represents the probability that sample i belongs to defect category c.
10. A battery casing welding defect detection device based on data expansion, characterized in that: include: Image data acquisition module, defect detection model module and model training module; The model training module includes an image sample acquisition unit, a grayscale image unit, a first label unit, a sampling unit, a splicing unit and a model generation unit; The image data acquisition module is used to acquire image data of the welding part of the battery shell to be inspected; The defect detection model module is used to input the image data of the battery shell welding position to be detected into the trained battery shell welding position defect detection model, so that the battery shell welding position defect detection model detects the image data of the battery shell welding position to be detected, and obtains the defect type and defect position of the battery shell welding position; The image sample acquisition unit is used to obtain image sample data of the welding part of the battery shell; The grayscale image unit is used to perform grayscale processing on the image sample data of the welding part of the battery shell to generate a grayscale image; The first label unit is used to label the defect position of the grayscale image, calculate the row range of the defect position, use the calculated row range value as the defect category in the label information, and generate a first label; The sampling unit is used to splice the grayscale image and the first label in the column direction, and set a plurality of random intervals for sampling to generate a plurality of sampled data and labels; The splicing unit is used to combine and splice the data and labels sampled from multiple different random intervals in the row direction to generate expanded data and labels; The model generation unit is used to input the expanded data and labels into the battery shell welding defect detection model for model training to obtain a trained battery shell welding defect detection model.
