Pig specified behavior recognition model training method, recognition method, recognition system, computer equipment and readable storage medium

CN119445469APending Publication Date: 2025-02-14ANYOU BIOTECH GRP
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411448018.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

The prior art consumes a lot of computing resources in pig behavior recognition, poor real-time performance, and high possibility of misjudgment and misjudgment, so it is impossible to effectively identify pig-specified behaviors.

Method used

The 3D UNet architecture is used to combine the 3D convolutional neural network classifier to perform image segmentation and behavior recognition of frame sequences through multi-task learning, and dynamically adjust the channel weight of the feature map using attention mechanism to extract high-dimensional features for behavior classification.

Benefits of technology

It reduces the consumption of computing resources, improves the accuracy and efficiency of behavior recognition, reduces the possibility of misjudgment and misjudgment, and achieves fast, real-time and accurate pig-specified behavior recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119445469A_ABST
    Figure CN119445469A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of pig behavior recognition, in particular to a pig specified behavior recognition model training method, a recognition method, a recognition system, computer equipment and a readable storage medium, and the formation of a training data set: cutting real-time video data into continuous frame sequences, each sequence comprising a plurality of frames, marking the range of the specified behavior of the pig in each frame; constructing a pig specified behavior recognition model: performing image segmentation and behavior recognition on the frame sequence in a multi-task learning mode by adopting a 3D UNet architecture and combining a 3D convolutional neural network classifier; training of a pig specified behavior recognition model: training the pig specified behavior recognition model based on the training data set, and stopping training when a training effect reaches a preset training condition to obtain a trained pig specified behavior recognition model; the method is low in computing resource consumption, and can quickly and accurately identify the specified behavior in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of pig behavior recognition, and in particular to a pig designated behavior recognition model training method, a recognition method, a recognition system, a computer device, and a readable storage medium. Background Art

[0002] In animal husbandry management, pig specific behaviors (such as fighting, food snatching and estrus) will affect the normal growth of pigs. In order to detect pig specific behaviors in time, the traditional method uses manual irregular monitoring, which is time-consuming and labor-intensive, inefficient, and has poor real-time performance. In order to overcome the shortcomings of traditional methods, video automatic monitoring methods are currently used to detect pig specific behaviors. There are two main modes: all-weather monitoring and key frame monitoring. All-weather monitoring requires a lot of computing resources, increasing the operating cost and complexity of the system; although key frame monitoring overcomes the problem of high computing resource consumption to a certain extent, it mainly judges pig specific behaviors through image recognition of key frames. The rationality and representativeness of key frame selection are not easy to control. In addition, since the specific behaviors between pigs presented in the key frames are static and deceptive, the system may have misjudgments and omissions. For example, if two pigs collide during play, if the collision moment appears in the key frame, it may be mistakenly identified by the system as a fighting behavior. For example, if one pig bites another pig and leaves immediately, if the biting moment does not appear in the key frame, the biting behavior may be missed by the system. In response to the defects of key frame monitoring, an invention patent application (publication number CN114333049A) discloses a method, system, computer equipment and storage medium for identifying pig attack behavior. It uses key frame sequences for monitoring, overcoming the limitations of a single frame. During the detection process, it extracts spatiotemporal information and spatial information through lightweight 3D convolutional neural networks and 2D convolutional neural networks, respectively, and then uses a void convolution layer to fuse the spatiotemporal features and spatial features to obtain spatiotemporal fusion features for bounding box prediction and action classification, thereby obtaining recognition results. The above model design is relatively complex, and does not consider the impact of the interaction between the convolutional neural network and the void convolution layer on the recognition results, resulting in limited accuracy and reliability of the recognition results. BRIEF DESCRIPTION OF THE DRAWINGS

[0003] The present invention is further described below in conjunction with the accompanying drawings and embodiments.

[0004] Figure 1 It is a flow chart of the pig designated behavior recognition model training method of the present invention;

[0005] Figure 2 It is a workflow diagram of the pig designated behavior recognition model in the present invention;

[0006] Figure 3 It is a structural diagram of the 3D UNet architecture in the present invention. Summary of the invention

[0007] The technical problem to be solved by the present invention is to overcome the deficiencies in the prior art and provide a pig specified behavior recognition model training method, recognition method, recognition system, computer equipment, and readable storage medium that consumes low computing resources and can quickly, in real time and accurately recognize specified behaviors.

[0008] The technical solution adopted by the present invention to solve the technical problem is: a method for training a pig designated behavior recognition model, the specific steps are as follows:

[0009] S1. Formation of training dataset

[0010] Cut the real-time video data into continuous frame sequences, each sequence contains several frames, and mark the range of the pig's specified behavior in each frame;

[0011] S2. Construction of a pig specific behavior recognition model

[0012] The 3D UNet architecture is used in combination with a 3D convolutional neural network classifier to perform image segmentation and behavior recognition on frame sequences in a multi-task learning manner;

[0013] The 3D UNet architecture adopts a decoder-encoder structure, uses a convolutional neural network to extract high-dimensional features from frame sequences, and outputs sequence image segmentation results;

[0014] The 3D convolutional neural network classifier is composed of multiple 3D convolutional layers and pooling layers. The input is the sequence image segmentation result of 3D UNet. The 3D convolutional layer extracts high-dimensional features and combines the attention mechanism to dynamically adjust the channel weights of the feature map to enhance the feature expression ability of the model. The high-dimensional features are extracted and then the 3D convolutional neural network classifier is used to determine whether the frame sequence has the specified behavior of the pig.

[0015] The multi-task learning method is to combine the 3D UNet architecture and the 3D convolutional neural network classifier, use 3D UNet as a shared feature extractor, set two branch layers, one branch layer is used for image segmentation, and the other branch layer is used for pig behavior classification, extract high-dimensional features from the frame sequence, and the high-dimensional features are simultaneously applied to image segmentation and behavior classification. The shared layer learns common features, and the branch layers learn their respective tasks;

[0016] S3. Training of pig specific behavior recognition model

[0017] Based on the training data set, the pig designated behavior recognition model is trained, and the training is stopped when the training effect reaches the preset training condition to obtain the trained pig designated behavior recognition model.

[0018] Furthermore, in the encoding process, high-dimensional features of pig behavior are gradually captured through layer-by-layer convolution and pooling operations; in the decoding process, image resolution is restored layer by layer through deconvolution and upsampling operations, and accurate semantic segmentation is achieved by utilizing the high-dimensional feature map in the encoding stage.

[0019] Furthermore, the influencing factors of the channel weight include: the contribution of high-dimensional features in each channel, the difference of high-dimensional features in spatial dimensions, the difference of high-dimensional features in temporal dynamics, and context dependency, and the influencing factors are dynamically adjusted by the attention mechanism.

[0020] Furthermore, the formula of the attention mechanism is as follows

[0021]

[0022] in, represents the weighted feature set after calculation; X is the input feature map, X = {x1, x2, ..., x n}, x i The feature vector representing a channel of the feature map; the function F is trained to learn the relative importance of each feature and convert it into a weight; the sigmoid function σ normalizes the calculated weight value to the range of 0 to 1.

[0023] Furthermore, the multi-task loss function in the multi-task learning method is as follows

[0024]

[0025] in, is the loss function of the image segmentation branch, is the loss function of the behavior classification branch, and α and β are weight hyperparameters used to balance the impact of image segmentation loss and behavior classification loss.

[0026] Furthermore, the loss function of the image segmentation branch is one or more of IoU loss, FoCal loss, and Dice loss, which are mainly used to deal with the problem of category imbalance.

[0027] Furthermore, the loss function of the image segmentation branch is Dice loss, and the formula is as follows:

[0028]

[0029] Among them, y i is the true label of the i-th pixel, p i is the predicted probability of the ith pixel, N is the total number of pixels in the image, and ∈ is a small constant to prevent division by zero;

[0030] The loss function of the behavior classification branch is the cross entropy loss, which is applicable to classification problems and is as follows:

[0031]

[0032] Among them, y j is the one-hot encoded vector of the true label of the jth sample, p j is the predicted probability of the class corresponding to the jth sample, and M is the total number of samples.

[0033] Furthermore, the high-dimensional features include spatial features and temporal features. The spatial features include the distance, angle, speed, position overlap or separation between pigs, and the relative position relationship of specific parts of pigs. The temporal features include the continuity, regularity, speed change, and frequency of contact between body parts.

[0034] Furthermore, the behavior classification includes fighting, snatching food and estrus.

[0035] A method for identifying specific pig behaviors, comprising:

[0036] Get the video to be identified;

[0037] Preprocess the frame sequence of the video to be identified;

[0038] The pig behavior recognition model trained by the above-mentioned pig designated behavior recognition model training method is used to recognize the video to be recognized to obtain a recognition result, wherein the recognition result is a video that identifies the pig designated behavior area.

[0039] Furthermore, the video to be identified is acquired by setting a time interval and an acquisition duration for acquiring the video.

[0040] A pig specific behavior recognition system, comprising:

[0041] Data acquisition module, obtaining the video to be identified;

[0042] A video processing module pre-processes the frame sequence of the video to be recognized;

[0043] The pig designated behavior recognition model is trained by the above-mentioned pig designated behavior recognition model training method to recognize the video to be recognized and obtain a recognition result; the recognition result is: a video that identifies the pig designated behavior area.

[0044] Furthermore, the video to be identified in the video acquisition module is acquired by setting a time interval and an acquisition duration for the video acquisition.

[0045] Furthermore, it also includes an alarm module, which notifies the management personnel, automatically displays the real-time video stream, and highlights the designated behavior area when the designated behavior recognition model of the pig recognizes the designated behavior.

[0046] Furthermore, the methods of notifying the administrator in the alarm module include on-site alarms, lights, text messages, emails, and instant messaging tools.

[0047] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0048] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.

[0049] The beneficial effects of the present invention are:

[0050] (1) The present invention uses a 3D UNet architecture to perform image segmentation on a frame sequence of group-raised pigs acquired at intervals, and divides each frame in the frame sequence into a designated behavior area and a non-designated behavior area. Then, a 3D convolutional neural network classifier is used to perform probability distribution on the designated behavior and non-designated behavior in the designated behavior area segmented from each frame, and whether there is a designated behavior in the designated behavior area is identified based on the highest probability. Compared with all-weather monitoring, the interval acquisition of video segments significantly reduces the consumption of computing resources. Compared with key frame monitoring, continuous frames form dynamic monitoring, which reduces the possibility of misjudgment and missed judgment, and the accuracy and efficiency of behavior recognition are higher.

[0051] (2) The present invention continuously optimizes model parameters during model training by applying a multi-task learning method, and balances the impact of the image segmentation branch loss and the behavior classification branch loss, so that the behavior classification branch can be fed back to the image segmentation branch, thereby making the image segmentation of the image segmentation branch more accurate. When the image segmentation is more accurate, the accuracy of the behavior classification branch in determining whether there is a specified behavior of the pig is also improved, thereby further improving the accuracy, efficiency and reliability of model recognition.

[0052] (3) The present invention introduces jump connections in the image segmentation branch processing process, so that the feature map in the encoding process can be directly used in the decoding process, thereby improving the accuracy and stability of image segmentation and realizing more fine-grained behavior monitoring.

[0053] (4) By introducing the attention mechanism, the present invention dynamically allocates weights according to the contribution of spatial features and temporal features in different channels, so as to more accurately identify specified behaviors.

[0054] (5) The present invention processes the frame sequence, crops and removes the remaining area outside the pigpen, and adjusts the size to reduce the amount of calculation, further reduce the consumption of computing resources, and further improve the efficiency of model recognition. DETAILED DESCRIPTION

[0055] The present invention will now be further described in conjunction with the accompanying drawings and preferred embodiments. These drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.

[0056] Example 1

[0057] like Figure 1 and Figure 2 As shown, a method for training a pig-specific behavior recognition model is shown in the figure. The specific steps are as follows:

[0058] S1. Formation of training dataset

[0059] Cut the real-time video data into continuous frame sequences, each sequence contains several frames, and mark the range of the pig's specified behavior in each frame;

[0060] S2. Construction of a pig specific behavior recognition model

[0061] The 3D UNet architecture is used in combination with the 3D convolutional neural network classifier (3D CNN Classification) to perform image segmentation and behavior recognition on frame sequences in a multi-task learning manner;

[0062] The 3D UNet architecture adopts a decoder-encoder structure, uses a convolutional neural network to extract high-dimensional features from frame sequences, and outputs sequence image segmentation results;

[0063] The 3D convolutional neural network classifier is composed of multiple 3D convolutional layers and pooling layers. The input is the sequence image segmentation result of 3D UNet. The 3D convolutional layer extracts high-dimensional features and combines the attention mechanism to dynamically adjust the channel weights of the feature map to enhance the feature expression ability of the model. The high-dimensional features are extracted and then the 3D convolutional neural network classifier is used to determine whether the frame sequence has the specified behavior of the pig.

[0064] The multi-task learning method is to combine the 3D UNet architecture and the 3D convolutional neural network classifier, use 3D UNet as a shared feature extractor, set two branch layers, one branch layer is used for image segmentation, and the other branch layer is used for pig behavior classification, extract high-dimensional features from the frame sequence, and the high-dimensional features are simultaneously applied to image segmentation and behavior classification. The shared layer learns common features, and the branch layers learn their respective tasks;

[0065] S3. Training of pig specific behavior recognition model

[0066] Based on the training data set, the pig designated behavior recognition model is trained, and the training is stopped when the training effect reaches the preset training condition to obtain the trained pig designated behavior recognition model.

[0067] The 3D UNet architecture is used to perform image segmentation on the frame sequence of group-raised pigs acquired at intervals, and each frame in the frame sequence is segmented into designated behavior areas and non-designated behavior areas. Then, the 3D convolutional neural network classifier is used to perform probability distribution on the designated behavior and non-designated behavior in the designated behavior area segmented in each frame, and the highest probability is used to identify whether there is a designated behavior in the designated behavior area. Compared with all-weather monitoring, the interval acquisition of video segments significantly reduces the consumption of computing resources. Compared with key frame monitoring, continuous frames form dynamic monitoring, which reduces the possibility of misjudgment and missed judgment, and the accuracy and efficiency of behavior recognition are higher. Through the application of multi-task learning, the model parameters are continuously optimized during the model training process, and the influence of the image segmentation branch loss and the behavior classification branch loss are balanced, so that the behavior classification branch can be fed back to the image segmentation branch, thereby making the image segmentation of the image segmentation branch more accurate. When the image segmentation is more accurate, the accuracy of the behavior classification branch for judging whether there is a pig's designated behavior is also improved, thereby further improving the accuracy, efficiency and reliability of model recognition.

[0068] Specifically, the frame sequence contains 16 frames, and the interval time and duration of the frame sequence can be dynamically adjusted according to the application scenario and pig habits; the high-dimensional features include spatial features and temporal features, the spatial features include the distance, angle, speed, position overlap or separation between pigs, and the relative position relationship of specific parts of pigs (such as the proximity of the pigs' noses and mouths); the temporal features include the continuity, regularity, speed change, and frequency of contact between body parts; the influencing factors of channel weights include: the contribution of high-dimensional features in each channel, the difference in high-dimensional features in spatial dimensions, the difference in high-dimensional features in temporal dynamics, and context dependence, and the influencing factors are dynamically adjusted by the attention mechanism; behavior classification includes fighting, food snatching, and estrus.

[0069] In step S2, the shared layer captures and extracts complex and high-dimensional common features between multiple tasks from the input frame sequence. These common features represent global features in the frame sequence, including temporal and spatial information, and can be effectively used in two different tasks (image segmentation and behavior classification). They can help the model identify different areas in the frame sequence (for segmentation) and help the model identify the behavior patterns of pigs (for classification). By learning these common features, the model can improve its overall efficiency, reduce the redundancy of independent learning of each task, and promote information sharing between tasks, thereby improving the accuracy and generalization ability of the model. Based on the common features learned by the shared layer, the branch layer further refines and learns the specific features of each task, thereby further realizing accurate image segmentation and pig behavior classification.

[0070] During the encoding process, the high-dimensional features of pig behavior are gradually captured through layer-by-layer convolution and pooling operations; during the decoding process, the image resolution is restored layer by layer through deconvolution and upsampling operations, and the high-dimensional feature maps in the encoding stage are used to achieve accurate semantic segmentation.

[0071] The introduction of skip connections in the image segmentation branch processing allows the feature maps in the encoding process to be directly used in the decoding process, thereby improving the accuracy and stability of image segmentation and achieving more fine-grained behavior monitoring.

[0072] The formula of the attention mechanism is as follows

[0073]

[0074] in, represents the weighted feature set after calculation; X is the input feature map, X = {x1, x2, ..., x n}, x i The feature vector representing a channel of the feature map; the function F is trained to learn the relative importance of each feature and convert it into a weight; the sigmoid function σ normalizes the calculated weight value to the range of 0 to 1.

[0075] By introducing the attention mechanism, weights are dynamically assigned according to the contribution of spatial and temporal features in different channels, so as to more accurately identify the specified behavior. The attention mechanism also takes into account the spatial features in the channel to ensure that the behavior classification branch can focus on key areas, such as the action location of the specified behavior. Temporal dynamics is also an important factor. Since the input is a sequence of frames, the time changes between frames will also affect the channel weights. The behavior classification branch gives higher weights to channels that can capture time changes to enhance the model's understanding of continuous actions, such as fast movements or sudden movements when pigs fight. Channel weights are also affected by contextual dependence. The model will adjust according to the contextual information in the frame sequence. If the surrounding environment or background is highly correlated with the pig's specified behavior, the attention mechanism will enhance the weights of the relevant channels to more accurately judge the specified behavior.

[0076] Multi-task loss function in multi-task learning as follows

[0077]

[0078] in, is the loss function of the image segmentation branch, is the loss function of the behavior classification branch, and α and β are weight hyperparameters used to balance the impact of image segmentation loss and behavior classification loss.

[0079] Specifically, the loss function of the image segmentation branch can be one or more of IoU loss, Focal loss, and Dice loss, which is mainly used to deal with the problem of category imbalance. The loss function of the image segmentation branch is Dice loss, and the formula is as follows:

[0080]

[0081] Among them, y i is the true label of the i-th pixel, p i is the predicted probability of the ith pixel, N is the total number of pixels in the image, and ∈ is a small constant to prevent division by zero.

[0082] The loss function of the behavior classification branch is the cross entropy loss, which is suitable for classification problems and the formula is as follows:

[0083]

[0084] Among them, y j is the one-hot encoded vector of the true label of the jth sample, p j is the predicted probability of the class corresponding to the jth sample, and M is the total number of samples.

[0085] like Figure 3As shown, the specific structure of the 3D UNet architecture is as follows:

[0086] ①The input layer is a 3D-RGB image of size 224×224×16×3;

[0087] ② Downsampling path

[0088] Convolutional block 1: Contains two 3x3x3 convolutional layers, each followed by a batch normalization layer and a ReLU activation function, with 32 channels.

[0089] Downsampling 1: Use 2x2x2 maximum pooling with a step size of 2 to reduce the size of the feature map;

[0090] Convolutional block 2: Contains two 3x3x3 convolutional layers, each followed by a batch normalization layer and a ReLU activation function, with 64 channels.

[0091] Downsampling 2: Use 2x2x2 maximum pooling with a step size of 1;

[0092] Convolutional block 3: contains two 3x3x3 convolutional layers, each followed by a batch normalization layer and a ReLU activation function, and the number of channels is 128;

[0093] Downsampling 3: Use 2x2x2 maximum pooling with a step size of 1;

[0094] ③ Bottom layer

[0095] Convolutional block 4: contains two 3x3x3 convolutional layers, each followed by a batch normalization layer and a ReLU activation function, and the number of channels is 256;

[0096] ④Upsampling path

[0097] Upsampling 1: Upsample the result feature map of convolution block 4 to 2x2x2;

[0098] Convolutional block 5: concatenates the feature maps of convolutional block 3, and then performs two 3x3x3 convolutional layers, each followed by a batch normalization layer and a ReLU activation function, with 256 and 128 channels respectively;

[0099] Upsampling 2: Perform 2x2x2 upsampling;

[0100] Convolutional block 6: concatenates the feature maps of convolutional block 2, and then performs two 3x3x3 convolutional layers, each followed by a batch normalization layer and a ReLU activation function, with 128 and 64 channels respectively;

[0101] Upsampling 3: Perform 2x2x2 upsampling;

[0102] ⑤Output layer

[0103] Convolutional block 7: Use a 1x1x1 convolutional layer with 2 channels to represent the class probability of binary classification of pixels, and output a result image of size 224×224×16×2.

[0104] The specific structure of the 3D convolutional neural network classifier is as follows:

[0105] ①The input layer is a 3D segmented image of size 224×224×16×2;

[0106] ② Convolution layer and pooling layer 1: The convolution kernel size is 7×7×7, the step size is 1×2×2, the number of channels is 64, followed by a batch normalization layer and a ReLU activation function, followed by a 3×3×3 maximum pooling with a step size of 2, and finally the attention mechanism is introduced;

[0107] ③ Convolution layer and pooling layer 2: The convolution kernel size is 5×5×5, the step size is 1×2×2, the number of channels is 128, followed by a batch normalization layer and a ReLU activation function, followed by a 3×3×3 maximum pooling with a step size of 2, and finally the attention mechanism is introduced;

[0108] ④Convolutional layer and pooling layer 3: The convolution kernel size is 3×3×3, the step size is 1×2×2, the number of channels is 128, followed by 1×4×4 average pooling with a step size of 1;

[0109] ⑤Fully connected layer: The output feature number is 2, which is used to map the output of the convolution layer and the pooling layer to the probability distribution of specified behaviors and non-specified behaviors.

[0110] Example 2

[0111] A method for identifying specific pig behaviors, comprising:

[0112] Get the video to be identified;

[0113] Preprocess the frame sequence of the video to be identified;

[0114] The pig behavior recognition model trained by the pig designated behavior recognition model training method in Example 1 is used to recognize the video to be recognized, and a recognition result is obtained. The recognition result is: a video that identifies the pig designated behavior area.

[0115] Specifically, the video to be identified is obtained by setting the time interval and duration of video acquisition; the preprocessing is to lock the pig activity area, use the crop function to crop and remove the remaining area outside the pig pen, and adjust the image size to 224x224.

[0116] Example 3

[0117] A pig specific behavior recognition system, comprising:

[0118] Data acquisition module, obtaining the video to be identified;

[0119] A video processing module pre-processes the frame sequence of the video to be recognized;

[0120] The pig designated behavior recognition model is trained by the pig designated behavior recognition model training method in Example 1 to recognize the video to be recognized and obtain a recognition result; the recognition result is: a video identifying the pig designated behavior area.

[0121] Specifically, the video to be identified in the video acquisition module is obtained by setting the time interval and duration of video acquisition; the preprocessing in the video processing module is to lock the pig activity area, crop and remove the remaining area outside the pig pen using the crop function, and adjust the image size to 224x224.

[0122] The pig designated behavior recognition system also includes an alarm module. When the pig designated behavior recognition model recognizes the designated behavior, it notifies the management personnel, automatically displays the real-time video stream, and highlights the designated behavior area. Specifically, the alarm module notifies the management personnel by means of on-site alarm bells, lights, text messages, emails, and instant messaging tools.

[0123] Example 4

[0124] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method in embodiment 1, embodiment 2, or embodiment 3 when executing the computer program.

[0125] Example 5

[0126] A computer-readable storage medium stores a computer program, which implements the steps of the method in embodiment 1, embodiment 2, or embodiment 3 when the computer program is executed by a processor.

[0127] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with this technology to understand the content of the present invention and implement it. They cannot be used to limit the protection scope of the present invention. Any equivalent changes or modifications made according to the spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for training a pig designated behavior recognition model, characterized in that: The specific steps are as follows: S1. Formation of training dataset Cut the real-time video data into continuous frame sequences, each sequence contains several frames, and mark the range of the pig's specified behavior in each frame; S2. Construction of a pig specific behavior recognition model The 3D UNet architecture is used in combination with a 3D convolutional neural network classifier to perform image segmentation and behavior recognition on frame sequences in a multi-task learning manner; The 3D UNet architecture adopts a decoder-encoder structure, uses a convolutional neural network to extract high-dimensional features from frame sequences, and outputs sequence image segmentation results; The 3D convolutional neural network classifier is composed of multiple 3D convolutional layers and pooling layers. The input is the sequence image segmentation result of 3D UNet. The 3D convolutional layer extracts high-dimensional features and combines the attention mechanism to dynamically adjust the channel weights of the feature map to enhance the feature expression ability of the model. The high-dimensional features are extracted and then the 3D convolutional neural network classifier is used to determine whether the frame sequence has the specified behavior of the pig. The multi-task learning method is to combine the 3D UNet architecture and the 3D convolutional neural network classifier, use 3DUNet as a shared feature extractor, set two branch layers, one branch layer is used for image segmentation, and the other branch layer is used for pig behavior classification, extract high-dimensional features from the frame sequence, and the high-dimensional features are simultaneously applied to image segmentation and behavior classification. The shared layer learns common features, and the branch layers learn their respective tasks; S3. Training of pig specific behavior recognition model Based on the training data set, the pig designated behavior recognition model is trained, and the training is stopped when the training effect reaches the preset training condition to obtain the trained pig designated behavior recognition model.

2. The pig designated behavior recognition model training method according to claim 1, characterized in that: In the encoding process, high-dimensional features of pig behavior are gradually captured through layer-by-layer convolution and pooling operations; in the decoding process, image resolution is restored layer by layer through deconvolution and upsampling operations, and accurate semantic segmentation is achieved by utilizing the high-dimensional feature map in the encoding stage.

3. The pig designated behavior recognition model training method according to claim 1, characterized in that: The influencing factors of the channel weight include: the contribution of high-dimensional features in each channel, the difference of high-dimensional features in spatial dimensions, the difference of high-dimensional features in temporal dynamics, and contextual dependence. The influencing factors are dynamically adjusted by the attention mechanism.

4. The pig designated behavior recognition model training method according to claim 3, characterized in that: The formula of the attention mechanism is as follows in, represents the weighted feature set after calculation; X is the input feature map, X = {x1, x2, ..., x n }, x i The feature vector representing a channel of the feature map; the function F is trained to learn the relative importance of each feature and convert it into a weight; the sigmoid function σ normalizes the calculated weight value to the range of 0 to 1.

5. The pig designated behavior recognition model training method according to claim 1, characterized in that: The multi-task loss function in the multi-task learning method as follows in, is the loss function of the image segmentation branch, is the loss function of the behavior classification branch, and α and β are weight hyperparameters used to balance the impact of image segmentation loss and behavior classification loss.

6. The pig designated behavior recognition model training method according to claim 5, characterized in that: The loss function of the image segmentation branch is IoU loss, Fo c al loss, Dic e One or more of the losses are mainly used to deal with class imbalance problems.

7. The pig designated behavior recognition model training method according to claim 6, characterized in that: The loss function of the image segmentation branch is Dice loss, and the formula is as follows: Among them, y i is the true label of the i-th pixel, p i is the predicted probability of the ith pixel, N is the total number of pixels in the image, and ∈ is a small constant to prevent division by zero; The loss function of the behavior classification branch is the cross entropy loss, which is applicable to classification problems and is as follows: Among them, y j is the one-hot encoded vector of the true label of the jth sample, p j is the predicted probability of the class corresponding to the jth sample, and M is the total number of samples.

8. The pig designated behavior recognition model training method according to claim 1, characterized in that: The high-dimensional features include spatial features and temporal features. The spatial features include the distance, angle, speed, position overlap or separation between pigs, and the relative position relationship of specific parts of pigs. The temporal features include the continuity, regularity, speed change, and frequency of contact between body parts of the action.

9. The pig designated behavior recognition model training method according to claim 1, characterized in that: The behavioral categories include fighting, food snatching, and estrus.

10. A method for identifying specific pig behaviors, characterized in that: include: Get the video to be identified; Preprocess the frame sequence of the video to be identified; The pig behavior recognition model trained by the pig designated behavior recognition model training method described in any one of claims 1 to 9 is used to recognize the video to be recognized to obtain a recognition result, wherein the recognition result is a video that identifies the pig designated behavior area.

11. The method for identifying pig designated behaviors according to claim 10, characterized in that: The video to be identified is acquired by setting a time interval and an acquisition duration for acquiring the video.

12. A pig specific behavior recognition system, characterized in that: include: Data acquisition module, obtaining the video to be identified; A video processing module pre-processes the frame sequence of the video to be recognized; The pig designated behavior recognition model is trained by the pig designated behavior recognition model training method described in any one of claims 1 to 9 to recognize the video to be recognized and obtain a recognition result; the recognition result is: a video that identifies the pig designated behavior area.

13. The pig designated behavior recognition system according to claim 12, characterized in that: The video to be identified in the video acquisition module is acquired by setting a time interval and an acquisition duration for the video acquisition.

14. The pig designated behavior recognition system according to claim 12, characterized in that: It also includes an alarm module, which notifies the management personnel when the designated behavior recognition model of the pig recognizes the designated behavior, automatically displays the real-time video stream, and highlights the designated behavior area.

15. The pig designated behavior recognition system according to claim 14, characterized in that: The ways of notifying the administrator in the alarm module include on-site alarm bells, lights, text messages, emails, and instant messaging tools.

16. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.

17. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

Citation Information

Patent Citations

  • Livestock behavior analysis method and device

    CN108596014A

  • Sow estrus detection method and device, electronic equipment and storage medium

    CN111914685A

  • Method for identifying pig feeding behaviors in video based on convolutional neural network

    CN114170673A

  • Cxl device, electronic device, and data storing method

    KR1020250066111A