Livestock ear tag information processing method and system, and storage medium

By fusing visual and other methods, a self-attention mechanism is used to extract ear tag features and introduce ear tag encoding rules, which solves the problem of accurate positioning and recognition of ear tags in harsh environments and achieves efficient and accurate ear tag information processing.

CN119672494BActive Publication Date: 2026-04-14山东银广印务科技有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
山东银广印务科技有限公司
Filing Date
2024-12-06
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing ear tag recognition technologies suffer from inconsistent image quality in harsh environments. Traditional methods struggle to accurately locate characters, handcrafted features lack semantic expressive power and cannot depict the fine structure of characters, and purely data-driven methods have limited generalization ability and are ill-suited for complex images.

Method used

By integrating visual and graphical methods, multi-scale and multi-angle ear tag features are extracted through a self-attention mechanism. Prior knowledge such as ear tag encoding rules is introduced for explicit modeling, and a generative probabilistic graphical model is constructed for end-to-end training to improve recognition accuracy.

Benefits of technology

It significantly improves the intelligence and robustness of ear tag identification, enabling accurate identification of ear tag information in harsh environments, reducing labor costs and error risks, and improving the efficiency of information management in farms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119672494B_ABST
    Figure CN119672494B_ABST
Patent Text Reader

Abstract

The present application provides a livestock ear tag information processing method and system and a storage medium. In view of the problem of automatic collection of ear tag information in livestock breeding, an end-to-end recognition method combining vision and is proposed. First, the method uses an encoder to adaptively extract multi-scale and high-level semantic features of the ear tag image. Then, the existing character rules of the farm are modeled, and they are used to guide the more accurate and consistent prediction of the character sequence. On a large-scale ear tag image dataset collected and labeled by the applicant, the method achieves a high character recognition accuracy and shows good generalization and robustness on difficult samples such as misalignment, occlusion and blur, which is significantly better than manual input methods and other models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of ear tag information processing technology, and in particular to a method, system and storage medium for processing ear tag information of livestock. Background Technology

[0002] Ear tags are an important tool for information management in livestock farming. In large-scale farms, each animal is given a unique ear tag at birth, recording its identity information such as date of birth, breed, pedigree, and immunization status. This information accompanies the animal throughout its life, forming the basis for disease prevention and control, production management, and product traceability.

[0003] However, due to the complex and ever-changing rearing environment, ear tags are prone to physical damage such as fading, staining, and deformation, making the serial numbers on them difficult to read and causing great inconvenience for data entry. Traditional manual transcription methods are not only inefficient and prone to errors, but also struggle to handle tens of thousands of individual livestock, becoming a bottleneck in the process of livestock informatization.

[0004] To address this problem, automated ear tag recognition technology has emerged. Its main idea is to use machine vision to detect and identify the ear tag region and number in an image, thereby replacing the human eye in information entry. However, the inconsistent quality of ear tag images places high demands on the intelligence and robustness of the algorithm.

[0005] Optical character recognition (OCR) Text-to-image (TPO) technology converts text content in images into computer-editable character sequences, and has wide applications in document processing, license plate recognition, and other fields. Traditional The method typically employs manually designed feature extraction algorithms, such as... , Waiting to detect and describe text regions in the image, then using a support vector machine (SVM) ), nearest neighbor ( Classifiers such as [list of classifiers] are used for identification. These methods work reasonably well on printed text images, but their performance is often significantly reduced when dealing with ear tag images from livestock farming environments.

[0006] First, the harsh breeding environment leads to inconsistent image quality of ear tags, with common issues such as distortion, blurring, shadows, and occlusion, making it difficult to accurately locate characters using traditional methods. Second, hand-designed features lack semantic expressiveness and cannot depict the fine structure of characters, resulting in low recognition rates when character shapes are diverse. Third, the numbers and letters on ear tags are tightly arranged and may contain irrelevant text such as farm markings; a simple character-by-character recognition method lacks contextual information and is prone to errors. In short, the irregularity of ear tag characters poses significant challenges. The generalization ability of technology presents a challenge.

[0007] In recent years, with Deep learning methods, represented by [example name], are beginning to emerge in the field of computer vision. By using end-to-end feature learning, the limitations of hand-crafted features are overcome. It has achieved performance surpassing human capabilities on large-scale image classification tasks, bringing new opportunities to the ear tag recognition problem. Inspired by this, the industry has begun to... A series of works have attempted to apply this to the problem of ear tag recognition. It is used for ear tag localization and identification.

[0008] For example, patent document CN114255382A proposes a method for identifying epidemic prevention ear tags based on neural networks. This method is an epidemic prevention ear tag identification method based on neural networks. It implements an algorithm for identifying epidemic prevention ear tags using a convolutional neural network, thereby enabling rapid identification of ear tag numbers through mobile devices such as mobile phones and tablets with cameras, reducing the difficulty of ear tag information collection.

[0009] Patent document CN115171156A proposes a cow ear tag identification system, which adopts a system based on... The technology employs methods such as bull head extraction model, color thresholding, CPTN algorithm text detection model, and CRNN algorithm text recognition model to achieve the technical effect of ear tag recognition.

[0010] although and its variants ( While technologies like [examples of such technologies] have shown certain advantages in ear tag recognition tasks, they still have significant shortcomings. On the one hand, The features extracted by these variants are mainly concentrated in local receptive fields, lacking global semantic modeling capabilities and failing to effectively capture the regularity of ear tag encoding. On the other hand, Its variants represent a purely data-driven learning paradigm, whose generalization ability is limited by the training data and makes it difficult to fully utilize prior knowledge of ear tag numbers. Furthermore, existing work primarily focuses on frontal images of ear tags under ideal conditions, lacking systematic research on various complex images in harsh environments.

[0011] In addition, in recent years The model based on this architecture is also widely used in fields such as image recognition. It is a neural network model based on a self-attention mechanism, initially applied in the field of natural language processing, and has achieved significant results in tasks such as machine translation and language modeling. Compared to and Models, It can better model long-range dependencies and has stronger feature representation and generalization capabilities. Based on this, some scholars have proposed... ( ) model, in In classification tasks, it has achieved the same level as Comparable performance. Subsequent work further improved it. The architecture and training methods have expanded its application scope. This inspires us to utilize vision... Automatically learn ear tag features from data to overcome... Inherent limitations.

[0012] on the other hand, It is a reasoning tool based on probabilistic graphical models, which is good at expressing the causal dependencies between things and is widely used in fields such as fault diagnosis and risk assessment. Through directed acyclic graph ( ) describes the conditional dependency structure between variables, and uses conditional probability tables ( This quantifies the strength of the dependency, thereby enabling probabilistic reasoning and decision-making.

[0013] While existing methods for ear tag recognition have made progress under certain conditions, there is still room for improvement in terms of algorithm intelligence, data adaptability, and recognition accuracy.

[0014] To address the aforementioned shortcomings, this invention proposes a fusion method. and A novel ear tag recognition method. Its innovation lies in: 1) utilizing... Excellent feature extraction and relationship modeling capabilities, automatically learning multi-scale, multi-angle features of ear tags from a data-driven perspective; 2) Introduction By modeling the inherent relationships between ear tag numbers and making full use of prior knowledge about numbers and letters in ear tag coding rules, recognition accuracy can be improved.

[0015] In other words, this invention innovatively integrates vision. and These two advanced artificial intelligence technologies work together to enhance the expression and recognition of ear tag features from both data-driven and knowledge-guided perspectives. Summary of the Invention

[0016] To address the problems mentioned in the background art, the present invention proposes a method for processing livestock ear tag information, which includes the following steps:

[0017] Step 1: Constructing a dataset of livestock ear tag information:

[0018] Step 1.1: Data Acquisition. Use a high-definition camera to acquire raw ear tag images in the cattle passage. The image specifications are as follows: Pixels Color modes. Among them, Represents the width and height of the image in pixels; It represents the three color channels: red, green, and blue.

[0019] Step 1.2: Data Labeling. Labeling includes: 1) Bounding box coordinates. ;2) Ear tag character sequence .in, Represents the coordinates of the top-left corner of the bounding box; Represents the coordinates of the bottom right corner of the bounding box; Representing the One character.

[0020] Step 2: Preprocessing of livestock ear tag information data:

[0021] Step 2.1: Image Enhancement. For the original image... Perform transformations such as random cropping, translation, Gaussian noise, and blurring. Generate enhanced images .in, Represents the original RGB image; This represents the image enhancement transformation function.

[0022] Step 2.2: Scale Normalization. The labeled ear tag area is cropped from the original image and scaled to a fixed size. Then fill in The normalized image is obtained. .in, and These represent the normalized ear tag region size and the filled image size, respectively.

[0023] Step 2.3: Image segmentation. Using a semantic segmentation model. Will The foreground (ear tag region) and background are separated to obtain a binarized mask. Final input image .in, Represents a segmentation mask; Represents matrix dot product.

[0024] Step 3: Visual information from animal ear tags Feature extraction:

[0025] Step 3.1: Image segmentation. [The image will be divided into blocks.] Divided into indivual Small pieces, and flatten them into one sequence .in, This represents the number of small blocks obtained from the segmentation; This represents the size of each small block; Represents the length of the sequence; This represents the dimension of each vector.

[0026] Step 3.2: Location Encoding. Encode the learnable locations. and Add them together to get the input sequence with positional information. .in, This represents the positional encoding matrix.

[0027] Step 3.3: Encoding. enter layer The encoder obtains the final feature map. .in, This represents the number of layers in the encoder.

[0028] Step 3.4: Self-attention calculation. The core is the self-attention layer, for the first Layer input First calculate :

[0029] ;in, Representing the Layer The weights of the matrix; represent Dimensions.

[0030] Then through and The product of attention weights is calculated. :

[0031] ;in, Representing the Attention matrix of the layer; This represents the scaling factor.

[0032] Finally Acting on Obtain output features :

[0033] ;in, Representing the The output feature matrix of the layer.

[0034] Step 4: Perform decoding:

[0035] Step 4.1: Building .Will Treated as an observed variable, character category Treating them as latent variables, we construct the following generative probabilistic graphical model:

[0036] ;in, Represents the posterior probability; Represents the likelihood probability; Represents prior probability; Represents evidence factors.

[0037] Step 4.2: Likelihood probability modeling. Assume each feature vector... Obey Category The likelihood probability of a multivariate Gaussian distribution can be expressed as:

[0038] ;in, and Representing categories The mean vector and covariance matrix; Represents the feature dimension.

[0039] Step 4.3: Prior Probability Estimation. Estimate the marginal probability based on the frequency of character occurrences in the training set. Then construct the transition probabilities according to the farm rules. .in, Representative character The prior probability; This means that the previous character is known. The current character is The conditional probability.

[0040] Step 4.4: Inference and Prediction. For each location... Features Calculate the posterior probability of each category and select the category with the highest probability as the prediction:

[0041] ;in, Representative position Predicted characters; Representative position The neighborhood of.

[0042] Step 5: Perform end-to-end training of the livestock ear tag information model:

[0043] Step 5.1: Random Sampling. Randomly sample a batch of images from the training set. and corresponding character tags .in, Represents batch size; Representing the The label sequence of each sample.

[0044] Step 5.2: Forward propagation. For each The feature map is obtained through steps 2-4. and predicted probability .in, Representing the The predicted class sequence of each sample.

[0045] Step 5.3: Loss Calculation. Based on Real Labels and predicted probability Calculate the negative log-likelihood loss:

[0046] ;in, represent and All parameters; Representing the Sample locations Real characters; Represents the length of the character sequence.

[0047] Step 5.4: Backpropagation. Calculate the loss. right gradient and update with optimizer Repeat steps 5.1-5.4 until convergence.

[0048] Step 6: Conduct livestock ear tag information model testing:

[0049] Step 6.1: Evaluate the model performance on the test set, including character recognition accuracy. and character error rate :

[0050] ; ;in, This represents the number of samples that were completely and correctly identified. Represents the total number of samples in the test set; Represents the total character edit distance; This represents the total number of characters.

[0051] Step 6.2: Calculate the recognition accuracy under different character lengths, image quality and other conditions, and plot the corresponding performance curves.

[0052] Step 6.3: Observe the model's performance on some representative real samples and analyze the rationality and limitations of the identification results.

[0053] Step 7: Deployment of Livestock Ear Tag Information Model:

[0054] Step 7.1: Convert the trained model into a format suitable for the production environment (e.g., ...). , And perform necessary optimizations (such as quantization, pruning, etc.) to balance the performance and efficiency of the model.

[0055] Step 7.2: Develop the corresponding reasoning program to... , The model is encapsulated in various forms, and necessary documentation is written to facilitate external calls.

[0056] Step 7.3: Deploy the model to a specific device or cloud platform, such as an embedded device, Servers, cloud computing platforms, etc., and configure the corresponding operating environment and dependency libraries.

[0057] Step 7.4: Conduct necessary stress tests to evaluate the model's response speed and stability under high concurrency and high traffic scenarios, and adjust resource configurations appropriately.

[0058] On the other hand, the present invention also provides a livestock ear tag information processing system, which is used to implement the above method, and the system includes the following parts:

[0059] Data Acquisition and Preprocessing Module: This module is responsible for acquiring raw ear tag images through a high-definition camera in the cattle passage. It preprocesses the acquired images, including random cropping, translation, adding Gaussian noise, blurring, and other transformations, as well as scale normalization and image segmentation, to improve data quality and model robustness.

[0060] Feature extraction module: Inputs the preprocessed image The encoder adaptively extracts multi-scale, hierarchical ear tag features from images through a self-attention mechanism. This module is better able to model long-range dependencies and has stronger feature representation and generalization capabilities.

[0061] Decoding module: Introduction Explicitly model the existing prior knowledge of the farm, such as ear tag encoding rules and character combination patterns, to provide... It provides strong reasoning guidance, improving the accuracy and consistency of identification.

[0062] End-to-end training module: Training is conducted using a joint end-to-end approach. encoder and By maximizing the parameters of the joint probabilistic learning model, the two modules can promote each other and work together.

[0063] Inference and prediction module: In practical applications, the input ear tag image is first processed using... Extract features, then use The character categories are decoded and then concatenated in order to form the complete ear tag number.

[0064] On the other hand, we also propose a computer storage medium for processing livestock ear tag information, wherein the computer storage medium is used to store instructions and data for running the above method, including:

[0065] Model storage area: Used to store trained models. Model and The model, including its structure, parameter weights, and other information, should be converted to a production-ready format (e.g., [format not specified]). , (etc.), and make necessary optimizations.

[0066] Data storage areas include a raw image database, a preprocessed image database, and an ear tag character annotation database. The database must support high-concurrency access and fast retrieval, and employ a distributed storage architecture to ensure data security.

[0067] Cache storage area: Used to store intermediate results during image processing, such as feature maps, probability distributions and other temporary data. High-speed caching is used to improve processing efficiency.

[0068] Configure storage area: Stores various configuration files required for the system to run, including adjustable configuration items such as model hyperparameters, preprocessing parameters, and inference parameters.

[0069] Log storage area: Records system running status, identification results, error information and other running logs, and supports hierarchical log storage and periodic cleanup mechanisms.

[0070] The beneficial technical effects of this invention include:

[0071] Compared with traditional methods, the method of this invention can complete the task of information technology for ear tags in livestock farms more intelligently, efficiently and accurately, providing important technical support for the construction of smart animal husbandry and having broad application prospects.

[0072] While existing methods for ear tag recognition have made progress under certain conditions, further improvements are needed in terms of algorithmic intelligence, data adaptability, and recognition accuracy. This invention innovatively integrates visual... and These two advanced artificial intelligence technologies synergistically enhance the expression and recognition of ear tag features from both data-driven and knowledge-guided perspectives. Compared with existing work, the method of this invention has unique advantages in the following aspects:

[0073] 1) Utilize Its powerful feature extraction and relationship modeling capabilities allow it to adaptively learn the visual features of ear tags from multiple scales and angles, eliminating the need for manual design and greatly enhancing the intelligence and robustness of the algorithm.

[0074] 2) Introduction Explicit modeling is performed on the existing prior knowledge of livestock farms, such as ear tag coding rules and character combination patterns, to provide... It provides strong guidance for reasoning, which to some extent makes up for the shortcomings of purely data-driven methods. Detailed Implementation

[0075] The present invention will now be explained in further detail. The fusion proposed in this invention... and The ear tag recognition method mainly consists of four parts: dataset construction, data preprocessing, Encoding and Decoding. The dataset construction module is responsible for collecting and labeling real ear tag image data, providing support for subsequent model training. The data preprocessing module performs a series of enhancement and normalization operations on the original images to improve data quality and model robustness. The encoding module uses a self-attention mechanism to adaptively extract multi-scale, multi-angle ear tag features from images. The decoding module integrates prior knowledge such as farm ear tag encoding rules to... The extracted features are constrained and enhanced, and the final character recognition result is output. Each module will be described in detail below.

[0076] To ensure the ear tag recognition model can truly learn and reflect the actual scene of a livestock farm, this invention selects a large-scale livestock farm as the data collection object, and continuously collects images of cattle entering and exiting through high-definition cameras installed in the livestock pen passages. The original image specifications are as follows: Pixels The color models cover individuals from multiple breeds (such as Holstein, Limousin, Charolais, etc.) and growth stages (such as calves, growing cattle, adult cattle, etc.), as well as images under various conditions such as different shooting angles (front, side, back), image quality (sharp, blurry, occluded), and lighting conditions (daytime, nighttime, backlight). The scale and diversity of the data far exceed those of existing public datasets.

[0077] For positioning, manually select the boundary coordinates of the ear tag in the annotation software. During recognition, the text within the bounding box is labeled character by character. Possible character sets include... , , as well as , , Separator.

[0078] To further improve the quality and richness of the data, this invention designs a systematic data preprocessing workflow based on labeled data, which mainly includes the following steps:

[0079] 1) Image Enhancement. To address the harsh shooting environment of the farm, data augmentation was used to simulate various image quality degradation scenarios, thereby improving the model's robustness. Specifically, transformations such as cropping, translation, adding Gaussian noise, and blurring were employed to increase the amount of data.

[0080] 2) Scale Normalization. Due to the variable spatial relationship between cattle and the camera, the size of the ear tags varies considerably in the image, which is detrimental to subsequent feature extraction. Therefore, based on the labeled ear tag bounding box, the ear tag region is scaled to a uniform size ( ), then fill to the fixed input size ( ).

[0081] 3) Image segmentation. Ear tag images often contain a large amount of irrelevant background, increasing the difficulty of recognition. This invention is based on... Automatic segmentation of the ear tag area was achieved, further reducing interference from invalid information.

[0082] After the above preprocessing, the size, quality, and diversity of the dataset were significantly improved, which laid the foundation for subsequent... Feature extraction and Reasoning laid a solid foundation.

[0083] use We perform feature extraction to adaptively learn multi-scale, multi-angle feature representations of ear tag numbers and letters.

[0084] Specifically, the present invention employs The structure will be the pre-processed The ear tag image is uniformly segmented into indivual Small pieces, and flatten them into a The sequence is used. To incorporate positional information, learnable positional codes are added to the feature vectors of each small block. Next, the serialized ear tag features are input... It contains multiple identical each By self-attention ( ) and feedforward networks ( It consists of two sub-layers and also has... ( ) and residual connections.

[0085] Feature aggregation is achieved by calculating attention weights between different positions. Specifically, given an input sequence... First, it is generated through linear transformation. matrix , matrix and matrix :

[0086] ;in, The weight matrix is ​​a learnable matrix. for , , The dimension. Next, by calculating and The attention matrix is ​​obtained by dot product and normalization. :

[0087] ; Each element in Indicates position Arrive at the location Attention weights. Finally, Applied to Obtain the aggregated feature representation :

[0088] The self-attention layer can dynamically focus on the correlation between different regions, thereby achieving the transmission and fusion of global information. This invention uses a variant of multi-head self-attention, which... Enter them separately Each head has an independent self-attention layer, and the outputs of each head are then concatenated to capture richer features.

[0089] go through indivual Through iterative updates, the shallow, middle, and deep features of the ear tag image are fully extracted and fused to form a highly semantic feature map. This multi-scale, hierarchical feature representation is beneficial for depicting the fine structure and contextual relationships of ear tag characters. It should be noted that... All parameters are data-driven and learned end-to-end, avoiding the limitations of manual design.

[0090] although It can adaptively learn ear tag features from data, but its feature extraction process is unsupervised and purely data-driven.

[0091] To further enhance The extracted features are made to conform to the prior rules of ear tag characters. The following section introduces... As a decoder, it models the farm's existing ear tag encoding knowledge in the form of a probabilistic graph and guides... Feature modification and identification.

[0092] Specifically, record The feature map output by the last layer is ,in This represents the number of feature vectors. Will Treated as an observed variable, character category Consider them as latent variables, where This represents the number of character types. The goal is to calculate the posterior probability. , indicating that the observed features The following characters represent the conditional probabilities of each category. According to... Theorem: The posterior probability can be decomposed into:

[0093] ;in, Let be the likelihood probability. For prior probability, As an evidence factor, it can be considered a normalization constant. Prior probability. This reflects the marginal distribution of character categories and can be estimated based on the frequency of character occurrences in ear tag numbers. Likelihood probability The conditional distribution of observed features generated for a given character category is characterized using a multivariate Gaussian distribution model:

[0094] ;in, For feature dimension, and Categories The mean vector and covariance matrix can be obtained through maximum likelihood estimation.

[0095] During the reasoning phase, for each position eigenvectors , Calculate the posterior probability of it belonging to each character category, and select the category with the highest probability as the prediction result:

[0096] To further utilize prior knowledge about the farm to guide the reasoning process, this invention... Some additional constraint edges have been introduced. For example, let's denote... For position The neighborhood of the farm can be used to construct conditional probabilities based on the character combination rules of the farm. , indicating that the neighboring character is Prerequisite position The characters are The probability of . Therefore, the reasoning formula can be extended to:

[0097] This decoding method, which integrates prior knowledge, allows the model to not only rely on local visual features when recognizing characters, but also consider the contextual relationships between characters, thereby improving the accuracy and consistency of recognition.

[0098] The following training method uses a combined end-to-end approach. and The specific process is as follows:

[0099] 1) Randomly crop out from the preprocessed ear tag image The region is used as the training sample, and the corresponding character label is generated. ,in For the first Character categories for each position.

[0100] 2) Input the image region Extract features to obtain feature maps .

[0101] 3) by As the observed variable, As a monitoring signal, by maximizing the joint probability Learn the model parameters. The loss function is defined as:

[0102] ;in for and The parameters, The number of training samples, For the first The first sample Character labels at each position.

[0103] 4) Update via backpropagation algorithm and The parameters are iterated through the above process until convergence.

[0104] During the reasoning phase, for each ear tag image, first use... Extract features, then use The character category at each position is decoded and then concatenated in order to form the complete ear tag number.

[0105] In summary, the fusion proposed in this invention Encoding and The decoding method is innovative in the following aspects: 1) Utilizing 1) Its powerful feature extraction capabilities adaptively learn multi-scale, hierarchical ear tag features; 2) Introducing Explicit modeling of prior knowledge such as farm ear tag coding rules makes up for the shortcomings of pure data-driven methods; 3) Through end-to-end joint training, the two modules promote each other and work together to maximize their respective intelligent advantages.

[0106] To comprehensively assess the integration and To assess the performance of our ear tag recognition method in real-world scenarios, we conducted extensive experimental studies on a large-scale ear tag image dataset that we constructed ourselves. We focused on the following key questions: 1) Can our method surpass existing methods in overall recognition accuracy? Methods such as: 2) How well this method adapts to ear tag images of varying difficulty (e.g., incomplete characters, damaged or blurred images); 3) Fusion Encoding and The necessity and feasibility of decoding; 4) The impact of factors such as prior knowledge and data augmentation on the recognition rate.

[0107] This invention uses a self-constructed large-scale real ear tag image dataset, which is derived from a large-scale dairy farm and was captured by high-definition cameras in the cattle passage. After annotation and quality screening, images with character-level annotations are finally obtained, with each image corresponding to a 10-digit ear tag number (a mixture of letters and numbers).

[0108] We randomly sort the dataset according to The model is divided into training, validation, and test sets. The training set is used for model training and parameter learning, the validation set is used for hyperparameter selection and early stopping strategies, and the test set is used to evaluate the model's generalization performance. Additionally, we select [specific parameters] from the test set. The representative difficult examples are divided into three subsets: 1) the occlusion subset, which includes images with partial occlusion and missing edges; 2) the blurry subset, which includes images with motion blur and out-of-focus blur; and 3) the damaged subset, which includes images with stains, scratches, and fading. A subset is used to examine the robustness of the model under adverse conditions.

[0109] This invention uses character recognition accuracy ( ) and character error rate ( Two metrics are used to evaluate the model's performance. (Note: The original text contains some inconsistencies and unclear formatting. A more accurate translation would require the full context.) The total number of samples in the test set. To completely identify the correct number of samples, The sum of character edit distances. Given the total character length, the two metrics are defined as follows:

[0110] ; ;in, The percentage of ear tags that are correctly identified overall is measured. Measure the average number of character errors per number. The higher, The lower the value, the better the model performance.

[0111] The present invention The encoder uses Architecture, input image size is . A tree structure is used, where each character node is connected to its preceding and following character nodes. Prior probabilities are estimated based on character frequencies. The training process employs... Optimizer, batch size is The initial learning rate is The weight decay coefficient is .

[0112] First, we compare the overall recognition accuracy of the method of this invention with the following baseline methods: 1) ,use The architecture; 2) ,use The architecture; 3) ,use The architecture; 4) , only use Encoding and Classification headers. Table 1 shows the performance of each method on the test set and... A collection of difficult examples and index.

[0113] Table 1. Performance comparison of various methods on the ear tag recognition task:

[0114] ; As can be seen from Table 1, fusion and The method significantly outperformed other baselines across all metrics, with a particularly noticeable improvement on poorly performing samples. Compared to the second-ranked method... The method of the present invention is in Significant improvements were observed in the metrics: from 94.0% to 96.5% (a 2.5 percentage point increase) on the Occ. subset, from 83.1% to 90.7% (a 7.6 percentage point increase) on the Blur. subset, and from 87.9% to 92.6% (a 4.7 percentage point increase) on the Dmg. subset. The method of this invention is also superior to... ,average It decreased from 5.79% to 4.25% (a decrease of 1.54 percentage points). In contrast, the traditional and based on The method performs poorly when processing various types of samples, especially on the Blur subset. The accuracy rates were only 78.5% and 80.2%, significantly lower than the 90.7% of the method described in this invention. This indicates that fusing Bayesian inference can significantly improve the robustness of recognition, thanks to the guidance of prior knowledge. This fully demonstrates the stronger feature extraction and sequence modeling capabilities of the method described in this invention. This shows that fusing... Reasoning can significantly improve the robustness of recognition, thanks to the guidance of prior knowledge. In contrast, purely data-driven... and The method is easily affected by noise.

[0115] To gain a more detailed understanding of the internal mechanisms of the method of this invention, we designed a series of experiments to examine the impact of each module. Specifically, the following were compared: Configuration 1) ,Right now ;2) ,exist Add to the basis Decoding; 3) ,exist Add data augmentation to the existing data; 4) This refers to the complete method of the present invention. Table 2 presents a performance comparison of each configuration on the test set.

[0116] Table 2 Module Comparison:

[0117] ; As can be seen, whether joining Decoding or data augmentation can both provide... It brings a considerable performance improvement, but the best results are achieved when used in combination. and The top is higher than and Percentage points. Among them, The decoding component contributes more and can be used independently. improve The percentage point fully demonstrates the guiding role of prior knowledge. The role of data augmentation is relatively minor, but still significant. Complementary decoding can further improve the model's generalization ability. The above experiments show that... Encoding and Decoding is one of the two essential pillars of this invention; neither can be dispensed with, and together they constitute an efficient and robust ear tag recognition system. This also verifies the uniqueness of this invention in comprehensively utilizing data-driven and knowledge-guided approaches.

[0118] Finally, we explored the impact of different types of prior knowledge on recognition performance. Table 3 compares the results. The effect of incorporating three types of knowledge—character frequency, character combination, and farm rules—into the data.

[0119] Table 3. The impact of different types of prior knowledge on recognition performance.

[0120] ; As can be seen from Table 3, in Incorporating prior knowledge at different granularities significantly improves model performance. However, when using character frequency information alone... On for More than pure Baseline higher The percentage point indicates that the prior distribution of characters has a certain guiding role in recognition. Adding character combination rules (such as letters not appearing consecutively, numbers following an increasing trend) on this basis can improve the recognition accuracy of the test set and difficult samples. respectively upgraded to and average improvement Percentage points. This indicates that the constraints between characters can help correct some recognition errors, especially under poor image quality. Furthermore, if farm-specific ear tag encoding knowledge (such as the number of digits, the relative positions of letters and numbers, etc.) is incorporated, the performance on the test set and difficult samples will improve. Can achieve respectively and Another slight increase Percentage points. Correspondingly, It also gradually decreases with the incorporation of prior knowledge, eventually reaching... More than simple Reduced percentage points, a decrease of 1 percentage point .

[0121] To more intuitively demonstrate the practical value of the method of this invention, we compared it with manual recognition. Specifically, multiple images were randomly selected from the test set and assigned to several skilled workers for annotation, with their average recognition time and accuracy recorded. Simultaneously, the automatic recognition system of this invention was used to predict the results of these images. The results are shown in Table 4.

[0122] Table 4 Comparison of efficiency and accuracy between manual and automatic identification:

[0123] ; As can be seen, the automatic recognition system of this invention has an overwhelming advantage in recognition efficiency, requiring only a small amount of time per image on average. Seconds are the speed of human operation. This means that in the same amount of time, the processing capacity of the automatic identification system is many times that of the manual system. The accuracy rate is several times higher than that of manual identification. At the same time, the automatic identification system also has a slightly higher accuracy rate than manual identification. The percentage point improvement is attributed to the machine's advantages in recognizing character details and comparing information. Furthermore, prolonged, high-intensity, repetitive manual labor can easily lead to visual and judgment fatigue, resulting in misidentification. In summary, the automated intelligent identification system of this invention can significantly improve the efficiency of ear tag information dissemination in livestock farms, reduce labor costs and error risks, and has great practical value and promotion potential. This fully demonstrates the application significance of this invention.

[0124] In summary, large-scale experiments and multi-angle evaluations demonstrate that this invention integrates visual... and The method demonstrated excellent performance in livestock ear tag recognition tasks, with an overall recognition accuracy of up to [percentage missing]. It also exhibits good robustness in challenging scenarios. This reveals... coding, The method utilizes a collaborative mechanism involving modules such as decoding and data augmentation. Through comparison with manual recognition, it was verified that this method can significantly improve operational efficiency in practical applications and has broad application prospects. This provides important technical support for the information management of smart livestock farms.

[0125] To address the challenge of automatically collecting ear tag information in livestock farming, this invention proposes an innovative fusion method. and The identification method. Adaptively extract multi-scale, hierarchical feature representations from ear tag images, and then introduce... Prior information such as character combination rules and encoding knowledge in network modeling of aquaculture farms is crucial for... The output features are constrained and enhanced to collaboratively optimize the recognition process from both data-driven and knowledge-guided perspectives. Experiments on a self-constructed large-scale real ear tag image dataset show that the method of this invention significantly outperforms existing methods in terms of accuracy and robustness on various recognition difficulties. and This method can process massive amounts of data at a speed far exceeding that of manual labor. Ablation research further reveals... Encoding and Decode the underlying mechanism and key points of implementation of this fusion mechanism.

[0126] The main innovations of this invention are: 1) It is the first to introduce ear tag recognition technology in the field of ear tag recognition. and These two This powerful tool overcomes the limitations of traditional methods in generalizing to complex scenarios; 2) it creatively... and These efforts have built bridges and formed a collaborative framework that emphasizes both data-driven and knowledge-guided approaches, making a valuable attempt to develop agricultural artificial intelligence and promote the construction of smart animal husbandry.

Claims

1. A method for processing ear tag information of livestock, characterized in that, The method includes the following steps: Step 1: Constructing a dataset of livestock ear tag information; Step 2: Preprocessing of livestock ear tag information data; Step 3: Livestock Ear Tag Information Feature extraction, including: Step 3.1: Image segmentation; Divided into indivual Small pieces, and flatten them into one sequence ;in, This represents the number of small blocks obtained from the segmentation; This represents the size of each small block; Represents the length of the sequence; Represents the dimension of each vector; Step 3.2: Location Encoding; Encode the learnable location. and Add them together to get the input sequence with positional information. ;in, Represents the position encoding matrix; Step 3.3: Encoding; will enter layer The encoder obtains the final feature map. ;in, Represents the number of layers in the encoder; Step 3.4: Self-attention calculation; The core is the self-attention layer, for the first Layer input First calculate : ;in, Representing the Layer The weights of the matrix; represent The dimension; Then through and The product of attention weights is calculated. : ;in, Representing the Attention matrix of the layer; Represents the scaling factor; Finally Acting on Obtain output features : ;in, Representing the The output feature matrix of the layer; Step 4: Perform Decoding, including: Step 4.1: Building ;Will Treated as an observed variable, character category Treating them as latent variables, we construct the following generative probabilistic graphical model: ;in, Represents the posterior probability; Represents the likelihood probability; Represents prior probability; Represents evidence factors; Step 4.2: Likelihood probability modeling; assuming each feature vector Obey Category The likelihood probability of a multivariate Gaussian distribution can be expressed as: in, and Representing categories The mean vector and covariance matrix; Represents the feature dimension; Step 4.3: Prior probability estimation; estimate marginal probabilities based on the frequency of character occurrences in the training set. Then construct the transition probabilities according to the farm rules. ;in, Representative character The prior probability; This means that the previous character is known. The current character is The conditional probability; Step 4.4: Inference and Prediction; for each location Features Calculate the posterior probability of each category and select the category with the highest probability as the prediction: ;in, Representative position Predicted characters; Representative position The neighborhood; Step 5: Perform end-to-end training of the livestock ear tag information model; Step 6: Conduct testing of the livestock ear tag information model; Step 7: Deployment of livestock ear tag information model.

2. The method for processing livestock ear tag information according to claim 1, characterized in that, Step 1 specifically includes: Step 1.1: Data Acquisition; Use a high-definition camera to acquire raw ear tag images in the cattle passage. The image specifications are as follows: Pixels Color modes; among which, Represents the width and height of the image in pixels; Represents the three color channels: red, green, and blue. Step 1.2: Data annotation; Annotation content includes: 1) Bounding box coordinates ;2) Ear tag character sequence ;in, Represents the coordinates of the top-left corner of the bounding box; Represents the coordinates of the bottom right corner of the bounding box; Representing the One character.

3. The method for processing livestock ear tag information according to claim 1, characterized in that, Step 2 specifically includes: Step 2.1: Image Enhancement; Enhance the original image Perform random cropping, translation, Gaussian noise, and fuzzy transformation. Generate enhanced images ;in, Represents the original RGB image; Represents the image enhancement transform function; Step 2.2: Scale normalization; crop the labeled ear tag area from the original image and scale it to a fixed size. Then fill in The normalized image is obtained. ;in, and These represent the normalized ear tag region size and the filled image size, respectively; Step 2.3: Image segmentation; using a semantic segmentation model Will The foreground (ear tag region) and background are separated to obtain a binarized mask. Final input image ;in, Represents a segmentation mask; Represents matrix dot product.

4. The method for processing livestock ear tag information according to claim 1, characterized in that, Step 5 specifically includes: Step 5.1: Random sampling; randomly sample a batch of images from the training set. and corresponding character tags ;in, Represents batch size; Representing the The label sequence of each sample; Step 5.2: Forward propagation: For each The feature map is obtained through steps 2-4. and predicted probability ;in, Representing the The predicted class sequence of each sample; Step 5.3: Loss Calculation: Based on Real Labels and predicted probability Calculate the negative log-likelihood loss: ;in, represent and All parameters; Representing the Sample locations Real characters; Represents the length of the character sequence; Step 5.4: Backpropagation: Calculate the loss right gradient and update with optimizer Repeat steps 5.1-5.4 until convergence.

5. The method for processing livestock ear tag information according to claim 1, characterized in that, Step 6 specifically includes: Step 6.1: Evaluate the model performance on the test set, including character recognition accuracy. and character error rate : ; ;in, This represents the number of samples that were completely and correctly identified. Represents the total number of samples in the test set; Represents the total character edit distance; Represents the total number of characters; Step 6.2: Calculate the recognition accuracy under different character lengths and image quality conditions, and plot the corresponding performance curves; Step 6.3: Observe the model's performance on some representative real samples and analyze the rationality and limitations of the identification results.

6. The method for processing livestock ear tag information according to claim 1, characterized in that, Step 7 specifically includes Step 7.1: Convert the trained model into a format suitable for the production environment and optimize it; Step 7.2: Develop the corresponding reasoning program to... , Encapsulate the model formally and write necessary documentation to facilitate external calls; Step 7.3: Deploy the model to a specific device or cloud platform; Step 7.4: Conduct necessary stress tests to evaluate the model's response speed and stability under high concurrency and high traffic scenarios, and adjust resource configurations appropriately.

7. A livestock ear tag information processing system, characterized in that, The system implements the method as described in any one of claims 1-6, and the system comprises the following parts: Data Acquisition and Preprocessing Module: Responsible for acquiring raw ear tag images through a high-definition camera in the cattle passage; this module preprocesses the acquired images, including random cropping, translation, etc. Noise reduction, blur transformation, scale normalization, and image segmentation improve data quality and model robustness; Feature extraction module: Inputs the preprocessed image The encoder adaptively extracts multi-scale, hierarchical ear tag features from images through a self-attention mechanism; This module is better able to model long-range dependencies and has stronger feature representation and generalization capabilities; Decoding module: Introduction Explicitly model the existing ear tag encoding rules and character combination patterns of the farm to provide... It provides strong reasoning guidance, improving the accuracy and consistency of identification; End-to-end training module: Training is conducted using a joint end-to-end approach. encoder and By maximizing the parameters of the joint probability learning model, the two modules can promote each other and work together. Inference and prediction module: In practical applications, the input ear tag image is first processed using... Extract features, then use The character categories are decoded and then concatenated in order to form the complete ear tag number.

8. A computer storage medium for processing livestock ear tag information, characterized in that, The computer storage medium is used to store instructions and data for running the method according to any one of claims 1-6, including a model storage area for storing trained models. Model and The model, including its structure and parameter weights; The model should be converted to a production-ready format and optimized as necessary. Data storage areas include: raw image database, preprocessed image database, and ear tag character annotation database; The database needs to support high concurrency access and fast retrieval, and adopt a distributed storage architecture to ensure data security; Cache storage area: Used to store intermediate results during image processing, such as feature maps and temporary probability distribution data. High-speed caching is used to improve processing efficiency. Configuration storage area: Stores various configuration files required for the system to run, including adjustable configuration items for model hyperparameters, preprocessing parameters, and inference parameters; Log storage area: Records system running status, identification results, and error information running logs, and supports hierarchical log storage and periodic cleanup mechanisms.

Citation Information

Patent Citations

  • Neural network-based epidemic prevention ear tag identification method

    CN114255382A

  • Cow ear tag identification system

    CN115171156A

  • Image recognition method and data processing method for image recognition

    CN116109896A