Livestock abnormal behavior intelligent monitoring method and system based on time dimension, computing device and readable storage medium
Through the intelligent monitoring method of livestock abnormal behavior based on the time dimension, combined with the SlowFast network and Vision Transformer, the problems of high manual monitoring cost and poor generalization ability are solved, the whole process monitoring and timely warning are realized, and the subjectivity and difficulty of manual detection are reduced. cost.
Patent Information
- Application Number
- CN202410639951.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-10-01
AI Technical Summary
Existing technologies require high labor costs in monitoring abnormal livestock behavior, making it difficult to detect and isolate potentially sick pigs in a timely manner, and methods based on target detection have poor results and poor generalization capabilities when data quality requirements are high and targets overlap.
Adopt an intelligent monitoring method for abnormal livestock behavior based on the time dimension, use SlowFast network and Vision Transformer to improve the model through video data preprocessing, behavior recognition, data enhancement and Focal Loss loss function, and count the duration of lying behavior. If it exceeds the threshold, Issue an early warning.
It achieves full-process monitoring, issues early warnings in a timely manner, reduces the subjectivity and cost of manual detection, improves the efficiency of abnormal behavior detection, is suitable for multiple targets and interleaved situations, and has strong generalization capabilities.
Smart Images

Figure CN118736665A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of animal husbandry phenotype recognition and detection technology, and in particular to a method and system for intelligently monitoring abnormal livestock behaviors based on a time dimension. Background Art
[0002] The ViT (Vision Transformer) neural network was proposed by the Google team for computer vision tasks such as target detection and image segmentation. Its main idea is to convert the image into a sequence and use the attention mechanism to extract features. ViT is based on the Transformer model and is extended from the field of natural language processing to the field of images. Compared with the traditional convolutional neural network model, it has better interpretability and scalability; the SlowFast network, that is, the fast-slow network, has two channels, the slow channel and the fast channel. The difference lies in the time resolution and the number of channels. The slow channel runs at a lower time resolution and has a larger number of channels, which is used to capture the semantic information of video objects; the fast channel runs at a higher time resolution and has a smaller number of channels, which is used to obtain the motion information of video objects; the Focal Loss loss function used to solve the problem of category imbalance is used to solve the problems of positive and negative sample imbalance and difficult-to-classify sample learning in target detection in the image field.
[0003] The existing technology of manual monitoring of abnormal behavior of livestock is relatively labor-intensive. Since the actual breeding base has a large number of pigs and a small number of professional breeders, it is time-consuming to monitor the behavioral health of each livestock, and it is difficult to monitor the behavioral status of livestock throughout the entire process. Potentially sick pigs cannot be separated in time, resulting in disease transmission and increased breeding costs. The current method of combining machine learning to monitor abnormal behavior of livestock is based on target detection and tracking, which has high requirements for data quality and a relatively complex data collection process. It works better when there are fewer livestock targets and fewer target overlaps. However, in actual breeding, there are more livestock in a pen and overlaps between livestock are also common, affecting the tracking quality. The traditional algorithm model for target detection and tracking has poor generalization ability. Continuous monitoring of target behavior requires continuous and large-scale annotation of a certain behavior, which may result in unstable results on new sample data sets. Summary of the invention
[0004] The present invention provides a method and system for intelligently monitoring abnormal livestock behaviors based on a time dimension, which reduces the cost of manpower monitoring abnormal livestock behaviors, reduces the time for discovering and isolating potentially sick pigs, and improves the quality of livestock breeding.
[0005] In order to solve the above technical problems, the technical solution of the present invention is as follows:
[0006] In a first aspect, a method for intelligently monitoring abnormal behavior of livestock based on a time dimension is provided, the method comprising:
[0007] Obtain video data, construct livestock behavior datasets, and preprocess pig behavior datasets;
[0008] Use the SlowFast network to perform behavior recognition on the preprocessed pig dataset to obtain livestock behavior recognition results;
[0009] According to the livestock behavior recognition results, a behavior time statistical algorithm is used to count the duration of the livestock lying behavior, so as to obtain the statistical results of the duration of the lying behavior;
[0010] Based on the statistical results, it is determined whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, an early warning message and the visualization results of livestock behavior monitoring are issued. If the duration of the lying behavior does not exceed the threshold, behavior recognition and time statistics continue.
[0011] Furthermore, video data is obtained, and a livestock behavior dataset is constructed, and the livestock behavior dataset is preprocessed, including:
[0012] Use monitoring equipment to obtain video data;
[0013] Classify the video data to obtain a number of classified videos;
[0014] According to the lying and non-lying behaviors of livestock, several classified videos are labeled and different behavior categories are encoded to obtain pig targets;
[0015] Construct a livestock behavior dataset based on several classified videos and livestock targets;
[0016] Data augmentation is performed on the pig behavior dataset to obtain the preprocessed livestock dataset.
[0017] Furthermore, the SlowFast network is used to perform behavior recognition on the preprocessed pig dataset to obtain livestock behavior recognition results, including:
[0018] Construct the SlowFast network structure and determine the behavior recognition task;
[0019] The Focal Loss function is used to improve the imbalance of pig behavior categories in the SlowFast network structure to obtain the improved SlowFast network structure;
[0020] The preprocessed livestock dataset is input into the slow and fast branches of the improved SlowFast network;
[0021] Use the slow branch to perform convolution operations to obtain semantic information in the livestock dataset videos;
[0022] Use fast branches to perform convolution operations to obtain behavioral information in the video;
[0023] After the fast branch convolution operation, the obtained behavior information is adjusted using the Vision Transformer structure to obtain adjusted behavior information;
[0024] The semantic information and the adjusted behavioral information are laterally connected through time dimension convolution to obtain the pig behavior recognition results.
[0025] Furthermore, the Focal Loss loss function is used to improve the imbalance of pig behavior categories in the SlowFast network structure to obtain the improved SlowFast network structure, including:
[0026] Determine the exponent γ of the focusing factor and the Focal Loss function training model;
[0027] The Focal Loss loss function training model updates parameters according to the loss calculated by the Focal Loss loss function, where the formula of the Focal Loss loss function is:
[0028] FL(p t )=-α t (1-p t ) γ log(p t );
[0029] Among them, p t is the model's predicted probability for the sample, α t is the focusing factor, γ is the exponent of the focusing factor;
[0030] The SlowFast network structure is improved using the updated loss parameters to obtain an improved SlowFast network structure.
[0031] Furthermore, after the fast branch convolution operation, the obtained behavior information is adjusted using the Vision Transformer structure to obtain adjusted behavior information, including:
[0032] In the SlowFast network structure, the Vision Transformer structure is introduced after the convolution operation of the fast channel;
[0033] Divide the images of the livestock dataset into a set of fixed-size image patches;
[0034] Convert image blocks into sequence data;
[0035] Input the sequence data into the Transformer Encoder image processing encoder for processing;
[0036] In the Transformer Encoder image processing encoder, the self-attention mechanism is used to capture the relationship between different regions within the image;
[0037] According to the relationship between different regions within the image, the relationship between the high-dimensional features of the frames is obtained;
[0038] According to the relationship between the high-dimensional features of the frames, the behavior information is adjusted to obtain adjusted behavior information.
[0039] Furthermore, according to the livestock behavior recognition result, a behavior time statistics algorithm is used to count the duration of the livestock lying behavior to obtain the duration statistics of the lying behavior, including:
[0040] Inputting the number of livestock behaviors NT and the video frame rate fps into the behavior time statistics algorithm, wherein NT includes the number of lying behaviors and the number of non-lying behaviors;
[0041] For each video frame, determine whether the behavior video frame number DT is equal to the number of lying behaviors. If it is equal to the number of lying behaviors, then the number of lying behaviors is increased by 1. If it is not equal to the number of lying behaviors, then the number of non-lying behaviors is increased by 1.
[0042] The behavior duration BT is calculated according to the behavior video frame number DT and the video frame rate fps, wherein BT=DT / fps. The behavior duration BT is equal to the behavior video frame number DT divided by the video frame rate fps, which represents the duration of the behavior.
[0043] Further, based on the statistical results, it is determined whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, an early warning message and a visualization result of the livestock behavior monitoring are issued. If the duration of the lying behavior does not exceed the threshold, the behavior recognition and time statistics are continued, including:
[0044] Determine whether the duration of lying down behavior exceeds a preset threshold;
[0045] If the duration of lying behavior exceeds the threshold, an early warning message will be issued to remind the breeding staff through message push and sound alarm;
[0046] Generate and display the visual results of livestock behavior monitoring on the device's web interface;
[0047] If the duration of lying behavior does not exceed the threshold, continue with behavior identification and time statistics.
[0048] In the second aspect, an intelligent monitoring system for abnormal livestock behavior based on a time dimension includes:
[0049] An acquisition module is used to acquire video data, construct a livestock behavior data set, and pre-process the livestock behavior data set;
[0050] The processing module uses the SlowFast network to perform behavior recognition on the preprocessed pig data set to obtain livestock behavior recognition results; based on the livestock behavior recognition results, the behavior time statistics algorithm is used to count the duration of the livestock lying behavior to obtain the statistical results of the lying behavior duration; based on the statistical results, it is determined whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, an early warning message and a visualization result of the pig behavior monitoring are issued; if the duration of the lying behavior does not exceed the threshold, behavior recognition and time statistics are continued.
[0051] According to a third aspect, a computing device includes:
[0052] one or more processors;
[0053] The storage system is used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the above method.
[0054] In a fourth aspect, a computer-readable storage medium stores a program, and the program implements the above method when executed by a processor.
[0055] The above solution of the present invention includes at least the following beneficial effects:
[0056] The above scheme of the present invention combines computer vision and deep learning framework to monitor and warn of abnormal behavior of livestock, which can realize full-process monitoring, issue early warnings in time, isolate potential sick pigs, and improve breeding quality; detecting abnormal behavior by computer vision and deep learning framework can avoid the subjectivity of manual detection, improve the efficiency of abnormal behavior detection, and reduce cost investment;
[0057] Combined with breeding expertise, when livestock remain lying on the ground for a long time, do not respond obviously to environmental stimuli, and show mental dullness, they may have symptoms of viral infection and colds. Lying on the ground is considered an abnormal behavior. Based on the time dimension, when the duration of the behavior exceeds a certain threshold, an early warning is issued; compared with other behaviors that require trajectory tracking, when there are many targets and a large number of intersections, the behavior of lying on the ground is less affected, and its requirements for data annotation quality are relatively low, and its generalization ability is stronger. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1It is a flow chart of a method for intelligently monitoring abnormal behavior of livestock based on the time dimension provided by an embodiment of the present invention.
[0059] Figure 2 It is a schematic diagram of a system for intelligent monitoring of abnormal livestock behaviors based on the time dimension provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0060] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0061] like Figure 1 As shown, an embodiment of the present invention proposes an intelligent monitoring method for abnormal livestock behavior based on a time dimension, the method comprising:
[0062] Step 11, acquiring video data, constructing a livestock behavior data set, and preprocessing the livestock behavior data set;
[0063] Step 12, using the SlowFast network to perform behavior recognition on the preprocessed livestock data set to obtain livestock behavior recognition results;
[0064] Step 13, based on the livestock behavior recognition result, using a behavior time statistics algorithm to count the duration of the livestock lying behavior, so as to obtain a statistical result of the duration of the lying behavior;
[0065] Step 14, based on the statistical results, determine whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, issue a warning message and visualize the results of livestock behavior monitoring. If the duration of the lying behavior does not exceed the threshold, continue to perform behavior recognition and time statistics.
[0066] Specifically, in this implementation, live pigs are taken as an example to illustrate the implementation process of this solution.
[0067] In an embodiment of the present invention, an intelligent monitoring method for abnormal livestock behavior based on a time dimension is used to monitor and warn of abnormal lying behavior of live pigs; by acquiring video data and constructing a live pig behavior data set, the data set is preprocessed to improve the quality and availability of the data; then, by using a SlowFast network to perform behavior recognition on the preprocessed live pig data set, the behavior type of the live pig, such as lying or non-lying behavior, can be accurately identified; through behavior recognition, the live pig behavior recognition result can be obtained; according to the live pig behavior recognition result, a behavior time statistical algorithm is used to perform statistics on the duration of the live pig lying behavior; the purpose is to obtain the duration statistical result of the live pig lying behavior; then, according to the statistical result, it is determined whether the duration of the lying behavior exceeds a preset threshold; if the duration of the lying behavior exceeds the threshold, it means that the lying behavior of the live pig is abnormal, and there may be problems such as illness or injury; the system will issue a warning message to remind relevant personnel to handle it, and at the same time display the visualization results of the live pig behavior monitoring, so that the personnel can understand the specific situation; if the duration of the lying behavior does not exceed the threshold, it means that the lying behavior of the live pig is normal, and the system will continue to perform behavior recognition and time statistics operations to maintain the continuity of monitoring.
[0068] like Figure 1 As shown, step 11, obtaining video data, and constructing a pig behavior data set, and preprocessing the pig behavior data set, including:
[0069] Step 111, using monitoring equipment to obtain video data;
[0070] Step 112, classifying the video data to obtain a number of classified videos;
[0071] Step 113, labeling a number of classified videos according to the lying behavior and non-lying behavior of the live pigs, encoding different behavior categories to obtain live pig targets;
[0072] Step 114, constructing a pig behavior dataset based on a number of classified videos and pig targets;
[0073] Step 115, performing data enhancement on the pig behavior dataset to obtain a preprocessed pig dataset.
[0074] In the embodiment of the present invention, by installing monitoring equipment, video data of live pigs can be obtained in real time; the obtained video data is classified according to time periods for subsequent behavior annotation and data set construction; for each classified video data, the lying behavior and non-lying behavior of the live pigs are labeled, and different behavior categories are encoded for subsequent behavior recognition and statistics, and about 5,000 frames of each video are labeled. For the accuracy of model training and recognition accuracy, only targets in which the live pigs appear more than half of their bodies in the picture are labeled; the labeled video data and behavior category codes are organized into the form of a data set for subsequent model training and behavior recognition; In order to improve the robustness and generalization ability of the training model, data enhancement operations can be performed on the pig behavior dataset to add noise, blur, adjust contrast, and make a series of random changes or extensions to the original data, thereby enhancing the quantity and diversity of training data and enabling the model to learn richer features; providing high-quality training data, reducing noise and redundant information, and increasing data diversity; through the preprocessed pig dataset, the accuracy and stability of the behavior recognition model can be improved, thereby achieving effective monitoring and early warning of abnormal pig behavior; at the same time, through data enhancement operations, the robustness of the model can also be improved, and it can adapt to various scenarios and environmental conditions.
[0075] like Figure 1 As shown, step 12, using the SlowFast network to perform behavior recognition on the preprocessed pig data set to obtain the pig behavior recognition result, including:
[0076] Step 121, constructing a SlowFast network structure and determining a behavior recognition task;
[0077] Step 122, using the Focal Loss loss function to improve the imbalance of pig behavior categories in the SlowFast network structure to obtain an improved SlowFast network structure;
[0078] Step 123, inputting the preprocessed pig data set into the slow branch and the fast branch in the improved SlowFast network;
[0079] Step 124, using the slow branch to perform a convolution operation to obtain semantic information in the video of the pig dataset;
[0080] Step 125, using the fast branch to perform a convolution operation to obtain behavior information in the video;
[0081] Step 126, after the fast branch convolution operation, use the Vision Transformer structure to adjust the acquired behavior information to obtain adjusted behavior information;
[0082] Step 127, the semantic information and the adjusted behavior information are laterally connected through time dimension convolution to obtain the pig behavior recognition result.
[0083] In an embodiment of the present invention, the SlowFast network is a deep learning network structure for video data, which processes video frame sequences through slow branches and fast branches, and samples the time dimension to different degrees respectively; the slow branch performs sparse sampling on the frame sequence, while the fast branch performs dense sampling on the frame sequence. The slow branch has a low temporal sampling rate and a large number of convolution kernel channels, and mainly obtains semantic information in the video; the fast branch has a high temporal sampling rate and a small number of convolution kernel channels, and mainly obtains behavioral information in the video; the feature extraction network of the slow channel can be any convolution model that processes spatiotemporal frame sequences, and reduces the redundancy of information by sampling the video at intervals. For different data inputs, Set the sampling interval to a reasonable value. Since the slow channel has a low temporal resolution, the sampling interval is generally set to a larger value. Assuming that the number of frames collected by the slow channel is T, the original video contains T×τ frames. Considering the richness of the spatial information that can be extracted, more convolution kernels are generally set. The purpose of the fast channel is to extract temporal information. Therefore, its sampling interval is smaller, which is τ / α (α>1), where α is the frame rate ratio of the fast channel and the slow channel, usually set to 8. Since the fast channel can extract temporal resolution features, it does not perform pooling or cross-temporal convolution in the temporal dimension. The number of convolution kernels is small, which is the extraction of motion information. Therefore, the fast channel can well perceive temporal motion changes. Loss is a loss function used to solve the problem of category imbalance in classification tasks; in the slow branch, by using the Focal Loss loss function, the imbalance of pig behavior categories can be better handled and the recognition ability of minority categories can be improved; Vision Transformer is an image processing model based on the self-attention mechanism, which is used to extract high-dimensional features of images; in the fast branch, by using the Vision Transformer model, the relationship between video frames can be captured, further improving the accuracy of behavior recognition; through the convolution operation in the time dimension, the output information between the slow branch and the fast branch is fused and connected; the feature representation of the two branches can be fully utilized to improve the expression ability of behavior recognition.
[0084] like Figure 1 As shown, step 122 uses the Focal Loss function to improve the imbalance of pig behavior categories in the SlowFast network structure to obtain an improved SlowFast network structure, including:
[0085] Step 1221, determining the exponent γ of the focusing factor and the Focal Loss function training model;
[0086] Step 1222, the Focal Loss loss function training model performs parameter updates according to the loss calculated by the Focal Loss loss function, wherein the formula of the Focal Loss loss function is:
[0087] FL(p t )=-α t (1-p t ) γ log(p t );
[0088] Among them, p t is the model's predicted probability for the sample, α t is the focusing factor, γ is the exponent of the focusing factor;
[0089] Step 1223, using the updated loss parameters to improve the SlowFast network structure to obtain an improved SlowFast network structure.
[0090] In the embodiment of the present invention, in the pig behavior data, the frequencies of lying down and the other two categories are different, which is prone to class imbalance, causing the model to be more likely to be biased towards the majority category during the training process; Focal Loss is a loss function based on binary cross entropy for class imbalance, which can make the model pay more attention to samples that are difficult to classify when facing minority category samples, thereby improving the performance of the model;
[0091] The cross entropy loss function expression is as follows:
[0092] make
[0093] Focal Loss can be expressed as:
[0094] L fl =-(1-p t ) γ log(p t )
[0095] Focal Loss solves the problem of class imbalance by adjusting the weight of samples to make the loss of minority class samples more important. When a sample belongs to the majority class, the closer the predicted probability pt of the sample is to 1, the easier the sample is to classify. The value of (1-pt)γ is close to 0, which means that for samples that are easy to classify, the loss of the sample will be reduced. When a sample belongs to the minority class, for difficult samples, pt is close to 0, and (1-pt)γ is close to 1, which increases the loss of difficult samples and makes the model pay more attention to difficult samples.
[0096] The final expression is as follows:
[0097] FL(pt )=-α t (1-p t ) γ log(p t )
[0098] Among them, p t is the model's predicted probability for the sample, α t is the focusing factor, γ is the exponent of the focusing factor; it can suppress the imbalance in the number of positive and negative samples, and control the imbalance in the number of simple or difficult samples; by introducing the exponent γ of the focusing factor, the Focal Loss loss function can adjust the weight of samples during training, increase the importance of difficult samples in the loss function, and make the model pay more attention to pig behaviors that are difficult to classify; it can improve the model's recognition ability for minority categories and enhance the detection and early warning effects of abnormal behaviors.
[0099] like Figure 1 As shown, step 123, after the fast branch convolution operation, the obtained behavior information is adjusted using the Vision Transformer structure to obtain adjusted behavior information, including:
[0100] Step 1231, in the SlowFast network structure, the VisionTransformer structure is introduced after the convolution operation of the fast channel;
[0101] Step 1232, dividing the images of the pig dataset into a set of image blocks of fixed size;
[0102] Step 1233, converting the image block into sequence data;
[0103] Step 1234, inputting the sequence data into a Transformer Encoder image processing encoder for processing;
[0104] Step 1235, in the Transformer Encoder image processing encoder, use a self-attention mechanism to capture the relationship between different regions within the image;
[0105] Step 1236, obtaining the relationship between high-dimensional features of the frames according to the relationship between different regions within the image;
[0106] Step 1237, adjusting the behavior information according to the relationship between the high-dimensional features of the frames to obtain adjusted behavior information.
[0107] In an embodiment of the present invention, the traditional convolutional neural network uses local perception and weight sharing when processing images, which may not be able to fully capture the relationship between different areas within the image; the Vision Transformer model introduces a self-attention mechanism in the Transformer Encoder image processing encoder, which can capture the relationship between different areas within the image and extract the correlation between high-dimensional features; the fast branch inputs the pig data set into the Vision Transformer model to obtain the relationship between different areas within the image; the relationship information can provide richer contextual information and enhance the understanding and recognition of pig behavior; by using the Vision Transformer model, the fast branch can better capture the relationship between high-dimensional features of frames in the pig data set; the understanding and expression of pig behavior can be improved, thereby enhancing the accuracy and robustness of behavior recognition, and the feature information at different levels can be comprehensively considered to improve the monitoring and early warning effects of abnormal pig behavior.
[0108] like Figure 1 As shown, step 13, based on the pig behavior recognition result, a behavior time statistics algorithm is used to count the duration of the pig lying behavior to obtain the statistical result of the duration of the lying behavior, including:
[0109] Step 131, inputting the number of pig behaviors NT and the video frame rate fps into a behavior time statistics algorithm, wherein NT includes the number of lying behaviors and the number of non-lying behaviors;
[0110] Step 132, for each video frame, determine whether the behavior video frame number DT is equal to the number of lying behaviors, if it is equal to the number of lying behaviors, then the number of lying behaviors is increased by 1, if it is not equal to the number of lying behaviors, then the number of non-lying behaviors is increased by 1;
[0111] Step 133, calculate the behavior duration BT according to the behavior video frame number DT and the video frame rate fps, wherein BT=DT / fps, and the behavior duration BT is equal to the behavior video frame number DT divided by the video frame rate fps, which represents the duration of the behavior.
[0112] In an embodiment of the present invention, the number of pig behaviors NT and the video frame rate fps are input into a behavior time statistics algorithm to judge each video frame; if the number of behavior video frames DT is equal to the number of lying behaviors, it means that there is lying behavior in the video frame, and the number of lying behaviors is increased by 1; if the number of behavior video frames DT is not equal to the number of lying behaviors, it means that there is no lying behavior in the video frame, and the number of non-lying behaviors is increased by 1; according to the ratio of the number of behavior video frames DT and the video frame rate fps, the duration BT of the lying behavior is calculated; the behavior duration BT is equal to the number of behavior video frames DT divided by the video frame rate fps, indicating that the lying behavior The duration of the lying behavior can be counted through the behavior time statistics algorithm. The duration of the lying behavior can be understood to help determine whether the pig behavior is abnormal. If the duration of the lying behavior exceeds the set threshold, it may indicate that the pig has abnormal behavior and needs to be monitored and warned in time. By counting the duration of the lying behavior, more accurate abnormal behavior detection and warning can be provided. At the same time, by comparing with the set threshold, the degree of abnormality can be judged according to the duration of the lying behavior, further optimizing the monitoring and early warning strategies and improving the effectiveness of pig breeding management.
[0113] like Figure 1 As shown, step 14, based on the statistical results, determines whether the duration of lying behavior exceeds the threshold. If the duration of lying behavior exceeds the threshold, an early warning message and a visualization result of pig behavior monitoring are issued. If the duration of lying behavior does not exceed the threshold, behavior recognition and time statistics are continued, including:
[0114] Step 141, determining whether the duration of lying on the ground behavior exceeds a preset threshold;
[0115] Step 142, if the duration of lying behavior exceeds the threshold, a warning message is issued to remind the breeding staff through message push and sound alarm;
[0116] Step 143, generating and displaying the visualization results of pig behavior monitoring on the web interface of the device;
[0117] Step 144: If the duration of the lying behavior does not exceed the threshold, continue to perform behavior recognition and time statistics.
[0118] In the embodiment of the present invention, by comparing the duration BT of the lying behavior with a preset threshold, it is determined whether it exceeds the set threshold; if the duration of the lying behavior exceeds the threshold, it means that the lying behavior of the pig is abnormal, and there may be problems or poor health; if the duration of the lying behavior does not exceed the threshold, it is considered that the lying behavior is normal; if the duration of the lying behavior exceeds the threshold, the system will issue an early warning message to remind the breeder through message push, sound alarm, etc.; at the same time, the system will generate a visualization result of the pig behavior monitoring and display it on the Web interface of the device; the visualization result can include video clips of abnormal behavior, behavior duration curves, etc., to help breeders understand the pig more intuitively. Abnormal behavior of pigs; if the duration of lying behavior does not exceed the threshold, the system will continue to perform behavior recognition and time statistics, and can continuously monitor the behavior of pigs; the behavior of pigs can be monitored in real time, and abnormal behavior can be discovered and handled in time to ensure the health of pigs and breeding benefits; by judging whether the duration of lying behavior exceeds the threshold, and issuing early warning information and visual display accordingly, it can provide timely abnormal behavior monitoring and early warning functions; it can help breeders to discover and handle abnormal behavior of pigs in time, reduce breeding risks, and improve the effectiveness of breeding management; at the same time, through visual display, it can provide more intuitive information display, which is convenient for breeders to analyze and judge pig behavior.
[0119] like Figure 2 As shown, the embodiment of the present invention further provides an intelligent monitoring system 20 for abnormal behavior of pigs based on time dimension, comprising:
[0120] An acquisition module 21 is used to acquire video data, construct a pig behavior data set, and pre-process the pig behavior data set;
[0121] Processing module 22 uses the SlowFast network to perform behavior recognition on the preprocessed pig data set to obtain the pig behavior recognition result; based on the pig behavior recognition result, use the behavior time statistics algorithm to count the duration of the pig lying behavior to obtain the statistical result of the duration of the lying behavior; based on the statistical result, determine whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, issue a warning message and visualize the pig behavior monitoring results. If the duration of the lying behavior does not exceed the threshold, continue to perform behavior recognition and time statistics.
[0122] Optionally, a method for intelligently monitoring abnormal livestock behavior based on a time dimension comprises:
[0123] Obtain video data, construct a pig behavior dataset, and preprocess the pig behavior dataset;
[0124] Use the SlowFast network to perform behavior recognition on the preprocessed pig dataset to obtain pig behavior recognition results;
[0125] According to the pig behavior recognition results, the duration of the pig lying behavior is counted using the behavior time statistics algorithm to obtain the duration statistics of the lying behavior;
[0126] Based on the statistical results, determine whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, an early warning message and the visualization results of the pig behavior monitoring will be issued. If the duration of the lying behavior does not exceed the threshold, behavior recognition and time statistics will continue.
[0127] Furthermore, video data is obtained, and a pig behavior dataset is constructed, and the pig behavior dataset is preprocessed, including:
[0128] Use monitoring equipment to obtain video data;
[0129] Classify the video data to obtain a number of classified videos;
[0130] According to the lying and non-lying behaviors of pigs, several classified videos are labeled and different behavior categories are encoded to obtain pig targets;
[0131] Construct a pig behavior dataset based on several classified videos and pig targets;
[0132] Data enhancement is performed on the pig behavior dataset to obtain a preprocessed pig dataset.
[0133] Furthermore, the SlowFast network is used to perform behavior recognition on the preprocessed pig dataset to obtain pig behavior recognition results, including:
[0134] Construct the SlowFast network structure and determine the behavior recognition task;
[0135] The Focal Loss function is used to improve the imbalance of pig behavior categories in the SlowFast network structure to obtain the improved SlowFast network structure;
[0136] The preprocessed pig dataset is input into the slow branch and the fast branch of the improved SlowFast network;
[0137] Use the slow branch to perform convolution operations to obtain semantic information in the pig dataset video;
[0138] Use fast branches to perform convolution operations to obtain behavioral information in the video;
[0139] After the fast branch convolution operation, the obtained behavior information is adjusted using the Vision Transformer structure to obtain adjusted behavior information;
[0140] The semantic information and the adjusted behavioral information are laterally connected through time dimension convolution to obtain the pig behavior recognition results.
[0141] Furthermore, the Focal Loss loss function is used to improve the imbalance of pig behavior categories in the SlowFast network structure to obtain the improved SlowFast network structure, including:
[0142] Determine the exponent γ of the focusing factor and the Focal Loss function training model;
[0143] The Focal Loss loss function training model updates parameters according to the loss calculated by the Focal Loss loss function, where the formula of the Focal Loss loss function is:
[0144] FL(p t )=-α t (1-p t ) γ log(p t );
[0145] Among them, p t is the model's predicted probability for the sample, α t is the focusing factor, γ is the exponent of the focusing factor;
[0146] The SlowFast network structure is improved using the updated loss parameters to obtain an improved SlowFast network structure.
[0147] Furthermore, after the fast branch convolution operation, the obtained behavior information is adjusted using the Vision Transformer structure to obtain adjusted behavior information, including:
[0148] In the SlowFast network structure, the Vision Transformer structure is introduced after the convolution operation of the fast channel;
[0149] Divide the images of the pig dataset into a set of fixed-size image patches;
[0150] Convert image blocks into sequence data;
[0151] Input the sequence data into the Transformer Encoder image processing encoder for processing;
[0152] In the Transformer Encoder image processing encoder, the self-attention mechanism is used to capture the relationship between different regions within the image;
[0153] According to the relationship between different regions within the image, the relationship between the high-dimensional features of the frames is obtained;
[0154] According to the relationship between the high-dimensional features of the frames, the behavior information is adjusted to obtain adjusted behavior information.
[0155] Furthermore, according to the pig behavior recognition result, a behavior time statistics algorithm is used to count the duration of the pig lying behavior to obtain the duration statistics of the lying behavior, including:
[0156] Input the number of pig behaviors NT and the video frame rate fps into the behavior time statistics algorithm, where NT includes the number of lying behaviors and the number of non-lying behaviors;
[0157] For each video frame, determine whether the behavior video frame number DT is equal to the number of lying behaviors. If it is equal to the number of lying behaviors, then the number of lying behaviors is increased by 1. If it is not equal to the number of lying behaviors, then the number of non-lying behaviors is increased by 1.
[0158] The behavior duration BT is calculated according to the behavior video frame number DT and the video frame rate fps, wherein BT=DT / fps. The behavior duration BT is equal to the behavior video frame number DT divided by the video frame rate fps, which represents the duration of the behavior.
[0159] Further, based on the statistical results, it is determined whether the duration of lying behavior exceeds the threshold. If the duration of lying behavior exceeds the threshold, an early warning message and a visualization result of pig behavior monitoring are issued. If the duration of lying behavior does not exceed the threshold, behavior recognition and time statistics are continued, including:
[0160] Determine whether the duration of lying down behavior exceeds a preset threshold;
[0161] If the duration of lying behavior exceeds the threshold, an early warning message will be issued to remind the breeding staff through message push and sound alarm;
[0162] Generate and display the visual results of pig behavior monitoring on the device's web interface;
[0163] If the duration of lying behavior does not exceed the threshold, continue with behavior identification and time statistics.
[0164] It should be noted that the system is a system corresponding to the above method, and all implementation methods in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.
[0165] The embodiment of the present invention further provides a computing device, comprising: a processor, a memory storing a computer program, wherein when the computer program is executed by the processor, the method described above is executed. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.
[0166] The embodiment of the present invention also provides a computer-readable storage medium storing instructions, which, when executed on a computer, enable the computer to execute the method described above. All implementations in the above method embodiment are applicable to this embodiment and can achieve the same technical effect.
[0167] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0168] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems, systems and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0169] In the embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of systems or units, which can be electrical, mechanical or other forms.
[0170] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0171] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0172] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0173] In addition, it should be noted that in the system and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. Moreover, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order, and some steps can be performed in parallel or independently of each other. For those of ordinary skill in the art, it is understood that all or any steps or components of the method and system of the present invention can be implemented in any computing system (including processors, storage media, etc.) or a network of computing systems in hardware, firmware, software or a combination thereof, which can be achieved by those of ordinary skill in the art using their basic programming skills after reading the description of the present invention.
[0174] Therefore, the purpose of the present invention can also be achieved by running a program or a group of programs on any computing system. The computing system can be a well-known general system. Therefore, the purpose of the present invention can also be achieved by simply providing a program product containing a program code that implements the method or system. That is to say, such a program product also constitutes the present invention, and the storage medium storing such a program product also constitutes the present invention. Obviously, the storage medium can be any well-known storage medium or any storage medium developed in the future. It should also be pointed out that in the system and method of the present invention, it is obvious that each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present invention. In addition, the steps of performing the above-mentioned series of processing can naturally be performed in chronological order according to the order of description, but it is not necessary to perform them in chronological order. Some steps can be performed in parallel or independently of each other.
[0175] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. An intelligent monitoring method for abnormal livestock behavior based on time dimension, It is characterized in that The method comprises: Obtain video data, construct a livestock behavior dataset, and preprocess the livestock behavior dataset; Use the SlowFast network to perform behavior recognition on the preprocessed pig dataset to obtain livestock behavior recognition results; According to the livestock behavior identification results, the duration of the lying behavior of the pigs is counted using the behavior time statistics algorithm to obtain the duration statistics of the lying behavior; Based on the statistical results, it is determined whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, an early warning message and the visualization results of livestock behavior monitoring are issued. If the duration of the lying behavior does not exceed the threshold, behavior recognition and time statistics continue.
2. The method for intelligent monitoring of abnormal livestock behavior based on time dimension according to claim 1, It is characterized in that Obtain video data, construct a livestock behavior dataset, and preprocess the livestock behavior dataset, including: Use monitoring equipment to obtain video data; Classify the video data to obtain a number of classified videos; According to the lying and non-lying behaviors of livestock, several classified videos are labeled and different behavior categories are encoded to obtain pig targets; Construct a livestock behavior dataset based on several classified videos and livestock targets; Data augmentation is performed on the pig behavior dataset to obtain the preprocessed livestock dataset.
3. The method for intelligent monitoring of abnormal livestock behavior based on time dimension according to claim 2, It is characterized in that Use the SlowFast network to perform behavior recognition on the preprocessed livestock dataset to obtain livestock behavior recognition results, including: Construct the SlowFast network structure and determine the behavior recognition task; The Focal Loss function is used to improve the imbalance of livestock behavior categories in the SlowFast network structure to obtain the improved SlowFast network structure; The preprocessed livestock dataset is input into the slow and fast branches of the improved SlowFast network; Use the slow branch to perform convolution operations to obtain semantic information in the livestock dataset videos; Use fast branches to perform convolution operations to obtain behavioral information in the video; After the fast branch convolution operation, the obtained behavior information is adjusted using the Vision Transformer structure to obtain adjusted behavior information; The semantic information and the adjusted behavioral information are laterally connected through time dimension convolution to obtain the pig behavior recognition results.
4. The method for intelligent monitoring of abnormal livestock behavior based on time dimension according to claim 3, It is characterized in that The Focal Loss function is used to improve the imbalance of livestock behavior categories in the SlowFast network structure to obtain the improved SlowFast network structure, including: Determine the exponent γ of the focusing factor and the Focal Loss function training model; The Focal Loss loss function training model updates parameters according to the loss calculated by the Focal Loss loss function, where the formula of the Focal Loss loss function is: FL(p t )=-a t (1-p t ) γ log(p t ); Among them, p t is the model's predicted probability for the sample, α t is the focusing factor, γ is the exponent of the focusing factor; The SlowFast network structure is improved using the updated loss parameters to obtain an improved SlowFast network structure.
5. The method for intelligent monitoring of abnormal livestock behavior based on time dimension according to claim 4, It is characterized in that After the fast branch convolution operation, the obtained behavior information is adjusted using the Vision Transformer structure to obtain adjusted behavior information, including: In the SlowFast network structure, the Vision Transformer structure is introduced after the convolution operation of the fast channel; Divide the images of the livestock dataset into a set of fixed-size image patches; Convert image blocks into sequence data; Input the sequence data into the Transformer Encoder image processing encoder for processing; In the Transformer Encoder image processing encoder, the self-attention mechanism is used to capture the relationship between different regions within the image; According to the relationship between different regions within the image, the relationship between the high-dimensional features of the frames is obtained; According to the relationship between the high-dimensional features of the frames, the behavior information is adjusted to obtain adjusted behavior information.
6. The method for intelligent monitoring of abnormal livestock behavior based on time dimension according to claim 5, It is characterized in that According to the livestock behavior recognition results, the duration of the livestock lying behavior is counted using the behavior time statistics algorithm to obtain the duration statistics of the lying behavior, including: Inputting the number of livestock behaviors NT and the video frame rate fps into the behavior time statistics algorithm, wherein NT includes the number of lying behaviors and the number of non-lying behaviors; For each video frame, determine whether the behavior video frame number DT is equal to the number of lying behaviors. If it is equal to the number of lying behaviors, then the number of lying behaviors is increased by 1. If it is not equal to the number of lying behaviors, then the number of non-lying behaviors is increased by 1. The behavior duration BT is calculated according to the behavior video frame number DT and the video frame rate fps, wherein BT=DT / fps. The behavior duration BT is equal to the behavior video frame number DT divided by the video frame rate fps, which represents the duration of the behavior.
7. The method for intelligently monitoring abnormal behavior of livestock based on time dimension according to claim 6, It is characterized in that According to the statistical results, it is determined whether the duration of lying behavior exceeds the threshold. If the duration of lying behavior exceeds the threshold, an early warning message and the visualization results of livestock behavior monitoring are issued. If the duration of lying behavior does not exceed the threshold, behavior identification and time statistics are continued, including: Determine whether the duration of lying down behavior exceeds a preset threshold; If the duration of lying behavior exceeds the threshold, an early warning message will be issued to remind the breeder through message push and sound alarm; Generate and display the visual results of pig behavior monitoring on the device's web interface; If the duration of lying behavior does not exceed the threshold, continue with behavior identification and time statistics.
8. An intelligent monitoring system for abnormal livestock behavior based on time dimension, It is characterized in that include: An acquisition module is used to acquire video data, construct a livestock behavior data set, and pre-process the livestock behavior data set; The processing module uses the SlowFast network to perform behavior recognition on the preprocessed livestock data set to obtain livestock behavior recognition results; based on the livestock behavior recognition results, the behavior time statistics algorithm is used to count the duration of the livestock lying behavior to obtain the statistical results of the lying behavior duration; based on the statistical results, it is determined whether the duration of the lying behavior exceeds the threshold. If the duration of the lying behavior exceeds the threshold, an early warning message and a visualization result of the livestock behavior monitoring are issued; if the duration of the lying behavior does not exceed the threshold, behavior recognition and time statistics are continued.
9. A computing device, It is characterized in that include: one or more processors; A storage system for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program, which, when executed by a processor, implements the method according to any one of claims 1 to 7.
Citation Information
Cited By
Pig farm disease monitoring and early warning method and system based on machine learning
CN119007412A
A pig farm disease monitoring and early warning method and system based on machine learning
CN119007412B
