A method for predicting sow squeezing piglet events, a readable medium and an electronic device

By constructing an event evolution graph and adaptive adjacency matrix for sows and piglets, combined with a graph convolutional network and a BiLSTM model, accurate prediction of piglet stress events is achieved, solving the problem of efficient prediction of piglet stress in existing technologies and reducing mortality and economic losses.

CN118378738BActive Publication Date: 2025-09-26SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410365669.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-28
Publication Date
2025-09-26
Estimated Expiration
2044-03-28

AI Technical Summary

Technical Problem

Existing technologies make it difficult to efficiently and timely predict events of piglets being squeezed by sows in large-scale pig farming, resulting in high piglet mortality rates and a lack of effective intelligent early warning technology.

Method used

By collecting sow and piglet-related data, we constructed the sow and piglet behavioral corpus event chain, the stable corpus event chain, and the target corpus event chain. We combined the adaptive self-attention time node deployment and the adaptive adjacency matrix to construct a directed event evolution graph. We used the Mask R-CNN model for instance segmentation and Euclidean distance calculation, and combined it with the BiLSTM model to optimize the prediction results, thus achieving accurate prediction of piglet stress events.

Benefits of technology

It improves the prediction accuracy of piglet stress events and reduces the risk of piglet death. It is suitable for intelligent early warning in modern intensive farms to reduce economic losses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118378738B_ABST
    Figure CN118378738B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for predicting a sow squeezing piglet event, a readable medium, and an electronic device. The method comprises: collecting sow and piglet-related data within a preset time period; and constructing a sow's behavioral corpus event chain, a stable corpus event chain, and a target corpus event chain based on the sow and piglet-related data; constructing a directed event evolution graph based on the behavioral corpus event chain, the stable corpus event chain, and the target corpus event chain, combined with adaptive self-attention time node deployment and an adaptive adjacency matrix; obtaining a preliminary probability value of the piglet squeezing event at the current moment based on the directed event evolution graph; and obtaining a final probability value of the piglet squeezing event at the current moment based on the preliminary probability value of the piglet squeezing event at the current moment, combined with the target corpus event chain. This method constructs a directed event evolution graph based on sow and piglet-related data, fully explores the relationship between sow and piglet events, and improves the accuracy of piglet squeezing event prediction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video image behavior recognition, and more particularly to a method for predicting a sow squeezing piglet event, a readable medium, and an electronic device. Background Art

[0002] Piglet survival rate directly impacts the economic benefits of pig farms, and improving piglet survival has significant economic value. Numerous studies have shown that sow crushing is one of the most important factors leading to piglet mortality, accounting for over 50% of pre-weaning piglet deaths. Crushing within the first four days after farrowing accounts for over 80% of all crush-related deaths.

[0003] The risk of piglet stress is primarily influenced by a combination of factors: sow maternal characteristics, weight, parity and litter size, environmental factors, and housing systems. The direct causes of piglet death from sow body compression are primarily asphyxiation and physical injury. The combined mortality and disability rates for piglets squeezed by sows for more than one minute range from 76% to 86%. Therefore, predicting piglet stress is more important than detecting it. However, manually monitoring piglets to prevent crushing is clearly unsuitable for modern intensive, large-scale farming models. Therefore, there is an urgent need to develop low-cost, efficient, and timely intelligent piglet stress early warning technologies to reduce the risk of piglet stress and prevent it before it occurs.

[0004] Currently, the mortality rate of piglet stress remains high, causing significant economic losses to large-scale pig farming operations. Although computer vision-based intelligent devices have begun to be applied to smart farming, they are mostly used for relatively simple pig behavior analysis. Further research into behavioral detection or prediction has been superficial. Research into detecting and even predicting complex interactive behaviors, such as piglet stress, remains exploratory and lacks in-depth research. Piglet stress events are essentially complex interactions between sows and piglets, influenced by multiple factors.

[0005] Therefore, how to fully consider the spatiotemporal relationship between piglets and sows, the changing patterns of sow and piglet states on the time axis, and external objective factors, and accurately predict piglet stress events, is an urgent problem that technicians in this field need to solve. Summary of the Invention

[0006] In view of the above problems, the present invention provides a method for predicting sow squeezing piglet events, a readable medium and an electronic device to at least solve some of the technical problems mentioned in the above background technology.

[0007] In order to achieve the above object, the present invention adopts the following technical solutions:

[0008] In one aspect, the present invention provides a method for predicting a sow squeezing piglet event, comprising the following steps:

[0009] S1. Collecting sow and piglet-related data within a preset time period; and constructing a sow and piglet behavior corpus event chain, a stable corpus event chain, and a target corpus event chain based on the sow and piglet-related data;

[0010] S2. Based on the behavioral corpus event chain, the stable corpus event chain, and the target corpus event chain, a directed event evolution graph based on the sow and piglet is constructed in combination with adaptive self-attention time node deployment and an adaptive adjacency matrix;

[0011] S3. Obtaining a preliminary probability value of the piglet stress event at the current moment according to the directed event evolution graph;

[0012] S4. Based on the initial probability value of the piglet stress event at the current moment and in combination with the target corpus event chain, obtain the final probability value of the piglet stress event at the current moment.

[0013] Furthermore, the step S1 specifically includes:

[0014] Collect video data of sows and their piglets, pig house environment information, sow physiological information, and piglet physiological information within a preset time period; and set an initial piglet stress marker value;

[0015] Using the trained Mask R-CNN model, the sow posture in each frame of the video data is identified, and amodal instance segmentation is performed on the sow and piglets in each frame of the video data;

[0016] Based on the amodal instance segmentation results, the Euclidean distance between each piglet and the sow in each frame is calculated;

[0017] Arrange the obtained sow postures and minimum Euclidean distances in chronological order to construct the behavioral event chain of the sow and piglets;

[0018] Arrange the pig house environment information, the sow physiological information, and the piglet physiological information in chronological order to construct a stable corpus event chain of sows and piglets;

[0019] Based on the initial piglet stress marker value, a target corpus event chain of the sow piglet is constructed.

[0020] Furthermore, in step S2, the adaptive self-attention time node deployment is expressed as:

[0021] w v =sigmoid((P r +sigmoid(F in ×w f +b f ))⊙w r +b r )

[0022] Among them, w v Represents the vector composed of the response weights of each attention time node; P r represents the normalized position encoding of each attention time node relative to the current self-attention time node; F in represents the feature matrix composed of all self-attention time node features in the initial time perception domain; w r represents the first affine transformation weight vector; w f represents the second affine transformation weight vector; b f represents the first bias parameter; b r represents the second bias parameter; ⊙ represents the Hadamard product operation.

[0023] Furthermore, in step S2, the adaptive adjacency matrix is ​​expressed as:

[0024]

[0025] Among them, A′ i,j A represents the edge from the i-th node to the j-th node in the adaptive adjacency matrix; i,j W represents the edge from the i-th time node to the j-th time node in the original adjacency matrix; 1×n represents the adjacency matrix attention vector; represents the feature vector of the i-th node; represents the j-th node feature vector; b represents the bias value.

[0026] Furthermore, the step S2 further includes dividing the time nodes in the directed event evolution graph:

[0027] The average value of the time node spacing is used as the reference distance; the average value of the time node coordinates on the time axis is used as the center of the graph; when the distance from the time node to the center of the graph is equal to the reference distance, the time node is classified as a root node; when the distance from the time node to the center of the graph is less than the reference distance, the time node is classified as a centripetal node; when the distance from the node to the center of the graph is greater than the reference distance, the time node is classified as a centrifugal node.

[0028] Furthermore, the step S3 specifically includes:

[0029] Extract high-level features of directed event evolution graphs through the space-time-channel attention mechanism;

[0030] The high-order features are sequentially passed through the average pooling layer and the Sigmoid function to obtain the initial probability value of the piglet stress event at the current moment.

[0031] Furthermore, the step S4 specifically includes:

[0032] S41, concatenating the initial probability value of the piglet stress event at the current moment and the target corpus event chain to form a state vector;

[0033] S42: Input the state vector into the BiLSTM model, and output the final probability value of the piglet stress event at the current moment.

[0034] Furthermore, it also includes:

[0035] S5. Using the final probability value of the piglet stress event at the current moment as a new piglet stress mark value, and updating the target corpus event chain.

[0036] On the other hand, the present invention further provides a computer-readable medium, wherein the computer-readable medium stores instructions. When the instructions are executed on the computer-readable medium, the computer-readable medium executes the method described above.

[0037] On the other hand, the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor implements the above method when executing the computer program.

[0038] It can be seen from the above technical solutions that, compared with the prior art, the present invention provides a method for predicting sow squeezing piglets, a readable medium, and an electronic device, which have the following beneficial effects:

[0039] The present invention constructs a directed event evolution graph based on the spatiotemporal relationship, physiological characteristics and environmental parameters of sows and piglets, fully explores the relationship between sow and piglet events, and improves the prediction accuracy of piglet stress events.

[0040] The present invention uses high-precision, anti-occlusion non-modal instance segmentation technology to extract the spatiotemporal relationship characteristics of sows and piglets; by constructing an event evolution graph and utilizing the powerful node high-order feature expression capabilities of graph neural networks, the event evolution graph information of the relationship between events is fully mined.

[0041] The present invention proposes an adaptive node deployment and adjacency matrix reorganization strategy, adopts a graph convolutional network with a space-time-channel multi-scale attention mechanism to perceive high-quality event evolution graphs, and uses a BiLSTM model to further optimize the prediction results, thereby improving the prediction accuracy.

[0042] Other features and advantages of the present invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the present invention.

[0043] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0045] Figure 1 A schematic flow chart of a method for predicting a sow squeezing piglet event provided in an embodiment of the present invention.

[0046] Figure 2 Schematic diagram of the process of sow squeezing piglets based on non-modal instance segmentation provided by an embodiment of the present invention.

[0047] Figure 3 A schematic diagram of the adaptive optimization process of directed event chain nodes and edges provided by an embodiment of the present invention.

[0048] Figure 4 Schematic diagram of converting the initial adjacency matrix provided in an embodiment of the present invention into an adaptive adjacency matrix.

[0049] Figure 5 Schematic diagram of the space-time-channel attention mechanism module provided by an embodiment of the present invention.

[0050] Figure 6 A schematic diagram of the confusion matrix of the test results provided by an embodiment of the present invention.

[0051] Figure 7 Schematic diagram of the process of implementing preliminary judgment and optimizing preliminary judgment results of the model provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0052] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0053] Example 1:

[0054] See also Figure 1 As shown, the embodiment of the present invention discloses a method for predicting a sow squeezing piglet event, comprising the following steps:

[0055] S1. Collecting data related to sows and piglets within a preset time period; and constructing a behavioral corpus event chain, a stable corpus event chain, and a target corpus event chain based on the data related to the sows and piglets;

[0056] S2. Based on the behavioral corpus event chain, the stable corpus event chain, and the target corpus event chain, combined with adaptive self-attention time node deployment and adaptive adjacency matrix, a directed event evolution graph based on sows and piglets is constructed;

[0057] S3. Obtain the initial probability value of the piglet stress event at the current moment according to the directed event evolution graph;

[0058] S4. Based on the initial probability value of the piglet stress event at the current moment and combined with the target corpus event chain, the final probability value of the piglet stress event at the current moment is obtained.

[0059] This method is based on the event evolution diagram, fully considering the spatiotemporal relationship between piglets and sows, the changing patterns of sow and piglet states on the time axis, and external objective factors, thereby achieving accurate prediction of piglet stress events.

[0060] Next, each of the above steps will be explained separately.

[0061] In the above step S1, it is specifically achieved through the following aspects:

[0062] 1. Collect relevant data of sows and piglets within a preset time period to provide a data basis for the subsequent prediction of the probability value of piglet stress events at the next moment in the preset time period;

[0063] The sow and piglet related data include: video data of the sow and her piglets within a preset time period, pig house environment information, sow physiological information and piglet physiological information; and a preset initial piglet stress mark value; specifically:

[0064] (1) Video data of sows and their piglets can be collected by installing an image acquisition system that shoots video diagonally above the pig house; the video acquisition frame rate is f;

[0065] (2) Pig house environmental information can be recorded by deploying various environmental sensors in the pig house, such as temperature sensors and humidity sensors, among which the temperature sensor can be a wall-mounted thermometer;

[0066] (3) Physiological information of sows, including parity and weight of sows;

[0067] (4) Piglet physiological information, including piglet age and other information;

[0068] (5) The initial piglet stress mark value is specifically a piglet stress probability value preset based on the piglet stress situation within a preset time period; the preset value range is [0,1]; more specifically, in order to prevent the preset initial piglet stress mark value from affecting the final probability value of the subsequent piglet stress event, the initial piglet stress mark value can be set to 0.5.

[0069] 2. Build a corpus event database;

[0070] The corpus event library includes behavioral corpus event chains, stable corpus event chains, and target corpus event chains. Specifically:

[0071] (1) Constructing the behavioral corpus event chain:

[0072] The trained Mask R-CNN model is used to identify the sow posture in each frame of the video data, and to perform amodal instance segmentation on the sow and piglet in each frame to generate piglet masks and sow masks. The Euclidean distance between each piglet mask pixel and the sow mask pixel in each frame is calculated. The obtained sow posture and minimum Euclidean distance are arranged in chronological order, where the minimum Euclidean distance is used as the piglet spatial distribution feature after being arranged in chronological order. Based on this, two behavioral corpus event chains of sow posture and piglet spatial distribution can be constructed. The sow squeezing piglet process based on amodal instance segmentation can be seen in [1]. Figure 2 As shown, the process is as follows Figure 2 Figures (a) to (d) in the middle;

[0073] The training process of the above Mask R-CNN model includes:

[0074] Data collection: Obtain activity videos of sows and their piglets over a historical period. For details, refer to the video data acquisition process described above.

[0075] Sample editing: Clip the activity video into several video clips of m minutes in length; divide the video clips into training sets and test sets;

[0076] Labeling data: Extract video images of crushing events from the training set, and annotate the positions and body areas of the sows and piglets in the images. For example, label piglets, standing sows, sitting sows, prone sows, and side-lying sows as "a," "b," "c," "d," and "e," respectively. Label video clips in the training set where sows crush piglets as "1," and those where they do not as "0." Use video images labeled "a," "b," "c," "d," or "e" as input and the corresponding label "1" or "0" as output to train the constructed Mask R-CNN framework, obtain a trained Mask R-CNN model, and finally test it on the test set.

[0077] (2) Constructing a stable corpus event chain:

[0078] Arrange the pig house environment information, sow physiological information, and piglet physiological information in chronological order to construct a stable corpus event chain of sows and piglets. For example, four stable corpus event chains can be constructed: pig house environment temperature, sow parity, sow weight, and piglet age. In addition, corpus event chains such as pig house environment humidity, sow body temperature, and piglet weight can also be constructed.

[0079] (3) Constructing the target corpus event chain:

[0080] For the initial target corpus event chain of the sow piglet, the present invention uses the above-mentioned preset initial piglet stress marker value to construct it;

[0081] In the above step S2, based on the behavioral corpus event chain, the stable corpus event chain and the target corpus event chain, combined with the adaptive self-attention time node deployment and the adaptive adjacency matrix, a directed event evolution graph based on the sow is constructed; specifically:

[0082] (1) Through adaptive self-attention time node deployment, the time node position in the corpus event chain is adjusted, which is expressed as:

[0083] w v =sigmoid((P r +sigmoid(F in ×w f +b f ))⊙w r +b r )

[0084] Among them, w v Represents the vector composed of the response weights of each attention time node; P r represents the normalized position encoding of each attention time node relative to the current self-attention time node; F in represents the feature matrix composed of all self-attention time node features in the initial time perception domain; w r represents the first learnable affine transformation weight vector; w f represents the learnable second affine transformation weight vector; b f represents the first learnable bias parameter; b r Represents the learnable second bias parameter; ⊙ represents the Hadamard product operation; according to w v The weight of the medium is large, and several time nodes with the highest response intensity are selected (such as Figure 3 V1 to V5) input graph convolutional network, generally speaking, the closer to V c The higher the correlation between the time node and the prediction target, when the response weights of two time nodes are equal and exceed the required number of time nodes, the time node closest to the current moment is preferred;

[0085] (2) Using the adaptive adjacency matrix, the connection status and connection weights of the time nodes in the corpus event chain are reorganized. For details, see Figure 3 and Figure 4 As shown;

[0086] There is an interactive relationship between the time nodes in the directed event evolution graph of the present invention, that is, there is an interaction between events, and each time node can only affect the downstream nodes on the time axis; the adjacency matrix is ​​a two-dimensional matrix used to indicate whether there is an interactive relationship between the time nodes in the graph, so the present invention uses the adjacency matrix to represent the constraint relationship between the time nodes. Figure 4 As shown in Figure (a), if there is a predefined logical link relationship between two time nodes, the corresponding element in the adjacency matrix is ​​set to "1", indicating that there is a positive edge (i.e. Figure 4 The gray area in (a) of the figure); and the transposed elements with the matrix diagonal as the symmetry line are set to "0", indicating a one-way constraint influence relationship between the two nodes (i.e. Figure 4 (a) in the white area); at the same time, the elements on the diagonal are set to "1", indicating a self-connection mode, that is, there is a connection relationship between the node and itself (i.e. Figure 4 In summary, the time nodes in the directed event evolution graph of the present invention have an obvious temporal logical order, so the node connections along the positive direction of the time axis are set as positive edges, and a self-connection method is adopted (the diagonal element values ​​are set to 1), and the adjacency matrix is ​​preset to obtain an adaptive adjacency matrix, such as Figure 4 As shown in Figure (b).

[0087] The process of obtaining the adaptive adjacency matrix can be expressed as:

[0088]

[0089] Among them, A′ i,j A represents the edge from the i-th node to the j-th node in the adaptive adjacency matrix; i,j W represents the edge from the i-th time node to the j-th time node in the original adjacency matrix; 1×n represents the learnable adjacency matrix attention vector; represents the feature vector of the i-th node; represents the j-th node feature vector; b represents the learnable bias value.

[0090] (3) Construct an event-oriented evolution diagram:

[0091] The event evolution graph is one of the most successful structured and semi-structured data models. Its main components include nodes, node features, and edges. The event evolution graph represents a snapshot of the time interval [t1, t2] on the event chain. V and E represent the time nodes and edges within the time interval, respectively. The method of constructing the corpus event chain fully utilizes the constraint logic relationship in the event chain and the nonlinear interaction between event chains. Therefore, the comprehensive corpus event chain is conducive to establishing a directed event evolution graph with strong event perception capabilities. A node feature vector F of a directed event evolution graph is i Expressed as:

[0092]

[0093] in, Represents the stable corpus event feature subvector; Represents the feature sub-vector of the behavior corpus event; Represents the target corpus event feature subvector;

[0094] (4) Divide the time nodes in the directed event evolution graph:

[0095] Since the event evolution graph composed of the time nodes of the present invention is a non-Euclidean data structure, that is, there is a connection relationship between non-adjacent nodes, it is necessary to divide the time nodes so that conventional convolution operations can be performed; to this end, the present invention uses the average value D of the time node spacing as the reference distance; and the average value X of the coordinates of the time nodes on the time axis as the center of the graph; when the distance from the time node to the graph center X is equal to the reference distance D, the time node is classified as a root node; when the distance from the time node to the graph center X is less than the reference distance D, the time node is classified as a centripetal node; when the distance from the node to the graph center X is greater than the reference distance D, the time node is classified as a centripetal node.

[0096] In the above step S3, based on the directed event evolution graph, the initial probability value of the piglet pressure event at the current moment is obtained; specifically, the high-order features of the directed event evolution graph are extracted through the space-time-channel attention mechanism; the obtained high-order features are sequentially passed through the average pooling layer and the Sigmoid function to obtain the initial probability value P of the piglet pressure event at the current moment; the probability value P is between 0 and 1, and a threshold value set between 0 and 1 can be used to determine whether the piglet pressure event will occur at the next moment; for example, the threshold is set to 0.5, and if the probability value P is greater than 0.5, it means that the sow squeezing piglet event will occur at the next moment; if the probability value is less than 0.5, it means that the sow squeezing piglet event will not occur at the next moment; the next moment mentioned here can be within one minute in the future;

[0097] This step can be achieved by using the graph convolutional model based on space-time-channel attention. Before using the graph convolutional model, it needs to be trained. The training process includes:

[0098] First, we build a graph convolutional model: we use the spatial-temporal-channel attention mechanism (STC-attention, STC) as the basic network structure of the graph convolutional network; the spatial-temporal-channel attention mechanism can be found in Figure 5 As shown in the figure, a data-driven approach is used to reorganize and adjust the feature weights in the encoding process, and feature information that is more responsive to the predicted behavior is flexibly extracted based on the input information, thereby improving the robustness and adaptability of the model. The spatial-temporal-channel attention mechanism is expressed as:

[0099] M s =Sigmoid(η s (AvgPooling(F input )))

[0100] M t =Sigmoid(η t (AvgPooling(F input )))

[0101] M c =Sigmoid(ω2(Sigmoid(ω1(AvgPooling(F input )))))

[0102] Among them, M s Represents the self-attention vector of the spatial dimension; M t Represents the self-attention vector in the time dimension; M c represents the self-attention vector in the channel dimension; η s represents the one-dimensional convolution operation of the spatial dimension; η t Represents the one-dimensional convolution operation in the time dimension; ω1 represents the weight of the first fully connected layer; ω2 represents the weight of the second fully connected layer;

[0103] Another use of this spatial-temporal-channel attention mechanism is that during the model debugging phase, feature visualization can be used to observe the results of the attention weight matrix's weight adjustment on nodes and edges, providing a reference for optimizing the adaptive directed event evolution graph.

[0104] Secondly, the m-minute video in the training set in step S1 is subjected to sliding segmentation with a window length of w minutes and an interval of i minutes; the video clip with a window length of w minutes is used as a sample; the sample is classified according to the squeezing situation of the video in the next 1 minute. If the sow squeezes the piglet event, the last moment of the sample is marked as "1"; if the sow squeezes the piglet event does not occur, the last moment of the sample is marked as "0"; finally, the labels of all samples in the long video are obtained, and the probability value of the sow squeezing the piglet event is generated. A target corpus event chain is constructed according to the time arrangement;

[0105] Finally, a behavioral corpus event chain is constructed using the sow posture identified by Mask R-CNN and the calculated closest distance, a stable corpus event chain is constructed using information such as ambient temperature and sow parity, and a target corpus event chain is constructed using the predicted probability value of the sow squeezing the piglet in the past. All corpus event chains are combined to form a directed event evolution graph. The directed event evolution graph is multiplied by the adjacency matrix, and the connection nodes and weights are reorganized to complete the input construction for graph convolutional model training.

[0106] In the above step S4, based on the initial probability value of the piglet stress event at the current moment and combined with the target corpus event chain, the final probability value of the piglet stress event at the current moment is obtained;

[0107] This process can be implemented using the BiLSTM model. As a variant of the LSTM model, the BiLSTM model excels at performing positive and negative bidirectional reasoning on input event feature vectors with strong logical relationships, obtaining cascaded positive and negative bidirectional hidden state vectors, inputting an activation function, and outputting prediction results to complete the decision.

[0108] Specifically, the initial probability value of the piglet stress event at the current moment obtained in the above step S3 and the target corpus event chain constructed in the above step S1 are concatenated to form a state vector; that is, the initial probability value of the piglet stress event at the current moment and the preset initial piglet stress mark value are concatenated to form a state vector, and input into the BiLSTM model, and the final probability value of the piglet stress event at the current moment is output; the current moment in this step is the next moment of the preset time period in step S1; the next moment can be within one minute in the future.

[0109] Next, the sow squeezing piglet event prediction method provided by the embodiment of the present invention is tested using the test set of the embodiment of the present invention:

[0110] In the embodiment of the present invention, f=25fps, m=120min, w=2min, i=1min, and sliding segmentation processing is performed to form a number of samples of video clips with a duration of 2 minutes, and the squeezing probability value of each sample is determined.

[0111] The test set consists of several 60-minute long videos, which contain several samples of sows squeezing piglets and no squeezing events. The total number of samples in the test set is 360, including 230 samples of no squeezing events and 130 samples of squeezing events. Input the first a minutes of the long video of the test set, a is called the step length. The model will predict whether squeezing will occur between sows and piglets in the next minute based on the dynamic information of the sows and piglets in a minute and the constructed corpus events. After the prediction is completed, the step length a will be moved back 1 minute and this operation will be repeated until the last minute of the test set video. Figure 6 As shown in Figure 2, the confusion matrix of the model predicting the squeeze event results when the step size a is determined to be 5, 10, 15 and 20. Finally, the accuracy rate A is used. cc Evaluate the effectiveness of the model in predicting extrusion.

[0112]

[0113] Among them, A cc represents the accuracy, T PP and T NP They represent the number of samples that successfully predicted the occurrence of squeeze events and the number of samples that successfully predicted the non-occurrence of squeeze events, S ump Represents the total number of samples of squeezing and non-squeezing events in the test set video;

[0114] When a = 5, the model's prediction accuracy was 90.0%; when a = 10, the model's prediction accuracy was 92.2%; when a = 15, the model's prediction accuracy was 93.8%; and when a = 20, the model's prediction accuracy was 95.0%. This fully demonstrates that the model can more accurately predict sow squeezing piglet events when a longer step size is selected.

[0115] In summary, the sow squeezing piglet event prediction method provided by the embodiment of the present invention provides a new method for early warning of sow squeezing piglet events in the current pig farm environment. It can effectively alleviate the situation where sows squeeze piglets to death, overcome the problem that piglets are squeezed to death and cannot be discovered in time in large-scale pig farming scenarios, realize intelligent piglet squeezing early warning, and provide a technical reference for early warning measures for future sow squeezing piglet events.

[0116] Example 2:

[0117] This embodiment 2, based on the above embodiment 1, further includes:

[0118] S5. Use the final probability value of the piglet stress event at the current moment as the new piglet stress mark value to update the target corpus event chain;

[0119] Since the purpose of the present invention is to predict the sow squeezing piglet event, it is intended to ultimately generate a probability value for the sow squeezing piglet event prediction to reflect the situation of the piglet being squeezed by the sow at a future moment; therefore, after each time the final probability value of the piglet squeezing event is obtained by the sow squeezing piglet event prediction method provided by the present invention, the latest final probability value of the piglet squeezing event is used to replace the piglet squeezing mark value in the previous target corpus event chain;

[0120] For details, please refer to Figure 7 As shown in the figure, the initial target corpus event chain is denoted as P0, and the initial probability value of the piglet stress event at the current moment obtained after the graph convolution model in step S3 is denoted as P1; the state vector formed by the concatenation of P0 and P1 is input into the BiLSTM model, and the final probability value of the piglet stress event at the current moment is denoted as P2; P2 is used as the new historical moment piglet stress mark value to update the target corpus event chain.

[0121] Since different time nodes have a strong logical constraint relationship on the same corpus event, each corpus event clue can be regarded as an independent event chain. Therefore, based on the update of the target corpus event chain, in the new round of prediction, the present invention inputs the state vector formed by concatenating the probability values ​​of the sow squeezing piglet event at the past moment (hidden state) and the current moment (initial judgment) into the BiLSTM model, and outputs the final probability value of the piglet pressure event at the current moment; specifically, in the first prediction, the state vector input into the BiLSTM model is formed by concatenating the initial judgment probability value of the piglet pressure event at the current moment and the preset initial piglet pressure mark value; and in each subsequent round of prediction, the state vector input into the BiLSTM model is formed by concatenating the initial judgment probability value of the piglet pressure event at the current moment and the final probability value of the piglet pressure event obtained in the previous round.

[0122] Example 3:

[0123] An embodiment of the present invention further provides a computer-readable medium storing instructions. When the instructions are executed on the computer-readable medium, the computer-readable medium executes the method for predicting sow squeezing piglet events as provided in the above-mentioned embodiment 1.

[0124] Example 4:

[0125] An embodiment of the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the sow squeezing piglet event prediction method provided in the above embodiment 1 is implemented.

[0126] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.

[0127] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for predicting sow squeezing piglets, characterized in that: The steps include: S1. Collecting sow and piglet-related data within a preset time period; and constructing a sow and piglet behavior corpus event chain, a stable corpus event chain, and a target corpus event chain based on the sow and piglet-related data; S2. Based on the behavioral corpus event chain, the stable corpus event chain, and the target corpus event chain, a directed event evolution graph based on the sow and piglet is constructed in combination with adaptive self-attention time node deployment and an adaptive adjacency matrix; S3. Obtaining a preliminary probability value of the piglet stress event at the current moment according to the directed event evolution graph; S4. Based on the initial probability value of the piglet stress event at the current moment and in combination with the target corpus event chain, obtain the final probability value of the piglet stress event at the current moment; The step S1 specifically includes: Collect video data of sows and their piglets, pig house environment information, sow physiological information, and piglet physiological information within a preset time period; and set an initial piglet stress marker value; Using the trained Mask R-CNN model, the sow posture in each frame of the video data is identified, and amodal instance segmentation is performed on the sow and piglets in each frame of the video data; Based on the amodal instance segmentation results, the Euclidean distance between each piglet and the sow in each frame is calculated; Arrange the obtained sow postures and minimum Euclidean distances in chronological order to construct the behavioral event chain of the sow and piglets; Arrange the pig house environment information, the sow physiological information, and the piglet physiological information in chronological order to construct a stable corpus event chain of sows and piglets; Based on the initial piglet stress marker value, constructing a target corpus event chain of the sow piglet; The step S3 specifically includes: Extract high-level features of directed event evolution graphs through the space-time-channel attention mechanism; The high-order features are sequentially passed through the average pooling layer and the Sigmoid function to obtain the initial probability value of the piglet stress event at the current moment; The step S4 specifically includes: S41, concatenating the initial probability value of the piglet stress event at the current moment and the target corpus event chain to form a state vector; S42: Input the state vector into the BiLSTM model, and output the final probability value of the piglet stress event at the current moment.

2. The method for predicting a sow squeezing piglet event according to claim 1, wherein: In step S2, the adaptive self-attention time node deployment is expressed as: w v =sigmoid((P r +sigmoid(F in ×w f +b f ))⊙w r +b r ) Among them, w v Represents the vector composed of the response weights of each attention time node; P r represents the normalized position encoding of each attention time node relative to the current self-attention time node; F in represents the feature matrix composed of all self-attention time node features in the initial time perception domain; w r represents the first affine transformation weight vector; w f represents the second affine transformation weight vector; b f represents the first bias parameter; b r represents the second bias parameter; ⊙ represents the Hadamard product operation.

3. The method for predicting a sow squeezing piglet event according to claim 1, wherein: In step S2, the adaptive adjacency matrix is ​​expressed as: Among them, A′ i,j A represents the edge from the i-th node to the j-th node in the adaptive adjacency matrix; i,j W represents the edge from the i-th time node to the j-th time node in the original adjacency matrix; 1×n represents the adjacency matrix attention vector; represents the feature vector of the i-th node; represents the j-th node feature vector; b represents the bias value.

4. The method for predicting a sow squeezing piglet event according to claim 1, wherein: The step S2 further includes dividing the time nodes in the directed event evolution graph: The average value of the time node spacing is used as the reference distance; the average value of the time node coordinates on the time axis is used as the center of the graph; when the distance from the time node to the center of the graph is equal to the reference distance, the time node is classified as a root node; when the distance from the time node to the center of the graph is less than the reference distance, the time node is classified as a centripetal node; when the distance from the node to the center of the graph is greater than the reference distance, the time node is classified as a centrifugal node.

5. The method for predicting a sow squeezing piglet event according to claim 1, wherein: Also includes: S5. Using the final probability value of the piglet stress event at the current moment as a new piglet stress mark value, and updating the target corpus event chain.

6. A computer-readable medium storing instructions, characterized in that: When the instructions are executed on the readable medium, the readable medium is caused to execute the method according to any one of claims 1 to 5.

7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Sow side-lying posture real-time detection system based on joint partitioning of sow key parts and environment

    CN110147771A

  • Piglet death event clustering analysis method

    CN116958611A