A deep wavelet transform based on attention mechanism gait detection method for dairy cows
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-29
- Publication Date
- 2026-08-11
AI Technical Summary
但完全可学习深度小波变换虽然将小波本身参数化且可训练,但小波最基本的性质,如能量归一化特性、双尺度关系特性被弱化甚至完全舍弃,使得学习后的变换框架退化为一般滤波器组,这降低了特征可解释性
[0033]This invention provides a method for detecting lameness in dairy cows based on deep wavelet transform with an attention mechanism. The method includes: acquiring the walking and weighing signal of a target dairy cow; introducing an attention mechanism into a fully learnable wavelet to construct a deep wavelet transform module with an attention mechanism; constructing a feature selection network and fusing the deep wavelet transform module with the feature selection network to obtain a lameness detection network; and inputting the walking and weighing signal into the lameness detection network to obtain the detection result. This invention not only improves the accuracy of detection but also, due to its low computational resource requirements, can be easily integrated into existing farm management systems, providing a more efficient and economical technical solution for dairy cow health management.
Smart Images

Figure CN117786397B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method for detecting lameness in dairy cows based on depth wavelet transform with an attention mechanism. Background Technology
[0002] Lameness is a common disease in dairy cows, caused by mechanical damage (unequal terrain), foot rot, or malnutrition. Lameness increases veterinary costs and culling rates, and reduces milk production and economic benefits. Early detection and prevention of lameness are crucial in dairy farming. Dynamic weight measurement systems often employ multi-degree-of-freedom dynamic systems to reduce errors caused by bias. In 2006, Rajkondawar tested the weight-bearing capacity of the left and right legs of dairy cows in a direction perpendicular to the horizontal test plate, thus obtaining single-leg weight-bearing capacity. Since lameness causes pain and reluctance to exert force, single-leg weight-bearing capacity can be used to determine the degree of lameness. Walker and Zillner further studied the relationship between walking speed and lameness from a kinematic and dynamic perspective. There is also considerable domestic research on lameness detection based on pressure sensors. For example, Yang Lijuan et al. constructed a pressure-sensitive walkway and analyzed a bovine gait simulation device, laying the foundation for early lameness detection in dairy cows. Cows can be viewed as dynamic systems, making the use of three-dimensional accelerometers for gait and pathological analysis, as well as behavioral recognition, an important option. Accelerometers are small and lightweight, and can be fixed to different parts of the cow as needed. Pastell et al. used a wireless three-dimensional accelerometer system to collect gait characteristics of cows, calculating the variance of each axis, wavelet variance, and synthesized velocity. Sulide used accelerometers to conduct research on gait feature extraction and early lameness prediction in cows. Another facility that can be used for lameness detection in cows is the Inertial Measurement Unit (IMU), which consists of three single-axis accelerometers and three single-axis gyroscopes. After processing the detected acceleration and angular velocity signals, the posture of the object can be calculated. IMUs are small and lightweight, and are often designed as wearable devices. With optimal wearing positions, their application in the diagnosis and rehabilitation of gait disorders is increasing. Although high-sensitivity wearable sensors can measure the impact of activity on various physiological indicators, their use in cow measurements is relatively expensive. Compared to dynamic weight measurement methods, lameness detection emphasizes weighing a single leg, placing higher demands on the design and layout of pressure sensors and resulting in a more complex model. Similar to dynamic weighing methods, it also requires filtering and discarding high-frequency information from the measurement signal. However, neither method considers the impact of cow activity levels caused by medical conditions or emotional states; such activity is often multi-scale. Multi-scale analysis of high-frequency information is crucial for early prediction of lameness.
[0003] Chaotic characteristics have been found in the high-frequency information of cow weight signals, indicating that these signals possess complex and unpredictable dynamics. Fully learnable deep wavelet transforms can achieve full learnability of wavelet basis functions based on data features, sensitively capturing anomalous patterns in weight signals, which is particularly important in chaotic systems. However, while fully learnable deep wavelet transforms parameterize and train the wavelet itself, the most fundamental properties of wavelets, such as energy normalization and dual-scale relationships, are weakened or even completely discarded, causing the learned transform framework to degenerate into a general filter bank, which reduces feature interpretability. Furthermore, for weight signals with key local characteristics or patterns, the model may not be able to fully capture this important information. Therefore, designing a deep Shannon-Cosine wavelet transform algorithm with an attention mechanism to achieve accurate cow lameness identification has become an urgent problem to solve. Summary of the Invention
[0004] To overcome the shortcomings of existing technologies, the purpose of this invention is to provide a method for detecting lameness in dairy cows based on deep wavelet transform with an attention mechanism, which can accurately identify lameness in dairy cows.
[0005] To achieve the above objectives, the present invention provides the following solution:
[0006] A method for detecting lameness in dairy cows based on deep wavelet transform with an attention mechanism, comprising:
[0007] Acquire the moving weighing signal of the target dairy cow;
[0008] An attention mechanism is introduced into fully learnable wavelets to construct a deep wavelet transform module with an attention mechanism;
[0009] A feature selection network is constructed, and the deep wavelet transform module is fused with the feature selection network to obtain a cow lameness detection network.
[0010] The walking and weighing signal is input into the dairy cow lameness detection network to obtain the detection result.
[0011] Preferably, an attention mechanism is introduced into the fully learnable wavelet to construct a deep wavelet transform module with an attention mechanism, including:
[0012] Formulas for multi-scale adaptive interpolation wavelet decomposition and reconstruction, objective function for network training, wavelet constraints, loss function, and wavelet attention mechanism are constructed respectively.
[0013] The deep wavelet transform module is constructed based on the formula for multi-scale adaptive interpolation wavelet decomposition and reconstruction, the objective function for network training, the wavelet constraints, the loss function, and the wavelet attention mechanism.
[0014] Preferably, the formula for the multi-scale adaptive interpolation wavelet decomposition and reconstruction is as follows: Among them, u J (x) is the input signal. Let k0 be the wavelet scaling function at the j0 level scale, and let the equation be... To approximate the original input signal at the j0-level scale; ψ jk (x) represents the interpolation wavelet at scale j; α jk Let be the difference between the j-scale approximation signal and the previous-level approximation signal, i.e.:
[0015]
[0016] Preferably, the objective function is: in This refers to the mean of the 1-norm of the original input signal and the reconstructed signal. This part is used to ensure the signal reconstruction effect during training; Equation L({d 1} l∈[1..L] ,a L The specific calculation method is as follows:
[0017]
[0018] That is, all wavelet coefficients d under the common L-scale l The 1-norm and the initial coefficients a L The average value of the 1-norm. This part is used to ensure the sparsity of signal decomposition during training. The hyperparameter γ is used to adjust the sparsity; experimental verification typically uses γ = 0.5.
[0019] Preferably, the formula for the wavelet constraint is:
[0020] Where h is a low-pass filter constructed by the scaling function φ, and g is a high-pass filter constructed by the wavelet function ψ; ||h||2-1、 as well as The construction conditions are based on wavelet filters:
[0021]
[0022]
[0023] g1 = h J g2=-h J-1 g3=h J-2 ,...,g J-1 =h2,g J =-h1
[0024] The design constraint ensures the energy normalization property of the wavelet, while the addition of the squaring operation guarantees the feasibility of the gradient descent method during network backpropagation optimization.
[0025] Preferably, the formula for the loss function is:
[0026]
[0027] in This refers to the mean of the 1-norm of the original input signal and the reconstructed signal. This part is used to ensure the signal reconstruction effect during training; Equation L1({d 1} l∈[1..L] ,a L The specific calculation method is as follows:
[0028]
[0029] That is, all wavelet coefficients d under the common L-scale l The 1-norm and the initial coefficients a L The average value of the 1-norm. This part is used to ensure the sparsity of signal decomposition during training. The hyperparameter λ1 is used to adjust the sparsity; λ2 is used for wavelet energy normalization constraints and can be modified according to the model's interpretability requirements.
[0030] Preferably, the calculation formula for the wavelet attention mechanism is: Here, WaveletAttention represents the operation of the wavelet attention mechanism. Q is the query matrix, representing the information we want to know. K j V is the key matrix at scale j, representing the local features of the signal. j It is a value matrix at scale j, representing the actual information related to the signal features. The wavelet coefficients represent the local characteristics of the signal at scale j and location k; d k It is the feature dimension at each scale.
[0031] Preferably, the feature selection network is any one of support vector machine, random forest, and K nearest neighbors.
[0032] According to specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0033] This invention provides a method for detecting lameness in dairy cows based on deep wavelet transform with an attention mechanism. The method includes: acquiring the walking and weighing signal of a target dairy cow; introducing an attention mechanism into a fully learnable wavelet to construct a deep wavelet transform module with an attention mechanism; constructing a feature selection network and fusing the deep wavelet transform module with the feature selection network to obtain a lameness detection network; and inputting the walking and weighing signal into the lameness detection network to obtain the detection result. This invention not only improves the accuracy of detection but also, due to its low computational resource requirements, can be easily integrated into existing farm management systems, providing a more efficient and economical technical solution for dairy cow health management. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0035] Figure 1 A flowchart of the method provided in an embodiment of the present invention;
[0036] Figure 2 This is a schematic diagram illustrating the attention mechanism of the adaptive feature capture operation provided in an embodiment of the present invention;
[0037] Figure 3 This is a schematic diagram of the deep wavelet transform network architecture provided in an embodiment of the present invention;
[0038] Figure 4 This is an initial weight signal image set provided in the embodiments of the present invention;
[0039] Figure 5 The logarithmic spectrum of the original signal provided in the embodiments of the present invention;
[0040] Figure 6 This is an image set of abnormal high-frequency information learned by deep wavelet transform, as provided in an embodiment of the present invention.
[0041] Figure 7 A spectrum diagram of abnormal information provided in an embodiment of the present invention; Detailed Implementation
[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0043] The purpose of this invention is to provide a method for detecting lameness in dairy cows based on deep wavelet transform with an attention mechanism, which can improve the accuracy of detection.
[0044] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0045] Figure 1 The method flowchart provided in the embodiments of the present invention is as follows: Figure 1 As shown, this invention provides a method for detecting lameness in dairy cows based on deep wavelet transform with an attention mechanism, comprising:
[0046] Step 100: Obtain the moving weighing signal of the target cow;
[0047] Step 200: Introduce an attention mechanism into the fully learnable wavelet to construct a deep wavelet transform module with an attention mechanism;
[0048] Step 300: Construct a feature selection network and fuse the deep wavelet transform module with the feature selection network to obtain a cow lameness detection network;
[0049] Step 400: Input the walking weighing signal into the dairy cow lameness detection network to obtain the detection result.
[0050] Preferably, an attention mechanism is introduced into the fully learnable wavelet to construct a deep wavelet transform module with an attention mechanism, including:
[0051] Formulas for multi-scale adaptive interpolation wavelet decomposition and reconstruction, objective function for network training, wavelet constraints, loss function, and wavelet attention mechanism are constructed respectively.
[0052] The deep wavelet transform module is constructed based on the formula for multi-scale adaptive interpolation wavelet decomposition and reconstruction, the objective function for network training, the wavelet constraints, the loss function, and the wavelet attention mechanism.
[0053] Specifically, this embodiment first constructs a deep wavelet transform with an attention mechanism, as follows:
[0054] (1) The mathematical description of multi-scale adaptive interpolation wavelet decomposition and reconstruction is as follows:
[0055]
[0056] (2) An attention mechanism is introduced based on fully learnable wavelets. Fully learnable wavelets achieve good sparse decomposition and signal reconstruction by learning the optimal wavelet and scaling filter. The objective function for network training is:
[0057]
[0058]
[0059] (3) To address the lack of dual-scale relationships and energy normalization constraints in fully learnable wavelet methods, this study will further design a more restrictive loss function and add wavelet constraints:
[0060]
[0061] (4) For the wavelet part, the loss function is designed as follows:
[0062]
[0063] (5) Based on multi-scale adaptive interpolation wavelet analysis, attention weights at different scales are learned to adaptively focus on important parts of the signal at different scales, thereby more accurately capturing its inherent complexity and dynamics. The wavelet attention mechanism is calculated as follows:
[0064]
[0065] WaveletAttention represents the operation of the wavelet attention mechanism. Q is the query matrix, representing the information we want to know. K j V is the key matrix at scale j, representing the local features of the signal. j It is a value matrix at scale j, representing the actual information related to the signal features. The wavelet coefficients represent the local characteristics of the signal at scale j and location k; d k This refers to the feature dimension at each scale. This attention mechanism not only provides the model with more robust feature extraction capabilities when facing highly noisy or interfering data, but also better handles data of different lengths and scales, thereby improving its applicability in various practical applications. Deep wavelet transforms with attention mechanisms, such as... Figure 2 As shown.
[0066] Furthermore, this embodiment discloses a method for implementing a deep wavelet transform network with an attention mechanism. This network, based on parameterized Shannon-Cosine wavelets, achieves multi-scale adaptive analysis of cow walking and weighing signals. Through backpropagation, the network can autonomously learn and adjust the parameters of the Shannon-Cosine wavelet to optimize the signal analysis process. In addition, an attention mechanism is introduced and integrated into the feature selection stage, thereby improving the sensitivity and recognition accuracy of lameness features. The final deep wavelet transform network is designed, and its architecture is as follows: Figure 3 .
[0067] Furthermore, this embodiment constructs a lameness recognition system based on deep wavelet analysis with an attention mechanism. This technique uses deep wavelet analysis to extract coefficient features reflecting lameness from the weighing signals of cows walking. The introduction of a self-attention mechanism further enhances the model's sensitivity and recognition ability for lameness features. Through deep wavelet transform, this method can decompose stable and interpretable deep wavelet coefficients from the cow weight signal, providing accurate indicators for lameness recognition. Based on these indicators, a machine learning algorithm classifies the features learned from the deep wavelet transform, thereby more accurately detecting lameness anomalies.
[0068] As an optional implementation, this embodiment utilizes deep wavelet transform with an attention mechanism for signal learning and sensitive information extraction: In this invention, a deep wavelet transform algorithm with an attention mechanism is combined to refine and learn sensitive information in the signal. Deep wavelet transform is used to perform multi-scale decomposition of the signal, and the attention mechanism enhances the extraction of key features. The introduction of this mechanism allows the model to dynamically adjust its focus, optimizing the identification and extraction of features that are crucial to the final classification result. Figures 4 to 7 This embodiment demonstrates an example of high-frequency sensitive information extracted using this algorithm. In-depth analysis of these high-frequency components highlights sensitive features in the signal that might be overlooked in traditional analysis methods.
[0069] Secondly, this embodiment employs multiple machine learning classifiers, such as Support Vector Machine (SVM), Random Forest (RF), and K-Nearest Neighbors (KNN), to analyze the features extracted by deep wavelet transform. Each classifier has its unique advantages; for example, SVM performs well in handling high-dimensional data, RF is robust to noisy data, and KNN performs well on small datasets. To validate the model's effectiveness and improve the classifier's generalization ability, cross-validation is used. This means that the dataset is divided into several parts, and training and testing are performed alternately on these parts to ensure that the model has good predictive ability for unknown data.
[0070] The beneficial effects of this invention are as follows:
[0071] (1) High sensitivity of feature recognition: This technology, through the application of attention mechanism, learns attention weights at different scales and adaptively focuses on important parts of the signal at different scales. It can focus on analyzing signal features directly related to limping. Even in the case of complex and variable data, it can accurately capture the subtle signals of limping, thereby more accurately capturing its inherent complexity and dynamism.
[0072] (2) Dynamic adaptability: The dynamic adjustment function of the attention mechanism enables this technology to adapt to changes in the behavior patterns of dairy cows in real time, ensuring that a high level of recognition accuracy can be maintained even under dynamic conditions.
[0073] (3) Reduce reliance on manual labor: Due to the high degree of automation of this technology, the reliance on professional and technical personnel is greatly reduced, the operation process is simplified, and the human resource cost is reduced.
[0074] (4) Significant economic benefits: By timely and accurate identification of lameness, this technology helps to reduce the loss of productivity and medical expenses caused by lameness, bringing considerable economic benefits to the dairy farming industry.
[0075] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0076] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A deep wavelet transform based on attention mechanism for detection of lame cows, characterized in that, include: Acquire the moving weighing signal of the target dairy cow; An attention mechanism is introduced into fully learnable wavelets to construct a deep wavelet transform module with an attention mechanism; The deep wavelet transform module includes: formulas for multi-scale adaptive interpolation wavelet decomposition and reconstruction, objective function for network training, wavelet constraints, loss function, and wavelet attention mechanism; A feature selection network is constructed, and the deep wavelet transform module is fused with the feature selection network to obtain a cow lameness detection network. The walking and weighing signal is input into the dairy cow lameness detection network to obtain the detection result; The formula for the wavelet constraint is: In the formula, For the scaling function Constructed low-pass filter, For wavelet function Constructed high-pass filter; , as well as The construction conditions are based on wavelet filters: Designed; The calculation formula of the wavelet attention mechanism is: ; wherein, represents the operation of the wavelet attention mechanism; is a query matrix; is a key matrix on a scale , representing the local features of the signal; is a value matrix on a scale , representing the actual information related to the signal features; represents a wavelet coefficient, reflecting the local features of the signal on a scale and a position ; is the feature dimension on each scale.
2. The method for detecting lameness in dairy cows based on deep wavelet transform with attention mechanism according to claim 1, characterized in that, An attention mechanism is introduced into fully learnable wavelets to construct a deep wavelet transform module with an attention mechanism, including: The deep wavelet transform module is constructed based on the formula for multi-scale adaptive interpolation wavelet decomposition and reconstruction, the objective function for network training, the wavelet constraints, the loss function, and the wavelet attention mechanism.
3. The method for detecting lameness in dairy cows based on deep wavelet transform with attention mechanism according to claim 2, characterized in that, The formula for the multi-scale adaptive interpolation wavelet decomposition and reconstruction is as follows: ;in, For input signal, for Level scale The wavelet scaling function of the location, equation In order to be in Approximation of the original input signal at a scale of [number]; for Interpolation wavelets at scale; for The difference between the scale approximation signal and the previous level approximation signal, i.e.: Threshold operation To achieve the effect of self-attentional feature extraction of signals, specific values are preset or learned, and smaller weights are discarded.
4. The method for detecting lameness in dairy cows based on deep wavelet transform with attention mechanism according to claim 3, characterized in that, The objective function is: ,in This refers to the mean of the 1-norm of the original input signal and the reconstructed signal. This part is used to ensure the signal reconstruction effect during training; Equation The specific calculation method is as follows: that is, total All wavelet coefficients at the scale The 1-norm and initial coefficients The average value of the 1-norm, which is used to ensure the sparsity of signal decomposition during training; hyperparameters Used to adjust the sparsity.
5. The method for detecting lameness in dairy cows based on deep wavelet transform with attention mechanism according to claim 1, characterized in that, The formula for the loss function is: ;in This refers to the mean of the 1-norm of the original input signal and the reconstructed signal. This part is used to ensure the signal reconstruction effect during training; Equation The specific calculation method is as follows: that is, total All wavelet coefficients at the scale The 1-norm and initial coefficients The average value of the 1-norm; this part is used to ensure the sparsity of the signal decomposition during training; hyperparameters Used to adjust the sparsity; Energy normalization constraints for wavelets.
6. The method for detecting lameness in dairy cows based on deep wavelet transform with attention mechanism according to claim 1, characterized in that, The feature selection network can be any one of support vector machine, random forest, and K nearest neighbor.