Face recognition method and system for cattle
Through the improved Res Net trunk network and FACE Net model, combined with specific loss functions, the problem of misunderstanding of risk and low efficiency in the cow -only method is solved. In modern large farms.
Patent Information
- Application Number
- CN202411496302.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-10-25
AI Technical Summary
The existing cattle recognition method has high risk of misidentification, low recognition efficiency, high cost, and has specific requirements for identification equipment and environment. It is no longer suitable for applications in modern large-scale breeding farms.
Using the RES NET main network and FACE Net model based on the residual module improvement, the beef is identified only on the face. Through the combination of multiple convolutional layers, batch returning layers, and residual connections, the complex characteristics of the cattle only face images are effectively extracted, and the accuracy of recognition is improved. At the same time, combined with the ARC Face loss function and the Triplet Loss loss function, the migration and generalization capabilities of the model are enhanced.
Improving the accuracy and efficiency of cattle only facial recognition, reducing the risk and cost of misunderstanding, suitable for the application of modern large farms, accurately identifying the identity information of insured cattle, and refined management of livestock breeding insurance.
Smart Images

Figure CN119380376A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of biometric identification technology, and in particular to a facial recognition method and system for cattle. Background Art
[0002] In recent years, as grassland animal husbandry has developed towards scale, informatization and refinement, my country's animal husbandry industry has gradually strengthened, but the support and guarantee system is still not perfect. To this end, the state vigorously promotes livestock breeding insurance, encourages the construction of livestock and poultry electronic archives, realizes refined management, strengthens technology application, and improves safety regulation capabilities.
[0003] As important livestock, cattle occupy an important position in agricultural production and economic development. In the field of livestock and poultry farming insurance, accurate identification of cattle is crucial. On the one hand, cattle are of high value. Once an accident occurs, the insurance compensation amount is large. Regular identification of insured cattle is intended to prevent cattle from being swapped and avoid risks such as repeated claims and uninsured claims. On the other hand, in the event of natural disasters, diseases and other accidents, quickly determining the identity of the damaged cattle and the actual loss can help insurance companies make timely and reasonable compensation, protect the legitimate rights and interests of farmers, and promote the healthy development of the livestock and poultry farming insurance industry.
[0004] However, in actual insurance, the method of cattle body recognition has become a key difficulty that needs to be solved urgently in the industry. Compared with traditional face recognition, cattle face recognition faces many difficulties. First, the facial features of cattle are relatively inconspicuous. The human face has rich facial features and high recognition, while the cow's face lacks obvious features similar to that of a human, making it difficult to accurately extract and distinguish the recognized feature points. Secondly, the living environment of cattle is more complex and may be covered by food residues, soil, feces, etc., affecting the overall quality of the image and the accuracy of recognition.
[0005] At present, the unique identification methods of cattle mainly include traditional contact identification and non-contact identification based on deep learning algorithms. Traditional identification methods such as ear incision, hot iron branding and ear tagging are not only inefficient, but also harmful to the animal's body and affect animal welfare. Although the electronic ear tag method based on radio frequency identification is convenient and fast, it is still limited by distance and the number of animals, and the worn equipment is also at risk of being lost or damaged.
[0006] The above methods are all inadequate when dealing with the large herds of cattle involved in insurance work. In contrast, contactless identification relies on computer vision technology, deep learning algorithms, and contactless collection equipment. It has the advantages of real-time and high efficiency, providing strong technical support for animal management and research.
[0007] As an important research direction in the field of biometrics in recent years, contactless cattle identification technology has made remarkable progress. The face of a cow, as the most intuitive external feature, is a unique symbol for identifying the identity of the cow.
[0008] In 2005, Kim used associative memory neural network to perform facial recognition of cattle. However, this method would overfit when the amount of data was large, and the accuracy of cattle recognition in complex environments was not stable enough. Subsequently, Cai calibrated the test images based on the method of face recognition through sparse and low-rank decomposition, but this method was not very targeted to the facial features of cattle and was easily interfered by other external factors. Gebar et al. used a classifier to identify the cow head from the WLD features of cattle, and thus proposed the k-NN classifier and Fk-NN classifier, but this method has low computational efficiency when processing large-scale cattle data, and has poor adaptability to dense cattle scenes, and is not suitable for use in the insurance industry.
[0009] In recent years, domestic scholars have also begun to pay attention to the research of cattle recognition technology. Lv Changwei proposed an incremental recognition algorithm framework, which uses convolutional neural networks to achieve real-time recognition of cattle in complex environments. However, the algorithm may not be precise enough for extracting individual features of cattle, and misidentification may occur in some special cases. Weng Zhi et al. combined the dual-branch structure with CNN to effectively reduce the impact of cattle posture changes on recognition accuracy. However, when facing scenes with large changes in lighting, the recognition effect will be affected to a certain extent. Zheng Peng introduced a learnable mask matrix based on the visual converter model and added a patch-shift network layer to effectively reduce the impact of image dirt on recognition effects. However, the model complexity of this method is high, and the cost of training and deployment is high. Wang Feng et al. extracted facial feature images through machine vision, and the recognition accuracy of the SIFT algorithm used was as high as 98.06%. However, SIFT feature calculation and matching requires a lot of calculations, takes a long time, and has high requirements on equipment. It is not suitable for use on platforms with limited computing.
[0010] In summary, the implementation of insurance in the future will rely on contactless, high-precision, and highly automated identification methods. However, existing identification methods have a high risk of misidentification, low identification efficiency, high costs, and specific requirements for identification equipment and environment. They are no longer suitable for application in modern large-scale farms. Summary of the invention
[0011] The present invention solves the problems that the existing cattle identification methods have a high risk of misidentification, low identification efficiency, high cost, specific requirements for identification equipment and environment, and are no longer suitable for application in modern large-scale breeding farms.
[0012] The image target recognition method based on the improved Res Net backbone network of the residual module described in the present invention is specifically as follows:
[0013] The original image goes through the first convolution layer, normalization, the second convolution layer, normalization, and the third convolution layer in sequence;
[0014] The first convolution layer, the second convolution layer, the second convolution layer, and the third convolution layer are connected with residuals;
[0015] After changing the number of the first convolutional layer, the second convolutional layer, and the third convolutional layer, the first convolutional layer, the second convolutional layer, and the third convolutional layer with the changed number are cycled, and the original image after multiple cycle operations is output;
[0016] The original image is added to the original image after multiple cycles of operation to identify the target of the original image.
[0017] Furthermore, in one embodiment of the present invention, the first convolutional layer is a 7×7 convolutional layer, and the second convolutional layer and the third convolutional layer are both 3×3 convolutional layers.
[0018] The method for recognizing image targets based on a convolutional neural network described in the present invention is implemented based on the method for recognizing image targets using a Res Net backbone network improved based on a residual module described in the above method, specifically:
[0019] The image is sequentially input into the convolution layer, pooling layer, Res Net backbone network improved based on residual module, global pooling, flattening and normalization for target recognition;
[0020] It is transformed into a fixed feature vector with a dimension of 32 through normalization.
[0021] The face recognition method for images based on Face Net described in the present invention is implemented based on the method for recognizing image targets based on a convolutional neural network described in the above method, specifically:
[0022] The image is processed by normalization and regularization in turn. The processed image is identified by residual module, global average pooling layer, fully connected layer and convolutional neural network in turn. The loss value of Triplet loss function and Arc face loss function are calculated for the image after feature recognition. Based on the weights of Triplet loss function and Arc face loss function, the loss values of the two are added to obtain the total loss value, and the facial recognition of the image is completed based on the total loss value.
[0023] The fully connected layer controls the embedding vector dimension to 32 dimensions.
[0024] Furthermore, in one embodiment of the present invention, the weight of the Triplet loss function is 0.6, and the weight of the Arc face loss function is 0.4.
[0025] The facial recognition method of an image described in the present invention is implemented based on the facial recognition method for an image based on FaceNet described in the above method, and comprises the following steps:
[0026] Step S1, collecting images, and after preprocessing the images, establishing an image data set, the image data set includes a facial feature data set and a corresponding identity information data set;
[0027] Step S2, performing target detection on the facial feature dataset based on the YOLOv7 model;
[0028] Step S3, based on the face recognition method of Face Net for images, the facial feature data set after target detection is recognized, and while the recognition of the facial feature data set is completed, the identity information data set corresponding to the facial feature data set is displayed.
[0029] The image facial recognition system of the present invention is implemented based on the image facial recognition method described in the above method, and includes the following modules:
[0030] Module S1, after collecting and preprocessing images, establishes an image data set, the image data set includes a facial feature data set and a corresponding identity information data set;
[0031] Module S2, performs target detection on facial feature dataset based on YOLOv7 model;
[0032] Module S3 recognizes the facial feature data set after target detection based on the facial recognition method of Face Net for images, and while completing the recognition of the facial feature data set, displays the identity information data set corresponding to the facial feature data set.
[0033] The facial recognition method for cattle described in the present invention realizes the recognition of cattle's face based on the facial recognition method of the image described in the above method.
[0034] The facial recognition system for cattle described in the present invention realizes the recognition of cattle faces based on the facial recognition system of the image described in the above method.
[0035] The present invention solves the problems that the existing cattle identification methods have a high risk of misidentification, low identification efficiency, high cost, specific requirements for identification equipment and environment, and are no longer suitable for application in modern large-scale farms. Specific beneficial effects include:
[0036] 1. The facial recognition method for cattle described in the present invention has a high risk of misidentification, low recognition efficiency, high cost, and specific requirements for recognition equipment and environment, which are no longer suitable for application in modern large-scale farms. In order to solve the above technical problems, the improved FaceNet model proposed in the present invention can better perform feature extraction and is more suitable for facial structure recognition of cattle. After a combination of multiple convolutional layers, batch normalization layers, and residual connections, it can effectively extract complex features in cattle facial images, from low-level texture and color features to high-level semantic features, improve recognition accuracy, enhance model performance and generalization ability, accurately identify the identity information of insurance cattle, distinguish the individual identities of cattle, and use it for livestock breeding insurance to help achieve refined management of farms;
[0037] 2. The image target recognition method based on the improved Res Net backbone network of the present invention integrates the residual module into the original backbone network Res Net, effectively alleviates the gradient vanishing problem, enables the gradient to propagate forward better, enhances the model training effect, and improves the model training efficiency;
[0038] 3. The face recognition method based on Face Net for images described in the present invention divides the Arc face loss function and the Tripletloss loss function according to a weight ratio of 4:6, which can retain the advantages of the two loss functions at the same time and improve the transferability and generalization ability of the model;
[0039] 4. The face recognition method for images based on Face Net described in the present invention modifies the dimension of the embedding vector from 128 in the previous model to 32. Considering that the embedding vector with a lower dimension is easier to visualize and explain, the 32-dimensional embedding vector is more suitable for cattle facial recognition, providing a strong technical support for cattle management and identification;
[0040] At the same time, the cattle facial recognition system of the present invention can display relevant electronic file information according to the identity information data set after identifying the identity of the individual cattle. After the whole system is mounted on the JETSON NANO development board, the development board is connected to the camera for data collection. By taking advantage of its high-speed operation, target detection and identity recognition comparison can be quickly completed, and a large amount of data information can be recorded and saved, which can greatly improve the work efficiency of the insurance industry and reduce human resources and work costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0042] Figure 1 is a diagram of a facial recognition system for cattle according to Embodiment 7;
[0043] Figure 2 It is the YOLOv7 model network structure diagram described in Implementation Mode 4;
[0044] Figure 3 is a flowchart of the Face Net algorithm described in the second implementation mode;
[0045] Figure 4 It is the original Res Net backbone network structure diagram described in Implementation Mode 1;
[0046] Figure 5 This is a structural diagram of the residual module described in Implementation Method 1. DETAILED DESCRIPTION
[0047] The following will clearly and completely describe various embodiments of the present invention in conjunction with the accompanying drawings. The embodiments described with reference to the accompanying drawings are exemplary and intended to be used to explain the present invention, but should not be understood as limiting the present invention.
[0048] Implementation method 1: The image target recognition method based on the improved Res Net backbone network based on the residual module described in this implementation method is specifically as follows:
[0049] The original image goes through the first convolution layer, normalization, the second convolution layer, normalization, and the third convolution layer in sequence;
[0050] The first convolution layer, the second convolution layer, the second convolution layer, and the third convolution layer are connected with residuals;
[0051] After changing the number of the first convolutional layer, the second convolutional layer, and the third convolutional layer, the first convolutional layer, the second convolutional layer, and the third convolutional layer with the changed number are cycled, and the original image after multiple cycle operations is output;
[0052] The original image is added to the original image after multiple cycles of operation to identify the target of the original image.
[0053] In this implementation, the first convolution layer is a 7×7 convolution layer, and the second convolution layer and the third convolution layer are both 3×3 convolution layers.
[0054] In this embodiment, the image input is based on the Res Net backbone network improved by the residual module to identify the target. The basic structure of the Res Net backbone network improved by the residual module is:
[0055] y=F(x)+x;
[0056] Among them, x is the input, F(x) is the residual map obtained through a series of operations such as convolution, and y is the output. The feature extraction of the input x is performed through the convolution operation to obtain the intermediate result r, and then a series of convolution and batch normalization operations are performed on r to obtain the residual map F(x) of x. The original input x and the residual map F(x) are further added to obtain the output. This structure allows the network to directly learn the residual between the input and output, rather than directly learning the target output. In this way, even if the number of network layers continues to increase, the residual module can ensure the effective flow of information and the stable back propagation of the gradient. The residual module also makes it easier for the network to learn simple mapping relationships such as identity mapping, improving the performance and generalization ability of the network.
[0057] like Figure 5 As shown, the original Res Net backbone network structure is as follows Figure 4 As shown in FIG. 1 , the improved Res Net backbone network based on the residual module is specifically:
[0058] Based on the residual learning principle, this implementation method performs a cyclic operation on the number of different convolutional layers [16, 32, 64, 128, 512] of the Res Net backbone network. When the number of the first convolutional layer, the second convolutional layer and the third convolutional layer is 16, the original image first passes through a first convolutional layer with a stride of 7x7, then performs batch normalization, and then connects a 3x3 convolutional layer with a stride of, then performs batch normalization, and finally connects a 3x3 convolutional layer with a stride of. The first convolution layer with a stride of 7x7, the second convolution layer with a stride of 3x3, the second convolution layer with a stride of 3x3, and the third convolution layer with a stride of 3x3 are connected by the Add() function. When the number of the first convolution layer, the second convolution layer, and the third convolution layer is changed to 32, the above operation is repeated until the number of the first convolution layer, the second convolution layer, and the third convolution layer is changed to 512. Then the above operation is terminated and the original image is added to the original image after multiple convolution processes to form a residual module.
[0059] The improved Res Net backbone network based on the residual module in this implementation helps alleviate the gradient vanishing problem, allowing the gradient to be propagated more directly to the previous layer, improving the training effect of the network. At the same time, it allows the network to learn the residual mapping between input and output, enhances the feature learning ability, can better capture the details and patterns in facial images, improves the recognition accuracy, enhances the nonlinear expression ability of the model, and avoids the gradient vanishing and performance degradation problems that occur as the network depth increases.
[0060] Implementation method 2: The method for identifying image targets based on a convolutional neural network described in this implementation method is implemented based on the method for identifying image targets based on the improved Res Net backbone network based on the residual module described in implementation method 1, specifically:
[0061] The image is sequentially input into the convolution layer, pooling layer, Res Net backbone network improved based on residual module, global pooling, flattening and normalization for target recognition;
[0062] It is transformed into a fixed feature vector with a dimension of 32 through normalization.
[0063] In this embodiment, the input of the convolutional neural network is the image data x of (224, 224, 3). input , the initial convolution and pooling layer is Conv&Pool, the deep convolution and residual connection described in Implementation 1 is Deep Conv&Res, the global pooling and flattening is Global Pool&Flat, and the output is a normalized feature vector x with a dimension of 32 output .
[0064] First, through Conv&Pool, x input =BatchNormalization()(x input );
[0065] x input =MaxPooling2D((3,3))(x input );
[0066] Using Deep Conv&Res, the feature map is repeatedly convolved and normalized for 3 times to alleviate the gradient vanishing problem.
[0067] Secondly, through Global Pool & Flat, x = GlobalAveragePooling2D()(x);
[0068] x = Flatten()(x);
[0069] The final output embedding vector dimension is a normalized feature vector of 32:
[0070] x output =Dense(32)(x output );
[0071] outputs = Lambda(lambda x output :tf.nn.12-normalize(x output ,axis=-1))(x output ).
[0072] Therefore, the image passes through the initial convolution and pooling layers in turn, using 16 7x7 filters with a step size of 2x2 to perform convolution operations on the input image, and using the ReLU activation function to extract preliminary feature vector information from the input image. By batch normalizing the output of the convolution layer, model training is accelerated and stability and generalization capabilities are improved. The initial pooling layer further performs a maximum pooling operation with a window size of 3x3, selecting the maximum value in each pooling window as the output, reducing the spatial size of the feature map and the number of parameters, while retaining the main feature information. Improve the computational efficiency of the model and the translation invariance of the image, provide a more abstract and representative feature vector representation for subsequent network layers, and lay the foundation for the model to accurately perform tasks such as image classification.
[0073] Implementation method 3: The facial recognition method for images based on Face Net described in this implementation method is implemented based on the method for recognizing image targets based on a convolutional neural network described in implementation method 2, specifically:
[0074] The image is processed by normalization and regularization in turn. The processed image is identified by residual module, global average pooling layer, fully connected layer and convolutional neural network in turn. The loss value of Triplet loss function and Arc face loss function are calculated for the image after feature recognition. Based on the weights of Triplet loss function and Arc face loss function, the loss values of the two are added to obtain the total loss value, and the facial recognition of the image is completed based on the total loss value.
[0075] The fully connected layer controls the embedding vector dimension to 32 dimensions.
[0076] In this implementation, the weight of the Triplet loss function is 0.6, and the weight of the Arc face loss function is 0.4.
[0077] In this embodiment, if Figure 3 As shown, the facial recognition method for images based on Face Net is specifically as follows:
[0078] First, the data set after target detection is trimmed through the input layer and unified into (224, 224, 3), which means that the size of the input image is 224x224 pixels and has three color channels.
[0079] Then, the input of each layer is normalized and regularized. The Dropout layer randomly sets the output of some neurons to 0 during training to reduce the co-adaptation between neurons, making the model more stable during training, accelerating convergence, and reducing the risk of overfitting. L2 normalization normalizes the length of the vector to 1, making the features between different samples comparable, improving the stability and convergence speed of the model, and its calculation formula is:
[0080]
[0081] in, is an n-dimensional vector, (v1,v2,…,v n ) are the component values of this vector in each dimension, Represents the length of the vector, that is, the L2 norm, v i is the original vector The component value in the i-th dimension, u i It is the component value of the new vector in the i-th dimension after L2 normalization.
[0082] Afterwards, the image is sequentially passed through a feature embedding module and the convolutional neural network described in Implementation Method 2 to identify features. The feature embedding module includes a residual module, a global average pooling layer, and a fully connected layer. The fully connected layer adjusts weights and biases, combines and abstracts the extracted feature vectors, and learns the complex relationship between input features and output categories or embeddings to adapt to specific task requirements.
[0083] The formula for the fully connected layer is:
[0084] y=Wx+b;
[0085] Where x is the input of the fully connected layer, W is the weight matrix, and b is the bias vector.
[0086] This implementation controls the embedding vector dimension to 32 dimensions through a fully connected layer. Compared with the previous 128-dimensional embedding vector, the 32-dimensional vector requires less computing resources and time during training and inference. In terms of model performance, although the reduction in dimensionality may lead to a certain amount of information loss, it also reduces the risk of overfitting and improves the generalization ability of the model. In terms of visualization and interpretability, 32-dimensional vectors are easier to visualize and analyze, can better understand the relationship and feature changes between different categories, and are more suitable for facial feature recognition. The output of the fully connected layer passes through the Lambda layer to ensure the standardization of the output vector in the spatial direction, making the output of the model more stable and comparable.
[0087] The global average pooling layer compresses the feature map processed by the previous complex convolution and residual modules in the spatial dimension, calculates the element average of each feature image, and converts each feature map into a single value, effectively reducing the number of parameters and avoiding overfitting, making the model robust to spatial changes in the input image. The feature embedding modules work together to gradually transform the features of the input image into the final classification results and outputs of specific tasks.
[0088] Finally, after the feature vector is obtained through the convolutional neural network, because each feature block contains information between itself and other feature blocks, in order to improve the discrimination, this implementation combines the Arcface loss function and the Tripletloss loss function to form a new loss function to guide network training.
[0089] The Arc face loss function is mainly used for face recognition. It focuses on learning discriminative angle margins and highly discriminative feature embeddings. It can distinguish features well, making samples of the same category more compact in the feature space and samples of different categories more separated. The Arc face loss function adds angle intervals to the traditional loss function. Its calculation formula is as follows:
[0090] Assume that the input feature vector is x, the weight vector is W, and the category label is y;
[0091]
[0092] Among them, θ yj is the eigenvector x j With the weight vector W y The angle between them, s is the scaling factor, and m is the angle interval penalty term. By introducing the angle interval m, the features that the model can learn are more discriminative in the angle space.
[0093] The Triplet loss function is mainly used to learn the relative relationship between samples, constrain the similarity and dissimilarity between sample triplets, and make the distance between the anchor sample and the positive sample as small as possible, and the distance between the anchor sample and the negative sample as large as possible. This ensures that the model can be effectively trained when the number of samples is limited, and has a certain degree of robustness to noise and changes, which can improve the accuracy and stability of the model in recognition and classification tasks.
[0094] The calculation formula is:
[0095]
[0096] Where N is the number of training samples, a i is the anchor point sample, p i is a positive sample, n iis a negative sample, d represents the Euclidean distance between samples, and α is a boundary value used to control the distance interval between positive and negative samples.
[0097] This implementation calculates the losses of the Triplet loss function and the Arc face loss function respectively, and then performs a weighted sum according to the weight of 6:4. The new loss function can make full use of the respective advantages of the two loss functions. The former focuses on the relative relationship between samples and can learn more discriminative feature representations, while the latter enhances the discriminability of features through angle intervals, making samples of the same category more compact. Mixed use can enhance the model's ability to learn highly discriminative features, improve recognition performance, increase the model's adaptability to various situations, and improve the model's robustness.
[0098] Embodiment 4: The facial recognition method for an image described in this embodiment is implemented based on the facial recognition method for an image based on Face Net described in embodiment 3, and includes the following steps:
[0099] Step S1, collecting images, and after preprocessing the images, establishing an image data set, the image data set includes a facial feature data set and a corresponding identity information data set;
[0100] Step S2, performing target detection on the facial feature dataset based on the YOLOv7 model;
[0101] Step S3, based on the face recognition method of Face Net for images, the facial feature data set after target detection is recognized, and while the recognition of the facial feature data set is completed, the identity information data set corresponding to the facial feature data set is displayed.
[0102] Based on the facial recognition of the image, this embodiment designs a facial recognition method of the image, including the following steps:
[0103] Step S1, data collection:
[0104] 1. To improve the robustness of the training model, multi-angle transformation is required during video shooting to ensure the diversity of the image data background and the angle differences between faces. At the same time, two time periods with obvious lighting differences in a day are selected for shooting to ensure the lighting changes of the collected video.
[0105] 2. Shoot two videos, one from the front and the other from an upward angle, to ensure that data videos of facial features are obtained from different angles.
[0106] Step S2, data preprocessing:
[0107] 1. Extract one frame every 20 frames of the collected video to obtain the initial feature information image;
[0108] 2. In order to obtain a dataset with rich facial features, it is necessary to ensure that there are large differences between key frame images. This implementation uses SSIM to clean the images and gives similarity indicators by comparing the brightness, contrast and structure between the images to measure the similarity of the images. Excluding similar images can improve the generalization ability and transferability of the model, making the model more suitable for the application of this dataset.
[0109] Assuming that the two images to be compared for similarity are x and y, the calculation formula for their SSIM values is:
[0110] SSIM(x,y)=[l(x,y)] α [c(x,y)] β [s(x,y)] γ α>0,β>0,γ>0;
[0111] The above formula is the definition of SSIM, where the expressions of l, c, and y functions are as follows:
[0112]
[0113] Among them, l(x,y) is brightness comparison, c(x,y) is contrast comparison, s(x,y) is structure comparison, μ x and μ y Represent the average values of x and y, σ x and σ y Represent the standard deviation of x and y, σ xy represents the covariance of x and y, c1, c2, c3 are constants respectively, to avoid calculation errors caused by denominator being 0. In actual engineering calculations, α=β=γ=1, c3=c2 / 2 are generally taken. In order to simplify the calculation steps, SSIM can be simplified as:
[0114]
[0115] Step S3, establishment of data set:
[0116] 1. Use the labellmg annotation tool to annotate the data of the images after removing duplicate features. Select the annotation format as PASCAL VOC and generate an annotation file in XML format. The file contains information such as image name, size, coordinates of the annotation rectangle, target category, degree of occlusion, and difficulty of identification.
[0117] 2. Divide the preprocessed images into a data set according to 8:1:1, where 80% is used as training set data, 10% is used as test set data, and 10% is used as validation data set;
[0118] 3. In order to enhance the generalization ability of the model for individual recognition, five image enhancement methods are used to expand the data set, including flipping the image, changing the color contrast, changing the color intensity, and changing the brightness;
[0119] 4. The facial feature data is thus established;
[0120] 5. In order to display the electronic information file of the image, this implementation method also needs to establish an identity information data set. It is necessary to count the information of each image, such as age, weight, gender, etc., and place the image data and the corresponding label data in different folders respectively, and then place the two folders in the same path.
[0121] Step S4, target detection:
[0122] This implementation uses the YOLOv7 model to complete the face detection task. The model consists of three core modules: the backbone network, the neck network, and the head network. Its network structure is as follows: Figure 2 shown.
[0123] 1. Through the powerful feature extraction network, multi-scale detection and anchor box clustering technology of the YOLOv7 model, target detection is performed to facilitate subsequent feature extraction. The backbone integrates CBS, MP-1 and ELAN modules, and with the help of auxiliary head training and corresponding positive and negative sample matching strategies, it can achieve accurate capture of image features, accurate classification of target categories and reliable evaluation of confidence.
[0124] CBS module: This module usually contains convolution, batch normalization and activation function operations. The convolution operation is:
[0125] Y = W*X+b;
[0126] Among them, Y is the output feature map, W is the convolution kernel, X is the input feature map, and b is the bias term.
[0127] Batch normalization helps stabilize the training process and improve the generalization ability of the model. Its formula is:
[0128]
[0129] Where x is the input data, μ is the mean, σ is the standard deviation, and ∈ is a small constant.
[0130] MP-1 module: This module represents the maximum pooling operation, which reduces the spatial resolution of the feature map by selecting the maximum value of the local area, thereby reducing the amount of calculation and extracting the main features. Its formula is:
[0131]
[0132] Among them, Y i,jis the value of the output feature map at position (i, j), R i,j It is the local area corresponding to the input feature map.
[0133] ELAN module: This module effectively improves the accuracy and speed of target detection by expanding and connecting features at different levels, thereby fusing multi-scale information.
[0134] 2. Use FPN and PAN structures to achieve effective combination of semantic information and spatial information at different levels. FPN transfers high-level semantic information to low-level layers to enhance the semantic expression of low-level features, while PAN transfers low-level spatial information to high-level layers to improve the positioning accuracy of high-level features.
[0135] 3. Adopt anchor frame clustering technology to adaptively adjust the size and proportion of anchor frames to adapt to the diversity of different facial features. The size and proportion of anchor frames are optimized by calculating the Euclidean distance from the sample to the cluster center. The calculation formula is:
[0136]
[0137] Among them, x and y are sample points, and n is the feature dimension.
[0138] 4. Use the feature extraction network containing the SPPCS module to enhance the expression ability of the convolutional neural network on detailed features. Through a series of convolution, pooling and splicing operations, richer feature information can be extracted.
[0139] 5. Finally, the CAT and RAP modules are used to enhance the robustness of the model to facial features under different lighting, angles and occlusion conditions. The CAT module concatenates different feature maps, and the RAP module highlights important areas by calculating attention weights.
[0140] The calculation formula of attention weight is:
[0141] ω=σ(f(X));
[0142] Among them, X is the input feature, f is a function, σ is the activation function, and ω is the attention weight.
[0143] 6. Use the detected images as a new facial feature dataset for the subsequent recognition model.
[0144] Step S5, design an improved facial recognition model based on Face Net:
[0145] The improved Face Net facial recognition model described in Implementation Example 3 used in this implementation example can utilize the powerful feature extraction capability of deep learning and maintain a high recognition accuracy rate even in complex breeding environments.
[0146] Embodiment 5: Image facial recognition system, the system is implemented based on the image facial recognition method described in embodiment 4, and includes the following modules:
[0147] Module S1, after collecting and preprocessing images, establishes an image data set, the image data set includes a facial feature data set and a corresponding identity information data set;
[0148] Module S2, performs target detection on facial feature dataset based on YOLOv7 model;
[0149] Module S3 recognizes the facial feature data set after target detection based on the facial recognition method of Face Net for images, and while completing the recognition of the facial feature data set, displays the identity information data set corresponding to the facial feature data set.
[0150] In this embodiment, the overall system is assembled as follows:
[0151] Deploy the trained model on the edge device JETSON NANO.
[0152] The facial recognition system can create a separate identity information file for each image, enabling precise management of individuals. In breeding insurance, this implementation method can ensure the accuracy and fairness of insurance claims and avoid insurance fraud. At the same time, it can improve management efficiency, reduce labor costs, and promote the development of the livestock breeding industry towards modernization and intelligence.
[0153] Embodiment 6: The facial recognition method for cattle described in this embodiment is based on the facial recognition method for images described in embodiment 5 to realize the recognition of cattle faces.
[0154] Existing identification methods have a high risk of misidentification, low identification efficiency, high costs, and specific requirements for identification equipment and environment. They are no longer suitable for application in modern large-scale farms.
[0155] In order to solve the above technical problems, this embodiment designs a facial recognition method for cattle, which provides strong technical support for the fields of animal husbandry insurance, etc., including the following steps:
[0156] Step S1, data collection:
[0157] Videos of the facial features of cattle on the farm were recorded using data collection equipment;
[0158] All experimental images in this embodiment were collected at Jiutai Cattle Breeding Co., Ltd. in Baicheng City, Jilin Province, China. During the shooting, the camera was fixed on a tripod about 1 meter away from the cows, and video recording was performed on Holstein cows and Simmental cows in actual breeding scenes. The recording time was about 20 seconds.
[0159] After shooting, the video files are named in the order of "cow1". To ensure the efficiency of data collection, the original data are all in MP4 video format, the frame rate of the video sequence is 30fps, and the resolution is 1920x1080 pixels.
[0160] Step S2, data preprocessing:
[0161] In order to obtain a dataset with rich facial features, it is necessary to ensure that there are large differences between key frame images. This implementation uses SSIM to clean the images and gives similarity indicators by comparing the brightness, contrast and structure between the images to measure the degree of image similarity. The SSIM similarity threshold is set to 0.5, and the adjacent image data of each cow are compared pairwise. Finally, 3152 images of 106 cows are obtained for data model training and verification.
[0162] Step S3, establishing a data set;
[0163] The data set should include two parts: one is the facial feature information of the cow, which is used for model training and recognition comparison; the other is the identity information of the cow, such as the breed, age, health status, etc.
[0164] The specific steps for making the facial feature dataset are as follows:
[0165] 1. Use the labellmg annotation tool to annotate the images preprocessed in step 2;
[0166] 2. Divide the preprocessed images into a data set according to 8:1:1, with 80% as training set data, 10% as test set data, and 10% as validation data set;
[0167] 3. Use five image enhancement methods such as flipping images, changing color contrast, changing color intensity, and modifying brightness to expand the data set and enhance the model's generalization ability for individual recognition.
[0168] Step S4, preliminary target detection:
[0169] The design of the YOLOv7 model consists of three core modules: the backbone network, the neck network, and the head network. The specific method of using this model to detect individual feature targets is as follows:
[0170] 1. Improve the accuracy and speed of target detection through CBS, MP-1 and ELAN modules in the backbone network;
[0171] 2. Using multi-scale feature fusion technology, through FPN and PAN structures, semantic information and spatial information at different levels are effectively combined;
[0172] 3. Adopt anchor frame clustering technology to adaptively adjust the size and proportion of anchor frames to adapt to the diversity of facial features of different cattle;
[0173] 4. Use the feature extraction network containing the SPPCS module to enhance the expression ability of the convolutional neural network in detail features, providing richer and more accurate feature information for subsequent facial feature recognition;
[0174] 5. Finally, the CAT and RAP modules are used to enhance the robustness of the model to the facial features of cattle under different lighting, angles and occlusion conditions.
[0175] Step S5, design an improved cattle facial recognition model based on Face Net:
[0176] 1. Receive cow facial image data through the image input module and convert it into a format that the model can process. Ensure that the image size is uniform (224,224,3) and the color channels meet the requirements of the model to ensure that the model can process image data from different sources.
[0177] 2. Using a deep convolutional neural network, through the operation of multiple convolution kernels and pooling layers, the feature vectors of the cow's facial images are automatically extracted, and the cow's face is recognized based on the Arc Face loss function and the Tripletloss loss function.
[0178] In summary, this implementation is based on a deep learning algorithm, and the improved Face Net model has stronger recognition performance and generalization ability. By simplifying the algorithm steps, it can improve recognition efficiency while ensuring recognition accuracy, making it more suitable for use in the insurance industry.
[0179] Embodiment 7: A facial recognition system for cattle, wherein the system is based on the facial recognition system for images described in embodiment 5 to realize the recognition of cattle's faces.
[0180] In this embodiment, if Figure 1 As shown, the aim is to design a facial recognition system for cattle and establish personalized electronic files for livestock. When applying livestock breeding insurance, the target cattle can be quickly identified and the electronic files of the target cattle can be displayed simultaneously, which will effectively promote the scientific and technological development, scale and quality improvement of my country's breeding farms.
[0181] Overall system assembly:
[0182] 1. Connect the camera, TF card, HDMI cable, etc. to the JETSON NANO development board and deploy the required environment;
[0183] 2. Save the data set to the cloud for easy access at any time;
[0184] 3. Use the camera on the JETSON NANO development board to obtain real-time image information, detect the facial features of the target cattle, and compare them with the cloud data.
[0185] This embodiment is aimed at the facial recognition system of cattle, and simultaneously displays the personalized electronic files of livestock. Compared with the current mainstream insurance identification method, it can greatly improve efficiency, reduce costs and manpower, and also illustrates the effectiveness of the method proposed in this embodiment.
[0186] The above is a detailed introduction to the cattle facial recognition method and system proposed in the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. The image target recognition method based on the improved Res Net backbone network of the residual module is characterized by: Specifically: The original image goes through the first convolution layer, normalization, the second convolution layer, normalization, and the third convolution layer in sequence; The first convolution layer, the second convolution layer, the second convolution layer, and the third convolution layer are connected with residuals; After changing the number of the first convolutional layer, the second convolutional layer, and the third convolutional layer, the first convolutional layer, the second convolutional layer, and the third convolutional layer with the changed number are cycled, and the original image after multiple cycle operations is output; The original image is added to the original image after multiple cycles of operation to identify the target of the original image.
2. According to claim 1, the image target recognition method based on the improved Res Net backbone network based on the residual module is characterized in that: The first convolution layer is a 7×7 convolution layer, and the second convolution layer and the third convolution layer are both 3×3 convolution layers.
3. A method for identifying image targets based on a convolutional neural network, wherein the method is implemented based on the method for identifying image targets using a Res Net backbone network improved based on a residual module as described in any one of claims 1-2, and is characterized in that: Specifically: The image is sequentially input into the convolution layer, pooling layer, Res Net backbone network improved based on residual module, global pooling, flattening and normalization for target recognition; It is transformed into a fixed feature vector with a dimension of 32 through normalization.
4. A facial recognition method for an image based on Face Net, wherein the method is implemented based on the method for recognizing an image target based on a convolutional neural network as claimed in claim 3, and is characterized in that: Specifically: The image is processed by normalization and regularization in turn. The processed image is identified by residual module, global average pooling layer, fully connected layer and convolutional neural network in turn. The loss value of Triplet loss function and Arc face loss function are calculated for the image after feature recognition. Based on the weights of Triplet loss function and Arc face loss function, the loss values of the two are added to obtain the total loss value, and the facial recognition of the image is completed based on the total loss value. The fully connected layer controls the embedding vector dimension to 32 dimensions.
5. The method for facial recognition of images based on Face Net according to claim 4, characterized in that: The weight of the Triplet loss function is 0.6, and the weight of the Arc face loss function is 0.
4.
6. A method for facial recognition of an image, wherein the method is implemented based on the method for facial recognition of an image based on Face Net as described in any one of claims 4-5, and is characterized in that: The following steps are involved: Step S1, collecting images, and after preprocessing the images, establishing an image data set, the image data set includes a facial feature data set and a corresponding identity information data set; Step S2, performing target detection on the facial feature dataset based on the YOLOv7 model; Step S3, based on the face recognition method of Face Net for images, the facial feature data set after target detection is recognized, and while the recognition of the facial feature data set is completed, the identity information data set corresponding to the facial feature data set is displayed.
7. An image facial recognition system, wherein the system is implemented based on the image facial recognition method according to claim 6, and is characterized in that: Includes the following modules: Module S1, after collecting and preprocessing images, establishes an image data set, the image data set includes a facial feature data set and a corresponding identity information data set; Module S2, performs target detection on facial feature dataset based on YOLOv7 model; Module S3 recognizes the facial feature data set after target detection based on the facial recognition method of Face Net for images, and while completing the recognition of the facial feature data set, displays the identity information data set corresponding to the facial feature data set.
8. A method for facial recognition of cattle, characterized in that: The method described is to realize the recognition of cattle faces based on the facial recognition method of the image described in claim 6.
9. A facial recognition system for cattle, characterized in that: The system is a facial recognition system based on the image described in claim 7 to realize the recognition of cattle faces.
Citation Information
Patent Citations
Classification model training method, image processing method and device
CN111242222A
Face recognition network model construction method combined with gender attribute training
CN111339931A
Improved residual network pig face recognition method
CN111666838A
Cow face identity recognition feature extraction model construction method and cow face identity recognition method
CN115311689A
Intelligent dairy cow identity recognition method and system
CN117475479A