A deep learning-based dairy cow behavior recognition method

By using improved high-resolution networks and hybrid graph convolutional networks, the robustness and computational complexity issues in cow behavior recognition were addressed, enabling end-to-end keypoint detection and behavior recognition, thus improving recognition accuracy and robustness.

CN122135406APending Publication Date: 2026-06-02XINJIANG UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
XINJIANG UNIVERSITY
Filing Date
2026-04-07
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies suffer from performance degradation, insufficient robustness, and high computational complexity in complex real-world farm scenarios, making them difficult to deploy in real-time in resource-constrained environments. Traditional methods lose spatial location information, have limited multi-scale perception capabilities, lack modeling of dairy cow anatomy, and disconnect between posture estimation and behavior recognition, making end-to-end feature sharing and optimization impossible.

Method used

An improved high-resolution network is used to fuse a multi-level attention mechanism, combined with a hybrid graph convolutional network. Key point detection is enhanced through efficient channel attention modules, coordinate attention modules, and efficient multi-scale attention modules. End-to-end behavior recognition is performed using a hybrid graph convolutional network.

Benefits of technology

It significantly improves the positioning accuracy of key points in dairy cows and the robustness of behavior recognition. It can adapt to different body sizes and scales in complex scenarios, achieve end-to-end posture estimation and behavior recognition, and improve recognition accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122135406A_ABST
    Figure CN122135406A_ABST
Patent Text Reader

Abstract

This invention discloses a deep learning-based method for recognizing cow behavior, comprising: S1 acquiring and preprocessing cow images; S2 inputting the images into an improved high-resolution network, which embeds an efficient channel attention module to enhance key joint features, integrates a coordinate attention module to accurately encode spatial location, and introduces an efficient multi-scale attention module to fuse multi-scale contextual information, generating a keypoint probability heatmap; S3 constructing a hybrid graph convolutional network, using the heatmap as input and constructing a spatial graph model, learning local relative motion patterns through EdgeConv and aggregating global spatial contextual information through SAGEConv, and outputting optimized node features; S4 outputting optimized two-dimensional coordinates of key points and classification results of cow behavior. This invention significantly improves the localization accuracy of cow pose estimation and the accuracy of behavior recognition in complex scenes through the synergistic enhancement of multi-level attention and hybrid graph convolution, with ablation experiments showing a recognition accuracy of 0.817.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of image recognition and analysis, specifically relating to a method for recognizing dairy cow behavior based on deep learning. Background Technology

[0002] With the development of precision farming concepts, individual dairy cow monitoring based on computer vision has become a research hotspot in smart animal husbandry. Accurate estimation of dairy cow skeletal posture is the cornerstone for achieving intelligent recognition of their key behaviors.

[0003] In the field of human pose estimation, the HRNet network achieved leading performance by constructing parallel multi-resolution subnetworks and maintaining high-resolution representation throughout the forward pass. However, its high computational complexity and memory consumption make it difficult to deploy on resource-constrained edge devices. Subsequent lightweight studies, such as Lite-HRNet, reduced the computational burden by introducing conditional channel weighting modules, but their performance was limited when dealing with extreme occlusion or complex backgrounds. With the development of the Transformer architecture, the TokenPose model proposed by Yanjie Li et al. represents each keypoint as a learnable token, explicitly capturing visual cues and structured dependencies through a self-attention mechanism. However, its requirement for large-scale data and long training cycles limits its application. In animal pose estimation, due to the scarcity of labeled data and the high morphological diversity of species, it faces even greater challenges than human pose estimation.

[0004] Existing research primarily addresses the data shortage problem by generating synthetic data from CAD models and performing self-training, unsupervised domain adaptation, or cross-domain transfer learning from human pose data. However, these methods still heavily rely on the realism of the synthetic data or are limited by the similarity between human and animal morphology, resulting in limited transfer effectiveness for structurally dissimilar species. For computationally limited scenarios, some studies have designed lightweight stacked hourglass networks and incorporated transfer learning from human pose data to reduce model complexity; however, their robustness in complex field environments may be insufficient.

[0005] However, in the process of implementing the inventive technical solution in the embodiments of this application, the inventors of this application discovered that the above-mentioned technology has at least the following technical problems:

[0006] 1) Model generalization problem: In complex scenarios of real farms (such as shading, lighting, and apparent changes), the model performance drops significantly and its robustness is insufficient.

[0007] 2) Computational complexity issues: Many advanced models have complex structures and high computational overhead, making them difficult to deploy in real time in resource-constrained aquaculture environments.

[0008] 3) Location information loss problem: Traditional feature extraction methods lose accurate spatial location information, affecting the positioning accuracy of key points.

[0009] 4) Multi-scale perception problem: The model has limited ability to perceive changes in the body size of dairy cows and key points at different scales, making it difficult to adapt to individuals of different breeds and ages.

[0010] 5) Lack of physical constraints: Existing methods lack modeling of the anatomical structure of dairy cows, which may lead to the prediction of postures that violate common sense in physics.

[0011] 6) Process fragmentation problem: Pose estimation and behavior recognition are usually performed as two independent tasks in series, failing to achieve end-to-end feature sharing and joint optimization. Summary of the Invention

[0012] This invention aims to overcome the shortcomings of existing technologies and proposes a deep learning-based method for recognizing dairy cow behavior. By integrating a multi-level attention mechanism with an improved high-resolution network and combining it with a hybrid graph convolutional network, end-to-end classification and recognition of dairy cow keypoint detection and behavior can be achieved.

[0013] This invention proposes a deep learning-based method for recognizing dairy cow behavior, comprising the following steps:

[0014] S1 acquires an image of a cow and preprocesses the image;

[0015] S2 inputs the preprocessed image into an improved high-resolution network to generate a probability heatmap for each predefined key point. The high-resolution network is enhanced by introducing a variety of attention mechanisms, including: an efficient channel attention module embedded in a parallel multi-resolution sub-network, a coordinate attention (CA) module integrated into the base module, and an efficient multi-scale attention module that replaces the second convolutional layer in the base building block.

[0016] S3 Constructing Hybrid Graph Convolutional Networks

[0017] Using the heatmap generated in step S2 as input, the geometric and visual features of each key point are extracted, and a spatial graph model is constructed based on the anatomical structure of dairy cows. A hybrid graph convolutional network is used to perform message propagation and feature learning on the spatial graph model, and outputs optimized node features. The hybrid graph convolutional network includes edge convolution (EdgeConv) and graph sampling aggregation convolution (SAGEConv). Edge convolution is responsible for learning the local relative motion patterns between joints, and graph sampling aggregation convolution (SAGEConv) is responsible for aggregating global spatial context information.

[0018] S4 Input the optimized node features output from step S3 into the keypoint coordinate regression head and the behavior classification head respectively, and output the optimized two-dimensional coordinates of the keypoints and the classification results of the cow behavior in parallel.

[0019] Preferably, in step S2, the efficient channel attention module specifically involves: obtaining channel-level statistical descriptors through global average pooling, then using a one-dimensional convolution that adaptively determines the kernel size to perform local cross-channel interaction to generate channel weights, and finally recalibrating the original input features at the channel level after activation by the Sigmoid function.

[0020] Preferably, in step S2, the coordinate attention (CA) module specifically performs one-dimensional average pooling along the horizontal and vertical directions using a decomposed coordinate information encoding strategy to generate a pair of independent direction-aware feature maps; then, it concatenates, transforms, and splits them into two direction-sensitive attention maps, which are then multiplied and weighted with the input feature map to embed precise spatial location information.

[0021] Preferably, in step S2, the efficient multi-scale attention module specifically involves: grouping the input features along the channel dimension, processing them separately through two parallel branches, and aggregating global spatial attention at different scales using a cross-dimensional interaction mechanism to achieve multi-scale calibration of the input features.

[0022] Preferably, in step S3, the EdgeConv convolution learns the feature differences between the center node and its neighboring nodes through a multilayer perceptron and uses mean aggregation to capture subtle relative motion patterns between joints.

[0023] Preferably, in step S3, the graph sampling aggregation convolution SAGEConv integrates multi-hop neighbor information through a mean aggregator, so that each node feature contains global spatial structure information.

[0024] Preferably, in step S4, the processing of the behavior classification head includes: performing global average pooling on all node features output by the hybrid graph convolutional network to obtain a global pose feature vector, and then outputting the probabilities of the three behaviors "standing", "walking" and "lying down" through a fully connected layer classifier.

[0025] Preferably, in step S4, the key point coordinate regression head directly regresses and outputs the optimized two-dimensional coordinates of all key points through a fully connected layer.

[0026] Preferably, the method further includes step S5: connecting the optimized key point coordinates output in step S4 to form a cow posture skeleton, and overlaying it together with the identified behavior category label onto the original image for visualization output.

[0027] The technical solution of this invention achieves synergistic enhancement of multi-level attention mechanisms and hybrid graph convolutional networks, and has at least the following technical effects:

[0028] 1. This invention employs an efficient channel attention module, which enables adaptive recalibration of feature channels, enhancing the feature response of key joints with minimal parameter cost, and providing higher quality input features for subsequent multi-scale fusion and graph convolution processing.

[0029] 2. This invention solves the problem of spatial information loss caused by global pooling in traditional channel attention by accurately encoding spatial position through the coordinate attention (CA) module, which significantly improves the positioning accuracy of cow joints, especially when dealing with complex postures such as limb bending and partial occlusion.

[0030] 3. This invention employs an efficient multi-scale attention module, which effectively integrates multi-scale contextual information, enhancing the model's ability to perceive cows of different sizes and key points at different scales, thereby improving detection robustness in complex scenarios.

[0031] 4. This invention achieves simultaneous capture of local relative motion patterns and global spatial context by integrating EdgeConv and SAGEConv into a hybrid graph convolutional network. It not only effectively refines the coordinates of key points detected in the initial detection, but also realizes end-to-end classification and recognition of three typical behaviors: standing, walking, and lying down through global feature aggregation, thus opening up a complete technical link from pose estimation to behavior recognition.

[0032] 5. This invention integrates the four improved modules into a unified framework in a synergistic cascade manner, achieving multi-level feature enhancement from channel, space, scale to structure. Ablation experiments show (as shown in Table 1) that the complete model achieves a recognition accuracy of 0.817 on the self-built dataset, an improvement of 32.6 percentage points compared to the baseline, verifying the effectiveness and synergistic gain of each module. Attached Figure Description

[0033] Figure 1 The diagram shows the structure of the improved high-resolution network model proposed in Embodiment 1 of the present invention and the schematic diagram of the ECA module structure in Embodiment 1 of the present invention.

[0034] Figure 2 This is a schematic diagram of the CA module structure in Embodiment 1 of the present invention;

[0035] Figure 3 This is a schematic diagram of the EMA module structure in Embodiment 1 of the present invention;

[0036] Figure 4 This is a flowchart of the method proposed in Embodiment 2 of the present invention;

[0037] Figure 5 This is a schematic diagram of the hybrid graph convolution module structure in Embodiment 2 of the present invention;

[0038] Figure 6 This is a schematic diagram of the key point annotation structure based on the physical anatomical model in Embodiment 2 of the present invention;

[0039] Figure 7 This is a diagram showing the skeleton detection and behavior recognition results of the model in Embodiment 2 of the present invention on a self-built dairy cow dataset;

[0040] Figure 8 This is a comparison diagram of the labeled skeleton key points and the skeleton key points detected and identified by the model in Embodiment 2 of the present invention. Detailed Implementation

[0041] This application provides a deep learning-based method for recognizing dairy cow behavior. Its purpose is to effectively address the bottleneck in recognition accuracy caused by scarce labeled data, poor robustness of the model environment, high computational complexity, and inaccurate spatial positioning by introducing a multi-branch attention mechanism and a hybrid graph convolutional network.

[0042] The technical solution in this invention is to solve the above problems, and the overall idea is as follows:

[0043] Using a high-resolution network as the backbone, an efficient channel attention module is embedded in its parallel multi-resolution sub-networks to achieve adaptive calibration of channel weights, thereby enhancing the representation ability of key joint features of dairy cows. At the basic building block level, the original second convolutional layer is replaced with an efficient multi-scale attention module to fuse multi-scale contextual information and effectively address the recognition difficulties caused by changes in dairy cow body size. Furthermore, a coordinate attention module is embedded after the efficient multi-scale attention module, which captures precise spatial location information through a decompositional coordinate encoding mechanism, significantly improving the localization accuracy of joint points. The above-mentioned multi-branch attention modules, through collaborative and cascaded system design, jointly enhance the model's ability to focus on and discriminate key features. Based on this, this embodiment of the invention also constructs a hybrid graph convolutional network, which combines the advantages of edge convolution and graph sampling hybrid convolution to refine the coordinates of key points obtained in the previous detection, and on this basis, completes efficient classification and recognition of three typical dairy cow behaviors: standing, walking, and lying down.

[0044] Through the above improvements, the embodiments of the present invention can achieve the following technical effects: effectively enhance the spatial positioning accuracy of the model for key joints of dairy cows, improve its adaptability to multi-scale body shape changes and complex occlusion, and ultimately achieve stable and reliable end-to-end recognition of its typical behaviors.

[0045] To better understand the above technical solution, the following will provide a detailed explanation of the technical solution in conjunction with the accompanying drawings and specific implementation schemes.

[0046] Example 1

[0047] This embodiment provides an improved method for high-resolution networks, the specific improvement method is as follows:

[0048] (1) Embedded Efficient Channel Attention (ECA) Module

[0049] To address the issues of lost inter-channel dependencies and increased computational burden caused by dimensionality reduction operations in traditional channel attention mechanisms, this method embeds an efficient channel attention (ECA) module into the parallel multi-resolution sub-network.

[0050] The ECA module works as follows: First, it obtains channel-level statistical descriptors from the input feature map through global average pooling.

[0051] (1)

[0052] in B represents the batch size, C represents the number of channels, and H and W represent the spatial dimensions.

[0053] Then, efficient local cross-channel interaction is performed through one-dimensional convolution to generate channel weight vectors:

[0054] (2)

[0055] Where the kernel size Adaptive determination, where C is the channel dimension. is the scaling factor, and b is the bias term.

[0056] The key to the ECA module lies in its adaptive convolutional kernel size strategy, which automatically adjusts the receptive field range based on the channel dimension of the input features, ensuring optimal cross-channel interaction performance across different network depths and widths. This design not only significantly reduces model complexity and the number of parameters but also more effectively captures important dependencies between channels, avoiding dimensionality reduction operations and effectively preventing the loss of inter-channel dependencies.

[0057] The final generated channel weights are activated by the Sigmoid function and then multiplied with the original input features to achieve channel-level feature recalibration.

[0058] The technical benefits of the ECA module are reflected in the following aspects: it eliminates the complex dimensionality reduction operations in traditional channel attention, enabling the network to automatically emphasize information-rich feature channels (such as key joints of cows) and suppress secondary channels with minimal parameter cost; it enhances the model's selective attention to channel features with almost no increase in computational overhead, thereby improving the accuracy of cow behavior recognition, significantly enhancing the model's ability to focus on discriminative features, providing higher-quality input for subsequent multi-scale feature fusion, and thus improving the overall feature representation quality of the network.

[0059] (2) Integrated Coordinate Attention (CA) Module

[0060] To address the issue of spatial location information loss caused by two-dimensional global pooling in channel attention, this method introduces a coordinate attention mechanism into the network's basic blocks. It embeds precise spatial location information through a decomposed coordinate information encoding strategy to enhance the model's ability to perceive spatial structures.

[0061] The mechanism of this module is as follows: First, for the input feature map, instead of using global pooling to compress it into a single feature vector, one-dimensional average pooling is performed along the horizontal and vertical coordinate directions respectively to generate a pair of independent orientation-aware feature maps:

[0062] (3)

[0063] (4)

[0064] Tensor .

[0065] This decomposition operation successfully captures spatial global information into two directional feature codes. These two feature maps, containing long-range dependencies in different directions, are then concatenated spatially and subjected to channel dimensionality reduction via a shared convolutional layer. After batch normalization and non-linear activation function processing:

[0066] (5)

[0067] (6)

[0068] in For the obtained intermediate mapping,

[0069] The encoded features are split into the original two directional components. , where r is the channel dimensionality reduction factor, with a reduction ratio of 1 / 32.

[0070] Finally, two convolutional layers are used to restore the number of channels, and two independent orientation-sensitive attention maps are generated using the sigmoid function. .

[0071] (7)

[0072] (8)

[0073] (9)

[0074] Finally, these two attention maps are multiplied and weighted with the input feature map to enhance the model's representation ability in the spatial dimension.

[0075] The technical benefits of the Coordinate Attention (CA) module are as follows: it enables the coordinate attention mechanism not only to model the relationships between channels, but also to accurately capture the long-range dependencies of the input feature map along the spatial dimension, efficiently storing positional information in the generated attention map, effectively solving the problem of spatial information loss in traditional channel attention; integrating the coordinate attention (CA) module into the basic blocks of this network effectively improves the model's accuracy in locating the spatial position of the cow's joints, especially when dealing with complex postures such as cow limb bending and partial occlusion, the joint location accuracy is significantly improved.

[0076] (3) Introduce an efficient multi-scale attention (EMA) module

[0077] To address the shortcomings of existing models in multi-scale feature perception and to cope with the recognition challenges posed by individual cow size differences and changes in shooting perspective, this method replaces the second 3×3 convolutional layer in the basic network block with an efficient multi-scale attention (EMA) module. Through grouped feature reshaping and cross-dimensional interaction strategies, it enhances the model's ability to fuse multi-scale contextual information.

[0078] The mechanism of the efficient multi-scale attention (EMA) module is as follows: coordinate attention obtains the adjusted tensor by multiplying and weighting the two attention maps with the input feature map. For feature tensors By taking the G group sub-features on the channel, one branch is used to obtain the adjusted tensor. The other branch is obtained through a 3×3 convolution. Then, 2D global average pooling is used to encode the global spatial information of the first branch output.

[0079] (10)

[0080] in, This is the output of the CA module.

[0081] Then, Softmax is applied to obtain the normalized channel descriptor. ,

[0082] (11)

[0083] Then and Multiplication is equivalent to a weighted summation of all channel features at each location, thus obtaining the global spatial attention representation at the current scale (1×1): ,

[0084] (12)

[0085] (13)

[0086] (14)

[0087] Similarly, by using 2D global average pooling to encode the global spatial information of the second branch, we obtain... And apply Softmax to obtain the normalized channel descriptor. Then reshape.

[0088] (15)

[0089] (16)

[0090] (17)

[0091] Then and Multiplication is equivalent to a weighted summation of all channel features at each location, thus obtaining the global spatial attention representation at the current scale (3×3): ,

[0092] (18)

[0093] (19)

[0094] Two global spatial attention mechanisms preserve spatial location information at different scales. Finally, the two spatial attention mechanisms are aggregated, and the weight representation is obtained through a gating function. ,

[0095] (20)

[0096] (twenty one)

[0097] And recalibrate the input using weights. , get output ,

[0098] (twenty two)

[0099] Since all operations are performed on all groups, the output is: The final output is obtained by restoring the shape to the same as the input through a reshape operation. .

[0100] The technical effects of the efficient multi-scale attention (EMA) module are reflected in: (1) by grouping feature reshaping and cross-dimensional interaction strategies, it efficiently captures the global context and enhances the module's ability to fuse multi-scale contextual information. (2) It establishes long-distance spatial dependence, enabling the network to perceive local details and global structure at the same time, thereby significantly enhancing the robustness of perception of key points of cows of different sizes and scales, and effectively addressing the recognition challenges caused by individual differences in cows and changes in shooting angle.

[0101] Example 2

[0102] This embodiment provides a deep learning-based method for recognizing dairy cow behavior. Please refer to [link / reference]. Figure 4 This includes the following steps:

[0103] S1 Data Acquisition and Preprocessing

[0104] The raw image data collected from the breeding farm is read, and the size and color are normalized. Data augmentation techniques such as rotation and scaling are used to expand the dataset and improve the robustness of the model.

[0105] S2 generates initial key point heatmap

[0106] The preprocessed image is input into the improved high-resolution network in Example 1, and a probability heatmap for each predefined keypoint is generated through a convolutional layer regression. Please refer to... Figure 6 Based on the physical anatomy of dairy cows, key points may include: the top of the head, neck, shoulders, back, hips, base of the tail, and the wrist, knee, and hoof joints of the limbs. The peak positions of the heat map are the preliminary predicted coordinates of the key points.

[0107] S3 constructs a hybrid graph convolutional network to refine key points and identify behaviors.

[0108] To optimize keypoint coordinates and simultaneously identify behavior, this step constructs a Hybrid Graph Convolutional Network (HybridGCN). Please refer to [reference needed]. Figure 5The processing flow of this module is as follows: First, rich node features, including geometric and visual features, are extracted from the heatmap generated in step S2; then, spatial graph relationships are constructed based on the anatomical structure of cattle; next, the complex spatial dependencies between key points are learned through a hybrid graph convolutional network; finally, coordinate regression and behavior classification tasks are completed through different output heads.

[0109] Among them, hybrid graph convolution innovatively combines two graph convolution methods:

[0110] (1) EdgeConv focuses on learning the relative displacement relationships between nodes rather than absolute position information. It learns the feature differences between the central node and its neighboring nodes through a multilayer perceptron. For each node, it calculates the feature combination of the node and all its neighboring nodes, usually by concatenating the features of the central node and the feature differences with its neighbors. This design enables the network to explicitly learn the relative motion patterns between joints—such as the range of motion of the foreleg joint relative to the trunk, the rotation angle of the head relative to the neck, and other subtle changes. These relative motion patterns are the key features for distinguishing different behaviors (such as leg alternation when walking, limb contraction when lying down). EdgeConv uses mean aggregation to equally consider the contributions of all neighboring joints, avoiding the excessive influence of certain dominant joints on feature learning. When processing cattle posture data, this design can effectively capture the coordinated motion patterns of various parts such as limbs, head, and tail, providing rich local motion features for behavior recognition.

[0111] (2) The graph sampling aggregation convolution SAGEConv employs efficient aggregation of multi-hop neighbor information and propagation of global context, focusing on building the global perception capability of nodes so that each node can perceive the overall state. SAGEConv uses a mean aggregator to integrate neighbor information. In the cow behavior recognition scenario, each key point not only considers directly connected neighbors (e.g., the knee joint considers the thigh and lower leg joints), but also indirectly obtains information from more distant joints (e.g., through multi-layer propagation, the knee joint can ultimately perceive the state of the head and tail). This global perception capability is crucial for behaviors requiring full-body coordination (e.g., lying down requires simultaneous analysis of limb flexion, trunk descent angle, and head posture). SAGEConv possesses inductive learning capabilities, effectively handling even new samples not seen during training. This gives the model good generalization ability, enabling it to adapt to the behavior recognition of cows of different individuals and postures.

[0112] By stacking multiple layers of graph sampling aggregation convolutions (SAGEConv), the network can build deep global dependencies and capture complex behavioral patterns.

[0113] By designing a hybrid graph convolutional network that integrates edge convolution (EdgeConv) and graph sampling aggregation convolution (SAGEConv), this network achieves collaborative perception of local relative motion and global spatial structure: EdgeConv captures local relative motion patterns between joints, while SAGEConv aggregates global spatial context information. This combination not only effectively refines the coordinates of initially detected key points, improving spatial accuracy, but also achieves high-precision, automated classification of three typical behaviors—standing, walking, and lying down—through global feature aggregation, thus establishing a complete technical chain from pose estimation to behavior recognition.

[0114] The optimized node features output from the hybrid graph convolutional network are input into two independent output heads for parallel decision-making:

[0115] 1) The key point coordinate regression head outputs the optimized two-dimensional coordinates of all key points.

[0116] 2) The behavior classification head performs global average pooling on all node features to obtain a sample-level pose feature vector, and finally outputs the probability of the three behaviors "standing", "walking" and "lying down" through a fully connected layer classifier.

[0117] S4 Results Visualization and Application

[0118] Connect the key point coordinates obtained from regression in step S3(1) to form a cow posture skeleton, and overlay it on the original image together with the behavior category labels identified in step S3(2) to complete the final visualization output.

[0119] The output results can be used for automated monitoring and early warning in ranch management systems.

[0120] To demonstrate the effectiveness of the method in this embodiment, we conducted ablation experiments on a dataset. Using recognition accuracy and loss as evaluation metrics, the experimental results are shown in Table 1. It can be seen that our method can significantly improve recognition accuracy.

[0121] Table 1 Ablation Experiment

[0122] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for recognizing dairy cow behavior based on deep learning, characterized in that, Includes the following steps: S1 acquires an image of a cow and preprocesses the image; S2 inputs the preprocessed image into an improved high-resolution network to generate a probability heatmap for each predefined key point; wherein, the improved high-resolution network is enhanced by introducing a variety of attention mechanisms, including: an efficient channel attention module embedded in a parallel multi-resolution sub-network, a coordinate attention (CA) module integrated into the base module, and an efficient multi-scale attention module that replaces the second convolutional layer in the base building block. S3 Constructing Hybrid Graph Convolutional Networks Using the heatmap generated in step S2 as input, the geometric and visual features of each key point are extracted, and a spatial graph model is constructed based on the anatomical structure of dairy cows. A hybrid graph convolutional network is used to perform message propagation and feature learning on the spatial graph model, and outputs optimized node features. The hybrid graph convolutional network includes edge convolution (EdgeConv) and graph sampling aggregation convolution (SAGEConv). Edge convolution (EdgeConv) is responsible for learning the local relative motion patterns between joints, and graph sampling aggregation convolution (SAGEConv) is responsible for aggregating global spatial context information. S4 Input the optimized node features output from step S3 into the keypoint coordinate regression head and the behavior classification head respectively, and output the optimized two-dimensional coordinates of the keypoints and the classification results of the cow behavior in parallel.

2. The dairy cow behavior recognition method as described in claim 1, characterized in that, In step S2, the efficient channel attention module specifically involves: obtaining channel-level statistical descriptors through global average pooling, then using a one-dimensional convolution that adaptively determines the kernel size to perform local cross-channel interaction to generate channel weights, and finally recalibrating the original input features at the channel level after activation by the Sigmoid function.

3. The dairy cow behavior recognition method as described in claim 1, characterized in that, In step S2, the coordinate attention (CA) module specifically performs one-dimensional average pooling along the horizontal and vertical directions using a decomposed coordinate information encoding strategy to generate a pair of independent direction-aware feature maps. These maps are then concatenated, transformed, and split into two direction-sensitive attention maps, which are then multiplied and weighted with the input feature map to embed precise spatial location information.

4. The dairy cow behavior recognition method as described in claim 1, characterized in that, In step S2, the efficient multi-scale attention module specifically involves: grouping the input features along the channel dimension, processing them separately through two parallel branches, and aggregating global spatial attention at different scales using a cross-dimensional interaction mechanism to achieve multi-scale calibration of the input features.

5. The method for recognizing dairy cow behavior as described in claim 1, characterized in that, In step S3, the EdgeConv convolution learns the feature differences between the center node and its neighboring nodes through a multilayer perceptron and uses mean aggregation to capture subtle relative motion patterns between joints.

6. The method for recognizing dairy cow behavior as described in claim 1, characterized in that, In step S3, the graph sampling aggregation convolution SAGEConv integrates multi-hop neighbor information through a mean aggregator, so that each node feature contains global spatial structure information.

7. The method for recognizing dairy cow behavior as described in claim 1, characterized in that, In step S4, the processing of the behavior classification head includes: performing global average pooling on all node features output by the hybrid graph convolutional network to obtain a global pose feature vector, and then outputting the probabilities of the three behaviors "standing", "walking" and "lying down" through a fully connected layer classifier.

8. The method for recognizing dairy cow behavior as described in claim 1, characterized in that, In step S4, the key point coordinate regression head directly regresses and outputs the optimized two-dimensional coordinates of all key points through a fully connected layer.

9. The method for recognizing dairy cow behavior as described in claim 1, characterized in that, It also includes step S5: connecting the optimized key point coordinates output in step S4 into a cow posture skeleton, and overlaying it on the original image together with the identified behavior category label for visualization output.