乳牛是種難以控制其行為的一種動物,不容易對其進行拍攝取樣,特別是牛臉這種局部特徵。因此本研究設計一套基於孿生神經網路的乳牛身分識別系統,能夠利用少量牛臉影像資料集,訓練出深度學習模型,達到有效的身分識別效果。利用Yolov4能快速偵測並分割影像中的牛臉,再將影像測試樣本與已訓練過的影像樣本輸入孿生神經網路(Siamese Neural Network)中的神經網路模型各別學習特徵,利用特徵向量計算出歐式距離(Euclidean Distance),再經由sigmoid將歐式距離正規化後,得出兩個輸入影像之間的相似度,最後比較相似度以判定乳牛身分。實驗結果顯示,我們的系統中基於Resnet50的孿生神經網路在少樣訓練樣本數(每隻牛20張影像)得到95.5%辨識率,優於單獨使用Resnet50的TOP1辨識率70%。我們系統中的網路模型除了使用Resnet50也嘗試替換不同神經網路模型,用以比較辨識效果,實驗結果顯示替換為Resnet18的辨識率可以達到99.5%;替換為我們自建的CNN網路模型辨識率為75%;替換為VGG16辨識率為90.5%。這顯示我們所設計的系統在基於Resnet18的孿生神經網路能達到最佳的辨識效果,在少量訓練樣本中能夠佔有優勢。;Dairy cows are an animal whose behavior is difficult to control. It is difficult to capture the ideal angle when shooting images on it, especially local features such as cow faces. In this research, a set of dairy cow biometric identity recognition system based on siamese neural network is designed, which can use a small amount of cow face image data set to train deep learning model to achieve effective identity recognition effect. In this research, Yolov4 can quickly detect and segment the dairy cow face in the image, and then input the image test sample and the trained image sample into the neural network model in the Siamese Neural Network to learn features, and use the feature vector to calculates the Euclidean Distance, and then normalize the Euclidean Distance by sigmoid to obtain the similarity between the two input images, and finally compares the similarity to determine the identity of the dairy cow. The experimental results show that Resnet50-based Siamese Neural Network in our system has a 95.5% recognition rate with a small number of training samples (20 images per cow), which is better than the 70% recognition rate of TOP1 using Resnet50 only. In addition to using Resnet50, we also tries to replace different neural network models in our system experiment to compare the recognition effect. The experimental results show that the recognition rate of replacing with Resnet18 can reach 99.5%, replacing with CNN network model has a recognition rate of 75%, replacing with VGG16 has a recognition rate of 90.5%. This shows that the dairy cow biometric identity recognition system we designed can achieve the best recognition effect in the Siamese Neural Network based on Resnet18 can achieve the best recognition effect, and it can have an advantage in a small number of training samples.