Method and computing device for cattle identity authentication
Through deep learning algorithms and image processing technology, the identity authentication of cattle is realized, solving the problems of high cost and invasiveness of traditional methods, improving the authentication efficiency and ease of use, and reducing the use of consumables.
Patent Information
- Application Number
- CN202411534028.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-12-26
- Filing Date
- 2024-10-30
- Publication Date
- 2025-04-01
AI Technical Summary
Traditional cattle identity identification methods are costly, highly invasive, affect animal behavior and may cause health risks, making it difficult to achieve efficient and low-cost cattle identity authentication.
Deep learning algorithms and image processing technology are used to obtain cow face images, and use cow face detection model, orientation detection model and cow face feature extractor to perform cow face segmentation, facial orientation recognition and feature extraction, calculate the similarity of feature vectors, and realize the identity authentication of cows.
It reduces the cost of identity authentication of cattle, improves authentication efficiency, reduces the use of consumables, improves the ease of use of the system, and does not pose health risks to animals.
Smart Images

Figure CN119741728A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of artificial intelligence technology and animal husbandry information technology, and in particular to a method and computing equipment for cattle identity authentication. Background Art
[0002] With the progress of society and the continuous expansion of cattle breeding, traditional breeding methods are difficult to scientifically and effectively care for and manage cattle. In large-scale cattle farms, in order to achieve automated and information-based daily refined management of individual cattle, track the health status of each cow, and trace the source of milk and meat products, it is necessary to build and improve the quality traceability system, and the key lies in the identification of individual cattle. Traditional cattle individual identification requires the use of external tools to mark a certain part of the body or wear a marking device. The identification method is invasive, which not only seriously affects daily behavior, but also may cause hidden dangers.
[0003] Therefore, a technical solution is needed that can reduce the cost of cattle identity authentication and increase the efficiency of authentication. Summary of the invention
[0004] The present invention aims to provide a method and computing equipment for cattle identity authentication, which can reduce cattle identity authentication costs, increase authentication efficiency, reduce consumables, and improve usability.
[0005] According to one aspect of the present invention, there is provided a method for cattle identity authentication, comprising:
[0006] Obtain the cow face image to be authenticated;
[0007] Inputting the cow face image to be authenticated into a cow face detection model for detection, and segmenting the cow face in the image from the background as a first cow face image;
[0008] Inputting the first cow face image into an orientation detection model to identify the facial orientation category of the cow face in the first cow face image, wherein the orientation detection model is a pre-trained neural network model;
[0009] Inputting the first cow face image into a pre-trained cow face feature extractor to obtain a feature vector of the first cow face image;
[0010] The similarity between the feature vector of the first cow face image and the cow face feature vector of the same orientation category in a pre-established cow face feature database is calculated, and the cow corresponding to the feature vector with the highest similarity is determined as the cow to be authenticated.
[0011] According to some embodiments, obtaining a cow face image to be authenticated includes:
[0012] Capture videos of the cow's face, including the front, left, and right faces of the cow;
[0013] The video is frame extracted to form image data.
[0014] According to some embodiments, inputting the cow face image to be authenticated into a cow face detection model for detection includes:
[0015] The image quality of the cow face image to be authenticated is detected, and an image with qualified quality is taken to perform a cow face segmentation background operation.
[0016] According to some embodiments, identifying the facial orientation category of the cow face in the first cow face image includes:
[0017] Identify whether the cow face in the first cow face image is a front face, a left face, or a right face.
[0018] According to some embodiments, inputting the first cow face image into a pre-trained cow face feature extractor to obtain a feature vector of the first cow face image includes:
[0019] A pre-trained cow face classification model is used to obtain a feature vector of the cow face in the first cow face image.
[0020] According to some embodiments, the cow face classification model is trained using an existing cow face dataset, and the cow face classification model is transformed into a cow face feature extractor, wherein the cow face dataset includes a front face, a left face, and a right face dataset;
[0021] The front face image, left face image and right face image of the target cow are input into the cow face feature extractor to obtain the cow face feature vector corresponding to each cow and store it in the cow face feature database.
[0022] According to some embodiments, a cow face feature database is pre-established:
[0023] Collect cow face images of all cows in the predetermined herd, including the front face, left face and right face of the cow;
[0024] Inputting the cow face image into a cow face detection model, performing a cow face and background segmentation operation, and obtaining a cow face image;
[0025] Inputting the cow face image into an orientation detection model to identify the cow face facial orientation category in the cow face image;
[0026] The cow face image is input into a corresponding cow face feature extractor to obtain a cow face feature vector and mark the orientation category, and store it in the cow face feature database.
[0027] According to some embodiments, calculating the similarity between the feature vector of the first cow face image and the cow face feature vector of the same category in a pre-established cow face feature database includes:
[0028] The cosine similarity measurement algorithm is used to calculate the similarity between the cow face feature vector to be authenticated and the cow face feature vector of the same category in the cow face feature database.
[0029] According to some embodiments, calculating the similarity between the feature vector of the first cow face image and the cow face feature vector of the same orientation category in a pre-established cow face feature database, and determining that the cow corresponding to the feature vector with the highest similarity is the cow to be authenticated includes:
[0030] Acquire multiple cow face images to be authenticated, determine the facial orientation categories of the multiple cow face images to be authenticated, and calculate multiple corresponding feature vectors;
[0031] Calculating the similarity between the plurality of feature vectors and the cow face feature vectors of the same orientation category in a pre-established cow face feature database according to the facial orientation;
[0032] The cattle corresponding to the feature vector with the highest similarity is determined as the cattle to be authenticated.
[0033] According to another aspect of the present invention, there is provided a computing device, comprising:
[0034] Processor; and
[0035] A memory storing a computer program, which, when executed by the processor, enables the processor to execute any of the methods described above.
[0036] According to another aspect of the present invention, there is provided a non-transitory computer-readable storage medium having computer-readable instructions stored thereon, and when the instructions are executed by a processor, the processor is caused to execute any of the above methods.
[0037] According to an embodiment of the present invention, by detecting cow face images, cow faces are classified according to facial orientation, a cow face feature extractor is used to extract cow face feature vectors, and similarity calculation is performed with cow faces in a pre-established cow face feature database to achieve cow authentication. The present invention can improve the efficiency of cow authentication, which is different from the prior art of using ear tags for authentication. Cow face recognition can be performed by only taking a video of the cow. Video shooting of the cow face is convenient and will not disturb the cow excessively, and is more user-friendly.
[0038] According to some embodiments, in terms of cost, ear tags are no longer used for cattle identity authentication, which saves a large amount of ear tag costs caused by constant damage or loss of ear tags, saves the steps of manual ear tagging and disinfection of cattle, and saves the cost of medicines for disinfecting cattle ears, effectively achieving cost reduction, reducing consumables, and being more environmentally friendly.
[0039] According to some embodiments, different cattle identity authentication strategies are adopted according to the number of cattle face photos of the target cattle that can be obtained, so as to meet the requirements of different scenarios at the same time. In addition, the cattle face is divided into three parts: the front face, the left face and the right face, and the similarity is calculated respectively, and the highest similarity is taken. The recognition accuracy of the cattle face is higher than the mixed recognition accuracy.
[0040] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for describing the embodiments are briefly introduced below.
[0042] Figure 1 A flow chart showing a method of cattle identity authentication according to an example embodiment.
[0043] Figure 2 A flow chart of a method for extracting cow face features according to an example embodiment is shown.
[0044] Figure 3 A flow chart of a method for establishing a cow face feature database according to an example embodiment is shown.
[0045] Figure 4 A flow chart showing a method of cattle image acquisition, processing and authentication according to an example embodiment.
[0046] Figure 5 A schematic diagram showing classification storage of cow faces according to an example embodiment.
[0047] Figure 6 A block diagram of a computing device is shown according to an exemplary embodiment. DETAILED DESCRIPTION
[0048] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that the present invention will be comprehensive and complete and fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0049] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.
[0050] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0051] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0052] It should be understood that although the terms first, second, third, etc. may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another component. Therefore, the first component discussed below can be referred to as the second component without departing from the teachings of the present inventive concept. As used herein, the term "and / or" includes any one of the associated listed items and all combinations of one or more.
[0053] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0054] Those skilled in the art will appreciate that the drawings are merely schematic diagrams of example embodiments, and the modules or processes in the drawings are not necessarily necessary for implementing the present invention, and therefore cannot be used to limit the protection scope of the present invention.
[0055] With population growth, accelerated urbanization, climate change, and higher requirements for food quality and safety standards, traditional farming methods face many challenges. Traditional cattle identification methods usually rely on physical tags, such as ear tags, collars or foot rings, which contain specific identifiers such as barcodes or RFID tags. These methods improve identification efficiency to a certain extent, but may cause discomfort to animals and require human intervention to read and interpret the data.
[0056] Cattle identification technology is an agricultural application technology that has emerged in recent years with the development of computer vision and machine learning. It is mainly used for livestock management, including tracking the health status, reproduction status, feeding plans, etc. of individual animals. Through automated identification systems, farmers and managers can manage and optimize their operations more effectively.
[0057] To this end, the present invention proposes a method for cattle identity authentication, which uses deep learning algorithms and image processing technology to automatically extract and analyze cattle facial features from photos or videos. The advantage of this method is that it is non-invasive and does not require physical operation of the animal. It can also achieve remote monitoring and real-time tracking, improve authentication efficiency, and reduce manpower and material costs.
[0058] According to some embodiments, in some current practical applications, some ranches use models to identify the cows according to their facial positions in order to improve the recognition accuracy. Although the accuracy can reach 95.91%, the recognition cost is high and the equipment hardware requirements are high. In order to save costs, some ranches use a model for all-round facial fuzzy recognition, resulting in a low accuracy of only 90.18%. The cattle identification and authentication method of the present invention not only takes into account the recognition accuracy, but also effectively reduces the cost. In practical applications, the recognition accuracy can reach 96.91%.
[0059] Before describing the embodiments of the present invention, some terms or concepts involved in the embodiments of the present invention are explained.
[0060] EID: electronic IDentity, electronic identification code.
[0061] RFID ear tag: Radio Frequency Identification, wireless radio frequency identification is radio frequency identification technology.
[0062] Exemplary embodiments of the present invention are described below with reference to the accompanying drawings.
[0063] Figure 1 A flow chart showing a method of cattle identity authentication according to an example embodiment.
[0064] See also Figure 1The method of the present invention is as follows: obtaining multiple cow face images to be authenticated. Video recording of the cow is performed, and after obtaining the cow video, the cow face image of the cow to be authenticated is obtained by video frame extraction; the facial orientation categories of the multiple cow face images to be authenticated are determined, namely, the front face, left face and right face of the cow face, and the corresponding multiple feature vectors are calculated; the similarities between the multiple feature vectors and the cow face feature vectors of the same orientation category in the pre-established cow face feature database are calculated according to the facial orientation, the front face feature vector is calculated to have a similarity with the front face feature vector in the pre-established cow face feature database, the left face feature vector is calculated to have a similarity with the left face feature vector in the pre-established cow face feature database, and the right face feature vector is calculated to have a similarity with the right face feature vector in the pre-established cow face feature database; after calculating the similarities respectively, the cow corresponding to the feature vector with the highest similarity is selected as the cow to be authenticated.
[0065] In S101, a cow face image to be authenticated is obtained.
[0066] According to some embodiments, a video of the cow's face is captured, including videos of the cow's front face, left face, and right face, and the video is frame-extracted to form image data.
[0067] According to some embodiments, for example, in a scenario where identity authentication is performed on a batch of cattle in a ranch, facial photos of the batch of cattle in various directions are obtained, including the front face, the left face, and the right face.
[0068] In S103, the cow face image to be authenticated is input into a cow face detection model for detection, and the cow face in the image is segmented from the background as a first cow face image.
[0069] According to some embodiments, the image quality of the cow face image to be authenticated is detected, and an image with qualified quality is taken to perform a cow face segmentation background operation.
[0070] In S105, the first cow face image is input into an orientation detection model to identify the facial orientation category of the cow face in the first cow face image.
[0071] According to some embodiments, the cow face in the first cow face image is identified as the front face, the left face, or the right face. For example, the orientation (front face, left face, right face) of the cow face image can be detected using a pre-trained Resnet neural network. According to other embodiments, the orientation of the cow face can be determined based on the position of the eyes.
[0072] In S107, the first cow face image is input into a pre-trained cow face feature extractor to obtain a feature vector of the first cow face image.
[0073] According to some embodiments, a pre-built cow face feature extractor is used to obtain a feature vector of the cow face in the first cow face image.
[0074] According to some embodiments, the cow face classification model is transformed into a cow face feature extractor, so that the output of the cow face feature extractor is a feature vector extracted from a cow face photo. For example, after training the cow face classification model based on the residual neural network ResNet, the model structure can be rewritten, the last fully connected output layer of the model can be removed, and then the feature vector (for example, a 512-dimensional vector) generated after the photo passes through the rewritten model is used as the feature vector of the cow face image. Using the residual neural network ResNet to train cow face images has the advantages of faster speed and requires fewer cow photos. The residual neural network ResNet solves the problem of network performance degradation based on residual learning. For a stacking layer structure formed by stacking the base layer, when the input is x, the learned feature is recorded as H(x), and it is hoped that it can learn the residual F(x)=H(x)-x, so that the original learning feature is actually F(x)+x. The reason for this is that residual learning is easier than directly learning the original feature. When the residual is 0, the stacking layer only performs an identity mapping, and at least the network performance will not decrease. In fact, the residual will not be 0, which will also enable the stacking layer to learn new features based on the input features, thereby having better performance. Therefore, Resnet also solves the problem of gradient disappearance or even explosion in deep networks. The example embodiment of the present invention uses a residual network for training and recognition, but it is easy to understand that the technical solution of the present application is not limited to this. Based on the technical teachings of the present application, other suitable neural network structures can also be used. In S109, the similarity between the feature vector of the first cow face image and the cow face feature vector of the same orientation category in the pre-established cow face feature database is calculated, and the cow corresponding to the feature vector with the highest similarity is determined as the cow to be authenticated.
[0075] According to some embodiments, a cosine similarity measurement algorithm is used to calculate the similarity between the cow face feature vector to be authenticated and the cow face feature vector of the same category in the cow face feature database.
[0076] According to some embodiments, cosine similarity is a method for measuring whether the directions of two non-zero vectors in space are close. It evaluates the similarity between the two vectors by calculating the cosine value of the angle between them. The cosine similarity metric uses the cosine value of the angle between two vectors in the vector space as a measure of the difference between the two vector individuals. The calculated similarity value is between 0 and 1. The closer the calculated result is to 0, the greater the difference between the two vectors. Conversely, the closer the calculated result is to 1, the higher the similarity between the two vectors. Given two vectors A and B, the formula for calculating cosine similarity is as follows:
[0077]
[0078] A in the formula i and Bi Represent the components of vectors A and B respectively.
[0079] The result of cosine similarity ranges from -1 to 1. When two vectors are exactly the same or point in the same direction, their cosine similarity is 1; when two vectors are orthogonal (perpendicular to each other), the cosine similarity is 0; when two vectors point in opposite directions, the cosine similarity is -1.
[0080] According to some embodiments, the ear tag may cause the cow to have a stress reaction after being inserted into the cow's ear, which may cause inflammation in the cow's ear, affecting the health and growth of the cow, and in severe cases may cause the death of the cow. The present invention uses cow face recognition technology, and only needs to take photos and videos of the cow from a distance, which has no health impact on the cow itself.
[0081] In terms of ease of use, the method of ear-tagging cattle requires professional equipment, post-disinfection and other steps, and there may be situations where cattle injure people. When collecting cattle face images in the present invention, it is convenient to take a video of the cattle face without disturbing the cattle excessively. At the same time, in the subsequent reading process, you only need to get slightly closer to the cattle to take a video to perform cattle face recognition. There is no need to use a professional ear tag reader, and an ordinary smart phone can be used. In terms of energy consumption, the cattle face recognition solution no longer needs to use hardware equipment such as ear tags, which is more environmentally friendly and low-energy.
[0082] According to some embodiments, the present invention solves the problems of damage or loss of cattle ear tags by storing and backing up cattle face images and videos on a server, thereby solving the problems of damage or loss of hardware devices.
[0083] In terms of cost, since ear tags are no longer used for cattle identification, the large amount of ear tag costs caused by constant damage and loss of ear tags and the cost of medicines for disinfecting cattle ears are saved. In terms of identification efficiency, on the one hand, the steps of manually ear-tagging and disinfecting cattle are saved, and only a very convenient and quick video recording of the cattle's face is required; on the other hand, when authenticating cattle identities, it is no longer necessary to manually use professional readers to approach the cattle's ears to read the ear tags. Only a mobile phone can be used to take a video of the cattle to perform cattle face recognition, which is more efficient.
[0084] According to some embodiments, cattle ear tags lack authority and can be forged. The present invention uses cattle face recognition technology to uniformly identify all cattle, which is authoritative and cannot be forged.
[0085] Figure 2 A flow chart of a method for extracting cow face features according to an example embodiment is shown.
[0086] See also Figure 2According to some embodiments, a cow face feature extractor is first constructed. For example, the following process can be followed.
[0087] Conduct data collection: Collect a large number of cow facial images, ensuring coverage of various lighting conditions, angles, and expression changes.
[0088] Perform data preprocessing and annotation: Preprocess the images, including scaling, cropping, normalization, and other operations to reduce the impact of lighting, background, and other environmental factors.
[0089] Select and train the model: Choose a suitable deep learning architecture as the base model, such as VGGFace, Facenet, ResNet, etc. Prepare a labeled training data set, where each sample corresponds to a specific cow, and train the model to learn to extract the facial features of the cow from the input image.
[0090] Fine-tune and optimize the model: Fine-tune the model, adjust hyperparameters to improve performance, use methods such as cross-validation to evaluate the model's performance on different data subsets, and make improvements as needed.
[0091] By pre-building a cow face feature extractor, the subsequent cow identification process can be significantly simplified and the overall efficiency and accuracy can be improved. At the same time, such a system can also support large-scale livestock management and decision-making, such as tracking animal health and optimizing feeding strategies.
[0092] See also Figure 2 ,In S201, a cow face feature extractor is pre-built.
[0093] For example, rewrite the trained model structure, remove the final fully connected output layer of the model, and then pass the photo through the rewritten model to generate a feature vector as output.
[0094] According to some embodiments, a cow face feature extractor is used to obtain a cow face feature vector of a target cow, and the cow face feature vector is stored in a database to obtain a pre-stored cow face feature vector.
[0095] According to some embodiments, the output of the cow face feature extractor is made to be a feature vector extracted from the cow face photo.
[0096] In S203, a cow face feature extractor is trained using an existing cow face dataset, wherein the cow face dataset includes a front face dataset, a left face dataset, and a right face dataset.
[0097] According to some embodiments, the hyperparameters of the model may be adjusted by cross-validation or the like to optimize the model performance.
[0098] In S205, the front face image, the left face image and the right face image of the target cow are input into the cow face feature extractor to obtain the cow face feature vector corresponding to each cow and store it in the cow face feature database.
[0099] According to some embodiments, the output of the cow face feature extractor is a feature vector extracted from the cow face photo.
[0100] According to the embodiment, multiple feature vectors are calculated according to facial orientation, the cow's front face feature vector is extracted from the front face image, the cow's left face feature vector is extracted from the left face image, and the cow's right face feature vector is extracted from the right face image, and then classified and stored in a database.
[0101] Figure 3 A flow chart of a method for establishing a cow face feature database according to an example embodiment is shown.
[0102] See also Figure 3 In S301, cow face images of all cows in a predetermined herd are collected, including the front face, left face and right face of the cows.
[0103] According to some embodiments, images and videos of the cow's face in three directions, namely, the front face, the left face, and the right face, are collected, and the videos are frame-extracted into images.
[0104] In S303, the cow face image is input into the cow face detection model, and a cow face and background segmentation operation is performed to obtain a cow face image.
[0105] According to some embodiments, based on key point detection and quality detection of the cow face image, the cow face image is filtered to obtain an initial image, and the cow face is segmented from the background in the image to obtain the cow face image.
[0106] According to some embodiments, cow face images are labeled for classification to distinguish whether two sample cows come from the same cow label, see Figure 5 .
[0107] In S305, the cow face image is input into the orientation detection model to identify the cow face facial orientation category in the cow face image.
[0108] According to some embodiments, the orientation detection model identifies a cow face in a cow face image and classifies the cow face's facial orientation, i.e., front face, left face, or right face.
[0109] In S307, the cow face image is input into a cow face feature extractor to obtain a cow face feature vector and mark the orientation category, and store it in a cow face feature database.
[0110] Figure 4 A flow chart showing a method of cattle image acquisition, model training and authentication according to an example embodiment.
[0111] See also Figure 4 In an example embodiment, in S401, a cow face video is captured using a mini program or app.
[0112] According to an example embodiment, a staff member uses a small program or app on a smart phone to collect cow face videos, including the cow's front face video, left face video, and right face video.
[0113] In S403, the video is extracted into images.
[0114] According to an exemplary embodiment, a cow face video is uploaded to a backend, and video frames are extracted to generate a large number of images.
[0115] In S405, image quality detection is performed in the background.
[0116] According to the exemplary embodiment, the background performs image quality detection on the image after frame extraction. If the detection quality is unqualified, the cow face video is collected again.
[0117] In S407, the image is stored in the cloud server.
[0118] According to the example embodiment, image quality detection is performed in the background, and the uploaded cow face images with qualified detection quality will be stored in the cloud server.
[0119] In S409, the image is fed into the yolov5 model to segment the cow face from the background.
[0120] According to some embodiments, a target detection algorithm model is used to segment the cow face from the background in the image, and the cow face image is retained.
[0121] At S411, the files are saved in folders and tagged with categories.
[0122] According to some embodiments, the cow's face is classified by identifying its facial orientation and stored in corresponding folders, see Figure 5 .
[0123] In S413, the cow face classification network is sent to be trained to obtain a cow face feature extractor.
[0124] According to some embodiments, after a large number of cow face images are collected, they are sent to a cow face recognition network for training until the cow face recognition network can distinguish between pictures of different sample cows in the sample cow face data set, and the training is terminated to obtain a trained cow face classification model. Then, the cow face classification model can be transformed into a cow face feature extractor, for example, the cow face feature extractor can be obtained by removing the last fully connected output layer of the model.
[0125] The following is an exemplary illustration of the training of the cow face classification model.
[0126] Collect photos of cow faces. For example, 30 photos of each cow were collected, 10 photos of the front face, 10 photos of the left face, and 10 photos of the right face. When collecting photos, try to ensure that the cow's face fills most of the photo area so that the model can better recognize the cow's face.
[0127] The collected photos are stored in corresponding classification folders, and the names of the folders are the numbers of the cattle.
[0128] Preprocess the collected cow face data set and divide it into a test set and a training set. After the image collection is completed, the training set and the test set can be randomly divided. When dividing the data, the ratio of the test set to the training set can be set. For example, in this example, the ratio is set to 4:1, that is, 8 images in the training set and 2 images in the test set.
[0129] Use the residual neural network to train the model and save the trained model. After dividing the cow face dataset into corresponding training sets and test sets, the model can be trained next. When training the model, the residual neural network ResNet is used. The model training content mainly includes: convolution operation, pooling operation, activation function, fully connected layer and objective function. After the original training set photos are input, they will undergo multiple convolution and pooling operations until all features are extracted. Then, all the extracted features are connected to the fully connected layer, and finally the fully connected layer will output a number, which is the value of the predicted cow number. The actual number corresponding to this cow is the target value. Finally, the model will repair the difference between the predicted value and the target value, and repeat the training to achieve a better training effect.
[0130] According to some embodiments, when training a data set, the folder path is configured as the folder path of the training set and the test set, and then after waiting for the training to be completed, the generated model file will be automatically saved in the folder. The generated model file can also be named in the training code.
[0131] The trained model is evaluated for the test set accuracy. After the training is completed and the model is successfully saved, the cow face photos in the test set are used to make relevant predictions, and the prediction accuracy is counted. According to the embodiment, when using the test set for prediction, the test set folder path is configured. When counting the accuracy, because the cow numbers are included in the names of the photos in the embodiment, they can be directly compared with the fully connected layer output of the final model. If they are consistent, the recognition is correct, otherwise the recognition is wrong. The running results show that the accuracy rate is 99.1%.
[0132] In S415, the cow face feature extractor is used to authenticate the cow's identity information.
[0133] According to some embodiments, multiple cow face images to be authenticated are obtained to calculate multiple corresponding feature vectors; the similarities between the multiple feature vectors and cow face feature vectors of the same orientation category in a pre-established cow face feature database are calculated according to the facial orientation; and the cow corresponding to the feature vector with the highest similarity is determined as the cow to be authenticated.
[0134] According to some embodiments, the process of cattle identity authentication will not only record the cattle's facial information, but also a lot of related information, such as the cattle's ranch, owner information, RFID ear tag information worn by the cattle, etc., so each cow needs to be individually video collected.
[0135] According to some embodiments, in addition to cattle face recognition, other biometric technologies are being investigated for livestock identification, such as iris scanning and gait analysis. Overall, the goal of cattle identification technology is to increase livestock production efficiency, reduce human error, improve animal welfare, and support sustainable agricultural practices.
[0136] Figure 6 A block diagram of a computing device according to an example embodiment of the invention is shown.
[0137] like Figure 6 As shown, computing device 30 includes processor 12 and memory 14. Computing device 30 may also include bus 22, network interface 16, and I / O interface 18. Processor 12, memory 14, network interface 16, and I / O interface 18 may communicate with each other via bus 22.
[0138] The processor 12 may include one or more general-purpose CPUs (Central Processing Units, processors), microprocessors, or application-specific integrated circuits, etc., for executing relevant program instructions. According to some embodiments, the computing device 30 may also include a high-performance graphics card (GPU) 20 for accelerating the processor 12.
[0139] The memory 14 may include a machine system readable medium in the form of a volatile memory, such as a random access memory (RAM), a read-only memory (ROM) and / or a cache memory. The memory 14 is used to store one or more programs including instructions and data. The processor 12 can read the instructions stored in the memory 14 to execute the above-mentioned method according to the embodiment of the present invention.
[0140] The computing device 30 may also communicate with one or more networks via the network interface 16. The network interface 16 may be a wireless network interface.
[0141] The bus 22 may include an address bus, a data bus, a control bus, etc. The bus 22 provides a path for exchanging information between components.
[0142] It should be noted that, in the specific implementation process, the computing device 30 may also include other components necessary for normal operation. In addition, those skilled in the art may understand that the above device may only include components necessary for implementing the embodiments of this specification, and need not include all components shown in the figure.
[0143] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above method when executed by a processor. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a microdrive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), a network storage device, a cloud storage device, or any type of medium or device suitable for storing instructions and / or data.
[0144] An embodiment of the present invention also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any method recorded in the above method embodiments.
[0145] Those skilled in the art can clearly understand that the technical solution of the present invention can be implemented with the help of software and / or hardware. "Unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array, an integrated circuit, etc.
[0146] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0147] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0148] In the several embodiments provided by the present invention, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0149] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0150] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0151] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention.
[0152] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0153] The exemplary embodiments of the present invention are specifically shown and described above. It should be understood that the present invention is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present invention is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended clauses.
Claims
1. A method for cattle identity authentication, characterized in that: include: Obtain the cow face image to be authenticated; Inputting the cow face image to be authenticated into a cow face detection model for detection, and segmenting the cow face in the image from the background as a first cow face image; Inputting the first cow face image into an orientation detection model to identify the facial orientation category of the cow face in the first cow face image, wherein the orientation detection model is a pre-trained neural network model; Inputting the first cow face image into a pre-trained cow face feature extractor to obtain a feature vector of the first cow face image; The similarity between the feature vector of the first cow face image and the cow face feature vector of the same orientation category in a pre-established cow face feature database is calculated, and the cow corresponding to the feature vector with the highest similarity is determined as the cow to be authenticated.
2. The method according to claim 1, characterized in that Get the cow face image to be authenticated, including: Capture videos of the cow's face, including the front, left, and right faces of the cow; The video is frame extracted to form image data.
3. The method according to claim 1, characterized in that Inputting the cow face image to be authenticated into a cow face detection model for detection, comprising: The image quality of the cow face image to be authenticated is detected, and an image with qualified quality is taken to perform a cow face segmentation background operation.
4. The method according to claim 1, characterized in that: Identifying the facial orientation category of the cow face in the first cow face image includes: Identify whether the cow face in the first cow face image is a front face, a left face, or a right face.
5. The method according to claim 1, characterized in that Inputting the first cow face image into a pre-trained cow face feature extractor to obtain a feature vector of the first cow face image includes: A pre-trained cow face classification model is used to obtain a feature vector of the cow face in the first cow face image.
6. The method according to claim 5, characterized in that Also includes: Using an existing cow face data set to train the cow face classification model, transforming the cow face classification model into the cow face feature extractor, the cow face data set includes a front face, a left face, and a right face data set; The front face image, left face image and right face image of the target cow are input into the cow face feature extractor to obtain the cow face feature vector corresponding to each cow and store it in the cow face feature database.
7. The method according to claim 1, characterized in that It also includes pre-establishing the cow face feature database: Collect cow face images of all cows in the predetermined herd, including the front face, left face and right face of the cow; Case number: Inputting the cow face image into a cow face detection model, performing a cow face and background segmentation operation, and obtaining a cow face image; Inputting the cow face image into an orientation detection model to identify the cow face facial orientation category in the cow face image; The cow face image is input into a corresponding cow face feature extractor to obtain a cow face feature vector and mark the orientation category, and store it in the cow face feature database.
8. The method according to claim 1, characterized in that Calculating the similarity between the feature vector of the first cow face image and the cow face feature vector of the same category in a pre-established cow face feature database includes: The cosine similarity measurement algorithm is used to calculate the similarity between the cow face feature vector to be authenticated and the cow face feature vector of the same category in the cow face feature database.
9. The method according to claim 8, characterized in that Calculating the similarity between the feature vector of the first cow face image and the cow face feature vector of the same orientation category in a pre-established cow face feature database, and determining the cow corresponding to the feature vector with the highest similarity as the cow to be authenticated, comprising: Acquire multiple cow face images to be authenticated, determine the facial orientation categories of the multiple cow face images to be authenticated, and calculate multiple corresponding feature vectors; Calculating the similarity between the plurality of feature vectors and the cow face feature vectors of the same orientation category in a pre-established cow face feature database according to the facial orientation; The cattle corresponding to the feature vector with the highest similarity is determined as the cattle to be authenticated.
10. A computing device, characterized in that include: processor; as well as A memory storing a computer program, which, when executed by the processor, enables the processor to perform the method according to any one of claims 1 to 9.