A method of animal recognition based on deep neural network
Through the animal recognition method based on deep neural network, the deep convolutional neural network and the improved YOLOv3 model are used to extract and recognize animal faces, which solves the problem of pets and stray cats and dog management, and improves recognition performance and recognition.
Patent Information
- Application Number
- CN202210377367.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-11
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-04-11
AI Technical Summary
The existing technology is difficult to effectively manage pets and stray cats and dogs, resulting in pet loss and the proliferation of stray cats and dogs.
An animal recognition method based on deep neural network is adopted, and feature extraction and recognition of animal faces is performed through deep convolutional neural network ResNet50 and the improved YOLOv3 model, and feature matching is performed in combination with KNN algorithm.
The recognition of animal facial features is improved, a model combination with excellent recognition performance is proposed, and the recognition performance is improved by improving the model structure.
Smart Images

Figure CN114863513B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer vision technology, and in particular to an animal recognition method based on deep neural network. Background Art
[0002] In the context of the intelligent era, artificial intelligence has gradually penetrated into various fields and affected all aspects of people's lives. Among them, face recognition is an important manifestation of artificial intelligence. People are paying more and more attention to face recognition technology and are constantly trying to apply it. With the rapid growth of the economy, people are paying more attention to spiritual needs. Pets have gradually entered thousands of households, but problems such as pet loss and the proliferation of stray cats and dogs have continued to emerge. The lack of effective management of pets and stray cats and dogs is a major problem and difficulty in the current pet industry. Therefore, how to digitally register and manage pets and stray cats and dogs is a hot topic in the current pet industry management, and it is also a very practical research direction.
[0003] Identity recognition and authentication based on biometric information has become a research hotspot in recent years. Biometric extraction is an important part of identity recognition. It is very important to be able to accurately extract biological facial information features and convert them into digital information to achieve accurate recognition. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide an animal recognition method based on a deep neural network in view of the defects in the prior art.
[0005] The technical solution adopted by the present invention to solve the technical problem is: an animal identification method based on a deep neural network, comprising the following steps:
[0006] 1) receiving an animal picture p submitted by a user, cropping the original animal picture p submitted by the user, and selecting the facial area of the animal to obtain an animal facial picture;
[0007] 2) According to the animal facial pictures, the features of the animal are extracted through a feature extraction model; the feature extraction model is a deep convolutional neural network ResNet50, and the feature matching algorithm is a multi-layer perceptron for multi-classification in the training stage, and the loss function is
[0008]
[0009] Among them, m is a hyperparameter penalty term, which indicates the size of the distance between classes; s is a hyperparameter, which indicates the radius of the hypersphere; N indicates the number of categories; θ i represents the angle formed by category i at the center of the sphere;
[0010] The input image of the feature extraction model is a 112*112 three-channel animal face image, which is then downsampled by the deep convolutional neural network ResNet50 to obtain a 7*7 feature map, which is then linearly mapped through the fully connected layer to output a 512-dimensional feature vector, denoted as t;
[0011] 3) Calculate the Euclidean distance between the feature vector t and the animal features in the animal feature information database, use the KNN algorithm for feature matching, and perform identification;
[0012] A threshold k of the Hamming distance is set in advance. When the Euclidean distance is less than the threshold k, the recognition is successful. If the distance between all animal features in the animal information feature database and the feature vector t is greater than k, the recognition fails.
[0013] According to the above scheme, in the step 1), the improved YOLOv3 model is used to crop the image p and then select the facial area of the animal. The preset Anchor in the improved YOLOv3 model is corrected to 10,10; 30,30; 50,50; 70,70; 100,100; 130,130; 180,180; 230,230; 330,330; at the same time, when predicting the Bounding Box, its aspect ratio is limited to 1:1.
[0014] According to the above scheme, the model in step 2) is an improved ResNet50 model, and the model structure is to replace the pooling operation in the native ResNet50 model with a batch normalization operation to avoid overfitting, and modify the native ResNet50 network model structure, use two 3*3 convolutions in a bottleneck, and reduce the number of convolution kernels.
[0015] According to the above scheme, the training process of the model in step 2) is:
[0016] The feature matching model in the training stage is a multi-layer perceptron. The images input into the training set are first subjected to feature extraction by the improved ResNet50 to obtain a 512-dimensional feature vector. Since the number of individuals in the training set is fixed during the training stage, a multi-layer perceptron is used for multi-classification tasks, and the loss function is used to train the model to achieve parameter updates.
[0017] The beneficial effects produced by the present invention are:
[0018] The animal facial feature extraction method adopted in the present invention ensures that the extracted features are more recognizable. At the same time, a model combination with excellent recognition performance is proposed, and the structure of the model is improved, so that the final recognition model has good recognition performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:
[0020] Figure 1 It is a method flow chart of an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0022] like Figure 1 As shown, an animal recognition method based on a deep neural network comprises the following steps:
[0023] 1) receiving an animal picture p submitted by a user, cropping and correcting the original animal picture p submitted by the user, and then selecting the facial area of the animal to obtain the animal facial picture;
[0024] In step 1), the improved YOLOv3 model is used to crop and correct the image p and then select the facial area of the animal. As a representative of the single-price segment target detection algorithm, YOLOv3 has the characteristics of high real-time performance. In the present invention, YOLOv3 is used as an algorithm for cropping photos, and the original photos are cropped into square images containing as much facial information as possible required in the subsequent network. Since the one-dimensional stretching of the photo will change the features such as the shape of the facial contour, it is necessary to ensure that the aspect ratio of the picture cropped by YOLOv3 is 1:1.
[0025] YOLOv3 model training data set production
[0026] First, collect a large number of pictures with animal faces from the Internet, and use the labelme tool to make them into the COCO dataset format. When selecting the facial area, it is necessary to make the aspect ratio of the selected area as 1:1 as possible, so that the subsequent algorithm will not stretch the picture to cause image deformation and thus cause errors in feature extraction. For the division of the data set, the created data set is divided into a training data set, a verification data set, and a test data set according to the ratio of 8:1:1. Finally, all labels are stored in the .json file in the "annotations" folder, the training data set is placed in the "train" folder, the verification data set is placed in the "val" folder, and the test data set is placed in the "test" folder. After obtaining the COCO type data set, it needs to be converted into the data set format used for YOLOv3 training. In the present invention, in addition to the animal category information, the data set also needs to include the relevant position information of the Bounding Box.
[0027] In the present invention, the preset Anchors are corrected to 10,10, 30,30, 50,50, 70,70, 100,100, 130,130, 180,180, 230,230, 330,330. At the same time, when predicting the Bounding Box, its aspect ratio is limited to 1:1. During the training process, incremental learning is used to further train the officially published model on the dataset of the present invention, and the number of training iterations is set to 1000.
[0028] 2) According to the animal facial pictures, the animal features are extracted through the feature extraction model; the feature extraction model is the improved deep convolutional neural network ResNet50, the feature matching model is a multi-layer perceptron in the training stage, and the KNN algorithm is used in the testing and use stages. The loss function is
[0029]
[0030] Among them, m is a hyperparameter penalty term, which indicates the size of the distance between classes; in the present invention, m is set to 0.5; s is set to 64.
[0031] The input image is a 112*112 three-channel image, which is then downsampled by the deep convolutional neural network ResNet50 to obtain a 7*7 feature map, and then linearly mapped by the fully connected layer to output a 512-dimensional feature vector, denoted as t; the improved ResNet50 model structure is shown in the following table:
[0032] Table 1 Improved ResNet50 model structure
[0033]
[0034]
[0035]
[0036] The ResNet50 model uses residual links as its main structure, and avoids the gradient vanishing and gradient exploding problems during training by adding shortcuts between hidden layers of different depths. It includes pooling operations to further improve the accuracy of model recognition. Therefore, the present invention abandons the pooling operation and uses batch normalization operations to avoid overfitting. At the same time, the native ResNet50 network model structure is modified, two 3*3 convolutions are used in a bottleneck, and the number of convolution kernels is reduced. Finally, batch normalization is used instead of global mean pooling, and then linear mapping is performed to obtain a 512-dimensional vector.
[0037] Since different photos of different individuals need to be identified and matched, different facial photos of different animal individuals need to be established.
[0038] Model dataset creation
[0039] In reality, we took photos of different faces of multiple animals and manually cropped them to make the aspect ratio of the cropped photos 1:1. Then we divided the data set, randomly selected one photo from each individual as the test set, and the rest as the training set.
[0040] Training process
[0041] The dataset is divided into a training dataset and a test dataset in an 8:2 ratio. The network is built using the TensorFlow2 deep learning framework. The divided training dataset is converted into TFRecord format for easy data reading. Hyperparameter options are specified and training is started. The batch size is set to 8 for training. The input image is converted into a 512-dimensional feature vector through downsampling and linear mapping of the improved ResNet50 network. A multi-layer perceptron is used for feature matching to achieve multi-classification tasks. The loss function is calculated through the output results. Momentum gradient descent is used for training to achieve parameter optimization. The number of training iterations is set to 38,000, and the model converges.
[0042] 3) Calculate the Euclidean distance between the feature vector t and the animal features in the animal feature information database, use the KNN algorithm for feature matching, and perform identification;
[0043] A threshold k of the Hamming distance is set in advance. When the Euclidean distance is less than the threshold k, the recognition is successful. If the distance between all animal features in the animal information feature database and the feature vector t is greater than k, the recognition fails.
[0044] Calculate the Euclidean distance between the feature vector t and the animal features in the animal feature information database:
[0045]
[0046] Among them, (x1, y1) and (x2, y2) are the feature vectors of t and the animal features in the animal feature information database respectively. The Euclidean distance ED is obtained by calculating the distance between these two points in the Euclidean space.
[0047] In the present invention, the feature matching and recognition stage searches for the four closest vectors in the database as matches and obtains the corresponding individual information, that is, obtains the four animal information in the database with the closest Euclidean distance to the extracted feature vector as the recognition result.
[0048] In order to verify the effectiveness of the animal recognition model proposed in the present invention, three performance indicators, namely Accuracy (ACC), False Acceptance Rate (FAR) and True Acceptance Rate (TAR), are introduced to quantitatively evaluate the animal recognition performance of the present invention.
[0049] FAR (False Accept Rate) is the false acceptance rate, which is equivalent to FPR (False Positive Rate). It refers to the number of times that different animals are mistakenly considered to be the same animal, which accounts for all the comparisons of different animals. The calculation formula is as follows:
[0050]
[0051]
[0052] TAR (True Accept Rate) represents the correct acceptance ratio, which is equivalent to TPR (True Positive Rate). It refers to the number of times the same animal is correctly considered to be the same animal among all the comparisons of the same animal. The calculation formula is as follows:
[0053]
[0054]
[0055] After comparative experiments, the results of the model proposed in this paper, the native ResNet50 model and VGG as the backbone network are as follows:
[0056] Table 2
[0057]
[0058] From the above results, it can be concluded that the improved ResNet50 proposed in the present invention has good performance in accuracy, false acceptance rate and correct acceptance rate in animal face recognition applications.
[0059] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. An animal recognition method based on deep neural network, characterized in that: The following steps are involved: 1) receiving an animal picture submitted by a user, cropping the animal picture submitted by the user, and selecting the facial area of the animal to obtain the animal facial picture; 2) According to the animal facial pictures, the features of the animal are extracted through a feature extraction model; the feature extraction model is a deep convolutional neural network ResNet50, and the feature matching algorithm is a multi-layer perceptron for multi-classification in the training stage, and the loss function is Among them, m is a hyperparameter penalty term, which indicates the size of the distance between classes; s is a hyperparameter, which indicates the radius of the hypersphere; N indicates the number of categories; θ i represents the angle formed by category i at the center of the sphere; The input image of the feature extraction model is a 112*112 three-channel animal face image, which is then downsampled by the deep convolutional neural network ResNet50 to obtain a 7*7 feature map, which is then linearly mapped through the fully connected layer to output a 512-dimensional feature vector, denoted as t; 3) Calculate the Euclidean distance between the feature vector t and the animal features in the animal feature information database, use the KNN algorithm for feature matching, and perform identification; A threshold k of the Hamming distance is set in advance. When the Euclidean distance is less than the threshold k, the recognition is successful. If the distance between all animal features in the animal information feature database and the feature vector t is greater than k, the recognition fails.
2. The animal recognition method based on deep neural network according to claim 1, characterized in that: In the step 1), the improved YOLOv3 model is used to crop the image p and select the facial area of the animal. The preset Anchors in the improved YOLOv3 model are corrected to 10,10; 30,30; 50,50; 70,70; 100,100; 130,130; 180,180; 230,230; 330,330; at the same time, when predicting the Bounding Box, its aspect ratio is limited to 1:
1.
3. The animal recognition method based on deep neural network according to claim 1, characterized in that: The model in step 2) is an improved ResNet50 model, and the model structure is to replace the pooling operation in the native ResNet50 model with a batch normalization operation to avoid overfitting, and modify the native ResNet50 network model structure, use two 3*3 convolutions in a bottleneck, and reduce the number of convolution kernels.
4. The animal identification method based on deep neural network according to claim 1, characterized in that: The training process of the feature extraction model in step 2) is: The feature matching model in the training stage is a multi-layer perceptron. The images input into the training set are first subjected to feature extraction by the improved ResNet50 to obtain a 512-dimensional feature vector. Since the number of individuals in the training set is fixed during the training stage, a multi-layer perceptron is used for multi-classification tasks, and the loss function is used to train the model to achieve parameter updates.
Citation Information
Patent Citations
An animal image search system based on convolutional neural network
AU2019100354A4
Animal identification method, system and device based on neural network, and storage medium
CN112529020A