Dairy cow delivery disorder early warning method, equipment, medium and product
A deep learning-based system using high-definition cameras and advanced algorithms for dairy cow delivery prediction addresses the limitations of manual observation, providing accurate and automated early warnings, enhancing breeding efficiency and cow health.
Patent Information
- Application Number
- CN202411793615.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-01-03
AI Technical Summary
Traditional manual observation methods for dairy cow delivery risks are time-consuming, prone to human error, and lack accuracy, especially during the critical second stage of labor, leading to potential misjudgment and increased breeding costs.
A method utilizing high-definition cameras and deep learning algorithms to analyze cow posture and behavior, employing models like YOLOv8, random forest, and neural networks for real-time prediction and early warning of delivery obstacles, integrated in a layered architecture system.
Enhances accuracy and automation in early warning, reducing human effort and costs, ensuring timely and reliable delivery predictions with dynamic adaptability and stable operation, improving breeding efficiency and cow health.
Smart Images

Figure CN119251877A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of early warning of dairy cow delivery risks, and in particular to an early warning method, device, medium and product for dairy cow delivery obstacles. Background Art
[0002] The early warning technology for the risk of dairy cow delivery refers to the diagnosis of the risk of delivery of dairy cows 3-7 days before delivery, the correct treatment technology for cows that have already developed diseases, and the preventive intervention technology for cows that have disease signals but have not yet shown disease symptoms. Among them, early and accurate detection of the impending delivery of dairy cows is of great significance. This not only allows farmers to reserve sufficient time to prepare for related matters. In the three stages of dairy cow delivery, especially the critical second stage, farmers will pay special attention to the various aspects of dairy cows. Usually, they pay close attention to the appetite of dairy cows to see if they have a decreased appetite; their mental state is also a key observation object. If the dairy cows appear to be mentally uneasy, it will arouse the vigilance of farmers; at the same time, changes in the breasts should not be ignored. Once the cows' breasts are found to be swollen, this is often regarded as one of the signs of impending delivery. In addition, farmers will fully combine the cows' previous delivery history and parity information to further infer the approximate time of the cows' delivery. However, this traditional early warning method that relies on manual observation has exposed many drawbacks in actual application, especially when the cows enter the second stage of labor, these problems are more prominent.
[0003] First, manual observation requires farmers to invest a lot of time and energy. When the cows are about to give birth, farmers need to patrol the cowshed for a long time and keep an eye on the status of each cow. Especially at night, since it is common for cows to give birth in the early morning, farmers must remain highly vigilant and patrol the cowshed regularly even when they are sleepy and exhausted, so as not to miss the key node when the cows enter the second stage of labor. In this way, long-term high-intensity work can easily lead to excessive fatigue of farmers, and then they may be careless during the observation process, affecting the accurate judgment of the cow's delivery. Secondly, the behavior and physiological changes of cows are not only determined by the factor of delivery, but they may be affected by a variety of external factors. If the cows themselves suffer from certain diseases, the symptoms they show in the second stage of labor may be confused with the performance of normal delivery, which makes it difficult for farmers to accurately judge the delivery of cows only through manual observation, increasing the risk of misjudgment. The traditional delivery warning method that relies on manual observation of cow behavior and physiological changes has obvious limitations when it comes to monitoring cow delivery, especially the second stage of delivery, and urgently needs to be improved with more scientific and efficient warning methods. At present, an effective delivery warning is urgently needed, which also plays an important role in optimizing breeding management processes, improving breeding efficiency, and reducing breeding costs. Summary of the invention
[0004] The purpose of this application is to provide a method, device, medium and product for early warning of dairy cow delivery difficulties, which can improve the accuracy and automation level of early warning of dairy cow delivery difficulties.
[0005] To achieve the above objectives, this application provides the following solutions: In a first aspect, the present application provides a method for early warning of dairy cow delivery disorders, comprising: Obtain monitoring videos of dairy cows waiting to give birth; The monitoring video is frame-processed to obtain a monitoring video frame sequence; the monitoring video frame sequence includes monitoring video frames corresponding to different moments; Inputting the monitoring video frame corresponding to the current moment into the cow lying posture recognition model to obtain the posture of the cow to be born; the posture is a lying posture or an abnormal posture; the cow lying posture recognition model is obtained by training the YOLOv8 model using the cow's historical monitoring video; When the posture of the cow to be born is abnormal, issuing an abnormal posture warning; When the posture of the cow to be born is a lying posture, the monitoring video frame sequence is input into a key part posture feature analysis model to obtain posture features of multiple key parts of the cow to be born at different times; the key part posture feature analysis model is obtained by training a deep learning framework using historical monitoring videos of the cow; According to the posture features of multiple key parts of the dairy cows at the same time, the posture feature vectors corresponding to different times are constructed to obtain a posture feature vector sequence; Inputting the posture feature vector corresponding to the current moment into the key part behavior tracking model to obtain the short-term prediction result of the delivery degree of the dairy cow; the key part behavior tracking model is obtained by training the random forest model using the historical monitoring video of the dairy cow; The posture feature vector sequence and the posture of the current cow in labor are input into a cow labor degree prediction model to obtain a long-term prediction result of the labor degree of the cow in labor; the cow labor degree prediction model is obtained by training an initial cow labor degree prediction model using historical cow monitoring videos.
[0006] Optionally, the initial cow delivery degree prediction model is a linear regression model, a decision tree model, a random forest model or a neural network model.
[0007] Optionally, before obtaining the monitoring video of the calving cow, the method further includes: Obtain multiple historical monitoring videos of dairy cows; Perform frame processing on a plurality of historical monitoring videos of dairy cows respectively to obtain a plurality of historical monitoring video frames; Label the cow posture in each frame of historical monitoring video; Taking the historical monitoring video frames as input and the cow posture in the historical monitoring video frames as output, the YOLOv8 model is trained to obtain the cow lying posture recognition model.
[0008] Optionally, before obtaining the monitoring video of the calving cow, the method further includes: Obtain multiple historical monitoring videos of dairy cows; Perform frame processing on a plurality of historical monitoring videos of dairy cows respectively to obtain a plurality of historical monitoring video frame sequences; Using the array operation function in the NumPy environment and the Scipy library, the posture characteristics of multiple key parts of the cow at different historical moments in each historical monitoring video frame sequence are determined; Taking the historical monitoring video frame sequence as input and the posture features of multiple key parts of the cow at different historical moments in the historical monitoring video frame sequence as output, the deep learning framework is trained to obtain the key part posture feature analysis model.
[0009] Optionally, before obtaining the monitoring video of the calving cow, the method further includes: Constructing multiple posture feature historical vector sequences; the posture feature historical vector sequences correspond one-to-one to the historical monitoring video frame sequences; any of the posture feature historical vector sequences includes multiple posture feature historical vectors; the multiple posture feature historical vectors correspond one-to-one to the historical moments in the corresponding posture feature historical vector sequences; any of the posture feature historical vector sequences is constructed based on the posture features of multiple key parts of the cow at the corresponding historical moments; Label each posture feature history vector sequence corresponding to the degree of delivery; After training the random forest model with the posture feature history vector as input and the degree of delivery as output, a key part behavior tracking model was obtained.
[0010] Optionally, before obtaining the monitoring video of the calving cow, the method further includes: The posture feature history vector sequence and the cow posture are used as input, and the delivery degree is used as output. The initial cow delivery degree prediction model is trained to obtain the cow delivery degree prediction model.
[0011] Optionally, after taking the posture feature history vector sequence and the cow posture as input and the delivery degree as output, training the initial cow delivery degree prediction model to obtain the cow delivery degree prediction model, the method further includes: Based on the cow lying posture recognition model, the key part posture feature analysis model, the key part behavior tracking model and the cow delivery degree prediction model, a cow delivery obstacle early warning system is constructed by adopting a layered architecture design; the cow delivery obstacle early warning system includes a data acquisition layer, a data processing layer, a model training layer, a model reasoning layer and an application display layer connected in sequence.
[0012] In a second aspect, the present application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-mentioned method for early warning of cow delivery disorders.
[0013] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned method for early warning of cow delivery disorders.
[0014] In a fourth aspect, the present application provides a computer program product, including a computer program, which implements the above-mentioned cow delivery disorder early warning method when executed by a processor.
[0015] According to the specific embodiments provided in this application, this application discloses the following technical effects: The present application provides a method, device, medium and product for early warning of dairy cow delivery obstacles. First, in terms of data collection and analysis, it can fully and accurately capture the details of key parts and changes in movement posture of dairy cows in lying posture, and integrate multi-dimensional information; through high-definition cameras and advanced image processing technology, real-time image data of dairy cows' legs, chest, abdomen and head are obtained, and these data are analyzed by deep learning algorithms to extract useful feature information, which provides a reliable basis for delivery judgment. Secondly, in terms of model algorithms, the system adopts advanced algorithms and models, such as YOLOv8 algorithm, which can achieve accurate judgment and effective prediction, and has dynamic adaptability. This means that the system can automatically adjust the judgment model according to the different conditions of dairy cows and changes in the delivery process, thereby improving the accuracy and timeliness of early warning. In addition, the system architecture adopts a layered architecture, and each functional module works together, with efficient data processing, and can quickly process a large amount of image data and analysis results, providing timely decision support for farmers. Finally, the system has a friendly operating interface, good integration, strong hardware and stability, and can run stably. This allows farmers to easily use the system for delivery warning without professional technical knowledge. At the same time, the system has a reliable backup and recovery mechanism to ensure the security and reliability of data, avoid the impact of data loss or damage on dairy farming, and can effectively solve the problems existing in today's farms in early warning of delivery, saving time and effort, and bringing higher efficiency and better economic benefits to dairy farming. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 This is a flow chart of a method for early warning of dairy cow delivery problems in one embodiment of the present application.
[0018] Figure 2 This is a flow chart of a method for early warning of cow delivery problems in another embodiment of the present application. DETAILED DESCRIPTION
[0019] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0020] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0021] The birthing process of dairy cows includes three key stages: uterine opening (first stage of labor), fetal expulsion (second stage of labor), and placenta expulsion (third stage of labor). Today's farms all use traditional methods to make dairy cow birth warnings, relying on manual judgment of the birthing status of dairy cows based on the above behaviors and taking corresponding measures. On the one hand, the observation content is relatively limited, and manual observation of cow behavior changes is not detailed enough, ignoring many details; in terms of judgment accuracy, it is highly dependent on the experience of farmers, which is greatly disturbed by subjective factors, and the judgment results of different farmers may be inconsistent; the preparation for delivery is also insufficient, and there are problems such as incomplete preparation work and lack of dynamic adjustment. In addition, dairy cows are generally likely to give birth in the early morning, which makes the monitoring and assistance of the entire birthing process extremely time-consuming and laborious. Farmers need to invest a lot of manpower in the already tired early morning to wait and handle related matters, which greatly consumes labor costs and brings many inconveniences and challenges to dairy cow farming. With the development of computer vision technology, its application in the field of animal husbandry is becoming more and more extensive. Among them, with the powerful advantages of deep learning algorithms, the cost of human input can be greatly reduced.
[0022] Based on this, in an exemplary embodiment, a method for early warning of dairy cow delivery obstacles is provided. In the process of dairy cow delivery, the second stage of delivery is particularly critical, and the cow will experience more intense physical changes and behavioral performances at this stage. In the data collection and analysis link, this embodiment can comprehensively and accurately capture the subtle details of key parts such as the legs, chest, abdomen, head, and every change in the movement posture of the cow in the second stage of delivery, and deeply integrate multi-dimensional information at the same time, obtain image data in real time through high-definition cameras and advanced image processing technology, and use deep learning algorithms to analyze and extract useful feature information to provide a reliable basis for delivery judgment; make full use of advanced algorithms and accurate models such as the YOLOv8 algorithm, not only for dairy cow delivery The second stage of delivery can achieve accurate and correct judgments and effective predictions, and has excellent dynamic adaptability, and can flexibly adjust the judgment and prediction strategies according to the real-time status of the cow during delivery; adopt the design concept of layered architecture, and the various functional modules work closely and collaboratively to ensure the efficiency of data processing, even in the face of a large number of complex The data information can also complete the processing process quickly and accurately; it shows strong compatibility, and can be matched with various common breeding environment hardware equipment and can run stably and reliably in the special stage of the second stage of dairy cow delivery, which requires extremely high stability, without problems such as freezing or data loss; it has a very reliable backup and recovery mechanism. In the storage and management of daily breeding data and the processing of a large amount of key data generated in the second stage of dairy cow delivery, once an unexpected situation occurs, it can be quickly restored through backup data to ensure data integrity and consistency; with the help of deep learning algorithms, the cost of manpower input is reduced, and the breeding staff does not need to patrol the dairy cow house for a long time, especially at night, without high vigilance, saving a lot of manpower and time costs; it has a friendly operation interface and good integration. Breeders do not need to have professional technical knowledge to use the system conveniently for delivery warning. Combining these significant advantages, the early warning model and system can not only issue early warnings for possible delivery obstacles in a timely and accurate manner during the second stage of dairy cow delivery and the entire delivery process, effectively improve breeding efficiency and production benefits, but also effectively protect the health and welfare of dairy cows, and comprehensively improve the overall level of breeding management.
[0023] like Figure 1 As shown, this embodiment provides a method for early warning of dairy cow delivery problems, comprising: Step 101: Obtain monitoring video of a dairy cow ready to give birth.
[0024] Step 102: Perform frame processing on the monitoring video to obtain a monitoring video frame sequence. The monitoring video frame sequence includes monitoring video frames corresponding to different moments.
[0025] Step 103: Input the monitoring video frame corresponding to the current moment into the cow lying posture recognition model to obtain the posture of the cow to be born. The posture is a lying posture or an abnormal posture. The cow lying posture recognition model is obtained by training the YOLOv8 model using the historical monitoring video of the cow.
[0026] Step 104: When the posture of the cow to be calved is abnormal, an abnormal posture warning is issued.
[0027] Step 105: When the cow is lying down, the monitoring video frame sequence is input into the key part posture feature analysis model to obtain the posture features of multiple key parts of the cow at different times. The key part posture feature analysis model is obtained by training the deep learning framework using the cow's historical monitoring video.
[0028] Step 106: constructing posture feature vectors corresponding to different moments according to the posture features of multiple key parts of the calving cow at the same moment, and obtaining a posture feature vector sequence.
[0029] Step 107: Input the posture feature vector corresponding to the current moment into the key part behavior tracking model to obtain a short-term prediction result of the delivery degree of the dairy cow. The key part behavior tracking model is obtained by training the random forest model using the historical monitoring video of the dairy cow.
[0030] Step 108: Input the posture feature vector sequence and the posture of the cow in labor at the current moment into the cow labor degree prediction model to obtain the long-term prediction result of the cow in labor. The cow labor degree prediction model is obtained by training the initial cow labor degree prediction model using the cow historical monitoring video. The initial cow labor degree prediction model is a linear regression model, a decision tree model, a random forest model or a neural network model.
[0031] The process of building a cow lying posture recognition model is as follows: obtain multiple historical monitoring videos of cows. Divide the multiple historical monitoring videos of cows into frames to obtain multiple historical monitoring video frames. Label the cow posture in each historical monitoring video frame. Take the historical monitoring video frame as input and the cow posture in the historical monitoring video frame as output, train the YOLOv8 model, and obtain the cow lying posture recognition model.
[0032] 1.1 Data acquisition equipment and installation.
[0033] Camera selection: Choose a high-definition camera with high resolution, low noise, and wide dynamic range to ensure that it can clearly capture the details of the cow's delivery process or a camera with visible-infrared dual-mode that can work normally under different lighting conditions. The infrared mode is used to obtain thermal imaging information of the cow's legs, chest, abdomen, and head to assist in judging the body condition.
[0034] Installation location: Install cameras around the delivery bed and above the passage to ensure that the main action area of the cow during delivery is covered. The best layout is determined according to the farm size and the layout of the cowshed to ensure that the key parts of the cow delivery are fully covered while avoiding mutual interference or blind spots. Adjust the angle and height of the camera to avoid being blocked by the cow's body to ensure the integrity and accuracy of the image.
[0035] 1.2 Data collection and preprocessing.
[0036] Data collection frequency: Set the collection frequency to 25fps or above to ensure that the cow’s movements and posture changes when lying down can be captured.
[0037] Image enhancement: Use histogram equalization, smoothing filtering and other methods to enhance the contrast and clarity of the image and improve the image quality.
[0038] 1.3 Data labeling.
[0039] According to the movement and posture standards of dairy cows, the labelimg tool was used in the Python environment to annotate the cows’ legs, chest, abdomen, and head in the remaining images, including the postures of cows giving birth in a recumbent position with their legs raised / kicking, not raised / kicking, and standing position, the outlines of the chest and abdomen, and the feature points of the head. The annotations included normal and abnormal postures.
[0040] 1.4 Model construction and training.
[0041] YOLOv8 is selected as the basic model. This model has the characteristics of fast detection and high-precision positioning, and can meet the requirements of leg, chest, abdomen, and head recognition during the cow's lying delivery process. The architecture of the YOLOv8 model includes the input layer, backbone network, neck network, and output layer. The backbone network is used to extract image features, the neck network is used to enhance feature expression, and the output layer is responsible for outputting the detection results.
[0042] Collect a large amount of video data of cows lying down to give birth, including normal birth and birth obstacles. Manually annotate the video data to ensure the accuracy and consistency of the annotations. Divide the annotated data into training set, validation set, and test set in a ratio of 7:2:1.
[0043] Verification and adjustment: Use the validation set to evaluate the model during training and monitor the model's performance indicators, such as precision, recall, F1 value, etc. According to the evaluation results, adjust the model's parameters, increase or decrease the number of network layers, adjust the number of neurons, etc. to prevent overfitting.
[0044] The process of building a key part posture feature analysis model is as follows: obtain multiple historical monitoring videos of dairy cows. Perform frame processing on multiple historical monitoring videos of dairy cows to obtain multiple historical monitoring video frame sequences. Use the array operation function and Scipy library in the NumPy environment to determine the posture features of multiple key parts of dairy cows at different historical moments in each historical monitoring video frame sequence. Take the historical monitoring video frame sequence as input and the posture features of multiple key parts of dairy cows at different historical moments in the historical monitoring video frame sequence as output, train the deep learning framework, and obtain the key part posture feature analysis model.
[0045] 2.1 Joint point detection algorithm.
[0046] Using a deep learning-based object detection algorithm, the trained model is used to analyze the extracted images to detect the key bone points of the cow's legs and the joint points of the head. The accuracy and robustness of joint point detection are improved through feature fusion and multi-scale feature extraction.
[0047] 2.2 Posture feature calculation method.
[0048] (1) Leg features.
[0049] Joint angle: The angles between leg joints, such as the angles between the hip joint, knee joint and ankle joint, are calculated using mathematical formulas based on the detected joint coordinates. These angle features can reflect the movement state and force transfer of the cow's legs.
[0050] Leg swing amplitude: measures the distance from the starting position to the maximum displacement of the legs during the swing process. This parameter can reflect the flexibility of the cow's legs and the degree of force applied during delivery.
[0051] (2) Chest and abdominal characteristics.
[0052] Fluctuation amplitude: Analyze the up and down fluctuation amplitude of the chest and abdomen during breathing and delivery. The fluctuation amplitude value is obtained by averaging the vertical coordinate difference of multiple key points on the chest and abdomen contour. Too large or too small fluctuation amplitude may indicate that the cow has breathing problems or abnormal delivery.
[0053] (3) Head features.
[0054] Tilt angle: Calculates the angle between the head and the ground in the vertical plane, determined by the head outline and key point locations in the image.
[0055] Rotation angle: Calculate the rotation angle of the head in the horizontal plane by tracking the position changes of the key points of the head.
[0056] Head raising and lowering amplitude: measure the difference between the maximum and minimum displacement of the head in the vertical direction as the characteristic parameter of the head raising and lowering amplitude.
[0057] 2.3 Data calculation and analysis tools.
[0058] Mathematical calculation library: Use the mathematical calculation library in Python, such as NumPy, Scipy, etc., to calculate the coordinates of joint points, angles and amplitudes, etc.
[0059] Deep learning framework: Use TensorFlow to implement posture detection model training and reasoning, and perform feature extraction and analysis.
[0060] Data visualization tools: Use data visualization tools such as Matplotlib and Seaborn to display the extracted posture feature parameters in the form of charts to help farmers intuitively understand the delivery status of dairy cows.
[0061] The construction process of the key part behavior tracking model is as follows: construct multiple posture feature history vector sequences. The posture feature history vector sequences correspond one-to-one to the historical monitoring video frame sequences. Any posture feature history vector sequence includes multiple posture feature history vectors. Multiple posture feature history vectors correspond one-to-one to the historical moments in the corresponding posture feature history vector sequence. Any posture feature history vector sequence is constructed based on the posture features of multiple key parts of the cow at the corresponding historical moment. Label the corresponding delivery degree of each posture feature history vector sequence respectively. After training the random forest model with the posture feature history vector as input and the delivery degree as output, the key part behavior tracking model is obtained.
[0062] The extracted posture feature parameters of the cow's legs, chest, abdomen, and head are fused to form a comprehensive feature vector. The features of different parts can be combined by weighted averaging, splicing, and other methods.
[0063] 3.1 Model construction.
[0064] Based on the fused feature vector, the random forest algorithm was used to build a dairy cow parturition degree identification model.
[0065] When building a model, you can set different parameters, such as the number of decision trees, the maximum depth, etc., and select the optimal parameter combination through methods such as cross-validation.
[0066] 3.2 Model training and optimization strategy.
[0067] Further expand the scale of training data and collect more data on dairy cows of different breeds, stages, and delivery environments to improve the generalization ability of the model.
[0068] Perform data enhancement on the training data, such as rotation, flipping, and cropping, to increase data diversity and reduce the risk of overfitting.
[0069] 3.3 Training process
[0070] The model is trained using optimization algorithms such as gradient descent, and the model parameters are continuously updated so that the model can better fit the training data.
[0071] During the training process, set a reasonable number of iterations and learning rate to avoid overfitting or underfitting of the model.
[0072] 3.4 Model optimization
[0073] Perform feature selection to select feature subsets that play an important role in predicting the degree of labor, reduce the complexity of the model, and improve the training efficiency and accuracy of the model.
[0074] Combine regularization techniques, such as L1 regularization and L2 regularization, to prevent model overfitting.
[0075] 3.5 Model evaluation indicators and methods.
[0076] Accuracy indicators: Use indicators such as precision, recall, and F1 value to evaluate the classification accuracy of the model and measure the model's ability to distinguish different stages of labor.
[0077] Performance indicators: Consider the model's running time, memory usage and other performance indicators to ensure that the model can run quickly and stably in actual applications.
[0078] 3.6 Evaluation method.
[0079] Cross-validation: Use methods such as K-fold cross-validation to divide the training data into K subsets, use K-1 subsets for training each time, and use the remaining 1 subset for testing. Repeat this K times to finally obtain the average performance index of the model.
[0080] 3.7 Determine the threshold.
[0081] The threshold is determined based on the distribution of the model's predictions on the validation set or test set. For example, for a model that predicts the extent of a cow's labor, its output may be a numerical value (such as between 0 and 1) indicating the probability of a labor disorder.
[0082] The process of constructing a dairy cow labor degree prediction model is as follows: taking the posture feature history vector sequence and the dairy cow posture as input and the labor degree as output, the initial dairy cow labor degree prediction model is trained to obtain a dairy cow labor degree prediction model.
[0083] 4.1 Feature integration.
[0084] In addition to posture characteristics, the behavioral performance characteristics of the cow's legs, chest, abdomen, and head are further integrated, such as movement frequency, movement amplitude, movement coordination, etc.
[0085] Consider adding some time series features, such as the changing trend and duration of the action, to better reflect the birthing behavior patterns of dairy cows.
[0086] 4.2 Prediction model construction.
[0087] According to the integrated feature data, select the appropriate machine learning algorithm to build a prediction model, such as support vector machine, neural network, long short-term memory network (LSTM), etc. If the feature data has obvious time series characteristics, you can use LSTM and other recurrent neural network models to process time series data and improve prediction accuracy.
[0088] 4.3 Model training and adjustment strategy.
[0089] Collect more historical data, including cow behavioral characteristic data and corresponding delivery degree labels, to enrich the diversity of training data.
[0090] Preprocess the data, such as data normalization and standardization, to map data with different features to the same scale and improve the training effect of the model.
[0091] 4.4 Training process
[0092] Use optimization algorithms such as gradient descent, Adagrad, and Adadelta to train the model and continuously adjust the model parameters so that the model can better fit the training data.
[0093] During the training process, techniques such as Early Stopping are used to prevent the model from overfitting.
[0094] The thresholds of the behavior parameters of the legs, chest, abdomen, and head in the second stage of labor in the lying-down delivery process of dairy cows were set, and a model for predicting the degree of dairy cow labor based on the behavior of key parts of dairy cows was constructed. The accuracy of the prediction model was verified by blood index determination, and the measured indicators included blood ketones, blood sugar, and blood calcium.
[0095] Adjust and optimize the model based on the evaluation of the prediction results. Try using the random forest ensemble learning method to integrate multiple models to improve prediction performance. Divide the prediction results into different delivery risk levels and the classification criteria.
[0096] After building the prediction model for the degree of cow delivery, it also includes: based on the cow lying posture recognition model, key part posture feature analysis model, key part behavior tracking model and the cow delivery degree prediction model, a cow delivery obstacle early warning system is built using a layered architecture design. The cow delivery obstacle early warning system includes a data acquisition layer, a data processing layer, a model training layer, a model reasoning layer and an application display layer connected in sequence.
[0097] It adopts a layered architecture design, including data collection layer, data processing layer, model training layer, model reasoning layer and application display layer.
[0098] The data collection layer is responsible for collecting video data of cows in real time; the data processing layer is responsible for preprocessing and feature extraction of the collected data; the model training layer is responsible for training and optimizing the model; the model inference layer is responsible for using the trained model to infer and predict new data; and the application display layer is responsible for displaying the prediction results to the user in an intuitive manner.
[0099] 5.1 Functional modules.
[0100] Data acquisition module: responsible for communicating with cameras and sensors, obtaining video data and sensor data of cows, and storing and transmitting data.
[0101] Data processing module: includes image preprocessing, feature extraction, data cleaning and other functions, processes the collected data and provides support for model training and reasoning.
[0102] Model training module: Use training data to train the dairy cow calving degree identification model and prediction model, optimize model parameters, and improve model performance.
[0103] Model reasoning module: Input the newly collected video data into the trained model, perform reasoning and prediction, determine the degree of cow delivery and possible obstacles, and output the prediction results to the application display layer.
[0104] Application display module: Design a user-friendly interface, including data visualization, warning information display, operation management and other functions, to facilitate breeding personnel to view data, set models, process warning information and other operations.
[0105] Lying cow recognition model building module: build relevant models.
[0106] Leg, chest, abdomen, and head behavior image extraction module: input video data into the model to obtain leg, chest, abdomen, and head behavior images.
[0107] Leg, chest, abdomen, and head behavior key feature parameter extraction module: extract key parameters from images.
[0108] Module for constructing a model for identifying the extent of the second stage of labor in dairy cows: construct a model for identifying the extent of the second stage of labor in dairy cows.
[0109] Module for identifying the degree of the second stage of labor in dairy cows: key parameters are input into the model to obtain the identification results.
[0110] Cow delivery warning module: analyze the results and provide feedback.
[0111] 5.2 System development tools and technology selection.
[0112] Development language: Choose Python as the main development language, and use its rich scientific computing library and deep learning framework to implement various functions of the system.
[0113] Database: Use relational databases such as MySQL and Oracle or non-relational databases such as MongoDB to store data, such as basic information of dairy cows, delivery records, test data, etc.
[0114] Front-end framework: Choose Vue.js, React and other front-end frameworks to build the user interface and realize data display and interactive functions.
[0115] Back-end framework: Use Django, Flask and other back-end frameworks to build the system's back-end services and process data requests and responses.
[0116] 5.3 System integration and deployment.
[0117] Integrate the dairy cow delivery disorder early warning model with the feed management system, disease prevention and control system, etc. to achieve data sharing and interaction.
[0118] Ensure the compatibility of the system with hardware devices such as cameras and sensors to achieve real-time data collection and transmission.
[0119] Deploy the developed system to the server, conduct performance testing and optimization, and ensure that the system can run stably.
[0120] Establish a systematic backup and recovery mechanism to ensure data security and reliability.
[0121] Provide system user manuals and technical support to facilitate farmers to use and maintain the system.
[0122] In an exemplary embodiment, Figure 2 As shown, a method for early warning of dairy cow delivery obstacles is provided, comprising: step (1) constructing a recognition model of the lying posture of dairy cows; step (2) constructing a posture feature analysis model of key parts of dairy cows during lying delivery; step (3) constructing a dairy cow delivery degree identification model based on the legs, chest, abdomen and head; step (4) constructing a dairy cow delivery degree prediction model based on the behavior performance of key parts of dairy cows; step (5) developing a dairy cow delivery obstacle early warning model and system based on the behavior of key parts.
[0123] 1. Step (1) Construct a recognition model for the cow lying posture.
[0124] 1.1 Data collection.
[0125] Installation location: Arrange the cameras reasonably in the farrowing house to ensure that they cover the key parts of the cows (legs, chest, abdomen, and head) where they lie down and give birth. The cameras should be located outside the cows' range of movement to avoid being hit and interrupting filming.
[0126] Camera parameters: The resolution should be no less than 1920×1080 and the frame rate should be 25fps.
[0127] 1.2 Dataset construction.
[0128] Image screening: Extract frames from the collected video to remove blurry, unclear images or images where key parts cannot be accurately identified due to cows blocking each other.
[0129] Annotation content: Use the labelimg tool in the Python environment to annotate the remaining images. Mark a coordinate point on the nose of the head, a specific number of coordinate points on the chest and abdomen (based on the actual specific contours), and four coordinate points on the legs (for one limb). The annotation content includes normal posture and abnormal posture (such as lifting / kicking legs in lying delivery, not lifting / kicking legs, and standing delivery leg posture, chest and abdomen contours, head feature points, etc.), and the image format is saved in txt.
[0130] Dataset division: The labeled image dataset is divided into training set, validation set and test set in a ratio of 7:2:1.
[0131] 1.3 Model selection and training.
[0132] Model selection: You can choose to use the YOLOv8 algorithm to build a recognition model.
[0133] Initialization: Initialize the model using random initialization or pre-trained weights.
[0134] Training iteration: Multiple iterations of training are performed, each of which includes forward propagation, loss function calculation, and backpropagation to update model parameters. During the training process, the model parameters are adjusted by monitoring the performance indicators of the validation set (such as precision, recall, and F1 value) to prevent overfitting.
[0135] Selection of evaluation indicators: Use indicators such as precision, recall, F1 value, and accuracy to evaluate the trained model.
[0136] Model adjustment: Adjust the model according to the evaluation results, such as adjusting the model parameters, adding data enhancement operations, etc.
[0137] 2. Step (2) constructs a posture feature analysis model for key parts of a cow during lying down delivery.
[0138] Using the recognition model of the cow's delivery process in step (1), the video of the cow's second stage of delivery is extracted.
[0139] Joint point detection algorithm: The video of cow delivery is input into the trained key part performance recognition model, and the posture is estimated using the YOLOv8 algorithm to detect the hip, knee, ankle joints of the cow's legs, key bone points of the chest and abdomen, and joint points of the head.
[0140] 2.1 Posture feature calculation.
[0141] (1) Leg features.
[0142] Joint angle calculation: According to the detected joint point coordinates, the angle between the leg joints is calculated using the mathematical formula ∠ABC=arccos((AB 2 +BC 2 -AC 2 ) / (2×AB×BC)), where AB, BC, and AC are the distance vectors from the hip joint to the knee joint, the knee joint to the ankle joint, and the hip joint to the ankle joint, respectively.
[0143] Leg swing amplitude: measures the distance from the starting position to the maximum displacement of the legs during the swing process. This parameter can reflect the flexibility of the cow's legs and the degree of force applied during delivery. It analyzes and sets the corresponding threshold to promptly detect new changes in the leg swing amplitude that may be caused by fluctuations in physical condition, thereby making a more accurate dynamic assessment of delivery risks.
[0144] Calculate the swing amplitude: measure the distance from the starting position to the maximum displacement. You can use the Euclidean distance formula to calculate the distance between two points. Set the starting position coordinates ( ), the maximum displacement position coordinates are ( ), the swing amplitude d is: .
[0145] (2) Chest and abdominal characteristics.
[0146] Fluctuation amplitude: Analyze the up and down fluctuation amplitude of the chest and abdomen during breathing and delivery movements, and obtain the fluctuation amplitude value by averaging the vertical coordinate differences of multiple key points on the chest and abdomen contours.
[0147] (3) Head features.
[0148] Tilt Angle: Measures the change in angle between the head and the ground in the vertical plane, determined by the head profile and key point locations in the image.
[0149] Rotation angle: Calculate the rotation angle of the head in the horizontal plane by tracking the position changes of the key points of the head.
[0150] Head-up and head-down amplitude: measures the difference between the maximum and minimum displacement of the head in the vertical direction.
[0151] 2.2 Data calculation and analysis tools.
[0152] Installation and Import: Install NumPy and Scipy libraries in the Python environment and import them in the code.
[0153] Functional application: Use NumPy's array operation function to perform coordinate calculations and data processing, and use Scipy's scientific computing function to perform more complex mathematical calculations.
[0154] 2.3 Deep learning framework.
[0155] Installation and import: According to the selected deep learning framework, install the corresponding library in the Python environment and import it in the code.
[0156] Functional application: Use the deep learning framework to implement the training and reasoning process of the posture detection model, including data loading, model construction, training optimization, model evaluation, etc. At the same time, use the tools provided by the framework for feature extraction and analysis.
[0157] 3. Step (3) constructs a behavior tracking model for key parts of the cow during lying down delivery.
[0158] The feature parameters extracted from step (2), historical data collected by the farm and actual diagnosis results. The feature parameters of the key parts of the cow (legs, chest and abdomen, head), and the data of cows with known delivery degree (normal, mild disorder, moderate disorder, severe disorder).
[0159] 3.1 Feature fusion and modeling.
[0160] Feature fusion: The extracted posture feature parameters of the cow's legs, chest, abdomen, and head are fused to form a comprehensive feature vector, which can be achieved by weighted averaging, splicing, and other methods.
[0161] Model construction: Use the random forest algorithm to build a dairy cow delivery stage identification model.
[0162] 3.2 Training data preparation
[0163] Data expansion: In order to improve the generalization ability of the model, the scale of training data is further expanded. More data on dairy cows of different breeds, stages, and delivery environments are collected.
[0164] Perform data augmentation operations on the training data, including rotating images (for example, randomly rotating 0-30 degrees), flipping images (horizontally or vertically), and cropping images (randomly cropping while retaining key parts), etc., to increase data diversity and reduce the risk of model overfitting.
[0165] Optimization algorithm selection and parameter adjustment.
[0166] Use optimization algorithms such as gradient descent to train the model. During the training process, set a reasonable number of iterations and learning rate. The number of iterations can be set to 100-200 times, and the initial learning rate can be set to 0.01. As the training progresses, adjust the learning rate according to the performance of the model on the validation set to avoid overfitting or underfitting of the model.
[0167] Label annotation: Ensure that the labels of the training data are accurate and that each set of feature data corresponds to a clear labor stage label.
[0168] 3.3 Training process
[0169] Optimization algorithm: Select a suitable optimization algorithm, such as stochastic gradient descent (SGD), Adagrad, Adadelta, RMSprop, etc., to optimize the model and adjust the parameters of the model so that the model can better fit the training data.
[0170] Training parameter adjustment: According to the training results, adjust the learning rate, number of iterations, batch size and other training parameters to find the optimal combination of training parameters.
[0171] 3.4 Model evaluation and adjustment.
[0172] Evaluation indicators: Use indicators such as precision, recall, F1 value, and accuracy to evaluate the trained model to ensure that the model has high classification accuracy.
[0173] Model adjustment: According to the evaluation results, the model is adjusted, such as adjusting the model structure, increasing the number of features, improving the algorithm, etc., to improve the performance of the model.
[0174] 3.5 Evaluation method.
[0175] Use K-fold cross validation (such as K=5 or 10) to divide the training data into K subsets. Each time, use K-1 subsets for training and the remaining 1 subset for testing, repeating K times.
[0176] Implementation steps: For example, for 5-fold cross validation, the training data is divided into 5 parts for the first time, 4 of which are used to train the model, and the 5th is used to test the model to obtain a set of performance indicators; then the other 4 parts are used for training the second time, and the first part is used for testing, and so on, for a total of 5 training and testing.
[0177] Finally, the performance indicators (such as precision, recall, F1 value, running time, memory usage, etc.) obtained from these five times are averaged to obtain the average performance indicators of the model. Through cross-validation, the performance of the model can be evaluated more comprehensively and accurately, avoiding evaluation bias caused by the randomness of data division, and thus selecting the model parameter group with the best performance.
[0178] 3.6 Determine the threshold.
[0179] The threshold is determined based on the distribution of the model's predictions on the validation set or test set. For example, for a model that predicts the extent of a cow's labor, its output may be a numerical value (such as between 0 and 1) indicating the probability of a labor disorder.
[0180] Observe the distribution of predicted values corresponding to different actual delivery degrees. You can draw a histogram or density map for intuitive display. If you find that the predicted values of normal delivery are mostly concentrated below 0.3, mild obstacles are between 0.3-0.5, moderate obstacles are between 0.5-0.7, and severe obstacles are above 0.7, then you can preliminarily set the thresholds to 0.3, 0.5, and 0.7, corresponding to different degrees of classification boundaries.
[0181] 4. Step (4) construct a model for predicting the degree of cow parturition based on the behavioral performance of key parts of the cow.
[0182] 4.1 Behavioral feature integration and prediction.
[0183] Multi-dimensional feature fusion: further integrate the behavioral performance characteristics of the cow's legs, chest, abdomen, head and the degree of second stage labor.
[0184] 4.2 Prediction model construction.
[0185] Model selection: According to the characteristics of the integrated feature data and the requirements of the prediction task, select the appropriate machine learning algorithm to build a prediction model. If there is a linear relationship between the feature data and the degree of labor, a linear regression model can be selected; if the relationship is more complex and nonlinear, algorithms such as decision trees, random forests, or neural networks can be considered.
[0186] Model initialization: Initialize the model using random initialization or pre-trained weights.
[0187] 4.3 Model training and adjustment.
[0188] Data collection: Collect more behavioral performance data of dairy cows during delivery, including historical data and real-time monitoring data, to enrich the diversity and representativeness of training data.
[0189] Data cleaning: Clean the collected data to remove noise, outliers and duplicate data.
[0190] Data normalization / standardization: Normalize or standardize data with different features to make different features comparable, speed up model training and improve model performance.
[0191] Training algorithm: Use optimization algorithms to train the model, such as stochastic gradient descent, Adagrad, Adadelta, etc., and continuously adjust the parameters of the model so that the model can better learn the relationship between behavioral characteristics and the degree of labor.
[0192] Regularization: Regularization techniques are used to prevent model overfitting and improve the generalization ability of the model.
[0193] 4.4 Blood index testing.
[0194] Blood collection: Based on the physiological and blood analysis of dairy cows before delivery to assist in determining the delivery situation, a group of dairy cows are randomly selected to collect blood samples.
[0195] 4.5 Model evaluation and adjustment.
[0196] Evaluation indicators: Use indicators such as mean square error (MSE), mean absolute error (MAE), accuracy, recall rate, F1 value, etc. to evaluate the trained model and select the model with the best performance.
[0197] Model adjustment: According to the evaluation results, the model is adjusted, such as adjusting the model structure, increasing the number of features, improving the algorithm, etc., to improve the prediction performance of the model.
[0198] 4.6 Early warning standards for dairy cow calving risk.
[0199] (1) Low-risk warning (high probability of normal delivery).
[0200] Posture and behavior characteristics: Legs: Leg joint angles fluctuate within normal thresholds, joint movements are flexible and regular, leg swing amplitude is moderate, and no abnormal stiffness or hyperextension occurs.
[0201] Chest and abdomen: The chest and abdomen rise and fall steadily, in line with the rhythm of normal breathing and physiological activities, without rapid, slow or irregular rise and fall.
[0202] Head: The head tilt angle, rotation angle, and head raising and lowering amplitude are all within the normal threshold range, and the cows show a natural and relaxed head posture.
[0203] Comprehensive behavior: The overall behavior is normal. The activity level, feeding, drinking and other behaviors are in line with daily rules. There are no abnormal behaviors such as irritability, isolation and solitary confinement, and each behavior is within the normal threshold range.
[0204] Risk assessment based on the model: The model analyzes the characteristic parameters of the cow's posture based on the collected video data. When these parameters are highly matched with the characteristic data of normal delivery cows, it is judged as a low-risk warning. For example, the calculated value of the leg joint angle deviates from the reference angle value of the normal delivery cow within ±5°, the fluctuation range of the chest and abdomen is within ±10% of the normal average value, and the deviation of the head-related angle and amplitude is also within the set reasonable range. At the same time, the comprehensive behavioral characteristics have not deviated significantly from the normal mode through time series analysis.
[0205] (2) Medium risk warning (mild obstacles may exist).
[0206] Posture and behavior characteristics: Legs: Leg joint angles may occasionally exceed normal thresholds, but deviations are relatively small (±10°), and leg swing amplitude may have slight abnormal variations, such as occasional brief stiffness or excessive swinging.
[0207] Chest and abdomen: The chest and abdomen may fluctuate beyond the normal threshold range, deviating from the normal average by ±15% or ±20%.
[0208] Head: There may be some abnormal fluctuations in the head tilt angle, rotation angle, or head raising and lowering amplitude. The amplitude exceeding the normal threshold range is small, but can be detected by the model.
[0209] Comprehensive behavior: Cows may show slight restlessness, and there may be some subtle changes in activity level or feeding and drinking behavior, such as a slight decrease in activity level and a slightly shortened feeding time.
[0210] Risk assessment based on the model: The model analysis found that some posture characteristic parameters deviated from the normal threshold range. For example, the leg joint angle deviation was within the above threshold range, the chest and abdomen fluctuations exceeded the normal threshold range more often, and the abnormalities of the head-related angles and amplitudes reached a certain frequency and exceeded the normal threshold range more often. At the same time, the time series analysis of the comprehensive behavioral characteristics and the values of the prenatal blood indicators were combined, and then the results were analyzed. These factors were combined to determine the medium-risk warning.
[0211] (3) High-risk warning (moderate or severe disorders may exist).
[0212] Posture and behavior characteristics: Legs: There are obvious abnormalities in the leg joint angles, with deviations of more than ±15°. There may be serious abnormalities in the leg swing range, such as frequent stiffness, overextension, or inability to move normally.
[0213] Chest and abdomen: There are significant abnormalities in the amplitude of chest and abdomen fluctuations, which may be rapid or too slow, deviating from the normal average by more than ±20%, and there may even be signs of rapid or difficult breathing.
[0214] Head: There are large abnormal fluctuations in the head tilt angle, rotation angle, and head raising and lowering amplitude, and the degree beyond the normal range is quite serious.
[0215] Comprehensive behavior: Cows show obvious restlessness and a significant decrease in activity. They may stand or lie still for a long time. Their eating and drinking behaviors are seriously affected or even stop completely.
[0216] The model detected that the posture characteristic parameters seriously deviated from the normal threshold range, and the parameters of the legs, chest, abdomen and head were frequently abnormal and had large amplitudes. The time series analysis of the comprehensive behavioral characteristics showed obvious abnormal patterns, which were quite different from the behavioral patterns of normal delivery cows, and the comprehensive judgment was a high-risk warning. At the same time, combined with historical data and prenatal blood indicators, these abnormal characteristics were highly correlated with moderate or severe delivery disorders.
[0217] 5. Step (5) Develop a dairy cow birthing disorder warning model and system based on key part behavior.
[0218] According to the statistical law of posture conversion frequency of cow delivery posture detection results, early warning of cow delivery behavior is issued. According to the target detection results of newborn cows, cow delivery behavior monitoring is realized. A layered architecture design is adopted, including data collection layer, data processing layer, model training layer, model reasoning layer and application display layer.
[0219] The data collection layer is responsible for collecting video data of cows lying in real time; the data processing layer is responsible for preprocessing and feature extraction of the collected data; the model training layer is responsible for training and optimizing the model; the model inference layer is responsible for using the trained model to infer and predict new data; the application display layer is responsible for displaying the prediction results to the user in an intuitive way.
[0220] 5.1 Functional modules.
[0221] Data acquisition module: responsible for communicating with cameras and sensors, obtaining video data and sensor data of cows, and storing and transmitting data.
[0222] Data processing module: includes image preprocessing, feature extraction, data cleaning and other functions, processes the collected data and provides support for model training and reasoning.
[0223] Model training module: Use training data to train the dairy cow calving degree identification model and prediction model, optimize model parameters, and improve model performance.
[0224] Model reasoning module: Input the newly collected video data into the trained model, perform reasoning and prediction, determine the degree of cow delivery and possible obstacles, and output the prediction results to the application display layer.
[0225] Application display module: Design a user-friendly interface, including data visualization, warning information display, operation management and other functions, to facilitate breeding personnel to view data, set models, process warning information and other operations.
[0226] Lying cow recognition model building module: build relevant models.
[0227] Leg, chest, abdomen, and head behavior image extraction module: input video data into the model to obtain leg, chest, abdomen, and head behavior images.
[0228] Leg, chest, abdomen, and head behavior key feature parameter extraction module: extract key parameters from images.
[0229] Module for constructing a model for identifying the extent of the second stage of labor in dairy cows: construct a model for identifying the extent of the second stage of labor in dairy cows.
[0230] Module for identifying the degree of the second stage of labor in dairy cows: key parameters are input into the model to obtain the identification results.
[0231] Cow delivery warning module: analyze the results and provide feedback.
[0232] 5.2 System development tools and technology selection.
[0233] Development language: Choose Python as the main development language, and use its rich scientific computing libraries and deep learning frameworks, such as NumPy, Pandas, TensorFlow, PyTorch, etc., to implement various functions of the system.
[0234] Database: Use relational databases such as MySQL and Oracle or non-relational databases such as MongoDB to store data, such as basic information of dairy cows, delivery records, test data, etc.
[0235] Front-end framework: Choose Vue.js, React and other front-end frameworks to build the user interface and realize data display and interactive functions.
[0236] Back-end framework: Use Django, Flask and other back-end frameworks to build the system's back-end services and process data requests and responses.
[0237] 5.3 System integration and deployment.
[0238] Integrate the dairy cow delivery disorder early warning model with other breeding management systems, such as feed management system, disease prevention and control system, to achieve data sharing and interaction.
[0239] Ensure the compatibility of the system with hardware devices such as cameras and sensors to achieve real-time data collection and transmission.
[0240] Deploy the developed system to the server, conduct performance testing and optimization, and ensure that the system can run stably.
[0241] Establish a systematic backup and recovery mechanism to ensure data security and reliability.
[0242] Provide system user manuals and technical support to facilitate farmers to use and maintain the system.
[0243] 1. Experimental Group 1.
[0244] 1. Data collection and labeling.
[0245] Install a high-definition camera in the dairy cow farrowing house to ensure coverage of the key parts of the dairy cow farrowing. The camera resolution is 1920×1080 and the frame rate is 25fps. After the video is collected, it is framed and extracted to remove images that do not meet the requirements. The labelimg tool is used in the Python environment to annotate the coordinate points and postures (normal and abnormal) of the key parts of the remaining images. The annotated image data set is divided into a training set, a validation set, and a test set in a ratio of 7:2:1. The YOLOv8 algorithm is used to build the recognition model. After initialization, multiple iterative training is performed, and the model parameters are adjusted according to the performance indicators of the validation set.
[0246] 2. Feature extraction and model training.
[0247] The trained recognition model is used to extract the cow delivery video, which is input into the posture estimation model to detect key bone points and joint points, and calculate the relevant posture feature parameters of the legs, chest, abdomen, and head. The delivery data of cows in the second stage of labor are collected, and the feature parameters are fused to form a comprehensive feature vector. The random forest algorithm is used to build a cow delivery degree identification model, expand the training data, and optimize the model parameters.
[0248] 3. Prediction model construction and evaluation.
[0249] According to the characteristics of the feature data, the decision tree algorithm is selected to build a prediction model. After initialization, more behavioral performance data is collected. After cleaning and normalization, it is trained using the stochastic gradient descent algorithm. The L1 regularization technology is used to prevent overfitting. Finally, the model is adjusted according to the evaluation indicators.
[0250] 4. Estimate test results.
[0251] When monitoring a herd of dairy cows, the system will comprehensively analyze the comparison between the cows' delivery posture and behavioral characteristic parameters and the threshold values based on the set risk assessment criteria, so as to determine the number and risk categories of cows that may have different degrees of risk of delivery disorders.
[0252] Based on the system's detection and analysis of these comprehensive abnormal conditions, the risk level of dairy cow delivery is preliminarily determined. In the relevant research on dairy cow delivery risk assessment, the delivery risk can be graded and the corresponding treatment measures can be arranged according to the abnormal alarm conditions in various parts of the dairy cow's body.
[0253] (1) If multiple parts of the body show serious abnormal alarms at the same time, the cow should be judged as a high-risk birthing cow. Given its high birthing risk, it is very likely that professional midwives will need to be arranged in advance to be on standby, and special midwifery equipment will be fully prepared to deal with possible complex birthing conditions. At the same time, it is also necessary to pay close attention to the condition of the cow and keep abreast of changes in its physical indicators and behavioral performance in real time.
[0254] (2) When there are obvious abnormal alarms in some parts of the body, the cow can be judged as a medium-risk calving cow. For such cows, the frequency of observation should be increased, especially focusing on the changes in those parts where abnormal alarms appear. In addition, according to the actual needs, some auxiliary measures should be taken to ensure that the calving process of the cow is as smooth as possible, such as providing additional nutritional support to enhance the cow's physical strength and physical function, or appropriately adjusting the environmental conditions in which it is located to create a more suitable calving environment.
[0255] (3) If there are only slight abnormalities in individual parts of a cow, or even if these abnormalities are close to the normal threshold, the cow can be judged as a low-risk calving cow. Although the risk is relatively low, it still needs to be monitored continuously so that any subtle changes that may occur can be detected in time to ensure that the entire calving process is completed smoothly.
[0256] 2. Experimental Group 2.
[0257] 1. Data collection and labeling.
[0258] Cameras with visible and infrared dual modes, high resolution, low noise, and wide dynamic range were installed around the delivery bed and above the channel to ensure normal operation under different lighting conditions. The infrared mode was used to obtain thermal imaging information. The data acquisition frequency was set to 30fps, and histogram equalization, smoothing filtering and other methods were used to enhance the image quality. The captured video was framed to remove bad images, and the labelimg tool was used in the Python environment to annotate the remaining images in detail, including various postures and corresponding logos. The annotated image data was divided into training set, validation set, and test set in a ratio of 7:2:1.
[0259] 2. Model construction and training.
[0260] YOLOv8 was selected as the basic model. A large amount of video data of cow delivery in the second stage of labor was collected and manually annotated. A deep learning target detection algorithm was used. The trained model was used to analyze the images, detect key bone points and joint points, calculate posture feature parameters, and use relevant computing libraries and frameworks for calculation, reasoning, analysis, and visualization.
[0261] The feature parameters are integrated to form a comprehensive feature vector, and a model for identifying the degree of parturition in dairy cows is constructed using the random forest algorithm. The relevant parameters are set and the optimal combination is selected through cross-validation. The scale of training data is expanded, data enhancement is performed, and training is performed using algorithms such as gradient descent, feature selection, and regularization to ensure model performance.
[0262] 3. Construction and adjustment of prediction model.
[0263] Integrate posture and behavior performance features and time series features, and select the long short-term memory network (LSTM) algorithm to build a prediction model. Collect more historical data, train it with the AdaGrad optimization algorithm after preprocessing, use early stopping methods to prevent overfitting, and adjust the optimization model according to the results.
[0264] 4. The estimated experimental results are consistent with Experiment 1.
[0265] 3. Experimental group three.
[0266] 1. Test method.
[0267] Data collection and annotation.
[0268] Multiple high-resolution cameras were installed in the dairy cow delivery area to ensure that key parts were covered without blind spots. The camera resolution was 2560×1440 and the frame rate was 25fps. The captured video was framed to remove bad images. The remaining images were annotated in detail using the labelimg tool in the Python environment, including various postures and corresponding logos. The annotated image data was divided into training set, validation set, and test set in a ratio of 7:2:1.
[0269] 2. Model construction and training.
[0270] The model architecture is based on YOLOv8, and the pre-trained weights are used for initialization. Then, iterative training is performed, and the model parameters are fine-tuned according to the performance indicators of the validation set. At the same time, data enhancement operations are performed on the training data.
[0271] 3. Feature extraction and fusion.
[0272] The trained model is used to extract key information from the video, detect key skeleton points and joint points, calculate posture feature parameters, and fuse these parameters to form a comprehensive feature vector, while considering time series features to enrich information.
[0273] 4. Model construction and evaluation.
[0274] The random forest algorithm was used to build a dairy cow calving stage identification model, and the relevant parameters were set and the optimal combination was selected through cross-validation. The Adadelta optimization algorithm was used to adjust the model parameters, and the L1 regularization technology was combined to prevent overfitting, and the model performance was ensured according to the evaluation indicators.
[0275] 5. Prediction model construction and optimization.
[0276] According to the fused feature vectors and behavioral performance characteristics, the support vector machine algorithm was selected to build a model for predicting the degree of cow delivery. After initialization, more behavioral data and labels were collected. After cleaning and standardization, the AdaGrad optimization algorithm was used for training. The early stopping method was used to prevent overfitting, and the optimization model was adjusted according to the evaluation results.
[0277] 6. The estimated test results are consistent with those of test 1.
[0278] 4. Analysis of test results
[0279] 1. Data collection and labeling.
[0280] Effect of image quality on the model: Different image enhancement methods and camera parameters were used in different test groups. Test groups 2 and 3 differ from test group 1 in that they set a higher data acquisition frequency and used histogram equalization, smoothing filtering and other methods to enhance image quality, which may help improve the model's accuracy in identifying key features of dairy cows. By comparing the model performance of different test groups under the same model construction and training conditions but with different image quality, we can further verify the degree of impact of image quality on the final warning results.
[0281] Importance of labeling accuracy: Accurate labeling is the basis of model training. Judging from the results of each test group, using the labelimg tool in the Python environment to label images in detail, including various postures and corresponding logos, helps the model better learn the different postures and behavioral characteristics of dairy cows. If there are errors in the labeling, it may cause deviations in the model during feature extraction and classification, thereby affecting the accuracy of the early warning. Therefore, in practical applications, it is necessary to strictly control the accuracy of labeling, ensure that the labelers are professionally trained, and establish an effective labeling quality review mechanism.
[0282] 2. Model construction and training.
[0283] The impact of training data scale and diversity: During the experiment, expanding the scale of training data and increasing data diversity helped improve the generalization ability of the model. When constructing the dairy cow delivery degree identification model, both test groups 2 and 3 took measures to expand the scale of training data and increase data diversity, and the performance of the model was improved to a certain extent. This shows that in practical applications, more dairy cow data of different breeds, different stages, and different delivery environments should be collected as much as possible, and the data should be effectively expanded and preprocessed to improve the model's adaptability to different situations.
[0284] 3. Prediction model construction and evaluation.
[0285] Performance of different algorithms under different feature data: According to the characteristics of the feature data, different experimental groups selected different machine learning algorithms to build prediction models. Experimental group 1 selected the decision tree algorithm, experimental group 2 selected the long short-term memory network (LSTM) algorithm, and experimental group 3 selected the support vector machine algorithm. From the estimated test results, different algorithms showed different performance when processing different feature data. The decision tree algorithm may be more suitable for processing data with simple structural characteristics in some cases, while the LSTM algorithm may have advantages when processing data with time series characteristics, and the support vector machine algorithm may perform better when processing linearly separable or approximately linearly separable data. Therefore, in practical applications, it is necessary to select a suitable machine learning algorithm to build a prediction model based on the specific characteristics of the feature data and the requirements of the prediction task, and optimize and adjust the algorithm to improve the prediction performance of the model.
[0286] The impact of comprehensive factors on risk assessment: When conducting risk assessment, the system comprehensively considers factors such as the posture and behavioral characteristic parameters of dairy cows and prenatal blood indicators. From the test results, comprehensive consideration of these factors helps to improve the accuracy of risk assessment. For example, in the assessment of medium-risk dairy cows, in addition to considering that the posture characteristic parameters partially deviate from the normal range, the time series analysis of comprehensive behavioral characteristics and the values of prenatal blood indicators are combined, and then the results are analyzed, and these factors are combined to determine a medium-risk warning. Therefore, in practical applications, we should continue to explore more comprehensive factors and reasonably incorporate them into the risk assessment system to improve the accuracy and comprehensiveness of risk assessment.
[0287] In an exemplary embodiment, a computer device is provided, which may be a server or a terminal. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a method for early warning of dairy cow delivery disorders is implemented.
[0288] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0289] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0290] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0291] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0292] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.
[0293] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0294] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A method for early warning of dairy cow delivery problems, characterized in that: include: Obtain monitoring videos of dairy cows waiting to give birth; The monitoring video is frame-processed to obtain a monitoring video frame sequence; the monitoring video frame sequence includes monitoring video frames corresponding to different moments; Inputting the monitoring video frame corresponding to the current moment into the cow lying posture recognition model to obtain the posture of the cow to be born; the posture is a lying posture or an abnormal posture; The cow lying posture recognition model is obtained by training the YOLOv8 model using the cow historical monitoring video; When the posture of the cow to be born is abnormal, issuing an abnormal posture warning; When the posture of the cow to be born is a lying posture, the monitoring video frame sequence is input into a key part posture feature analysis model to obtain posture features of multiple key parts of the cow to be born at different times; The key part posture feature analysis model is obtained by training a deep learning framework using historical monitoring videos of dairy cows; According to the posture features of multiple key parts of the dairy cows at the same time, the posture feature vectors corresponding to different times are constructed to obtain a posture feature vector sequence; Inputting the posture feature vector corresponding to the current moment into the key part behavior tracking model to obtain the short-term prediction result of the delivery degree of the dairy cow; the key part behavior tracking model is obtained by training the random forest model using the historical monitoring video of the dairy cow; Inputting the posture feature vector sequence and the posture of the cow expecting to give birth at the current moment into a cow delivery degree prediction model to obtain a long-term prediction result of the delivery degree of the cow expecting to give birth; The dairy cow calving degree prediction model is obtained by training an initial dairy cow calving degree prediction model using historical dairy cow monitoring videos.
2. The method for early warning of dairy cow delivery problems according to claim 1, characterized in that: The initial dairy cow delivery degree prediction model is a linear regression model, a decision tree model, a random forest model or a neural network model.
3. The method for early warning of dairy cow delivery problems according to claim 1, characterized in that: Before obtaining the monitoring video of the calving cows, it also includes: Obtain multiple historical monitoring videos of dairy cows; Perform frame processing on a plurality of historical monitoring videos of dairy cows respectively to obtain a plurality of historical monitoring video frames; Label the cow posture in each frame of historical monitoring video; Taking the historical monitoring video frames as input and the cow posture in the historical monitoring video frames as output, the YOLOv8 model is trained to obtain the cow lying posture recognition model.
4. The method for early warning of dairy cow delivery problems according to claim 2, characterized in that: Before obtaining the monitoring video of the calving cows, it also includes: Obtain multiple historical monitoring videos of dairy cows; Perform frame processing on a plurality of historical monitoring videos of dairy cows respectively to obtain a plurality of historical monitoring video frame sequences; Using the array operation function in the NumPy environment and the Scipy library, the posture characteristics of multiple key parts of the cow at different historical moments in each historical monitoring video frame sequence are determined; Taking the historical monitoring video frame sequence as input and the posture features of multiple key parts of the cow at different historical moments in the historical monitoring video frame sequence as output, the deep learning framework is trained to obtain the key part posture feature analysis model.
5. The method for early warning of dairy cow delivery problems according to claim 4, characterized in that: Before obtaining the monitoring video of the calving cows, it also includes: Constructing multiple posture feature historical vector sequences; the posture feature historical vector sequences correspond one-to-one to the historical monitoring video frame sequences; any of the posture feature historical vector sequences includes multiple posture feature historical vectors; the multiple posture feature historical vectors correspond one-to-one to the historical moments in the corresponding posture feature historical vector sequences; any of the posture feature historical vector sequences is constructed based on the posture features of multiple key parts of the cow at the corresponding historical moments; Label each posture feature history vector sequence corresponding to the degree of delivery; After training the random forest model with the posture feature history vector as input and the degree of delivery as output, a key part behavior tracking model was obtained.
6. The method for early warning of dairy cow delivery problems according to claim 5, characterized in that: Before obtaining the monitoring video of the calving cows, it also includes: The posture feature history vector sequence and the cow posture are used as input, and the delivery degree is used as output. The initial cow delivery degree prediction model is trained to obtain the cow delivery degree prediction model.
7. The method for early warning of dairy cow delivery problems according to claim 6, characterized in that: After the initial cow delivery degree prediction model is trained by taking the posture feature history vector sequence and the cow's posture as input and the delivery degree as output to obtain the cow delivery degree prediction model, the following is also included: Based on the cow lying posture recognition model, the key part posture feature analysis model, the key part behavior tracking model and the cow delivery degree prediction model, a cow delivery obstacle early warning system is constructed by adopting a layered architecture design; the cow delivery obstacle early warning system includes a data acquisition layer, a data processing layer, a model training layer, a model reasoning layer and an application display layer connected in sequence.
8. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method for early warning of dairy cow delivery disorders according to any one of claims 1 to 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for early warning of cow delivery disorders according to any one of claims 1 to 7 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for early warning of cow delivery disorders according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Livestock delivery monitoring and early warning system and method based on CLIP model
CN115359418A
Sow delivery intelligent prediction system and method
CN117197902A
Cow delivery stress degree identification method and system
CN117351404A
Sow delivery time prediction method based on computer vision
CN117392750A
Athlete throwing action analysis and training method and equipment based on deep learning
CN119068558A
