An X-ray lithium battery image electrode semantic segmentation method based on multi-task learning
By employing a multi-task learning approach, combined with natural image enhancement and lithium battery image enhancement networks, the challenge of enhancing low-dose X-ray lithium battery images was solved, achieving pixel-level precise segmentation of the electrode region and meeting the high-precision requirements of industrial quality inspection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NINGDE SKEQI INTELLIGENT EQUIP CO LTD
- Filing Date
- 2026-05-06
- Publication Date
- 2026-06-26
Smart Images

Figure CN122289696A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision and lithium battery defect detection technology, specifically involving a semantic segmentation method for X-ray lithium battery images based on multi-task learning. Background Technology
[0002] In the industrial production of lithium batteries, the alignment of electrode sheets is a core quality indicator. Electrode misalignment can directly lead to safety and performance problems such as short circuits, capacity decay, and thermal runaway. Therefore, accurate detection of electrode misalignment is a crucial step in the quality inspection of lithium battery production. Currently, the industry mainly uses X-ray imaging technology to obtain images of the internal electrodes of lithium batteries, and then uses image segmentation algorithms to extract key areas such as the positive electrode, negative electrode, and insulating layer, thereby calculating the electrode misalignment.
[0003] However, in actual industrial scenarios, X-ray lithium battery images present significant technical challenges: First, to reduce the impact of radiation on battery materials, low-dose X-ray sampling is often used in industrial settings, resulting in images with low contrast, poor signal-to-noise ratio, non-uniform spatial energy intensity, and blurred edge details. Second, traditional image enhancement algorithms rely on fixed parameter designs, resulting in poor robustness. Faced with X-ray lithium battery images of different batches and imaging qualities, it is difficult to achieve stable enhancement effects, failing to provide a high-quality image foundation for subsequent segmentation. Third, existing deep learning-based semantic segmentation methods often directly segment the original low-quality X-ray lithium battery images without deeply coupling image enhancement with semantic segmentation. They also lack cross-domain transfer and adaptation to mature technologies in the field of natural image enhancement. Furthermore, they struggle to balance image classification based on "whether or not there is an insulating layer" with multi-task collaboration of pixel-level semantic segmentation, leading to insufficient segmentation accuracy in electrode regions, large edge localization errors, and an inability to meet the precision requirements of industrial quality inspection for micrometer-level offset detection.
[0004] Therefore, developing a multi-task learning method that can achieve high-quality enhancement of low-quality X-ray lithium battery images while simultaneously performing accurate electrode semantic segmentation and image classification has significant engineering value for improving the accuracy and stability of lithium battery electrode quality inspection. Summary of the Invention
[0005] To address the challenges of existing X-ray lithium battery image segmentation methods, such as the difficulty in enhancing low-dose X-ray lithium battery images, the inability to provide a high-quality image foundation for subsequent segmentation, and insufficient segmentation accuracy, this invention provides a multi-task learning-based X-ray lithium battery image electrode semantic segmentation method. This method solves the problem of high enhancement difficulty in low-dose X-ray lithium battery images. Through multi-task collaborative learning involving image enhancement, semantic segmentation, image classification, and contrastive learning, pixel-level accurate segmentation of the lithium battery electrode region is achieved. Simultaneously, the model is lightweight and adaptable to industrial scenarios, providing high-precision technical support for lithium battery electrode offset detection.
[0006] The technical solution of the present invention is as follows: A semantic segmentation method for electrodes in X-ray lithium battery images based on multi-task learning, wherein the spatial resolution of the X-ray lithium battery image is w×h, where 512≤w≤2000, 384≤h≤640, w is the width, and h is the height, in pixels. The method includes the following steps: Step 1: Construct the dataset, specifically including constructing a low-light natural image dataset, an X-ray lithium battery image enhancement dataset, and an X-ray lithium battery image segmentation and classification dataset; Step 2: Construct a neural network model, which includes a natural image enhancement network, a lithium battery image enhancement network, a contrastive learning network, a semantic segmentation and classification network, and a discriminant network; Step 3: Train the neural network model. Divide the dataset constructed in Step 1 into training set, test set and evaluation set. Use a two-stage training method. First, train the natural image enhancement network, lithium battery image enhancement network and contrast learning network. Then freeze the network parameters that have been trained and further train the semantic segmentation and classification network and the discriminant network. Step 4: Preprocess the X-ray lithium battery images. The preprocessing refers to cropping each X-ray lithium battery image to w×h, and inputting the preprocessed X-ray lithium battery images into the trained semantic segmentation and classification network for prediction. The predicted category probability and classification result are obtained from the semantic segmentation and classification network.
[0007] Furthermore, step 1 specifically involves: Step 1.1: Construct a dark light natural image dataset. Specifically, select d1 pairs of natural images from the public datasets LOL-v1 and LOL-v2 to construct a dark light natural image dataset, where 500≤d1≤2000. Each pair of natural images includes a dark light natural image and its corresponding normal lighting natural image, all scaled to w×h. Step 1.2: Construct an X-ray lithium battery image enhancement dataset. Specifically, during the lithium battery production process, collect d2 X-ray lithium battery images, preprocess each X-ray lithium battery image, and construct an X-ray lithium battery image enhancement dataset, where 1000≤d2≤2000. Step 1.3: Construct an X-ray lithium battery image segmentation and classification dataset. Specifically, d3 X-ray lithium battery images are collected during the lithium battery production process. After preprocessing each X-ray lithium battery image, an X-ray lithium battery image segmentation and classification dataset is constructed, where 1500 ≤ d3 ≤ 6000. The images in the X-ray lithium battery image segmentation and classification dataset are labeled in two classes: First, region labeling: label the positive and negative regions of each image, and if there is an insulating layer, label the insulating layer region simultaneously; Second, X-ray lithium battery image category labeling: The images are labeled as category 0 and category 1. Category 0 contains only positive electrode area, negative electrode area and background area, and does not contain insulating layer area. Category 1 contains positive electrode area, negative electrode area, insulating layer area and background area.
[0008] Furthermore, the input to the natural image enhancement network is a low-light natural image, in tensor form [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the output is the LE-curve parameters of the low-light natural image; the natural image enhancement network employs 7 layers of depthwise separable convolutional coding, with the following specific structure: The first layer takes a 3-channel dark light natural image as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output 32-channel first layer encoded features. The second layer takes the encoded features of the first layer as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output 32 channels of second layer encoded features. The third layer takes the second layer's encoded features as input, performs 3×3 depthwise separable convolution operations, 1×1 convolution operations, and ReLU activation processing, and outputs 32 channels of third layer encoded features. The fourth layer takes the 64-channel feature obtained by concatenating the third layer's encoded features by channel as input, performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, and outputs 32-channel fourth layer encoded features. The fifth layer takes the 64-channel feature obtained by concatenating the second layer coding feature and the fourth layer coding feature by channel as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output the fifth layer coding feature with 32 channels. The sixth layer takes the 64-channel feature obtained by concatenating the first layer coding features and the fifth layer coding features by channel as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output the 32-channel sixth layer coding features. The seventh layer performs 3×3 depthwise separable convolution and 1×1 convolution on the encoded features from the sixth layer, followed by Tanh activation, to obtain the LE-curve parameters for the 3-channel dark-light natural image. .
[0009] Furthermore, the input of the lithium battery image enhancement network is a lithium battery low-light image, with tensor form [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the three channels of the lithium battery low-light image are all the same. The output is three sets of LE-curve parameters with the same spatial resolution as the lithium battery image, denoted as P1, P2 and P3 respectively. The lithium battery image enhancement network consists of a transfer subnetwork and a residual subnetwork. The structure of the transfer subnetwork is the same as that of the natural image enhancement network, and the two share network parameters. The input low-light image of a lithium battery is sequentially processed by a transfer network through 7 layers of depthwise separable convolutional encoding to obtain features T1, T2, T3, T4, T5, T6, and T7. The depthwise separable convolutional encoding is designed as a 3×3 depthwise separable convolution operation followed by a 1×1 convolution operation and feature activation processing. Feature T6 is then input into a residual network, which consists of three depthwise separable convolution operations: the first is a 3×3 depthwise separable convolution operation with ReLU activation, with boundary padding set to 1, and both input and output feature channels having 32; the second is a 1×1 depthwise separable convolution operation with ReLU activation, with boundary padding 0, and both input and output feature channels having 32; the third is a 1×1 depthwise separable convolution operation with ReLU activation, with boundary padding 0, and both input and output feature channels having 32, outputting the residual feature. Add the residual feature to feature T6 to obtain feature T8. Concatenate feature T8 and feature T1 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh. Add the result to feature T7 to obtain the LE-curve parameter P3. Concatenate feature T3 and feature T4 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh to obtain the LE-curve parameter P1. Concatenate feature T2 and feature T8 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh to obtain the LE-curve parameter P2.
[0010] Furthermore, the input to the contrastive learning network is a tensor of the form [b, 3, H, W], where b represents the number of images in a batch, 3 represents the number of channels, H is h, and W is [b, 3, H, W]. The output is a vector in the latent space. The contrastive learning network performs three layers of encoding calculation and feature compression processing on the input features sequentially, wherein: The three-layer encoding calculation encodes the input 3-channel features into 64-channel features, specifically as follows: The first layer of encoding computation includes a first encoding unit and a second encoding unit. The first encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 3-channel features into 32-channel features, reducing the spatial resolution by half. The second encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 32-channel features into 64-channel features, while maintaining the spatial resolution. The second layer of encoding computation includes a third encoding unit and a fourth encoding unit. The third encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 64-channel features into 128-channel features, reducing the spatial resolution by half. The fourth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 128-channel features into 128-channel features, maintaining the spatial resolution. The third layer of encoding computation includes the fifth encoding unit and the sixth encoding unit. The fifth encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 128-channel features into 64-channel features, reducing the spatial resolution by half. The sixth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 64-channel features into 64-channel features, maintaining the spatial resolution. The feature compression process specifically involves: performing 2D mean pooling on the input 64-channel features, flattening the features into a one-dimensional vector, encoding it through a 64×128 fully connected layer to obtain a 128-dimensional vector, and then performing a nonlinear transformation through the Tanh activation function to obtain the latent space vector.
[0011] Furthermore, the semantic segmentation and classification network includes an image enhancement processing module, an encoder, and a decoder. The input is a batch of lithium battery low-light images, and the output is the predicted class probability S and classification result C of the lithium battery low-light image segmentation. The tensor form of the lithium battery low-light image is [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the three channels of the lithium battery low-light image are all the same. The semantic segmentation and classification network sequentially performs image enhancement processing, encoding processing, and decoding processing on the input data, specifically as follows: Image enhancement processing: The low-light image of the lithium battery is processed through a lithium battery image enhancement network to obtain LE-curve parameters P1, P2, and P3. Based on the Zero-DCE method, for the input image... At that time, three enhanced X-ray lithium battery images F1, F2, and F3 were calculated according to formulas (1)-(3); (1) (3) Encoding Processing: Three enhanced X-ray lithium battery images were concatenated by channel. The resulting concatenated tensor was sequentially encoded using a 6-level encoding method, yielding 6-level encoded features f1, f2, f3, f4, f5, and f6. The first-level encoding involved a 3×3 convolution operation with a stride of 1 and a boundary padding of 1, encoding the input 9-channel features into 16-channel features while preserving spatial resolution. The second to fifth levels of encoding all involved a 3×3 convolution operation with a stride of 2 and a boundary padding of 1, encoding the 16-channel features into 32-channel features. The spatial resolution is reduced by half, and then a 3×3 convolution operation is performed with a stride of 1 and a boundary padding of 1 to encode the 32-channel features into 16-channel features while maintaining the spatial resolution. Batch normalization is performed simultaneously. The sixth level of encoding performs four convolution operations and ReLU activation processing in sequence, followed by batch normalization. The convolution kernels for the four operations are 5×5, 7×7, 5×5, and 3×3, with a stride of 2 for each operation and boundary padding of 2, 3, 2, and 1 for each operation. The number of channels activated in each operation is 16, 16, 8, and 8, respectively. Decoding Process: A four-stage progressive structure is adopted. In the first stage, the encoded feature f5 is subjected to a 2×2 transposed convolution to obtain the first-stage upsampled feature, with 16 input and 16 output channels. After ReLU activation, it is concatenated with the encoded feature f4, followed by two 3×3 convolution operations. The result is then residually concatenated with the first-stage upsampled feature and regularized with Dropout (0.3 dropout probability) to obtain feature M1. In the second stage, M1 is subjected to a 2×2 transposed convolution to obtain the second-stage upsampled feature, with 16 input and 16 output channels. After ReLU activation, it is concatenated with the encoded feature f3, followed by two 3×3 convolution operations. The result is then residually concatenated with the second-stage upsampled feature and regularized with Dropout (0.3 dropout probability). The third-level decoding process involves performing a 2×2 transpose convolution on feature M2 to obtain a third-level upsampled feature with 16 input and output channels. After ReLU activation, this feature is concatenated with the encoded feature f2, followed by two 3×3 convolution operations. The result is then residually concatenated with the third-level upsampled feature and regularized with Dropout (0.3) to obtain feature M3. The fourth-level decoding process involves performing a 2×2 transpose convolution on feature M3 to obtain a fourth-level upsampled feature with 16 input and output channels. After ReLU activation, this feature is concatenated with the encoded feature f1, followed by two 3×3 convolution operations. The result is then residually concatenated with the fourth-level upsampled feature and regularized with Dropout (0.3) to obtain feature M4. Features M1, M2, M3, and M4 are subjected to 1×1 convolution and upsampling to obtain four output features with the same spatial resolution as the input lithium battery low-light image. The four output features are concatenated by channel to obtain feature F. Feature F is subjected to two 3×3 convolution operations with a stride of 1, and the number of channels is changed from 4 to 16 channels and from 16 channels to 3 channels. After softmax activation, a probability feature map is obtained. The probability threshold is 0.75 times the difference between the maximum and minimum values in the spatial domain of the probability feature map. An uncertainty mask m is calculated based on the regions where the probability features are less than the probability threshold. The mask m is multiplied pixel by pixel with the LE-curve parameter P3 to obtain the uncertainty feature Pu. The uncertainty feature Fu obtained by enhancing the natural image is combined with the uncertainty feature Fu and feature F. The concatenated feature is subjected to three 3×3 convolution operations with a stride of 1, and the number of channels is changed from 7 channels to 16 channels, from 16 channels to 16 channels, and from 16 channels to the corresponding category channel number. The encoded feature f6 is flattened and then fed into a fully connected layer. The fully connected layer is a two-layer structure of 64×64 and 64×2. After being activated by Softmax, the category probability C of X-ray lithium battery image classification is obtained. If the category probability C is 0, the number of feature channels output by the last convolution operation is 3. If the category probability C is 1, the number of feature channels output by the last convolution operation is 4.
[0012] Furthermore, an adversarial network structure is designed. For the discriminant network, the input is a 6-channel concatenated feature: the 6-channel concatenated feature is obtained by concatenating the low-light image of the lithium battery, the spatial mask feature of the positive electrode region, the spatial mask feature of the negative electrode region, and the spatial mask feature of the background region according to the channels; the output is a pixel-level authenticity probability feature; the discriminant network performs 4 layers of asymptotic downsampling encoding on the input feature, specifically: The first layer of encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 2, to encode the 6-channel input features into 64-channel features, which are then activated by LeakyReLU with a negative slope of 0.2. The second layer of encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 2, to encode the 64-channel input features into 128-channel features, followed by batch normalization and LeakyReLU activation with a negative slope of 0.2. The third layer of encoding uses a 4×4 convolutional kernel, with boundary padding set to 1 and stride set to 1, to encode the 128-channel input features into 256-channel features. The fourth layer encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 1, to encode the 256-channel input features into a 1-channel feature.
[0013] Furthermore, in step 3, each dataset is divided into a training set, a test set, and an evaluation set in an 8:1:1 ratio. The initial learning rate for each set is set to 0.009. A two-stage training process is employed, in which the learning rate is manually adjusted, and the optimal model is used for training at each stage. The two-stage training is specifically as follows: (1) First stage: Train the natural image enhancement network, the lithium battery image enhancement network, and the contrast learning network, and train them for one round on the low-light natural image dataset and the X-ray lithium battery image enhancement dataset; In each loop, take a batch of low-light natural image pairs from the low-light natural image dataset, and take a batch of X-ray lithium battery images and their region annotations from the X-ray lithium battery image enhancement dataset. Input the low-light natural images into the natural image enhancement network, and perform training based on the low-light natural image LE-curve parameters output by the natural image enhancement network. For the input image The natural image enhancement result is calculated according to formula (4). ; (4) Three-channel low-light images of lithium batteries were constructed using X-ray lithium battery images, and then input into the lithium battery image enhancement network. The three enhanced X-ray lithium battery images F1, F2, and F3 were calculated according to formulas (1)-(3). The network model parameters were iteratively optimized until the loss of each batch was minimized. (2) Second stage: Train the semantic segmentation and classification network, train it for 50 to 100 rounds on the X-ray lithium battery image segmentation and classification dataset; freeze the parameters of the natural image enhancement network and the lithium battery image enhancement network, take a batch of X-ray lithium battery images from the X-ray lithium battery image segmentation and classification dataset and construct lithium battery dark light images, input the lithium battery dark light images into the semantic segmentation and classification network, calculate the semantic segmentation loss and classification loss based on the output predicted category probability S and classification result C, further calculate the positive electrode region spatial mask features, negative electrode region spatial mask features and background region spatial mask features according to the predicted category probability S, then concatenate the lithium battery dark light images with the positive electrode region spatial mask features, negative electrode region spatial mask features and background region spatial mask features by channel, input the obtained concatenated features into the discriminant network, calculate the discriminator network loss, and iteratively optimize the corresponding network parameters until the discriminator network loss of each batch is minimized; In the second stage of training, the training loss is a weighted sum of semantic segmentation loss L13, X-ray lithium battery image classification loss L14, and discriminator network loss L15, with weights of 900.0, 100.0, and 1.0, respectively. Specifically, the semantic segmentation loss L13 is calculated by weighting Dice loss and cross-entropy loss based on the predicted class probability of lithium battery low-light image segmentation, with weights of 5.0 and 0.9, respectively. The X-ray lithium battery image classification loss L14 is calculated using cross-entropy loss, and the discriminator network loss L15 is calculated using binary cross-entropy loss.
[0014] Furthermore, in the first stage of training, based on the region annotations of the X-ray lithium battery image, the Region of Interest (ROI) is calculated from the positive and negative electrode regions. The ROI is then divided into three equal parts horizontally, resulting in the ROI region subdivisions and corresponding subdivision masks. Based on this, the calculation formula for the first-stage training loss Le is: Le = W1L1 + W2L2 + W3L3 + W4L4 + W5L5 + W6L6 + W7L7 + W8L8 + W9L9 + W10L10 + W11L11 + W12L12 Wherein, L1 is the gradient consistency loss of the natural image, L2 is the spatial gradient consistency loss of the X-ray lithium battery image, L3 is the relative gradient loss of the natural image, L4 is the relative gradient loss of the X-ray lithium battery image, L5 is the loss to enhance the intensity inconsistency between channels of the natural image, L6 is the loss to enhance the intensity inconsistency between channels of the lithium battery image, L7 is the loss to enhance the brightness constraint of the natural image, L8 is the loss to enhance the brightness constraint of the lithium battery image, L9 is the loss to suppress spatial intensity non-uniformity, L10 is the loss to enhance the spatial smoothness constraint of the natural image, L11 is the loss to enhance the spatial smoothness constraint of the lithium battery image, and L12 is the contrast loss; W1 to W12 are the weights corresponding to each loss, with values of 1000, 2000, 100, 200, 1.0, 10, 100, 10.0, 10, 1200, 1200, and 2000, respectively. The contrast loss L12 is calculated as follows: During the training of the contrastive learning network, the enhanced lithium battery image is multiplied pixel-by-pixel with the equally divided region mask of the ROI to obtain three equally divided regions based on the ROI, denoted as region A, region B, and region C from left to right. Regions A and B are used as positive samples, and region C is used as a negative sample. Regions A and C are input into the contrastive learning network to obtain the first latent space vector, and contrast loss 1 is calculated based on cosine similarity. Regions B and C are input into the contrastive learning network to obtain the second latent space vector, and contrast loss 2 is calculated based on cosine similarity. The contrast loss L12 is a weighted sum of contrast loss 1 and contrast loss 2, with weights of 0.3 and 0.7, respectively. Both contrast loss 1 and contrast loss 2 are calculated based on cosine similarity: the latent space feature vectors of the two input regions are encoded separately, and their cosine similarity is calculated. For positive samples, the loss is directly calculated based on this similarity, and for negative samples, the loss is calculated based on the difference between the boundary parameter 1.0 and the similarity. Finally, the loss values of all samples are averaged.
[0015] Further, step 4 specifically involves cropping the sampled X-ray lithium battery image I1 to w×h to obtain the cropped X-ray lithium battery image I2, inputting the cropped X-ray lithium battery image I2 into the trained semantic segmentation and classification network, and outputting the predicted category probability S and classification result C for the segmentation of the lithium battery low-light image. Compared with the prior art, the present invention has the following beneficial effects: This invention achieves cross-domain knowledge transfer from natural image enhancement to industrial X-ray lithium battery images, addressing the industry pain point of limited labeled data and high enhancement difficulty for low-dose X-ray lithium battery images. By sharing parameters between the natural image enhancement network and the lithium battery image enhancement network, mature low-light natural image enhancement learning features are transferred to X-ray lithium battery image enhancement scene learning. Combined with a residual subnetwork, industrial scene adaptation optimization is achieved, significantly improving the enhancement effect of low-quality X-ray lithium battery images. Experimental data shows that the peak signal-to-noise ratio of the enhanced X-ray lithium battery images using the method of this invention can reach up to 55.3615, and the structural similarity can reach up to 0.9070, which is significantly better than existing mainstream enhancement algorithms.
[0016] A multi-task collaborative learning framework for enhancement, segmentation, and classification was constructed. Leveraging the advantages of contrastive learning, the enhancement effect was improved, achieving deep coupling between image enhancement and semantic segmentation. A two-stage training strategy was employed: first, a high-quality image enhancement model was trained; then, the enhancement network parameters were frozen to focus on optimizing the segmentation and classification tasks. Simultaneously, contrastive learning constrained the feature consistency of the enhanced images, and adversarial learning through a discriminant network further improved the accuracy and spatial intensity uniformity of the segmentation results, ultimately achieving pixel-level precise segmentation of the electrode region. Experimental results show that the electrode semantic segmentation accuracy of the proposed method reaches 0.9841, the intersection-over-union ratio reaches 0.9536, and the F1 score reaches 0.9761, fully meeting the requirements for high-precision detection of electrode offset in industrial scenarios.
[0017] Balancing model accuracy with lightweight design, this invention boasts excellent industrial applicability. It employs depthwise separable convolutions to construct the core network, significantly reducing the number of model parameters. The final model size is only 0.65M, allowing deployment on edge computing devices in industrial settings for real-time quality inspection. Furthermore, through an adaptive category determination mechanism, it can automatically adapt to both X-ray lithium battery images with and without insulating layers, eliminating the need for separate model training for different battery types and demonstrating strong versatility across various scenarios.
[0018] A multi-dimensional loss function system and uncertainty optimization mechanism were designed to ensure the stability of model training and the robustness of inference. In the augmented network training, 12 loss functions were designed, including gradient consistency, relative gradient, brightness constraint, and spatial non-uniformity suppression, to constrain the enhancement effect from multiple dimensions such as edge, brightness, channel consistency, and spatial uniformity. In the segmentation network, multi-scale feature fusion and uncertainty mask optimization were used to solve the problem of inaccurate electrode edge segmentation, significantly improving the algorithm's anti-interference capability in complex industrial scenarios. Attached Figure Description
[0019] Figure 1 This is an enhanced image of an X-ray lithium battery from the present invention. Figure 2 This is a semantic segmentation result diagram of the X-ray lithium battery image of the present invention; Figure 3 This is a statistical chart showing the semantic segmentation results of X-ray lithium battery images in this invention. Detailed Implementation
[0020] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0021] See Figure 1 A semantic segmentation method for electrodes in X-ray lithium battery images based on multi-task learning, wherein the spatial resolution of the X-ray lithium battery image is w×h, where w is the width and h is the height in pixels, 512≤w≤2000, 384≤h≤640, and the method includes the following steps: Step 1: Construct the dataset, specifically including constructing a low-light natural image dataset, an X-ray lithium battery image enhancement dataset, and an X-ray lithium battery image segmentation and classification dataset; Step 2: Construct a neural network model, which includes a natural image enhancement network, a lithium battery image enhancement network, a contrastive learning network, a semantic segmentation and classification network, and a discriminant network; Step 3: Train the neural network model. Divide the dataset constructed in Step 1 into training set, test set and evaluation set. Use a two-stage training method. First, train the natural image enhancement network, lithium battery image enhancement network and contrast learning network. Then freeze the network parameters that have been trained and further train the semantic segmentation and classification network and the discriminant network. Step 4: Preprocess the X-ray lithium battery images. The preprocessing refers to cropping each X-ray lithium battery image to w×h, and inputting the preprocessed X-ray lithium battery images into the trained semantic segmentation and classification network for prediction. The predicted category probability and classification result are obtained from the semantic segmentation and classification network.
[0022] In one embodiment of the present invention, step 1 specifically comprises: Step 1.1: Construct a dark light natural image dataset. Specifically, select d1 pairs of natural images from the public datasets LOL-v1 and LOL-v2 to construct a dark light natural image dataset, where 500≤d1≤2000. Each pair of natural images includes a dark light natural image and its corresponding normal lighting natural image, all scaled to w×h. Step 1.2: Construct an X-ray lithium battery image enhancement dataset. Specifically, during the lithium battery production process, collect d2 X-ray lithium battery images, preprocess each X-ray lithium battery image, and construct an X-ray lithium battery image enhancement dataset, where 1000≤d2≤2000. Step 1.3: Construct an X-ray lithium battery image segmentation and classification dataset. Specifically, d3 X-ray lithium battery images are collected during the lithium battery production process. After preprocessing each X-ray lithium battery image, an X-ray lithium battery image segmentation and classification dataset is constructed, where 1500 ≤ d3 ≤ 6000. The images in the X-ray lithium battery image segmentation and classification dataset are labeled in two classes: First, region labeling: label the positive and negative regions of each image, and if there is an insulating layer, label the insulating layer region simultaneously; Second, X-ray lithium battery image category labeling: The images are labeled as category 0 and category 1. Category 0 contains only positive electrode area, negative electrode area and background area, and does not contain insulating layer area. Category 1 contains positive electrode area, negative electrode area, insulating layer area and background area.
[0023] In one embodiment of the present invention, the input of the natural image enhancement network is a low-light natural image, in tensor form [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the output is the LE-curve parameters of the low-light natural image; the natural image enhancement network employs 7 layers of depthwise separable convolutional coding, with the following specific structure: The first layer takes a 3-channel dark light natural image as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output 32-channel first layer encoded features. The second layer takes the encoded features of the first layer as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output 32 channels of second layer encoded features. The third layer takes the second layer's encoded features as input, performs 3×3 depthwise separable convolution operations, 1×1 convolution operations, and ReLU activation processing, and outputs 32 channels of third layer encoded features. The fourth layer takes the 64-channel feature obtained by concatenating the third layer's encoded features by channel as input, performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, and outputs 32-channel fourth layer encoded features. The fifth layer takes the 64-channel feature obtained by concatenating the second layer coding feature and the fourth layer coding feature by channel as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output the fifth layer coding feature with 32 channels. The sixth layer takes the 64-channel feature obtained by concatenating the first layer coding features and the fifth layer coding features by channel as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output the 32-channel sixth layer coding features. The seventh layer performs 3×3 depthwise separable convolution and 1×1 convolution on the encoded features from the sixth layer, followed by Tanh activation, to obtain the LE-curve parameters for the 3-channel dark-light natural image. .
[0024] In one embodiment of the present invention, the input of the lithium battery image enhancement network is a lithium battery low-light image, with tensor form [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the three channels of the lithium battery low-light image are all the same. The output is three sets of LE-curve parameters with the same spatial resolution as the lithium battery image, denoted as P1, P2 and P3 respectively. The lithium battery image enhancement network consists of a transfer subnetwork and a residual subnetwork. The structure of the transfer subnetwork is the same as that of the natural image enhancement network, and the two share network parameters. The input low-light image of a lithium battery is sequentially processed by a transfer network through 7 layers of depthwise separable convolutional encoding to obtain features T1, T2, T3, T4, T5, T6, and T7. The depthwise separable convolutional encoding is designed as a 3×3 depthwise separable convolution operation followed by a 1×1 convolution operation and feature activation processing. Feature T6 is then input into a residual network, which consists of three depthwise separable convolution operations: the first is a 3×3 depthwise separable convolution operation with ReLU activation, with boundary padding set to 1, and both input and output feature channels having 32; the second is a 1×1 depthwise separable convolution operation with ReLU activation, with boundary padding 0, and both input and output feature channels having 32; the third is a 1×1 depthwise separable convolution operation with ReLU activation, with boundary padding 0, and both input and output feature channels having 32, outputting the residual feature. Add the residual feature to feature T6 to obtain feature T8. Concatenate feature T8 and feature T1 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh. Add the result to feature T7 to obtain the LE-curve parameter P3. Concatenate feature T3 and feature T4 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh to obtain the LE-curve parameter P1. Concatenate feature T2 and feature T8 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh to obtain the LE-curve parameter P2.
[0025] In one embodiment of the present invention, the input to the contrastive learning network is a tensor of the form [b, 3, H, W], where b represents the number of images in a batch, 3 represents the number of channels, H is h, and W is W. The output is a vector in the latent space. The contrastive learning network performs three layers of encoding calculation and feature compression processing on the input features sequentially, wherein: The three-layer encoding calculation encodes the input 3-channel features into 64-channel features, specifically as follows: The first layer of encoding computation includes a first encoding unit and a second encoding unit. The first encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 3-channel features into 32-channel features, reducing the spatial resolution by half. The second encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 32-channel features into 64-channel features, while maintaining the spatial resolution. The second layer of encoding computation includes a third encoding unit and a fourth encoding unit. The third encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 64-channel features into 128-channel features, reducing the spatial resolution by half. The fourth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 128-channel features into 128-channel features, maintaining the spatial resolution. The third layer of encoding computation includes the fifth encoding unit and the sixth encoding unit. The fifth encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 128-channel features into 64-channel features, reducing the spatial resolution by half. The sixth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 64-channel features into 64-channel features, maintaining the spatial resolution. The feature compression process specifically involves: performing 2D mean pooling on the input 64-channel features, flattening the features into a one-dimensional vector, encoding it through a 64×128 fully connected layer to obtain a 128-dimensional vector, and then performing a nonlinear transformation through the Tanh activation function to obtain the latent space vector.
[0026] In one embodiment of the present invention, the semantic segmentation and classification network includes an image enhancement processing module, an encoder and a decoder. The input is a batch of lithium battery low-light images, and the output is the predicted class probability S and classification result C of the lithium battery low-light image segmentation. The tensor form of the lithium battery low-light image is [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the three channels of the lithium battery low-light image are all the same. The semantic segmentation and classification network sequentially performs image enhancement processing, encoding processing, and decoding processing on the input data, specifically as follows: Image enhancement processing: The low-light image of the lithium battery is processed through a lithium battery image enhancement network to obtain LE-curve parameters P1, P2, and P3. Based on the Zero-DCE method, for the input image... At that time, three enhanced X-ray lithium battery images F1, F2, and F3 were calculated according to formulas (1)-(3); (1) (2) (3) Encoding Processing: Three enhanced X-ray lithium battery images were concatenated by channel. The resulting concatenated tensor was sequentially encoded using a 6-level encoding method, yielding 6-level encoded features f1, f2, f3, f4, f5, and f6. The first-level encoding involved a 3×3 convolution operation with a stride of 1 and a boundary padding of 1, encoding the input 9-channel features into 16-channel features while preserving spatial resolution. The second to fifth levels of encoding all involved a 3×3 convolution operation with a stride of 2 and a boundary padding of 1, encoding the 16-channel features into 32-channel features. The spatial resolution is reduced by half, and then a 3×3 convolution operation is performed with a stride of 1 and a boundary padding of 1 to encode the 32-channel features into 16-channel features while maintaining the spatial resolution. Batch normalization is performed simultaneously. The sixth level of encoding performs four convolution operations and ReLU activation processing in sequence, followed by batch normalization. The convolution kernels for the four operations are 5×5, 7×7, 5×5, and 3×3, with a stride of 2 for each operation and boundary padding of 2, 3, 2, and 1 for each operation. The number of channels activated in each operation is 16, 16, 8, and 8, respectively. Decoding Process: A four-stage progressive structure is adopted. In the first stage, the encoded feature f5 is subjected to a 2×2 transposed convolution to obtain the first-stage upsampled feature, with 16 input and 16 output channels. After ReLU activation, it is concatenated with the encoded feature f4, followed by two 3×3 convolution operations. The result is then residually concatenated with the first-stage upsampled feature and regularized with Dropout (0.3 dropout probability) to obtain feature M1. In the second stage, M1 is subjected to a 2×2 transposed convolution to obtain the second-stage upsampled feature, with 16 input and 16 output channels. After ReLU activation, it is concatenated with the encoded feature f3, followed by two 3×3 convolution operations. The result is then residually concatenated with the second-stage upsampled feature and regularized with Dropout (0.3 dropout probability). The third-level decoding process involves performing a 2×2 transpose convolution on feature M2 to obtain a third-level upsampled feature with 16 input and output channels. After ReLU activation, this feature is concatenated with the encoded feature f2, followed by two 3×3 convolution operations. The result is then residually concatenated with the third-level upsampled feature and regularized with Dropout (0.3) to obtain feature M3. The fourth-level decoding process involves performing a 2×2 transpose convolution on feature M3 to obtain a fourth-level upsampled feature with 16 input and output channels. After ReLU activation, this feature is concatenated with the encoded feature f1, followed by two 3×3 convolution operations. The result is then residually concatenated with the fourth-level upsampled feature and regularized with Dropout (0.3) to obtain feature M4. Features M1, M2, M3, and M4 are subjected to 1×1 convolution and upsampling to obtain four output features with the same spatial resolution as the input lithium battery low-light image. The four output features are concatenated by channel to obtain feature F. Feature F is subjected to two 3×3 convolution operations with a stride of 1, and the number of channels is changed from 4 to 16 channels and from 16 channels to 3 channels. After softmax activation, a probability feature map is obtained. The probability threshold is 0.75 times the difference between the maximum and minimum values in the spatial domain of the probability feature map. An uncertainty mask m is calculated based on the regions where the probability features are less than the probability threshold. The mask m is multiplied pixel by pixel with the LE-curve parameter P3 to obtain the uncertainty feature Pu. The uncertainty feature Fu obtained by enhancing the natural image is combined with the uncertainty feature Fu and feature F. The concatenated feature is subjected to three 3×3 convolution operations with a stride of 1, and the number of channels is changed from 7 channels to 16 channels, from 16 channels to 16 channels, and from 16 channels to the corresponding category channel number. The encoded feature f6 is flattened and then fed into a fully connected layer. The fully connected layer is a two-layer structure of 64×64 and 64×2. After being activated by Softmax, the category probability C of X-ray lithium battery image classification is obtained. If the category probability C is 0, the number of feature channels output by the last convolution operation is 3. If the category probability C is 1, the number of feature channels output by the last convolution operation is 4.
[0027] In one embodiment of the present invention, an adversarial network structure is designed. For the discriminant network, the input is a 6-channel concatenated feature: the 6-channel concatenated feature is obtained by concatenating the low-light image of the lithium battery, the spatial mask feature of the positive electrode region, the spatial mask feature of the negative electrode region, and the spatial mask feature of the background region according to the channels; the output is a pixel-level authenticity probability feature; the discriminant network performs 4-layer asymptotic downsampling encoding on the input feature, specifically: The first layer of encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 2, to encode the 6-channel input features into 64-channel features, which are then activated by LeakyReLU with a negative slope of 0.2. The second layer of encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 2, to encode the 64-channel input features into 128-channel features, followed by batch normalization and LeakyReLU activation with a negative slope of 0.2. The third layer of encoding uses a 4×4 convolutional kernel, with boundary padding set to 1 and stride set to 1, to encode the 128-channel input features into 256-channel features. The fourth layer encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 1, to encode the 256-channel input features into a 1-channel feature.
[0028] In one embodiment of the present invention, in step 3, each dataset is divided into a training set, a test set, and an evaluation set in an 8:1:1 ratio. The initial learning rate for each set is set to 0.009. Two-stage training is employed, in which the learning rate is manually adjusted, and the optimal model is used for training at each stage. The two-stage training specifically involves: (1) First stage: Train the natural image enhancement network, the lithium battery image enhancement network, and the contrast learning network, and train them for one round on the low-light natural image dataset and the X-ray lithium battery image enhancement dataset; In each loop, take a batch of low-light natural image pairs from the low-light natural image dataset, and take a batch of X-ray lithium battery images and their region annotations from the X-ray lithium battery image enhancement dataset. Input the low-light natural images into the natural image enhancement network, and perform training based on the low-light natural image LE-curve parameters output by the natural image enhancement network. For the input image The natural image enhancement result is calculated according to formula (4). ; (4) Three-channel low-light images of lithium batteries were constructed using X-ray lithium battery images, and then input into the lithium battery image enhancement network. The three enhanced X-ray lithium battery images F1, F2, and F3 were calculated according to formulas (1)-(3). The network model parameters were iteratively optimized until the loss of each batch was minimized. (2) Second stage: Train the semantic segmentation and classification network, train it for 50 to 100 rounds on the X-ray lithium battery image segmentation and classification dataset; freeze the parameters of the natural image enhancement network and the lithium battery image enhancement network, take a batch of X-ray lithium battery images from the X-ray lithium battery image segmentation and classification dataset and construct lithium battery dark light images, input the lithium battery dark light images into the semantic segmentation and classification network, calculate the semantic segmentation loss and classification loss based on the predicted category probability S and classification result C of the output lithium battery dark light image segmentation, further calculate the positive electrode region spatial mask features, negative electrode region spatial mask features and background region spatial mask features according to the predicted category probability S, then concatenate the lithium battery dark light images with the positive electrode region spatial mask features, negative electrode region spatial mask features and background region spatial mask features by channel, input the obtained concatenated features into the discriminant network, calculate the discriminator network loss, iteratively optimize the corresponding network parameters until the discriminator network loss of each batch is minimized; In the second stage of training, the training loss is a weighted sum of semantic segmentation loss L13, X-ray lithium battery image classification loss L14, and discriminator network loss L15, with weights of 900.0, 100.0, and 1.0, respectively. Specifically, the semantic segmentation loss L13 is calculated by weighting Dice loss and cross-entropy loss based on the predicted class probability of lithium battery low-light image segmentation, with weights of 5.0 and 0.9, respectively. The X-ray lithium battery image classification loss L14 is calculated using cross-entropy loss, and the discriminator network loss L15 is calculated using binary cross-entropy loss.
[0029] Specifically, in the first stage of training, to train the contrastive learning network, the Regions of Interest (ROIs) are first calculated from the positive and negative electrode regions based on the region annotations of the X-ray lithium battery image. The ROIs are then divided into three equal parts horizontally, resulting in the ROI regions and their corresponding masks. Based on this, the formula for calculating the first-stage training loss Le is: Le = W1L1 + W2L2 + W3L3 + W4L4 + W5L5 + W6L6 + W7L7 + W8L8 + W9L9 + W10L10 + W11L11 + W12L12 Wherein, L1 is the gradient consistency loss of the natural image, L2 is the spatial gradient consistency loss of the X-ray lithium battery image, L3 is the relative gradient loss of the natural image, L4 is the relative gradient loss of the X-ray lithium battery image, L5 is the loss to enhance the intensity inconsistency between channels of the natural image, L6 is the loss to enhance the intensity inconsistency between channels of the lithium battery image, L7 is the loss to enhance the brightness constraint of the natural image, L8 is the loss to enhance the brightness constraint of the lithium battery image, L9 is the loss to suppress spatial intensity non-uniformity, L10 is the loss to enhance the spatial smoothness constraint of the natural image, L11 is the loss to enhance the spatial smoothness constraint of the lithium battery image, and L12 is the contrast loss; W1 to W12 are the weights corresponding to each loss, with values of 1000, 2000, 100, 200, 1.0, 10, 100, 10.0, 10, 1200, 1200, and 2000, respectively. The contrast loss L12 is calculated as follows: During the training of the contrastive learning network, the enhanced lithium battery image is multiplied pixel-by-pixel with the equally divided region mask of the ROI to obtain three equally divided regions based on the ROI, denoted as region A, region B, and region C from left to right. Regions A and B are used as positive samples, and region C is used as a negative sample. Regions A and C are input into the contrastive learning network to obtain the first latent space vector, and contrast loss 1 is calculated based on cosine similarity. Regions B and C are input into the contrastive learning network to obtain the second latent space vector, and contrast loss 2 is calculated based on cosine similarity. The contrast loss L12 is a weighted sum of contrast loss 1 and contrast loss 2, with weights of 0.3 and 0.7, respectively. Both contrast loss 1 and contrast loss 2 are calculated based on cosine similarity: the latent space feature vectors of the two input regions are encoded separately, and their cosine similarity is calculated. For positive samples, the loss is directly calculated based on this similarity, and for negative samples, the loss is calculated based on the difference between the boundary parameter 1.0 and the similarity. Finally, the loss values of all samples are averaged.
[0030] In one embodiment of the present invention, step 4 specifically involves: cropping the sampled X-ray lithium battery image I1 to w×h to obtain the cropped X-ray lithium battery image I2; inputting the cropped X-ray lithium battery image I2 into the trained semantic segmentation and classification network; and outputting the predicted category probability S and classification result C of the lithium battery low-light image segmentation. The invention will be further illustrated by the following specific implementation example: The implementation was carried out on a PC with a Windows 10 64-bit operating system. The hardware configuration was: CPU i7-9700F, memory 32G, graphics card NVIDIA GeForce RTX4060 with 10G video memory; the software environment was: PyTorch 2.2 deep learning framework, Python programming language, and Adam optimizer algorithm optimizer.
[0031] In this embodiment, the spatial resolution of the processed X-ray lithium battery image is w×h, where w is 960 and h is 512, with units of pixels; during model training, the number of images in a batch, b, is 2. The specific implementation steps are as follows: Step 1: Building the dataset This step constructs three types of datasets, with all images uniformly scaled or cropped to a resolution of 960×512, as detailed below: (a) Constructing a low-light natural image dataset: Select 1080 pairs of natural images from the public datasets LOL-v1 and LOL-v2. Each pair of natural images includes a low-light natural image and a corresponding normal-light natural image. All images are scaled to a resolution of 960×512 to complete the construction of the low-light natural image dataset.
[0032] (b) Constructing an X-ray lithium battery image enhancement dataset: On the lithium battery industrial production line, 1400 original X-ray lithium battery images were collected from the lithium battery X-ray inspection station. Each image was cropped to a resolution of 960×512 to construct an X-ray lithium battery image enhancement dataset.
[0033] (c) Constructing an X-ray lithium battery image segmentation and classification dataset: 2200 X-ray lithium battery images were collected during the lithium battery production process. Each image was cropped to a resolution of 960×512 to construct an X-ray lithium battery image segmentation and classification dataset; two types of annotation were completed simultaneously: First, regional labeling: Professional technicians with experience in lithium battery quality inspection will label each image at the pixel level, marking the positive electrode area, negative electrode area, and the insulation layer area if there is an insulating layer in the image. Second, X-ray lithium battery image category labeling: Each image is categorized, with images containing only positive electrode area, negative electrode area, and background area but no insulating layer area labeled as category 0, and images containing positive electrode area, negative electrode area, insulating layer area, and background area labeled as category 1.
[0034] After the datasets are constructed, the three types of datasets are divided into training, testing, and evaluation sets in an 8:1:1 ratio for subsequent model training, validation, and performance evaluation.
[0035] Step 2: Construct a neural network model This step constructs a complete neural network model, which consists of five core sub-networks: a natural image enhancement network, a lithium battery image enhancement network, a contrastive learning network, a semantic segmentation and classification network, and a discriminant network. The specific structure of each sub-network is as follows: (1) Natural Image Enhancement Network The input to the Natural Image Enhancement Network is a low-light natural image in tensor form [2,3,512,960]. The output is the LE-curve parameters of the low-light natural image. The network uses 7 layers of depthwise separable convolutional coding, and its specific structure is as follows: First layer: The 3-channel dark light natural image is taken as input, and after 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, the first layer of 32-channel encoded features are output. The second layer: The first layer encoded features are taken as input, and after 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, the second layer encoded features with 32 channels are output. The third layer: The second layer encoding features are taken as input, and after 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, the 32-channel third layer encoding features are output. Fourth layer: The 64-channel feature obtained by concatenating the third layer coding features by channel is taken as input, and after 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, the 32-channel fourth layer coding feature is output. Fifth layer: The 64-channel feature obtained by concatenating the second layer coding feature and the fourth layer coding feature by channel is taken as input, and after 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, the 32-channel fifth layer coding feature is output. The sixth layer: The 64-channel feature obtained by concatenating the first layer coding feature and the fifth layer coding feature by channel is taken as input, and after 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, the 32-channel sixth layer coding feature is output. Layer 7: The encoded features from layer 6 are subjected to 3×3 depthwise separable convolution and 1×1 convolution, followed by Tanh activation to obtain the LE-curve parameters of the 3-channel dark-light natural image. .
[0036] (2) Lithium-ion battery image enhancement network The input to the lithium battery image enhancement network is a low-light image of a lithium battery, in tensor form [2,3,512,960]. The three channels of the low-light image of the lithium battery are identical, all derived from the original single-channel X-ray lithium battery image. The network outputs three sets of LE-curve parameters with the same spatial resolution as the input image, denoted as P1, P2, and P3.
[0037] The lithium battery image enhancement network consists of two parts: a transfer subnetwork and a residual subnetwork. The structure of the transfer subnetwork is exactly the same as that of the natural image enhancement network mentioned above, and the two share all network parameters, realizing cross-domain knowledge transfer for natural image enhancement.
[0038] The input low-light image of a lithium battery is first processed by a transfer network to complete 7 layers of depthwise separable convolutional encoding, corresponding to 7 layers of encoded features, denoted as features T1, T2, T3, T4, T5, T6, and T7. Feature T6 is then input into a residual network, which consists of three depthwise separable convolutional operations, specifically: First step: 3×3 depthwise separable convolution operation and ReLU activation processing, boundary padding set to 1, input and output feature channels are both 32; Second: 1×1 depthwise separable convolution operation and ReLU activation processing, with zero padding at the boundaries, and 32 input and output feature channels each; Third time: 1×1 depthwise separable convolution operation and ReLU activation processing, with zero padding at the boundaries, and 32 input and output feature channels; The final output yields the residual features.
[0039] The residual feature is added element-wise to feature T6 to obtain feature T8; based on the above encoded features, the calculation of three sets of LE-curve parameters is completed: Calculate P3: Concatenate feature T8 and feature T1 by channel, perform 3×3 depthwise separable convolution and 1×1 convolution on the concatenation result, then process it with the tanh activation function, add the resulting feature to feature T7, and finally obtain the LE-curve parameter P3; Calculate P1: Concatenate features T3 and T4 by channel, perform 3×3 depthwise separable convolution and 1×1 convolution on the concatenation result in sequence, and then process it with the tanh activation function to obtain the LE-curve parameter P1; Calculate P2: Concatenate features T2 and T8 by channel, perform 3×3 depthwise separable convolution and 1×1 convolution on the concatenation result, and then process it with the tanh activation function to obtain the LE-curve parameter P2.
[0040] (3) Comparative learning network The contrastive learning network takes a tensor of the form [2, 3, 512, 320] as input and outputs a 128-dimensional latent space vector. The network performs three layers of encoding computation and feature compression on the input features sequentially, with the specific structure as follows: The three-layer encoding calculation ultimately encodes the input 3-channel features into 64-channel features, specifically as follows: The first layer of encoding calculation includes a first encoding unit and a second encoding unit. The first encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 3-channel features into 32-channel features, reducing the spatial resolution by half. The second encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 32-channel features into 64-channel features, while maintaining the spatial resolution. The second layer of encoding computation includes a third encoding unit and a fourth encoding unit. The third encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 64-channel features into 128-channel features, reducing the spatial resolution by half. The fourth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 128-channel features into 128-channel features, maintaining the spatial resolution. The third layer of encoding computation includes the fifth encoding unit and the sixth encoding unit. The fifth encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 128-channel features into 64-channel features, reducing the spatial resolution by half. The sixth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 64-channel features into 64-channel features, maintaining the spatial resolution. The feature compression process specifically involves: performing 2D mean pooling on the input 64-channel features, flattening the features into a one-dimensional vector, encoding it through a 64×128 fully connected layer to obtain a 128-dimensional vector, and then performing a nonlinear transformation through the Tanh activation function to obtain the latent space vector.
[0041] (4) Semantic segmentation and classification network The semantic segmentation and classification network consists of three parts: an image enhancement module, an encoder, and a decoder. The input is a batch of low-light natural images, and the output is the predicted class probability S and classification result C for low-light image segmentation of lithium batteries. The network sequentially performs image enhancement, encoding, and decoding processing on the input data, as follows: 1. Image enhancement processing The input dark-light natural image is fed into the natural image enhancement network described above to obtain the corresponding LE-curve parameters. Then, based on the Zero-DCE method, the enhanced natural image is calculated; The low-light image of the lithium battery is input into the lithium battery image enhancement network mentioned above to obtain three sets of LE-curve parameters P1, P2 and P3. Then, based on the Zero-DCE method, three enhanced X-ray lithium battery images are calculated and denoted as F1, F2 and F3.
[0042] 2. Encoding Processing Three enhanced X-ray lithium battery images, F1, F2, and F3, are concatenated by channel to obtain a 9-channel concatenated tensor. This tensor is then encoded using a 6-level encoding method, outputting 6-level encoded features, denoted as f1, f2, f3, f4, f5, and f6. The specific encoding rules are as follows: First-level encoding: Perform a 3×3 convolution operation with a stride of 1 and a boundary padding of 1 to encode the input 9-channel features into 16-channel features while keeping the feature spatial resolution unchanged. The output is f1. Encoding levels 2 through 5: Each encoding level follows the same computational process. First, a 3×3 convolution operation is performed with a stride of 2 and padding of 1, encoding the 16-channel input features into 32-channel features, halving the feature spatial resolution. Then, another 3×3 convolution operation is performed with a stride of 1 and padding of 1, encoding the 32-channel features into 16-channel features while maintaining the same feature spatial resolution. Batch normalization is performed simultaneously. Levels 2 through 5 output f2, f3, f4, and f5, respectively. Level 6 encoding: Perform 4 convolution operations and ReLU activation processing in sequence, and then perform batch normalization processing. The convolution kernels for the 4 operations are 5×5, 7×7, 5×5 and 3×3, with a stride of 2 for each operation. The boundary padding is 2, 3, 2 and 1 for each operation. The number of output channels corresponding to each activation processing is 16, 16, 8 and 8 respectively. The final output is f6.
[0043] 3) Decoding Processing A four-level progressive decoding structure is adopted, and the specific process is as follows: First-level decoding: Perform a 2×2 transposed convolution operation on the encoded feature f5, with 16 input and output channels each, to obtain the first-level upsampled feature; after ReLU activation, concatenate the channel with the encoded feature f4, and then perform two 3×3 convolution operations. The result is then residual-connected with the first-level upsampled feature, and finally processed by Dropout regularization with a dropout probability of 0.3 to finally output feature M1; Second-level decoding: Perform a 2×2 transposed convolution operation on feature M1, with 16 input and output channels each, to obtain the second-level upsampled feature; after ReLU activation, concatenate the channel with the encoded feature f3, and then perform two 3×3 convolution operations. The result is then residual-connected with the second-level upsampled feature, and finally processed by Dropout regularization with a dropout probability of 0.3 to output feature M2. Third-level decoding: Perform a 2×2 transposed convolution operation on M2, with 16 input and output channels to obtain the third-level upsampled feature; after ReLU activation, concatenate the channel with the encoded feature f2, and then perform two 3×3 convolution operations. The result is then residual-connected with the third-level upsampled feature, and finally processed by Dropout regularization with a dropout probability of 0.3 to output the final feature M3. Fourth-level decoding: Perform a 2×2 transposed convolution operation on M3, with 16 input and output channels to obtain the fourth-level upsampled feature; after ReLU activation, concatenate the channel with the encoded feature f1, and then perform two 3×3 convolution operations. The result is then residual-connected with the fourth-level upsampled feature, and finally processed by Dropout regularization with a dropout probability of 0.3 to output the final feature M4.
[0044] After completing the 4-level decoding, 1×1 convolution operations are performed on M1, M2, M3, and M4 respectively, followed by upsampling to make the spatial resolution of all output features completely consistent with the scale of the input lithium battery low-light image (960×512), ultimately resulting in 4 output features.
[0045] Then, uncertainty feature calculation and segmentation optimization are performed: The four output features are concatenated by channels to obtain feature F; two 3×3 convolution operations are performed on feature F, with a stride of 1 for each operation, and the number of channels is successively transformed from 4 channels to 16 channels and then to 3 channels; softmax activation is performed on the convolution result to obtain a probability feature map; the difference between the maximum and minimum values in the spatial domain of the probability feature map is calculated, and 0.75 times this difference is taken as the probability threshold. Based on the regions where the probability features are less than this probability threshold, the uncertainty mask m is calculated.
[0046] The mask m is multiplied pixel-by-pixel with the LE-curve parameter P3 output by the aforementioned lithium battery image enhancement network to obtain the uncertainty feature Pu; at the same time, the uncertainty feature Fu of the enhanced image is calculated based on the enhanced natural image F3; the uncertainty feature Fu and feature F are concatenated, and three 3×3 convolution operations are performed on the concatenated 7-channel features with a stride of 1. The first two convolutions transform the number of channels to 16 channels and 16 channels respectively, and the last convolution outputs the number of channels for the corresponding category.
[0047] Simultaneously complete image category determination: Flatten the encoded features f6 obtained in the encoding stage, and connect the flattened one-dimensional vector to a fully connected layer. The fully connected layer adopts a two-layer structure of 64×64 and 64×2. Perform Softmax activation on the output features to obtain the category probability C of X-ray lithium battery image classification. If the category probability C is determined to be 0, the number of output feature channels of the last convolution operation is set to 3 (corresponding to the three categories of positive electrode, negative electrode, and background). If the category probability C is determined to be 1, the number of output feature channels of the last convolution operation is set to 4 (corresponding to the four categories of positive electrode, negative electrode, insulating layer, and background). Finally, the predicted category probability S of lithium battery low-light image segmentation is output.
[0048] (5) Discriminating network The discriminant network is designed based on a generative adversarial network structure to determine the authenticity of the predicted class probability S in low-light image segmentation of lithium batteries. The output is a pixel-level authenticity probability feature, and the accuracy of the segmentation network is further optimized through adversarial learning.
[0049] The input to the discriminant network is concatenated features: the original X-ray lithium battery image, the spatial mask features of the positive electrode region, the spatial mask features of the negative electrode region, and the spatial mask features of the background region corresponding to the semantic segmentation results are concatenated by channel to obtain 6-channel concatenated features.
[0050] The discriminant network performs a 4-layer asymptotic downsampling encoding on the input features, with the following structure: First layer encoding: Perform a 4×4 convolution operation, set the boundary padding to 1, and the stride to 2 to encode the 6-channel input features into 64-channel features, and then process them through the LeakyReLU activation function with a negative slope of 0.2; The second layer of encoding: Perform a 4×4 convolution operation, set the boundary padding to 1, and the stride to 2 to encode the 64-channel input features into 128-channel features. First, perform batch normalization, and then process them through the LeakyReLU activation function with a negative slope of 0.2. The third layer of encoding: Perform a 4×4 convolution operation, set the boundary padding to 1, set the stride to 1, and encode the 128-channel input features into 256-channel features; Fourth layer encoding: Perform a 4×4 convolution operation, set the boundary padding to 1, set the stride to 1, and encode the 256-channel input features into 1-channel features, i.e., pixel-level true / false probability features.
[0051] Step 3: Training the Neural Network This step employs a two-stage training strategy. The initial learning rate is set to 0.009. During training, the learning rate is manually adjusted based on the loss convergence. Simultaneously, the optimal model weights are periodically saved for the initialization of the next training stage. The specific training process is as follows: (1) First stage: Training the lithium battery image enhancement network This phase involves training on a low-light natural image dataset and an X-ray lithium battery image enhancement dataset, with one training epoch.
[0052] During training, a batch of dark-light natural image pairs is taken from the dark-light natural image dataset, and a batch of X-ray lithium battery images and their region annotations are taken from the X-ray lithium battery image enhancement dataset. The dark-light natural images are input into the natural image enhancement network, and a three-channel lithium battery dark-light image is constructed based on the X-ray lithium battery image and input into the lithium battery image enhancement network. The network model parameters are iteratively optimized through backpropagation until the training loss of each batch converges to the minimum.
[0053] In this training phase, the ROI region and its corresponding mask are calculated first, and then various losses are calculated, as follows: The L1 gradient consistency loss calculation method for natural images is based on the LE-curve parameters of the dark-light natural image enhancement network output. The enhanced natural image is calculated using the Zero-DCE method. Then, the horizontal and vertical gradients of the enhanced natural image and the dark-light natural image are calculated using a 3×3 Sobel operator. For each pixel, the squared difference of the horizontal gradient between the enhanced natural image and the dark-light natural image, as well as the squared difference of the vertical gradient between the enhanced natural image and the dark-light natural image, are calculated. The squared difference of the enhanced natural image and the squared difference of the dark-light natural image are added together, and finally the results of all pixels are averaged. The method for calculating the spatial gradient consistency loss L2 of X-ray lithium battery images is as follows: Based on the LE-curve parameter P3 of the lithium battery image enhancement output by the lithium battery image enhancement network, the enhanced lithium battery image is calculated using the Zero-DCE method. The gradient difference is then calculated as follows: The horizontal gradient h1 and vertical gradient v1 of the enhanced lithium battery image are calculated using a 3×3 Sobel operator. Then, the horizontal gradient h2 and vertical gradient v2 of the corresponding low-light lithium battery image are calculated. The sum of the squares of the differences between the horizontal gradient h1 and the horizontal gradient h2, and the sum of the squares of the differences between the vertical gradient v1 and the vertical gradient v2 are calculated. These two squared values are then added together. The relative gradient loss L3 of natural images: L3 is calculated as the sum of the relative loss of a single-channel natural image and the relative loss of a multi-channel natural image. The calculation method for the relative loss of a single-channel natural image is as follows: First, enhance the natural image and a batch of natural images to obtain the gradients of each channel intensity in the horizontal and vertical directions of the normally illuminated natural image, obtaining their respective gradient maps. For each color channel, calculate the ratio of the gradient inner product to the product of the L2 norm of the spatial gradient consistency loss of the X-ray lithium battery image. Subtract this ratio from 1, add the cosine of the gradient angle, and finally take the expected value. The calculation method for the relative loss of a multi-channel natural image is as follows: First, divide the sum of the gradient inner products of each channel by the magnitude of its respective gradient, then perform a cross-channel averaging. Then calculate the ratio of the gradient inner product to the product of the L2 norm of the spatial gradient consistency loss of the X-ray lithium battery image. Subtract this ratio from 1, add the cosine of the gradient angle, and finally take the expected value. The relative gradient loss L4 of X-ray lithium battery images: Using the LE-curve parameters P1, P2, and P3 of the lithium battery image enhancement network, three enhanced lithium battery images are calculated using the Zero-DCE method. For each enhanced lithium battery image, the relative gradient loss is calculated as follows: The relative gradient losses of the three enhanced lithium battery images are then summed: the sum of the relative loss of a single-channel X-ray lithium battery image and the relative loss of multiple-channel X-ray lithium battery images. The calculation method for the relative loss of a single-channel X-ray lithium battery image is as follows: First, the gradients of each channel intensity in the horizontal and vertical directions of the enhanced X-ray lithium battery image and the normal illumination natural image in a batch of natural images are calculated to obtain their respective gradient maps. For each color channel, the gradient inner product is calculated and summed with L2. The ratio of the norm product is calculated by subtracting this ratio from 1, adding the cosine of the gradient angle, and finally taking the expected value. The relative loss calculation method for multi-channel X-ray lithium battery images is as follows: First, divide the sum of the gradient inner products of each channel by the magnitude of their respective gradients, then perform cross-channel averaging, then calculate the ratio of the gradient inner product to the L2 norm product, subtract this ratio from 1, add the cosine of the gradient angle, and finally take the expected value. L5 is the loss due to inconsistency in intensity between channels of the enhanced natural image. First, calculate the average intensity of the three channels R, G, and B of the enhanced natural image. Then, calculate the square of the difference between the average values of each pair of channels and sum them up. Finally, take the square root of this sum and divide 1.0 by the square root to obtain L5.
[0054] L6, the intensity inconsistency loss between channels of the enhanced lithium battery image: For each of the three enhanced lithium battery images, calculate the average intensity of the three channels R, G, and B of the enhanced lithium battery image, then calculate the square of the difference between the average values of each pair of channels and sum them up. Finally, take the square root of this sum and divide 1.0 by the square root to obtain the intensity inconsistency loss between channels of the current enhanced lithium battery image. Further summing the intensity inconsistency loss between channels of each enhanced lithium battery image can yield L6. Enhanced natural image brightness constraint loss L7: Calculate the mean brightness of a 16×16 local region using the enhanced natural image, then calculate the difference between these mean values and the preset expected brightness value of 0.4, and finally take the expectation of the difference for all local regions; Enhanced lithium battery image brightness constraint loss L8: Calculate the average brightness of a 16×16 local area using the enhanced lithium battery image, then calculate the difference between these average values and the preset expected brightness value of 0.4, and finally take the expected value of the difference for all local areas. Suppression loss for spatial intensity non-uniformity L9: For each of the three enhanced lithium battery images, calculate the sum of squares of the average intensity difference between any two color channels in each equally divided region of the ROI region of the enhanced lithium battery image to obtain the difference value of the three regions. Then calculate the sum of squares of the differences between each pair of these three difference values and take the average to obtain the suppression loss for spatial intensity non-uniformity of each enhanced lithium battery image. Then, sum the suppression losses for spatial intensity non-uniformity of each enhanced lithium battery image to obtain the suppression loss for spatial intensity non-uniformity L9. Enhanced natural image spatial smoothness constraint loss L10: Calculate the intensity squared difference between adjacent pixels in the vertical and horizontal directions of the enhanced natural image, then sum these squared differences to obtain the total squared difference in the two directions. Divide the total squared difference in the two directions by the number of pixels in each direction to obtain the average squared difference. Sum these two average squared differences and divide them by the total number of pixels in the image. Enhanced Lithium Battery Image Spatial Smoothness Constraint Loss L11: Calculate the intensity squared difference between adjacent pixels in the vertical and horizontal directions of the enhanced lithium battery image, then sum these squared differences to obtain the total squared difference in the two directions. Divide the total squared difference in the two directions by the number of pixels in each direction to obtain the average squared difference. Sum these two average squared differences and divide them by the total number of pixels in the image. Contrast Loss L12: During the training of the contrast learning network, the enhanced lithium battery image is multiplied pixel-by-pixel with the ROI equally divided region mask to obtain three ROI equally divided regions, denoted as region A, region B, and region C from left to right. Region A and region B are used as positive samples, and region C is used as a negative sample. Region A and region C are input into the contrast learning network to encode the first latent space vector, and contrast loss 1 is calculated based on cosine similarity. Region B and region C are input into the contrast learning network to encode the second latent space vector, and contrast loss 2 is calculated based on cosine similarity. The contrast loss L12 is the weighted sum of contrast loss 1 and contrast loss 2, with weights of 0.3 and 0.7, respectively.
[0055] The calculation methods for contrast loss 1 and contrast loss 2 are the same: the latent space feature vectors are encoded for the two input regions respectively, and the cosine similarity between the two is calculated; for positive samples, the loss is calculated directly based on the similarity; for negative samples, the loss is calculated based on the difference between the boundary parameter 1.0 and the similarity; finally, the loss values of all samples are averaged.
[0056] Based on the above 12 losses, the training loss Le of the lithium battery image enhancement network is constructed, and the calculation formula is as follows: Le=W1L1+W2L2+W3L3+W4L4+W5L5+W6L6+W7L7+W8L8+W9L9+W10L10+W11L11+W12L12 Among them, W1 to W12 are the weights of each loss, with values of 1000, 2000, 100, 200, 1.0, 10, 100, 10.0, 10, 1200, 1200, and 2000, respectively.
[0057] (2) Second stage: Training semantic segmentation and classification network and discriminant network This phase involves training on a low-light natural image dataset and an X-ray lithium battery image segmentation and classification dataset, with 50 training epochs. During training, all parameters of the lithium battery image enhancement network trained in the first phase are frozen, and only the parameters of the semantic segmentation and classification networks and the discriminant network are optimized.
[0058] During training, a batch of low-light natural images is taken from the low-light natural image dataset, and a batch of X-ray lithium battery images is taken from the X-ray lithium battery image segmentation and classification dataset to construct a three-channel lithium battery low-light image. The low-light natural images and lithium battery low-light images are input into the semantic segmentation and classification network. Based on the predicted class probability S and classification result C of the lithium battery low-light image segmentation output by the network, the semantic segmentation loss L13 and the X-ray lithium battery image classification loss L14 are calculated respectively. At the same time, based on the predicted class probability S of the lithium battery low-light image segmentation, mask features of the positive electrode, negative electrode and background regions are extracted. The original X-ray lithium battery image and the mask features are concatenated by channel and input into the discriminant network to calculate the discriminator network loss L15. The corresponding network parameters are iteratively optimized through backpropagation until the loss converges to the minimum.
[0059] The calculation method for each loss in this stage is as follows: Semantic segmentation loss L13: Based on the predicted class probability of lithium battery low-light image segmentation, it is calculated by weighting Dice loss and cross-entropy loss, with weights of 5.0 and 0.9, respectively.
[0060] X-ray lithium battery image classification loss L14: calculated using cross-entropy loss.
[0061] Discriminator network loss L15: calculated using binary cross-entropy loss.
[0062] The total training loss in this stage is a weighted sum of semantic segmentation loss L13, X-ray lithium battery image classification loss L14, and discriminator network loss L15, with weights of 900.0, 100.0, and 1.0, respectively.
[0063] Step 4: Semantic segmentation reasoning of X-ray lithium battery image electrodes After completing model training, the trained model is used to perform electrode semantic segmentation on X-ray lithium battery images from industrial sites. The specific process is as follows: An X-ray image I1 of the lithium battery to be detected is acquired, preprocessed by cropping, and cropped to a resolution of 960×512 to obtain a cropped X-ray image I2. The cropped X-ray image I2 is then input into a trained semantic segmentation and classification network. The network automatically performs image enhancement, encoding and decoding, category determination, and semantic segmentation, and finally outputs the predicted category probability S (pixel-level segmentation mask for positive electrode, negative electrode, insulating layer, and background) and the classification result C (class determination of whether the insulating layer is present) for the low-light image segmentation of the lithium battery.
[0064] Based on the predicted category probability S of the output, the edge contour of the electrode can be further extracted, and the alignment and offset of the positive and negative electrodes can be calculated, providing accurate data support for the quality inspection and defect judgment of lithium batteries.
[0065] Implementation effect verification See Figure 1-3 To verify the effectiveness of the method in this embodiment, the model performance was quantitatively evaluated, and the results are as follows: Image enhancement performance: The X-ray lithium battery images enhanced by this method achieve a peak signal-to-noise ratio of up to 55.3615, a structural similarity of up to 0.9070, an information entropy of up to 6.8616, and a local sorting error as low as 0.0280. All indicators are significantly better than existing mainstream enhancement algorithms such as Zero-DCE, Retinex-Net, and MIRNet. Visually, it effectively improves the contrast of low-dose X-ray lithium battery images, preserves the details of electrode edges, and suppresses noise and spatial non-uniformity.
[0066] Semantic segmentation performance: The proposed method achieves an accuracy of 0.9841, a precision of 0.9677, a recall of 0.9849, an F1 score of 0.9761, an intersection-over-union ratio of 0.9536, a Dice coefficient of 0.9761, a true negative rate of 0.9909, and an area under the curve of 0.9981, fully meeting the requirements for accurate segmentation of electrode regions in industrial scenarios.
[0067] Lightweight model performance: The final trained model is only 0.65M in size, with a small number of parameters, fast inference speed, and can be adapted to edge computing devices in industrial settings, demonstrating excellent engineering feasibility.
[0068] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A semantic segmentation method for X-ray lithium battery images based on multi-task learning, characterized in that, The spatial resolution of the X-ray lithium battery image is w×h, where 512≤w≤2000, 384≤h≤640, w is the width, and h is the height, in pixels. The method includes the following steps: Step 1: Construct the dataset, specifically including constructing a low-light natural image dataset, an X-ray lithium battery image enhancement dataset, and an X-ray lithium battery image segmentation and classification dataset; Step 2: Construct a neural network model, which includes a natural image enhancement network, a lithium battery image enhancement network, a contrastive learning network, a semantic segmentation and classification network, and a discriminant network; Step 3: Train the neural network model. Divide the dataset constructed in Step 1 into training set, test set and evaluation set. Use a two-stage training method. First, train the natural image enhancement network, lithium battery image enhancement network and contrast learning network. Then freeze the network parameters that have been trained and further train the semantic segmentation and classification network and the discriminant network. Step 4: Preprocess the X-ray lithium battery images. The preprocessing refers to cropping each X-ray lithium battery image to w×h, and inputting the preprocessed X-ray lithium battery images into the trained semantic segmentation and classification network for prediction. The predicted category probability and classification result are obtained from the semantic segmentation and classification network.
2. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 1, characterized in that, Step 1 is as follows: Step 1.1: Construct a dark light natural image dataset. Specifically, select d1 pairs of natural images from the public datasets LOL-v1 and LOL-v2 to construct a dark light natural image dataset, where 500≤d1≤2000. Each pair of natural images includes a dark light natural image and its corresponding normal lighting natural image, all scaled to w×h. Step 1.2: Construct an X-ray lithium battery image enhancement dataset. Specifically, during the lithium battery production process, collect d2 X-ray lithium battery images, preprocess each X-ray lithium battery image, and construct an X-ray lithium battery image enhancement dataset, where 1000≤d2≤2000. Step 1.3: Construct an X-ray lithium battery image segmentation and classification dataset. Specifically, d3 X-ray lithium battery images are collected during the lithium battery production process. After preprocessing each X-ray lithium battery image, an X-ray lithium battery image segmentation and classification dataset is constructed, where 1500 ≤ d3 ≤ 6000. The images in the X-ray lithium battery image segmentation and classification dataset are labeled in two classes: First, region labeling: label the positive and negative regions of each image, and if there is an insulating layer, label the insulating layer region simultaneously; Second, X-ray lithium battery image category labeling: The images are labeled as category 0 and category 1. Category 0 contains only positive electrode area, negative electrode area and background area, and does not contain insulating layer area. Category 1 contains positive electrode area, negative electrode area, insulating layer area and background area.
3. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 1, characterized in that, The input to the natural image enhancement network is a low-light natural image, in tensor form [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the output is the LE-curve parameters of the low-light natural image. The natural image enhancement network employs a 7-layer depthwise separable convolutional coding structure, specifically as follows: The first layer takes a 3-channel dark light natural image as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output 32-channel first layer encoded features. The second layer takes the encoded features of the first layer as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output 32 channels of second layer encoded features. The third layer takes the second layer's encoded features as input, performs 3×3 depthwise separable convolution operations, 1×1 convolution operations, and ReLU activation processing, and outputs 32 channels of third layer encoded features. The fourth layer takes the 64-channel feature obtained by concatenating the third layer's encoded features by channel as input, performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing, and outputs 32-channel fourth layer encoded features. The fifth layer takes the 64-channel feature obtained by concatenating the second layer coding feature and the fourth layer coding feature by channel as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output the fifth layer coding feature with 32 channels. The sixth layer takes the 64-channel feature obtained by concatenating the first layer coding features and the fifth layer coding features by channel as input, and performs 3×3 depthwise separable convolution operation, 1×1 convolution operation, and ReLU activation processing to output the 32-channel sixth layer coding features. The seventh layer performs 3×3 depthwise separable convolution and 1×1 convolution on the encoded features of the sixth layer, and then activates them with Tanh to obtain the LE-curve parameter B of the 3-channel dark light natural image.
4. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 3, characterized in that, The input to the lithium battery image enhancement network is a lithium battery low-light image, with tensor form [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the three channels of the lithium battery low-light image are all the same. The output is three sets of LE-curve parameters with the same spatial resolution as the lithium battery image, denoted as P1, P2 and P3 respectively. The lithium battery image enhancement network consists of a transfer subnetwork and a residual subnetwork. The structure of the transfer subnetwork is the same as that of the natural image enhancement network, and the two share network parameters. The input low-light image of the lithium battery is sequentially processed by a transfer subnetwork through 7 layers of depthwise separable convolutional coding to obtain features T1, T2, T3, T4, T5, T6 and T7. The depthwise separable convolutional coding is designed as 3×3 depthwise separable convolutional operation, 1×1 convolutional operation and feature activation processing. Feature T6 is input into the residual sub-network, which consists of three depthwise separable convolution operations: the first is a 3×3 depthwise separable convolution operation and ReLU activation, with boundary padding set to 1, and both input and output feature channels are 32; the second is a 1×1 depthwise separable convolution operation and ReLU activation, with boundary padding 0, and both input and output feature channels are 32; the third is a 1×1 depthwise separable convolution operation and ReLU activation, with boundary padding 0, and both input and output feature channels are 32, outputting the residual feature; Add the residual feature to feature T6 to obtain feature T8. Concatenate feature T8 and feature T1 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh. Add the result to feature T7 to obtain the LE-curve parameter P3. Concatenate feature T3 and feature T4 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh to obtain the LE-curve parameter P1. Concatenate feature T2 and feature T8 by channel, perform a 3×3 depthwise separable convolution operation and a 1×1 convolution operation, and then activate with tanh to obtain the LE-curve parameter P2.
5. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 1, characterized in that, The input to the contrastive learning network is a tensor of the form [b, 3, H, W], where b represents the number of images in a batch, 3 represents the number of channels, H is h, and W is W. ,in This indicates a floor operation, and the output is a latent space vector. The contrastive learning network performs three layers of encoding calculation and feature compression processing on the input features sequentially, wherein: The three-layer encoding calculation encodes the input 3-channel features into 64-channel features, specifically as follows: The first layer of encoding computation includes a first encoding unit and a second encoding unit. The first encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 3-channel features into 32-channel features, reducing the spatial resolution by half. The second encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 32-channel features into 64-channel features, while maintaining the spatial resolution. The second layer of encoding computation includes a third encoding unit and a fourth encoding unit. The third encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 64-channel features into 128-channel features, reducing the spatial resolution by half. The fourth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 128-channel features into 128-channel features, maintaining the spatial resolution. The third layer of encoding computation includes the fifth encoding unit and the sixth encoding unit. The fifth encoding unit uses a 3×3 convolution kernel, a stride of 2, and a boundary padding of 1 to encode 128-channel features into 64-channel features, reducing the spatial resolution by half. The sixth encoding unit uses a 3×3 convolution kernel, a stride of 1, and a boundary padding of 1 to encode 64-channel features into 64-channel features, maintaining the spatial resolution. The feature compression process specifically involves: performing 2D mean pooling on the input 64-channel features, flattening the features into a one-dimensional vector, encoding it through a 64×128 fully connected layer to obtain a 128-dimensional vector, and then performing a nonlinear transformation through the Tanh activation function to obtain the latent space vector.
6. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 4, characterized in that, The semantic segmentation and classification network includes an image enhancement processing module, an encoder, and a decoder. The input is a batch of lithium battery low-light images, and the output is the predicted class probability S and classification result C of the lithium battery low-light image segmentation. The tensor form of the lithium battery low-light image is [b,3,h,w], where b represents the number of images in a batch, 3 represents the number of channels, and the three channels of the lithium battery low-light image are all the same. The semantic segmentation and classification network sequentially performs image enhancement processing, encoding processing, and decoding processing on the input data, specifically as follows: Image enhancement processing: The low-light image of the lithium battery is processed through a lithium battery image enhancement network to obtain LE-curve parameters P1, P2, and P3. Based on the Zero-DCE method, for the input image... At that time, three enhanced X-ray lithium battery images F1, F2, and F3 were calculated according to formulas (1)-(3); (1); (2); (3); Encoding Processing: Three enhanced X-ray lithium battery images are concatenated by channel. The resulting concatenated tensor is sequentially encoded at 6 levels to obtain 6-level encoded features f1, f2, f3, f4, f5, and f6. The first level of encoding is a 3×3 convolution operation with a stride of 1 and a boundary padding of 1, encoding the input 9-channel features into 16-channel features while maintaining spatial resolution. The second to fifth levels of encoding are first performed using a 3×3 convolution operation with a stride of 2 and a boundary padding of 1, encoding the 16-channel features into 32-channel features, reducing the spatial resolution by half. Then, a 3×3 convolution operation is performed again with a stride of 1 and a boundary padding of 1, encoding the 32-channel features into 16-channel features while maintaining spatial resolution. Batch normalization is performed simultaneously. The sixth-level encoding performs four convolution operations and ReLU activation processing in sequence, followed by batch normalization. The convolution kernels for the four operations are 5×5, 7×7, 5×5, and 3×3, with a stride of 2 for each operation. The boundary padding is 2, 3, 2, and 1 for each operation, and the number of channels activated in each operation is 16, 16, 8, and 8, respectively. Decoding process: A 4-level progressive structure is adopted. The first level of decoding obtains the first level upsampled feature by transposing the encoded feature f5 through a 2×2 convolution. The input and output channels are both 16. After ReLU activation, the channel is concatenated with the encoded feature f4. Then, after two 3×3 convolution operations, the result is residually connected with the first level upsampled feature. After Dropout regularization with a dropout probability of 0.3, feature M1 is obtained. The second-level decoder obtains the second-level upsampled feature by performing a 2×2 transposed convolution on M1. The input and output channels are both 16. After ReLU activation, the channel is concatenated with the encoded feature f3. Then, after two 3×3 convolution operations, the result is residually connected with the second-level upsampled feature. After Dropout regularization with a dropout probability of 0.3, feature M2 is obtained. The third-level decoder performs a 2×2 transposed convolution on feature M2 to obtain a third-level upsampled feature with 16 input and output channels. After ReLU activation, it is concatenated with the encoded feature f2, and then subjected to two 3×3 convolution operations. The result is residually concatenated with the third-level upsampled feature and regularized with Dropout with a dropout probability of 0.3 to obtain feature M3. The fourth-level decoder performs a 2×2 transposed convolution on feature M3 to obtain a fourth-level upsampled feature with 16 input and output channels. After ReLU activation, it is concatenated with the encoded feature f1, and then subjected to two 3×3 convolution operations. The result is residually concatenated with the fourth-level upsampled feature and regularized with Dropout with a dropout probability of 0.3 to obtain feature M4. Features M1, M2, M3, and M4 are subjected to 1×1 convolution and upsampling to obtain four output features with the same spatial resolution as the input lithium battery low-light image. The four output features are concatenated by channel to obtain feature F. Feature F is subjected to two 3×3 convolution operations with a stride of 1, and the number of channels is changed from 4 to 16 channels and from 16 channels to 3 channels. After softmax activation, a probability feature map is obtained. The probability threshold is 0.75 times the difference between the maximum and minimum values in the spatial domain of the probability feature map. An uncertainty mask m is calculated based on the regions where the probability features are less than the probability threshold. The mask m is multiplied pixel by pixel with the LE-curve parameter P3 to obtain the uncertainty feature Pu. The uncertainty feature Fu obtained by enhancing the natural image is combined with the uncertainty feature Fu and feature F. The concatenated feature is subjected to three 3×3 convolution operations with a stride of 1, and the number of channels is changed from 7 channels to 16 channels, from 16 channels to 16 channels, and from 16 channels to the corresponding category channel number. The encoded feature f6 is flattened and then fed into a fully connected layer. The fully connected layer is a two-layer structure of 64×64 and 64×2. After being activated by Softmax, the category probability C of X-ray lithium battery image classification is obtained. If the category probability C is 0, the number of feature channels output by the last convolution operation is 3. If the category probability C is 1, the number of feature channels output by the last convolution operation is 4.
7. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 6, characterized in that, The adversarial network structure is designed such that, for the discriminant network, the input is a 6-channel concatenated feature: the 6-channel concatenated feature is obtained by concatenating the low-light image of the lithium battery, the spatial mask feature of the positive electrode region, the spatial mask feature of the negative electrode region, and the spatial mask feature of the background region according to the channels; the output is a pixel-level authenticity probability feature; the discriminant network performs 4-layer asymptotic downsampling encoding on the input feature, specifically: The first layer of encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 2, to encode the 6-channel input features into 64-channel features, which are then activated by LeakyReLU with a negative slope of 0.
2. The second layer of encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 2, to encode the 64-channel input features into 128-channel features, followed by batch normalization and LeakyReLU activation with a negative slope of 0.
2. The third layer of encoding uses a 4×4 convolutional kernel, with boundary padding set to 1 and stride set to 1, to encode the 128-channel input features into 256-channel features. The fourth layer encoding uses a 4×4 convolution kernel, with boundary padding set to 1 and stride set to 1, to encode the 256-channel input features into a 1-channel feature.
8. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 6, characterized in that, In step 3, each dataset is divided into a training set, a test set, and an evaluation set in an 8:1:1 ratio. The initial learning rate is set to 0.009 for all sets. A two-stage training process is employed, with the learning rate manually adjusted in each stage, and the optimal model is used for training at different stages. The two-stage training is as follows: (1) First stage: Train the natural image enhancement network, lithium battery image enhancement network and contrast learning network, and train for one round on the low-light natural image dataset and the X-ray lithium battery image enhancement dataset; in each loop, take a batch of low-light natural image pairs from the low-light natural image dataset and a batch of X-ray lithium battery images and their region annotations from the X-ray lithium battery image enhancement dataset, input the low-light natural images into the natural image enhancement network, and output the LE-curve parameters of the low-light natural images from the natural image enhancement network. For the input image The natural image enhancement result is calculated using formula (4). ; (4); Three-channel low-light images of lithium batteries were constructed using X-ray lithium battery images, and then input into the lithium battery image enhancement network. The three enhanced X-ray lithium battery images F1, F2, and F3 were calculated according to formulas (1)-(3). The network model parameters were iteratively optimized until the loss of each batch was minimized. (2) Second stage: Train the semantic segmentation and classification network, train it for 50 to 100 rounds on the X-ray lithium battery image segmentation and classification dataset; freeze the parameters of the natural image enhancement network and the lithium battery image enhancement network, take a batch of X-ray lithium battery images from the X-ray lithium battery image segmentation and classification dataset and construct lithium battery dark light images, input the lithium battery dark light images into the semantic segmentation and classification network, calculate the semantic segmentation loss and classification loss based on the predicted category probability S and classification result C of the output lithium battery dark light image segmentation, further calculate the positive electrode region spatial mask features, negative electrode region spatial mask features and background region spatial mask features according to the predicted category probability S, then concatenate the lithium battery dark light images with the positive electrode region spatial mask features, negative electrode region spatial mask features and background region spatial mask features by channel, input the obtained concatenated features into the discriminant network, calculate the discriminator network loss, iteratively optimize the corresponding network parameters until the discriminator network loss of each batch is minimized; In the second stage of training, the training loss is a weighted sum of semantic segmentation loss L13, X-ray lithium battery image classification loss L14, and discriminator network loss L15, with weights of 900.0, 100.0, and 1.0, respectively. Specifically, the semantic segmentation loss L13 is calculated by weighting Dice loss and cross-entropy loss based on the predicted class probability of lithium battery low-light image segmentation, with weights of 5.0 and 0.9, respectively. The X-ray lithium battery image classification loss L14 is calculated using cross-entropy loss, and the discriminator network loss L15 is calculated using binary cross-entropy loss.
9. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 1, characterized in that, In the first stage of training, based on the region annotations of the X-ray lithium battery image, the Region of Interest (ROI) is calculated from the positive and negative electrode regions. The ROI is then divided into three equal parts horizontally, resulting in the ROI regions and their corresponding masks. Based on this, the formula for calculating the first-stage training loss Le is: Le = W1L1 + W2L2 + W3L3 + W4L4 + W5L5 + W6L6 + W7L7 + W8L8 + W9L9 + W10L10 + W11L11 + W12L12 Wherein, L1 is the gradient consistency loss of the natural image, L2 is the spatial gradient consistency loss of the X-ray lithium battery image, L3 is the relative gradient loss of the natural image, L4 is the relative gradient loss of the X-ray lithium battery image, L5 is the loss to enhance the intensity inconsistency between channels of the natural image, L6 is the loss to enhance the intensity inconsistency between channels of the lithium battery image, L7 is the loss to enhance the brightness constraint of the natural image, L8 is the loss to enhance the brightness constraint of the lithium battery image, L9 is the loss to suppress spatial intensity non-uniformity, L10 is the loss to enhance the spatial smoothness constraint of the natural image, L11 is the loss to enhance the spatial smoothness constraint of the lithium battery image, and L12 is the contrast loss; W1 to W12 are the weights corresponding to each loss, with values of 1000, 2000, 100, 200, 1.0, 10, 100, 10.0, 10, 1200, 1200, and 2000, respectively. The contrast loss L12 is calculated as follows: During the training of the contrastive learning network, the enhanced lithium battery image is multiplied pixel-by-pixel with the equally divided region mask of the ROI to obtain three equally divided regions based on the ROI, denoted as region A, region B, and region C from left to right. Regions A and B are used as positive samples, and region C is used as a negative sample. Regions A and C are input into the contrastive learning network to obtain the first latent space vector, and contrast loss 1 is calculated based on cosine similarity. Regions B and C are input into the contrastive learning network to obtain the second latent space vector, and contrast loss 2 is calculated based on cosine similarity. The contrast loss L12 is a weighted sum of contrast loss 1 and contrast loss 2, with weights of 0.3 and 0.7, respectively. Both contrast loss 1 and contrast loss 2 are calculated based on cosine similarity: the latent space feature vectors of the two input regions are encoded separately, and their cosine similarity is calculated. For positive samples, the loss is directly calculated based on this similarity, and for negative samples, the loss is calculated based on the difference between the boundary parameter 1.0 and the similarity. Finally, the loss values of all samples are averaged.
10. The X-ray lithium battery image electrode semantic segmentation method based on multi-task learning according to claim 1, characterized in that, Step 4 specifically involves cropping the sampled X-ray lithium battery image I1 to w×h to obtain the cropped X-ray lithium battery image I2. The cropped X-ray lithium battery image I2 is then input into the trained semantic segmentation and classification network, and the predicted category probability S and classification result C of the lithium battery low-light image segmentation are output.