Livestock ear tag information processing method and system and storage medium
By integrating vision, and using self-attention mechanism and prior knowledge explicit modeling, the problems of inconsistent image quality and noise interference in harsh environments in earmark recognition are solved, and higher recognition accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411786369.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-12-06
AI Technical Summary
In the ear tag identification, it is difficult to effectively deal with the problems of different quality of ear tag images, large noise interference, and lack of semantic expression capabilities of manual features in ear tag identification, resulting in insufficient recognition accuracy and robustness.
A new ear mark recognition method that integrates vision and and is adopted to automatically learn multi-scale and multi-angle features of ear marks from the data through self-attention mechanism, and introduce prior knowledge such as ear mark encoding rules, explicitly model and constraint feature extraction to improve recognition accuracy.
It significantly improves the intelligence, robustness and accuracy of ear tag recognition, and can more effectively process ear tag images under complex and harsh conditions, improving the information management efficiency of the farm.
Smart Images

Figure CN119672494A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of ear tag information processing technology, and in particular to a livestock ear tag information processing method, system and storage medium. Background Art
[0002] Ear tags are an important means of information management of animal husbandry. In large-scale farms, each animal is given a unique ear tag when it is born, which records its identity information such as date of birth, breed pedigree, and immune status. This information accompanies the animal throughout its life and becomes the basis for disease prevention and control, production management, product traceability, and other work.
[0003] However, due to the complexity and variability of the breeding environment, ear tags are prone to physical damage such as fading, staining, and deformation, making the number information on them difficult to recognize, which brings great inconvenience to information entry. The traditional manual transcription method is not only inefficient and has a high error rate, but also difficult to cope with tens of thousands of livestock individuals, becoming a bottleneck in the process of breeding informatization.
[0004] To solve this problem, automated ear tag recognition technology has emerged. Its main idea is to detect and identify the ear tag area and number in the image through machine vision, thereby replacing the human eye to complete information entry. However, the quality of ear tag images varies, which places high demands on the intelligence and robustness of the algorithm.
[0005] Optical Character Recognition (OCR) ) is a technology that converts text content in an image into a computer-editable character sequence, which is widely used in document processing, license plate recognition and other fields. The method usually adopts artificially designed feature extraction algorithms such as , etc. to detect and describe the text area in the image, and then use support vector machine ( )、Nearest Neighbor( ) and other classifiers for recognition. This type of method works well on printed text images, but its performance is often greatly reduced when it comes to ear tag images in livestock breeding environments.
[0006] First, the poor breeding environment leads to uneven quality of ear tag images, with widespread noise interference such as distortion, blur, shadow, and occlusion. Traditional methods find it difficult to accurately locate the position of characters. Second, manually designed features lack semantic expression capabilities and cannot depict the fine structure of characters. When characters are diverse in form, the recognition rate is low. Third, the numbers and letters on the ear tags are compactly arranged, and there may be irrelevant text such as farm logos. A simple character-by-character recognition method lacks contextual information and is prone to errors. In short, the irregularity of ear tag characters gives The generalization ability of technology poses a challenge.
[0007] In recent years, Deep learning methods represented by have emerged in the field of computer vision. Through end-to-end feature learning, the limitations of manual features are overcome. It has achieved performance that exceeds that of humans in large-scale image classification tasks such as . This has brought new opportunities for the ear tag recognition problem. Inspired by this, the industry has begun to Applied to the ear tag recognition problem, a series of works have attempted to Applied to ear tag positioning and identification.
[0008] For example, patent document CN114255382A proposes a neural network-based ear tag recognition method for epidemic prevention. This method is a neural network-based ear tag recognition method for epidemic prevention, which implements an algorithm based on a convolutional neural network to recognize the ear tag, thereby realizing rapid recognition of the ear tag number through mobile devices such as mobile phones and tablets with cameras, reducing the difficulty of collecting ear tag information.
[0009] Patent document CN115171156A proposes a cow ear tag identification system. The technical effect of ear tag recognition is achieved by using technical means such as the bull head extraction model, color threshold method, CPTN algorithm text detection model and CRNN algorithm text recognition model.
[0010] although and its variants ( etc.) have shown certain advantages in ear tag recognition tasks, but there are still some shortcomings that are difficult to overcome. The features extracted by and its variants are mainly concentrated in the local receptive field, lacking the ability of global semantic modeling and unable to effectively capture the regularity of ear tag encoding. It and its variants are a purely data-driven learning paradigm, and its generalization ability is limited by the training data, making it difficult to fully utilize the prior knowledge of ear tag numbers. In addition, existing work mainly focuses on the frontal images of ear tags under ideal conditions, and lacks systematic research on various complex images under harsh environments.
[0011] In addition, in recent years Models based on this architecture are also widely used in fields such as image recognition. It is a neural network model based on the self-attention mechanism. It was originally applied in the field of natural language processing and has achieved remarkable results in tasks such as machine translation and language modeling. and etc. models, It can better model long-distance dependencies and has stronger feature expression and generalization capabilities. On this basis, some scholars have proposed ( ) model, in The classification task achieved the same Since then, a series of works have further improved The architecture and training method of , expand its application range. This inspires us to use visual Automatically learn ear tag features from data to overcome Innate limitations.
[0012] on the other hand, It is a reasoning tool based on probabilistic graphical models. It is good at expressing the causal dependency between things and is widely used in fault diagnosis, risk assessment and other fields. Through the directed acyclic graph ( ) describes the conditional dependency structure between variables, and uses the conditional probability table ( ) quantifies the strength of this dependence, thereby enabling probabilistic reasoning and decision-making.
[0013] Although existing methods for ear tag recognition have made progress under certain conditions, they still need to be further improved in terms of algorithm intelligence, data adaptability, and recognition accuracy.
[0014] In view of the above shortcomings, the present invention proposes a fusion and A new ear tag recognition method. Its innovations are: 1) using Excellent feature extraction and relationship modeling capabilities, automatically learning the multi-scale and multi-angle features of ear tags from a data-driven perspective; 2) Introduction Model the intrinsic relationship between ear tag numbers and make full use of the prior knowledge of numbers and letters in ear tag coding rules to improve recognition accuracy;
[0015] That is to say, the present invention innovatively integrates visual and These two advanced AI technologies synergistically enhance the expression and recognition of ear tag features from both data-driven and knowledge-guided perspectives. Summary of the invention
[0016] In order to solve the problem mentioned in the background technology, the present invention proposes a method for processing livestock ear tag information, which comprises the following steps: Step 1: Construction of livestock ear tag information dataset: Step 1.1: Data collection. Use a high-definition camera to collect the original ear tag image in the cattle channel. The image specifications are Pixels, Color mode. Represents the width and height of the image in pixels; Represents the three color channels: red, green, and blue.
[0017] Step 1.2: Data annotation. The annotation content includes: 1) Bounding box coordinates ; 2) Ear tag number character sequence .in, Represents the coordinates of the upper left corner of the bounding box; Represents the coordinates of the lower right corner of the bounding box; Representative characters.
[0018] Step 2: Preprocessing of livestock ear tag information data: Step 2.1: Image enhancement. Perform random cropping, translation, Gaussian noise, blur and other transformations , generate enhanced image .in, Represents the original RGB image; Represents the image enhancement transformation function.
[0019] Step 2.2: Scale normalization. Crop the marked ear area from the original image and scale it to a fixed size. , then fill to , get the normalized image .in, and They represent the normalized ear tag area size and the padded image size, respectively.
[0020] Step 2.3: Image segmentation. Use semantic segmentation model Will The foreground (ear label area) and background are separated to obtain a binary mask The final input image .in, represents the segmentation mask; Represents matrix dot product.
[0021] Step 3: Livestock Ear Tag Information Visual Feature extraction: Step 3.1: Divide the image into blocks. Split into indivual of small pieces and flattened into a sequence .in, Represents the number of small blocks obtained by segmentation; Represents the size of each small block; Represents the length of the sequence; Represents the dimension of each vector.
[0022] Step 3.2: Position encoding. Encode the learnable position and Add together to get the input sequence with position information .in, Represents the position encoding matrix.
[0023] Step 3.3: Encoding. enter layer Encoder, get the final feature map .in, Represents the number of encoder layers.
[0024] Step 3.4: Self-attention calculation. The core of the self-attention layer is Layer Input , first calculate : ;in, Representative Layer The weights of the matrix; represent Dimension.
[0025] Then through and The attention weight is calculated by multiplying : ;in, Representative The attention matrix of the layer; Represents the scaling factor.
[0026] Finally Acts on Get output features : ;in, Representative The output feature matrix of the layer.
[0027] Step 4: Carry on decoding: Step 4.1: Build .Will Considered as observed variables, character categories Considered as a hidden variable, the following generative probabilistic graphical model is constructed: ;in, represents the posterior probability; represents the likelihood probability; represents the prior probability; Represents the evidence factor.
[0028] Step 4.2: Likelihood probability modeling. Assume that each feature vector Comply with category The multivariate Gaussian distribution of , the likelihood probability can be expressed as: ;in, and Represents categories The mean vector and covariance matrix of ; Represents the feature dimension.
[0029] Step 4.3: Prior probability estimation. Estimate the marginal probability based on the frequency of occurrence of the character in the training set Then construct the transition probability according to the farm rules .in, Representative characters The prior probability of Represents the known previous character When the current character is The conditional probability of .
[0030] Step 4.4: Inference prediction. For each position Features , calculate the posterior probability of belonging to each category, and choose the category with the largest probability as the prediction: ;in, Representative position The predicted characters; Representative position 's neighborhood.
[0031] Step 5: Perform end-to-end training of livestock ear tag information model: Step 5.1: Random sampling. Randomly sample a batch of images from the training set and the corresponding character tags .in, Represents the batch size; Representative The label sequence of each sample.
[0032] Step 5.2: Forward propagation. For each , after steps 2-4, we get the feature map and predicted probability .in, Representative The predicted class sequence of samples.
[0033] Step 5.3: Loss calculation. Based on the true label and predicted probability , calculate the negative log-likelihood loss: ;in, represent and All parameters of Representative Sample locations The real character; Represents the length of the character sequence.
[0034] Step 5.4: Backward Propagation. Calculate the loss right Gradient , and update it with the optimizer Repeat steps 5.1-5.4 until convergence.
[0035] Step 6: Conduct livestock ear tag information model test: Step 6.1: Evaluate model performance on the test set, including character recognition accuracy and character error rate : ; ;in, Represents the number of samples that are completely correctly identified; Represents the total number of test set samples; represents the total character edit distance; Represents the total number of characters.
[0036] Step 6.2: Count the recognition accuracy under different character lengths, image quality and other conditions, and draw the corresponding performance curve.
[0037] Step 6.3: Observe the performance of the model on some representative actual samples and analyze the rationality and limitations of the recognition results.
[0038] Step 7: Livestock ear tag information model deployment: Step 7.1: Convert the trained model to a format suitable for production environments (such as , etc.), and perform necessary optimizations (such as quantization, pruning, etc.) to balance the performance and efficiency of the model.
[0039] Step 7.2: Develop the corresponding reasoning procedure to , The model is encapsulated in other forms, and necessary documentation is written to facilitate external calls.
[0040] 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 dependent libraries.
[0041] Step 7.4: Perform necessary stress tests to evaluate the response speed and stability of the model in high-concurrency and high-traffic scenarios, and adjust resource configuration appropriately.
[0042] 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 comprises the following parts: Data acquisition and preprocessing module: responsible for collecting original ear tag images in the cattle channel through a high-definition camera. This module preprocesses the collected 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.
[0043] Feature extraction module: input the preprocessed image into The encoder adaptively extracts multi-scale and hierarchical ear tag features from the image through the self-attention mechanism. This module can better model long-range dependencies and has stronger feature expression and generalization capabilities.
[0044] Decoding module: import The prior knowledge of the farm’s existing ear tag coding rules, character combination rules, etc. is explicitly modeled. Provides powerful reasoning guidance to improve recognition accuracy and consistency.
[0045] End-to-end training module: training in a joint end-to-end manner Encoder and , by maximizing the joint probability to learn the model parameters, the two modules can promote each other and work together.
[0046] Inference prediction module: In practical applications, the input ear label image is first Extract features and then use The character categories are decoded and finally concatenated in sequence to form a complete ear tag number.
[0047] On the other hand, we also propose a computer storage medium for livestock ear tag information processing, wherein the computer storage medium is used to store instructions and data for running the above method, including: Model storage area: used to store trained Model and Model, including model structure, parameter weights, etc. Model should be converted into a format suitable for production environment (such as , etc.), and make necessary optimizations.
[0048] Data storage area: including original image database, pre-processed image database, ear label character annotation database, etc. The database needs to support high concurrent access and fast retrieval, and adopt a distributed storage architecture to ensure data security.
[0049] Cache storage area: used to store intermediate results in the image processing process, such as feature maps, probability distribution and other temporary data, using high-speed cache to improve processing efficiency.
[0050] Configuration storage area: stores various configuration files required for system operation, including model hyperparameters, preprocessing parameters, inference parameters, and other adjustable configuration items.
[0051] Log storage area: records system operation status, identification results, error information and other operation logs, and supports log hierarchical storage and regular cleanup mechanism.
[0052] The beneficial technical effects of the present invention include: Compared with traditional methods, the method of the present invention can complete the task of farm ear tag informatization more intelligently, efficiently and accurately, provides important technical support for the construction of smart animal husbandry, and has broad application prospects.
[0053] Although the existing methods for ear tag recognition have made progress under certain conditions, they still need to be further improved in terms of algorithm intelligence, data adaptability, and recognition accuracy. and These two advanced artificial intelligence technologies synergistically enhance the expression and recognition of ear tag features from the perspectives of data-driven and knowledge-guided. Compared with existing work, the method of the present invention has unique advantages in the following aspects:
[0054] 1) Utilize The powerful feature extraction and relationship modeling capabilities of the algorithm can adaptively learn multi-scale and multi-angle ear tag visual features without manual design, greatly improving the intelligence and robustness of the algorithm.
[0055] 2) Introduction The prior knowledge of ear tag coding rules and character combination rules of livestock farms is explicitly modeled. It provides powerful reasoning guidance, which to some extent makes up for the shortcomings of pure data-driven methods. DETAILED DESCRIPTION
[0056] The present invention is further explained in detail below. and The ear tag recognition method mainly includes four parts: data set construction, data preprocessing, Coding and Decoding. The dataset construction module is responsible for collecting and annotating real ear tag image data to provide support for subsequent model training. The data preprocessing module performs a series of enhancement and normalization operations on the original image to improve data quality and model robustness. The encoding module uses the self-attention mechanism to adaptively extract multi-scale and multi-angle ear landmark features from the image. The decoding module integrates prior knowledge such as farm ear tag coding rules to The extracted features are constrained and enhanced, and the final character recognition results are output. Each module will be described in detail below.
[0057] In order to enable the ear tag recognition model to truly learn and reflect the actual scene of the farm, this paper selects a large-scale farm as the data collection object, and continuously collects images of cattle entering and leaving the farm through high-definition cameras installed in the livestock pen passage. The original image specifications are Pixels, The color mode covers individuals of multiple breeds (such as Holstein, Limousin, Charolais, etc.) and growth stages (such as calves, growing cattle, adult cattle, etc.), as well as images of various situations such as different shooting angles (front, side, back), imaging quality (clear, blurred, occluded), and lighting conditions (daytime, nighttime, backlight). The data scale and diversity far exceed existing public datasets.
[0058] For positioning, manually select the boundary coordinates of the ear mark in the annotation software During recognition, the text within the bounding box is annotated character by character. Possible character sets include , , as well as , , etc. separator.
[0059] In order to further improve the quality and richness of data, this paper designs a systematic data preprocessing process based on the labeled data, which mainly includes the following steps: 1) Image enhancement. In view of the harsh shooting environment of the farm, data enhancement is used to simulate various image quality degradation situations, thereby improving the robustness of the model. Specifically, the amount of data is expanded by using transformations such as cropping, translation, adding Gaussian noise, and blurring.
[0060] 2) Scale normalization. Due to the variable spatial position relationship between the cow and the camera, the size of the ear tag in the image varies greatly, which is not conducive to subsequent feature extraction. Therefore, according to the marked ear tag bounding box, the ear tag area is scaled to a uniform size ( ), and then pad to a fixed input size ( ).
[0061] 3) Image segmentation. Ear tag images often contain a lot of irrelevant background, which increases the difficulty of recognition. Automatic segmentation of the ear tag area is achieved, further reducing the interference of invalid information.
[0062] After the above preprocessing, the scale, quality and diversity of the data set have been greatly improved, which provides a basis for the subsequent Feature extraction and The reasoning laid a solid foundation.
[0063] use The earmark feature extraction is performed in order to adaptively learn the multi-scale and multi-angle feature representation of earmark numbers and letters.
[0064] Specifically, the present invention adopts structure, the preprocessed The ear tag image is evenly divided into indivual small pieces and tile them into one In order to introduce position information, a learnable position code is added to the feature vector of each small block. Next, the serialized ear tag features are input into , which contains multiple identical , each By self-attention ( ) and feed-forward networks ( ) consists of two sub-layers, and also sets ( ) and residual connections.
[0065] Feature aggregation is achieved by calculating the attention weights between different positions. Specifically, given an input sequence , first generate through linear transformation matrix , matrix and matrix : ;in, is the learnable weight matrix, for , , Next, by calculating and The dot product of and normalized to get the attention matrix : ; Each element in Indicates location To location Finally, Application Get the aggregated feature representation : ; The self-attention layer can dynamically focus on the correlation between different regions, thereby realizing the transmission and fusion of global information. The present invention uses a variant of multi-head self-attention. Enter separately It uses an independent self-attention layer and then concatenates the outputs of each head to capture richer features.
[0066] go through indivual 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 conducive to describing the fine structure and contextual association of ear mark characters. It should be pointed out that All parameters in the proposed method are data-driven and end-to-end learned, avoiding the limitations of manual design.
[0067] although It is able to adaptively learn ear tag features from data, but its feature extraction process is unsupervised and purely data-driven.
[0068] To further enhance The extracted features are made to conform to the prior rules of ear mark characters. As a decoder, it models the farm’s existing ear tag coding knowledge in the form of a probability graph and guides Modification and identification of features.
[0069] Specifically, remember The feature map output by the last layer is ,in is the number of eigenvectors. Will Considered as observed variables, character categories is considered as a hidden variable, where The number of character types. The goal is to calculate the posterior probability , indicating that the observed feature The following characters are the conditional probabilities of each category. Theorem, the posterior probability can be decomposed into: ;in, is the likelihood probability, is the prior probability, is the evidence factor, which can be regarded as a normalizing constant. Prior probability It reflects the marginal distribution of the character category and can be estimated based on the frequency of the character appearing in the ear tag number. It describes the conditional distribution of observed features generated by a given character category, and uses multivariate Gaussian distribution modeling: ;in, is the feature dimension, and Respectively The mean vector and covariance matrix of can be obtained by maximum likelihood estimation.
[0070] In the inference phase, for each position The eigenvector of , Calculate the posterior probability of belonging to each character category and select the category with the highest probability as the prediction result: In order to further use the prior knowledge of the farm to guide the reasoning process, the present invention Some additional constraint edges are introduced. For example, For location The neighborhood of the farm can be used to construct the conditional probability according to the character combination rules of the farm. , which means that in the neighborhood character is On-premise location The characters are Therefore, the inference formula can be expanded to: This decoding method that integrates prior knowledge enables the model to not only rely on local visual features when recognizing characters, but also consider the contextual associations between characters, thereby improving the accuracy and consistency of recognition.
[0071] The following joint end-to-end training is adopted and , the specific process is as follows: 1) Randomly crop the preprocessed ear tag image The area is used as a training sample and the corresponding character label is generated ,in For the The character class at position .
[0072] 2) Input the image area Extract features and get feature maps .
[0073] 3) by is the observed variable, is the supervisory signal, by maximizing the joint probability Learn the model parameters. The loss function is defined as: ;in for and Parameters, is the number of training samples, For the Sample No. Character labels for positions.
[0074] 4) Update through back propagation algorithm and The above process is iterated until convergence.
[0075] In the inference phase, for each ear tag image, we first use Extract features and then use The character category of each position is obtained by decoding and concatenated in sequence to form a complete ear tag number.
[0076] In general, the fusion Coding and The decoding method is innovative in the following aspects: 1) The powerful feature extraction capability of the CNN is used to adaptively learn multi-scale and 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.
[0077] To fully evaluate the integration and In order to investigate the performance of ear tag recognition methods in real scenarios, the present invention has conducted extensive experimental research on a large-scale ear tag image dataset constructed by itself. The focus is on the following issues: 1) Can this method surpass existing methods in terms of overall recognition accuracy? etc.; 2) How well does this method adapt to ear tag images of different difficulty levels (such as incomplete, damaged, blurred characters, etc.); 3) Fusion Coding and The necessity and feasibility of decoding; 4) The impact of factors such as prior knowledge and data enhancement on the recognition rate.
[0078] The present invention uses a self-constructed large-scale real ear tag image dataset, which originates from a large-scale dairy farm and is captured in the cattle channel using a high-definition camera. After labeling and quality screening, images with character-level annotations are finally obtained. Each image corresponds to a 10-digit ear tag number (a mixture of letters and numbers).
[0079] We randomly divide the data set into The training set is used for model training and parameter learning, the validation set is used for hyperparameter selection and early stopping strategy, and the test set is used to evaluate the generalization performance of the model. In addition, we select There are three representative sets of difficult examples, namely: 1) occlusion subset, including images with partial occlusion and missing edges; 2) blur subset, including images with motion blur and out-of-focus blur; 3) contamination subset, including images with stains, scratches, and fading. The subsets are used to examine the robustness of the model under harsh conditions.
[0080] The present invention adopts the character recognition accuracy ( ) and character error rate ( ) Two indicators are used to evaluate the model performance. is the total number of test set samples, To completely identify the correct number of samples, is the sum of the character edit distances, is the total length of characters, then the two indices are defined as: ; ;in, Measures the proportion of ear tag numbers that are recognized as whole pairs. Measures the average number of character errors per number. The higher, The lower it is, the better the model performance is.
[0081] The present invention Encoder uses Architecture, the input image size is . A tree structure is used, where each character node is connected to the previous and next character nodes, and the prior probability is estimated based on the character frequency. Optimizer, batch size is The initial learning rate is , the weight decay coefficient is .
[0082] First, we compare the overall recognition accuracy of our method with the following baseline methods: 1) ,use Architecture; 2) ,use Architecture; 3) ,use Architecture; 4) , only use Coding and Table 1 shows the performance of each method on the test set and A collection of difficult examples and index.
[0083] Table 1 Performance comparison of various methods on ear tag recognition tasks: ; As can be seen from Table 1, the fusion and The method of is significantly better than other baselines in all indicators, especially in the case of bad samples. The method of the present invention The indicators have been significantly improved, from 94.0% to 96.5% (an increase of 2.5 percentage points) on the Occ. subset, from 83.1% to 90.7% (an increase of 7.6 percentage points) on the Blur. subset, and from 87.9% to 92.6% (an increase of 4.7 percentage points) on the Dmg. subset. The method of the present invention is also superior to ,average From 5.79% to 4.25% (a decrease of 1.54 percentage points). and based on The method performs poorly when processing various samples, especially on the Blur. subset. Only 78.5% and 80.2%, far lower than 90.7% of the method of the present invention. This shows that the fusion of $\text{Bayesian} reasoning 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 of the present invention. Reasoning can significantly improve the robustness of recognition, thanks to the guidance of prior knowledge. and The method is easily affected by noise.
[0084] In order to understand the internal mechanism of the method in more detail, we designed a series of experiments to examine the impact of each module. Specifically, we compared the following Configuration: 1) ,Right now ; 2) ,exist Add on the basis Decoding; 3) ,exist Add data enhancement on the basis; 4) , which is the complete method of the present invention. Table 2 shows the performance comparison of each configuration on the test set.
[0085] Table 2 Module comparison: ; It can be seen that whether joining Decoding or data enhancement, both can be given brings considerable performance improvements, but the best effect is achieved when the two are used together. and Higher than and percentage points. Decoding contributes more and can be used independently improve percentage points, which fully reflects the guiding role of prior knowledge. The role of data enhancement is relatively minor, but Decoding complementarity can further improve the generalization of the model. The above experiments show that Coding and Decoding is the two important pillars of the method of the present invention, and both are indispensable, and together they constitute an efficient and robust ear tag recognition system. This also verifies the uniqueness of the present invention in the comprehensive use of data-driven and knowledge-guided.
[0086] Finally, we explored the impact of different types of prior knowledge on the recognition effect. Table 3 compares The effects of three types of knowledge are added: character frequency, character combination, and farm rules.
[0087] Table 3 The impact of different types of prior knowledge on recognition effect ; As can be seen from Table 3, Incorporating prior knowledge of different granularities into the model has a significant effect on improving model performance. on for , than pure Baseline above percentage points, indicating that the prior distribution of characters has a certain guiding role in recognition. On this basis, adding character combination rules (such as letters cannot appear continuously, numbers must meet the increasing trend, etc.) can make the test set and difficult samples Respectively increased to and , average improvement This shows that the constraints between characters can help correct some recognition errors, especially under poor image quality. Furthermore, if the farm-specific ear tag coding knowledge (such as the number of digits, the relative position of letters and numbers, etc.) is incorporated, the accuracy of the test set and difficult samples will be improved. Can reach and , again slightly improved Correspondingly, It also gradually decreases with the integration of prior knowledge, and finally reaches , than simply Reduced percentage points, a decrease of .
[0088] In order to more intuitively present the practical value of the method of the present invention, we compared it with manual recognition. Specifically, a number of images were randomly selected from the test set and respectively handed over to a number of skilled workers for annotation, and their average recognition time and accuracy were recorded. At the same time, the automatic recognition system of the present invention was used to predict these images. The results are shown in Table 4.
[0089] Table 4 Comparison of efficiency and accuracy between manual and automatic recognition: ; It can be seen that the automatic recognition system of the present invention has an overwhelming advantage in recognition efficiency, and only needs Seconds, is the artificial speed times. This means that in the same amount of time, the processing capacity of the automatic identification system is At the same time, the automatic recognition system is slightly more accurate than the manual recognition system. percentage points, thanks to the advantages of the machine in recognizing character details and comparing information. In addition, long-term, high-intensity, repetitive manual labor can easily lead to visual and judgment fatigue, and then cause misidentification. In summary, the automated intelligent recognition system of the present invention can greatly improve the efficiency of ear tag informatization in farms, reduce labor costs and error risks, and has great practical value and promotion potential. This also fully confirms the application significance of the work of the present invention.
[0090] In summary, large-scale experiments and multi-angle evaluations show that the present invention combines visual and The method showed excellent performance in the livestock ear tag recognition task, with an overall recognition accuracy of up to , and has good robustness even in challenging scenarios. coding, The synergistic mechanism of decoding, data enhancement and other modules. By comparing with manual recognition, it is verified that this method can significantly improve the operating efficiency in practical applications and has broad application prospects. This provides important technical support for the information management of smart livestock farms.
[0091] Aiming at the problem of automatic collection of ear tag information in the process of animal husbandry, the present invention proposes an innovative fusion and identification method. Adaptively extract multi-scale, hierarchical feature representations from ear tag images, and then introduce The character combination rules, coding knowledge and other prior information of the network modeling farm are The output features of the proposed method are constrained and enhanced, and the recognition process is optimized from two levels: data-driven and knowledge-guided. Experiments on a large-scale real ear tag image dataset constructed by ourselves show that the accuracy and robustness of the proposed method on various difficult recognition examples are significantly better than those of existing methods. and method, and can process massive amounts of data at a speed far exceeding that of manual labor. Ablation studies further reveal Coding and Decode the intrinsic mechanism and implementation points of this fusion mechanism.
[0092] The main innovations of this invention are: 1) It is the first to introduce and These two It overcomes the limitation of traditional methods in generalization ability for complex scenarios; 2) creatively and These efforts have made useful attempts to develop agricultural artificial intelligence and promote the construction of smart animal husbandry.
Claims
1. A method for processing livestock ear tag information, characterized in that: The method comprises the following steps: Step 1: Construction of livestock ear tag information dataset; Step 2: Preprocessing of livestock ear tag information data; Step 3: Livestock Ear Tag Information Feature extraction; Step 4: Carry on decoding; Step 5: Perform end-to-end training of livestock ear tag information model; Step 6: Conduct livestock ear tag information model testing; Step 7: Livestock ear tag information model deployment.
2. A livestock ear tag information processing method according to claim 1, characterized in that: The step 1 specifically includes: Step 1.1: Data collection: Use a high-definition camera to collect the original ear tag image in the cattle channel. The image specifications are Pixels, Color mode; where Represents the width and height of the image in pixels; Represents the three color channels of red, green and blue; Step 1.2: Data annotation; the annotation content includes: 1) Bounding box coordinates ; 2) Ear tag number character sequence ;in, Represents the coordinates of the upper left corner of the bounding box; Represents the coordinates of the lower right corner of the bounding box; Representative characters.
3. The method for processing livestock ear tag information according to claim 1, characterized in that: The step 2 specifically includes: Step 2.1: Image enhancement; for the original image Perform random cropping, translation, Gaussian noise, and blur transformation , generate enhanced image ;in, Represents the original RGB image; represents the image enhancement transformation function; Step 2.2: Scale normalization: crop the marked ear area from the original image and scale it to a fixed size , then fill to , get the normalized image ;in, and represent the normalized ear tag area size and the padded image size, respectively; Step 2.3: Image segmentation; using semantic segmentation model Will The foreground (ear label area) and background are separated to obtain a binary mask ; Final input image ;in, represents the segmentation mask; Represents matrix dot product.
4. A livestock ear tag information processing method according to claim 1, characterized in that: The step 3 specifically includes: Step 3.1: Divide the image into blocks; Split into indivual of small pieces and flattened into a sequence ;in, Represents the number of small blocks obtained by segmentation; Represents the size of each small block; Represents the length of the sequence; Represents the dimension of each vector; Step 3.2: Position encoding: Encode the learnable position and Add together to get the input sequence with position information ;in, represents the position encoding matrix; Step 3.3: Encode; enter layer Encoder, get the final feature map ;in, Represents the number of layers of the encoder; Step 3.4: Self-attention calculation; The core of the self-attention layer is Layer Input , first calculate : ; in, Representative Layer The weights of the matrix; represent Dimensions; Then through and The attention weight is calculated by multiplying : ; in, Representative The attention matrix of the layer; represents the scaling factor; Finally Acts on Get output features : ; in, Representative The output feature matrix of the layer.
5. The method for processing livestock ear tag information according to claim 1, characterized in that: The step 4 specifically includes: Step 4.1: Build ;Will Considered as observed variables, character categories Considered as hidden variables, the following generative probabilistic graphical model is constructed: ; in, represents the posterior probability; represents the likelihood probability; represents the prior probability; represents the evidential factor; Step 4.2: Likelihood probability modeling; assume that each feature vector Comply with category The multivariate Gaussian distribution of , the likelihood probability can be expressed as: ; in, and Represents categories The mean vector and covariance matrix of ; Represents the feature dimension; Step 4.3: Prior probability estimation; estimate the marginal probability based on the frequency of occurrence of the character in the training set ; Then construct the transfer probability according to the farm rules ;in, Representative characters The prior probability of Represents the known previous character When the current character is The conditional probability of Step 4.4: Inference prediction; for each position Features , calculate the posterior probability of belonging to each category, and choose the category with the largest probability as the prediction: ; in, Representative position The predicted characters; Representative position 's neighborhood.
6. A livestock ear tag information processing method according to claim 1, characterized in that: The step 5 specifically includes: Step 5.1: Random sampling: randomly sample a batch of images from the training set and the corresponding character tags ;in, Represents the batch size; Representative The label sequence of each sample; Step 5.2: Forward propagation: For each , after steps 2-4, we get the feature map and predicted probability ;in, Representative The predicted category sequence of samples; Step 5.3: Loss calculation: based on true labels and predicted probability , calculate the negative log-likelihood loss: ; in, represent and All parameters of Representative Sample locations The real character; Represents the length of the character sequence; Step 5.4: Backward Propagation: Calculating Loss right Gradient , and update it with the optimizer ; Repeat steps 5.1-5.4 until convergence.
7. A livestock ear tag information processing method according to claim 1, characterized in that: The step 6 specifically includes: Step 6.1: Evaluate model performance on the test set, including character recognition accuracy and character error rate : ; ; in, Represents the number of samples that are completely correctly identified; Represents the total number of test set samples; represents the total character edit distance; Represents the total number of characters; Step 6.2: Count the recognition accuracy under different character lengths and image quality conditions, and draw the corresponding performance curve; Step 6.3: Observe the performance of the model on some representative actual samples and analyze the rationality and limitations of the recognition results.
8. The method for processing livestock ear tag information according to claim 1, characterized in that: The step 7 specifically includes Step 7.1: Convert the trained model into a format suitable for production environment and optimize it; Step 7.2: Develop the corresponding reasoning procedure to , Formally encapsulate the model and write necessary documentation to facilitate external calls; Step 7.3: Deploy the model to a specific device or cloud platform; Step 7.4: Perform necessary stress tests to evaluate the response speed and stability of the model in high-concurrency and high-traffic scenarios, and adjust resource configuration appropriately.
9. A livestock ear tag information processing system, characterized in that: The system consists of the following parts: Data acquisition and preprocessing module: responsible for collecting original ear tag images in the cattle channel through high-definition cameras; this module preprocesses the collected images, including random cropping, translation, Noise, blur transformation, as well as scale normalization and image segmentation to improve data quality and model robustness; Feature extraction module: input the preprocessed image into The encoder adaptively extracts multi-scale and hierarchical ear landmark features from the image through a self-attention mechanism; This module can better model long-range dependencies and has stronger feature expression and generalization capabilities; Decoding module: import The farm’s existing ear tag coding rules and character combination rules prior knowledge are explicitly modeled. Provide powerful reasoning guidance to improve recognition accuracy and consistency; End-to-end training module: training in a joint end-to-end manner Encoder and ,By maximizing the joint probability of learning the model parameters, the two modules can promote each other and work together; Inference prediction module: In practical applications, the input ear label image is first Extract features and then use The character categories are decoded and finally spliced in order to form a complete ear tag number; the system implements the method as described in any one of claims 1-8.
10. A computer storage medium for livestock ear tag information processing, characterized in that: The computer storage medium is used to store instructions and data for running the method described in any one of claims 1 to 8, including a model storage area: for storing trained Model and Model, including model structure and parameter weight information; The model should be converted to a format suitable for production environments (such as , ), and make necessary optimizations; Data storage area: including original image database, pre-processed image database, ear mark character annotation database; The database needs to support high concurrent access and fast retrieval, and adopt a distributed storage architecture to ensure data security; Cache storage area: used to store intermediate results in the image processing process, such as feature maps and temporary probability distribution data, and use high-speed cache to improve processing efficiency; Configuration storage area: various configuration files required for the storage system operation, including model hyperparameters, preprocessing parameters, and inference parameter adjustable configuration items; Log storage area: records system operation status, identification results, error information operation logs, and supports log hierarchical storage and regular cleanup mechanisms.
Citation Information
Patent Citations
Neural network-based epidemic prevention ear tag identification method
CN114255382A
Livestock image instance segmentation method based on improved Transform
CN115115830A
Cow ear tag identification system
CN115171156A
Image recognition method and data processing method for image recognition
CN116109896A
Image processing method and apparatus, storage medium, and electronic device
WO2023098912A1