Triplet Siamese Network Model for Lithium-ion Battery Defects Classification Using Few-shot Learning Approach

In this paper, we propose a triplet siamese model for lithium-ion battery defects classification. It is a difficult task to detect the surface defects of lithium-ion batteries with stainless steel surface. The lack of three-dimensional information and the lack of marker datasets due to reflections prevent two-dimensional computer vision detection methods from meeting classification needs. In this work, the multiple exposure structured light method is utilized to obtain the three-dimensional shape of a lithium-ion battery with a stainless steel surface. The defect point cloud with three-dimensional information is obtained by this method, and then the 3D information of the defect point cloud is converted into grayscale information, and the grayscale image is used as the target domain data of the triplet siamese network. The public dataset MiniImageNet is utilized as the training data of the triplet siamese network model. The accuracies of the experimental results are 88.9%, 95.6%, and 97.8% for 1-shot, 5-shot, and 10-shot respectively. This result proves that our method can be used for lithium-ion battery defect detection.


Introduction
As an essential electronic energy storage device, lithium batteries are not only a powerful weapon against the problems of air pollution and rising oil prices but also a partner in our daily life [1][2]. Lithium-ion batteries have a wide range of applications, for example consumer electronics, electric transportation, and so on. Therefore, the safety of lithium-ion batteries needs extra attention. Detecting defects on the surface of lithium-ion batteries is an important way to ensure their safety and stability [3][4].
Currently, there are mainly three major difficulties in detecting surface defects of lithium-ion batteries with stainless steel surfaces, firstly, the stainless steel surface affects image acquisition, making the application of computer vision detection methods more difficult; secondly, the lack of three-dimensional information on the surface of lithium-ion batteries makes it impossible to identify the type of lithium-ion battery surface defects by two-dimensional computer vision methods; Finally, the huge number of anomalous samples is difficult to obtain, which makes it difficult to train a deep neural network model with strong robustness.
The first two problems can be solved by using the structured light method with multiple exposure sequences. Firstly, the structured light method can acquire the 3D information of the target, and then the multiple exposure sequence method can eliminate the influence of reflected light on image acquisition. While the shortage of anomalous samples is a difficult problem to solve. In many practical  [5][6][7]. How to learn new classes on deep neural network models using a small number of samples has become the main goal of research in this field.
To solve the problem of training deep network models with few shots, different approaches are proposed. For example, Dandage, H. K. proposed a multi-scale image method [8]. This method is similar to the Siamese network approach, which designs a skillful structure to take a pair of image devices as input samples, and then training the network model so that the input samples of different categories are as far away as possible in the first stage, and finally separating the samples of two categories in the second stage. A similar approach to solve the few-sample problem is the Siamese network. This model has been applied to solve the few-shot problem in the field of plant disease, PCB detection, and so on [9][10]. Besides that, data augmentation and weak-supervised learning are also can be used to deal with few-shot learning problems [11][12].
In order to deal with the above problems. In this paper, a triplet Siamese network model for the lithium-ion battery defects classification approach is proposed. First, a phase shift method based on multiple exposures is used to obtain accurate three-dimensional information of the Li-ion battery. After that, the defective part of the anomalous Li-ion cells can be separated by aligning with the criteria model. Finally, defective Li-ion cells can be well classified by triple Siamese network.

Approach
The Triplet Siamese network for lithium-ion battery defects classification method proposed in this paper consists of two main parts, firstly, a multi-exposure structured light 3D reconstruction method, and secondly, a lithium-ion battery defect classification model based on the Siamese network. Figure 1 shows an overview of the proposed approach, described as follows.

Multiple exposure fusion
2.1.1. Digital fringe projection technique with phase shift Generally, a classic fringe pattern of the digital fringe projection technique with phase shift method can be described as follows [13].
Where u and v represents projector's pixel horizontal and vertical coordinates respectively.
, I u v is the amplitude,  represents the phase value that we want to acquire, and k  represents the phase shift. In general, we set The phase  can be obtained by following equation: Finally, by collapsing the input images using the weighted blending method, the fused results can be obtained. Please see [15] for detail.

Height-grey transformation
Assuming that 0 P is the prepared criteria three-dimensional cloud points. The three-dimensional reconstruction result produced by multiple exposure fusion methods is defined as a three-dimensional cloud point P . The disparity three-dimensional cloud point d P can be obtained after aligning P to 0 P , which a height threshold 0 a in the 3 rd dimension. Then, the two-dimensional image x I can be acquired by transforming d P into an 8-bit grey image.
Lithium-ion batteries have three main defects: dents, bumps and scratches, which need to be detected in our tasks. 0 a is related to the producing process, the grayscale point cloud with no height information exceeding the threshold value indicates that the inspection object corresponding to the point cloud is a product with qualified appearance, or it indicates that the object is a defective product. The height-grey transformer can be conducted as: Where H is the farthest distance between a pair of points in all 3D point cloud pairs.   Figure 1, the whole lithium-ion battery defect classification process is divided into two stages: pre-training and fine-tuning. In the pre-training stage, we mainly use the Triplet Siamese network model, which is a variation of the Siamese network model, similar to Siamese network, in  [16][17]. The public dataset is used as source domain data for pre-training the triplet model. In this stage, the weight parameters of the feature extractor, which is able to extract advanced features f , and the weight parameters of the fully connected layers FC are trained and updated. Then Triplet loss Loss is used to ensure that features of different categories can be separated in the embedding space, while features of similar categories can be as close as possible in the embedding space.
In the fine-tuning stage, the height-grayscale transformed result from the multi-exposure fusion phase shift method are trained as the training set for the classification model. In this stage, the feature extractors F  from the training phase are directly adopted. Therefore, this method is to achieve knowledge migration from large to small datasets by fixing the weight parameters of the CNN image feature extractor F  trained in the pre-training environment and adjusting the parameters of the CNN classifier 1 C by fine-tuning.

Objective Function
The objective function reflects the loss between the estimated value and the true value in a certain mapping space, and a good objective function can help Siamese networks generate more easily distinguishable representations. Generally, the objective function contains a loss term part and a regularization term part. In face recognition tasks, it is necessary to determine whether two faces are the same. The contrastive loss used in the Siamese network calculates the similarity between two samples, but only the similarity is not enough. If we want to get a better model, we not only need to distinguish the positive and negative samples but also make the distance between the intra-class samples smaller and the inter-class samples larger. This requires the usage of Triplet loss, which is trained with two positive examples and one negative example. Usually, the triplet loss can be designed as follows: Where a X denotes the anchor image, p X denotes the positive image, and n X denotes the negative image. margin is a hyper-parameter that indicates how far   To improve the generalization performance of the model migration model, we add a batch spectral regularization (BSR) term to the loss function. Bing and Chen had experimentally verified that the BSR term has some performance in improving the generalization ability of the model [18][19].  Figure. 1. We used a shallow CNN 1 C of dimension 1024 to 3 as a classifier for classifying the distance between the features of different classes in the fine-tuning stage.

Setup
In this experiment, the source domain samples are obtained from the MiniImage public dataset, which contains a total of 60,000 samples and 6000 categories, and the dataset is divided into a training set (80%) and a test set (20%) for training the Triplet Siamese network. the target domain samples contain a total of 60 samples and 3 lithium-ion battery defect classes. For each class, 1, 5, and 10 images are randomly selected to form the target domain training set, and the remaining data set as the test set.
For the experimental parameters, when pre-training the model in the source domain, the values of training epoch, learning rate, batch size,  , and margin are 1000, 1e-7, 1e-4, 64, and 1.0, respectively. When fine-tuning the classifier with the target domain dataset, the gradient descent optimization algorithm is used, and the values of momentum, learning rate, and weight decay are set to 0.9, 1e-2, and 1e-3, respectively. The training epoch is set as 300.

Result
As shown in Table 1, the accuracies of the proposed lithium-ion battery defect classification model in the target domain are 0.889%, 0.956%, and 0.978% for 1-shot, 5-shot and 10-shot respectively, while the classification accuracies without the BSR term are 0.844%, 0.933%, and 0.933% for 1-shot, 5shot and 10-shot respectively. As a comparison, the classification accuracy of the Siamese network using contrastive loss and the Siamese network with the BSR term are 0.867%, 0.933%, 0.911%, and 0.733%, 0.867%, 0.889%, respectively. The results show that the Triplet Siamese network proposed in this method has a better ability to learn new defect classes of lithium-ion batteries and can better classify different defects.

Conclusion
In this work, a triplet Siamese network approach for the classification of the Li-ion battery using a few-shot learning method is proposed. The experiment result indicate that our approach can overcome the effect of reflectivity, the limitation of acquiring the 3D information, and the lack of large training data. The accuracy of the target domain is 88.9%, 95.6%, and 97.8% respectively for 1-shot, 5-shot and 10-shot, which shows that the proposed method is useful for the new defects class classification of Li-ion batteries with a few new labelled data.