Sow uterine contraction behavior identification method based on machine vision

By using an improved SLP3D model and lightweight processing technology, the problems of insufficient generalization ability and high computational cost in sow uterine contraction behavior recognition have been solved, achieving efficient and low-cost sow status monitoring and meeting actual breeding needs.

CN120877386AActive Publication Date: 2025-10-31NAT CENT OF TECH INNOVATON FOR PIGNS +1
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511373532.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2025-10-31
Estimated Expiration
2045-09-25

AI Technical Summary

Technical Problem

Existing technologies for recognizing sow uterine contractions suffer from insufficient generalization ability and high computational costs, making them difficult to apply effectively in real-world production environments and failing to meet the needs of agricultural farming.

Method used

The SLP3D model is combined with the lightweight spatial channel attention module LSCA and the partial bidirectional spatial pyramid feature fusion module PBFPN. The model is deployed on a backend server for real-time video processing to identify sow uterine contraction behavior. The Swish activation function is used to optimize the model, reducing computational complexity and resource requirements.

Benefits of technology

It significantly reduces computational overhead and equipment requirements while ensuring recognition accuracy, enabling real-time monitoring of sow status in actual production environments and improving breeding efficiency and economic benefits.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120877386A_ABST
    Figure CN120877386A_ABST
Patent Text Reader

Abstract

The invention provides a sow uterine contraction behavior recognition method based on machine vision, and relates to the field of image processing, and the method comprises the steps: S1, data collection, S2, data transmission, S3, model reasoning and processing, and S4, behavior detection and output. According to the method, the sow uterine contraction behavior can be automatically identified, supervision of the state of the to-be-delivered sow by first-line breeding personnel is facilitated, death of the to-be-delivered sow and newborn piglets is reduced, and economic benefits of breeding enterprises are improved; meanwhile, the method effectively balances the accuracy of sow uterine contraction behavior recognition and the complexity of the model, has high practicability, and meets the requirements of the actual production environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and more specifically to a machine vision-based method for recognizing sow uterine contraction behavior. Background Technology

[0002] Changes in the frequency of sow uterine contractions are an important physiological indicator of approaching farrowing. Accurately determining the timing of farrowing is crucial for ensuring sow health, extending the reproductive cycle, improving newborn piglet survival rates, optimizing piglet quality, increasing farming efficiency, and reducing management costs. With the increasing scale of farming, the care of sows awaiting farrowing (such as monitoring their health and farrowing status) requires significant human resources. Automated detection of sow uterine contractions using cameras and machine vision technology can alleviate the burden on frontline farm workers. Furthermore, it allows for monitoring the sow's health status and predicting farrowing time based on uterine contraction patterns.

[0003] Currently, existing behavior recognition methods are mostly applied to human behavior analysis. Although they have high recognition accuracy, they suffer from problems such as insufficient generalization ability and high computational cost in aquaculture scenarios, making them difficult to apply directly to actual production environments. Specifically, this manifests as follows: (1) Insufficient generalization ability: For some actions with weak temporal correlation (such as standing or eating), current behavior recognition algorithms can achieve action recognition based on a single image of the action, with high accuracy, and can be verified on animals. However, for actions with strong temporal correlation, which are usually fine-grained actions (such as uterine contractions), they cannot be judged by a single image and need to rely on information from previous and subsequent frames. For these highly correlated behaviors, the accuracy often decreases during the recognition process, requiring network improvements to adapt to specific actions, resulting in poor adaptability to the environment. (2) High computational cost: For actual production environments, accuracy is just as important as the size of computational resources. Existing behavior recognition algorithms often ignore computational load and focus too much on improving accuracy. This leads to higher requirements for equipment performance in practical applications, greatly increasing aquaculture costs and failing to meet the needs of agricultural aquaculture. Summary of the Invention

[0004] To address the problems existing in the prior art, the present invention aims to provide a machine vision-based method for recognizing sow uterine contraction behavior. This method can automatically identify sow uterine contraction behavior, which is beneficial for frontline farmers to monitor the status of sows about to give birth, reduce the mortality of sows and newborn piglets, and improve the economic benefits of farming enterprises. At the same time, this method balances the accuracy of uterine contraction behavior recognition with the complexity of the model, thereby improving the practicality of the model.

[0005] The objective of this invention is achieved through the following technical solution:

[0006] A machine vision-based method for recognizing sow uterine contractions includes:

[0007] Step S1, Data Acquisition: By installing high-definition network cameras in the breeding room, real-time capture of individual sow activity is achieved, accurately focusing on the behavioral dynamics of the sows.

[0008] Step S2, Data Transmission: The camera transmits the real-time monitoring video stream it collects to the backend server via the local area network in the delivery room;

[0009] Step S3, Model Inference and Processing: The SLP3D model, which has been pre-trained and optimized and deployed to the backend server, receives real-time video, extracts frames according to preset rules, and preprocesses the extracted video frames; then, the SLP3D model accurately identifies feature patterns related to "uterine contraction behavior" by capturing the spatiotemporal dynamic features of sow behavior.

[0010] Step S4, Behavior Detection and Output: The SLP3D model calculates and outputs the "confidence level of uterine contraction behavior" corresponding to the current frame based on the information obtained from the previous frame and the current frame. When the confidence level exceeds the preset threshold, it is determined that the sow's uterine contraction behavior has been detected, and an early warning prompt is generated in real time on the server's monitoring terminal, and the corresponding information is recorded.

[0011] Based on further optimization of the above scheme, the high-definition network camera in step S1 has low light adaptability and continuous recording function, and can capture the complete activity of a single sow in real time (including details such as body posture, limb movements, and abdominal changes); the camera is installed in a key monitoring position in the breeding house (e.g., directly above the sow restraint fence).

[0012] Based on further optimization of the above scheme, in step S2, the local area network in the delivery room adopts a 5G / 4G wireless network, and the collected real-time monitoring video stream is processed at a frame rate of 15-25fps; a lightweight data compression protocol (such as H.264 / H.265) is used during transmission.

[0013] Based on further optimization of the above scheme, the network architecture of the SLP3D model includes a backbone network, a neck network, and a head network. The backbone network extracts features from the input video and maps these features to a high-dimensional space, facilitating classification by the head network. The neck network fuses multi-scale features to ensure the network can obtain multi-scale information flow, enabling the identification of uterine contractions of varying intensity. The head network classifies the fused features and obtains the behavioral patterns of the detected sow (e.g., whether uterine contractions are occurring).

[0014] Meanwhile, the SLP3D model is improved based on the C3D network. By embedding the Lightweight Spatial-Channel Attention (LSCA) module into the CoLs convolution, the model's attention to key regions is enhanced. The Partial Bidirectional Feature Pyramid Network (PBFPN) module is set in the cervical network to improve the ability to recognize uterine contractions of different intensities. Combined with the Swish activation function, the model is further improved in a targeted manner.

[0015] Based on further optimization of the above scheme, the Lightweight Spatial Channel Attention Module (LSCA) adopts a dual-branch structure: the upper branch is a spatial attention mechanism used to capture the spatial importance of the feature map; the lower branch is a channel attention mechanism used to enhance the feature information of key channels. After the upper and lower branches generate corresponding attention weights, they are weighted and fused with the original feature map respectively. Finally, the two results are integrated through an adaptive feature fusion strategy, which effectively improves the network's ability to capture important features and its overall expressive performance. Specifically:

[0016] ;

[0017] In the formula: The energy function representing the generation of attention weights in 3D space; One-dimensional convolution representing an adaptive convolution kernel; Indicates global average sampling; Represents the learnable fusion weights; express The operation is used to transform five-dimensional data into four-dimensional data (this can be achieved by introducing existing functions). This represents the input feature map; at the same time, learnable parameters are introduced in the feature fusion stage to construct an adaptive weight fusion paradigm, enabling the model to dynamically adjust the feature interaction mode of spatial and channel dimensions; this design significantly improves the model's ability to represent complex spatial context and channel semantic information, providing a new solution for efficient feature extraction.

[0018] The energy function for generating 3D spatial attention weights is as follows:

[0019] ;

[0020] In the formula: Represents pixels, Indicates a channel. and Indicates spatial location; , This represents the mean and variance of the entire input; Indicates the bias term. , which is a coefficient used to further reflect the directionality of neuron activation values ​​(i.e., the different effects of positive and negative activation).

[0021] The adaptive convolutional kernel in channel attention is:

[0022] ;

[0023] In the formula: This represents the number of channels for the input feature; Indicates the bias term; Indicates the scaling factor; This indicates rounding down to the nearest integer.

[0024] Based on further optimization of the above scheme, the partially bidirectional spatial pyramid feature fusion module PBFPN adopts a three-layer bidirectional structure, including a feature map input part, an upsampling module part, and a downsampling module part. The feature map input part is responsible for receiving the original features and completing the basic representation. The upsampling part improves the feature resolution through interpolation to capture fine-grained information. The downsampling part reduces the dimensionality through convolution to enhance global feature extraction. While constructing a multi-scale information flow, the module introduces a residual structure and directly transmits the input features through shortcut connections, effectively compensating for the loss of detailed information that may occur during feature extraction and ensuring feature integrity.

[0025] Based on further optimization of the above scheme, the Swish activation function is:

[0026] .

[0027] Based on further optimization of the above scheme, the preset rule in step S3 is to extract one valid frame every one frame interval; preprocessing includes cropping the video.

[0028] The following are the technical effects of the present invention:

[0029] This invention processes real-time acquired video frames using an improved SLP3D model, namely the Lightweight Spatial Channel Attention Module (LSCA) and the Partial Bidirectional Spatial Pyramid Feature Fusion Module (PBFPN), combined with the Swish activation function, to obtain an SLP3D network for recognizing uterine contractions in sows. This not only effectively balances the model's expressive power and training stability, but also introduces learnable parameters in the feature fusion stage, enabling the model to autonomously optimize the fusion mode of spatial and channel weights, thereby enhancing the model's ability to express complex feature relationships. Furthermore, it effectively mitigates information loss during convolution and upsampling, significantly reduces computational overhead, and further balances performance and efficiency.

[0030] The method of this invention effectively balances the accuracy of uterine contraction behavior recognition with the complexity of the model, enabling the model to maintain a high FPS (Frames Per Second) while ensuring accurate recognition of uterine contraction behavior, and also has low FLOPs (Floating-Point Operations) and Parameters. This reduces the requirements of the deployment equipment, realizes intelligent breeding of sows, and facilitates the monitoring of sow status by farmers. Attached Figure Description

[0031] Figure 1 This is an architecture diagram of the SLP3D network in an embodiment of the present invention; wherein, Partial convolution is a new type of convolutional structure used to reduce the computation of redundant features and improve efficiency; P1-P5 refer to feature maps of different sizes, for example: P1 refers to a (56x56) size, P2 refers to a (28x28) size; Upsample refers to upsampling.

[0032] Figure 2 This is a schematic diagram of the lightweight spatial channel attention module LSCA in an embodiment of the present invention, where X refers to the feature map; H, W, and C refer to the length, width, and number of channels of the feature map, respectively.

[0033] Figure 3 This is a schematic diagram of the structure of a partial bidirectional spatial pyramid feature fusion module PBFPN in an embodiment of the present invention, wherein P5, P6, and P7 refer to feature maps of different sizes;

[0034] Figure 4 This is a channel feature map in an embodiment of the present invention;

[0035] Figure 5 The Swish activation function differs in the embodiments of the present invention. A graph showing the values;

[0036] Figure 6 This is a comparison diagram of the Swish activation function and the ReLU activation function in an embodiment of the present invention;

[0037] Figure 7 This is a comparison diagram of the original frames and corresponding cropped frames of sow uterine contractions and normal walking behavior in an embodiment of the present invention;

[0038] Figure 8 This is a heat map from an embodiment of the present invention. Detailed Implementation

[0039] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0040] Example 1:

[0041] A machine vision-based method for recognizing sow uterine contractions includes:

[0042] Step S1, Data Acquisition: By installing high-definition network cameras in the breeding room, with the cameras installed at key monitoring positions in the breeding room (such as directly above the sow restraint pen), real-time capture of individual sow activity can be achieved, accurately focusing on the behavioral dynamics of the sows; the high-definition network cameras have low-light adaptability and continuous recording functions, and can capture complete activity images of individual sows in real time (including details such as body posture, limb movements, and abdominal changes).

[0043] Step S2, Data Transmission: The camera transmits the real-time monitoring video stream collected by the camera to the backend server via the local area network in the delivery room. The local area network uses a 5G / 4G wireless network, and the collected real-time monitoring video stream is processed at a frame rate of 15-25fps. Lightweight data compression protocols (such as H.264 / H.265) are used during transmission to avoid delays caused by excessive network bandwidth usage, ensuring that the delay from video stream acquisition to server reception is controlled within 1-3 seconds.

[0044] Step S3, Model Inference and Processing: The pre-trained and optimized SLP3D model deployed to the backend server receives real-time video, extracts frames according to preset rules (i.e., extracts one valid frame every other frame), and preprocesses the extracted video frames (e.g., cropping the video). Then, the SLP3D model captures the spatiotemporal dynamic features of sow behavior (analyzing not only the static posture of a single frame but also the changes in motion in consecutive frames, such as the time series differences in the frequency of abdominal undulations and the amplitude of body curling), accurately identifying feature patterns related to "uterine contraction behavior" (such as the typical features of sows arching their backs, tightening their abdomens, and retracting their limbs while remaining relatively still during uterine contractions).

[0045] like Figure 1 As shown, the network architecture of the SLP3D model includes a backbone network, a neck network, and a head network. The backbone network is used to extract features from the input video and map the features to a high-dimensional space, which facilitates classification by the head network. The neck network is used to fuse multi-scale features to ensure that the network can obtain multi-scale information flow and recognize uterine contractions of different intensities. The head network is used to classify the fused features and obtain the behavioral patterns of the detected sow (e.g., whether uterine contractions are occurring).

[0046] Meanwhile, the SLP3D model is an improvement on the C3D (Convolutional 3D Network). By embedding the Lightweight Spatial-Channel Attention (LSCA) module into the CoLs convolution, the model's attention to key regions is enhanced. The Partial Bidirectional Feature Pyramid Network (PBFPN) module is set in the cervical network to improve the ability to recognize uterine contractions of different intensities. Combined with the Swish activation function, the model is further improved in a targeted manner.

[0047] Among them, such as Figure 2 As shown, the Lightweight Spatial Channel Attention Module (LSCA) adopts a dual-branch structure: the upper branch is a spatial attention mechanism used to capture the spatial importance of features in the feature map; the lower branch is a channel attention mechanism used to enhance the feature information of key channels. After the upper and lower branches generate corresponding attention weights, they are weighted and fused with the original feature map respectively. Finally, the two results are integrated through an adaptive feature fusion strategy, which effectively improves the network's ability to capture important features and its overall expressive performance. This design deeply integrates the spatial focusing idea of ​​SimAM and the channel selection mechanism of ECA, effectively overcoming the shortcomings of traditional methods in the collaborative modeling of spatial and channel features. At the module architecture level, to balance performance and efficiency, LSCA reduces computational redundancy through a dual-branch parallel computing strategy. At the same time, learnable parameters are introduced in the feature fusion stage to construct an adaptive weight fusion paradigm, enabling the model to dynamically adjust the feature interaction mode of spatial and channel dimensions. This design significantly improves the model's ability to represent complex spatial context and channel semantic information, providing a new solution for efficient feature extraction.

[0048] Specifically:

[0049] ;

[0050] In the formula: E represents the energy function for generating 3D spatial attention weights; Conv represents the one-dimensional convolution of the adaptive convolution kernel; GAP represents global average sampling; represents the learnable fusion weights; r represents the rearrange operation, which transforms five-dimensional data into four-dimensional data (this can be achieved by introducing an existing function), that is, transforming the five-dimensional data (B,T,C,H,W) into the four-dimensional data [(B,T),C,H,W].

[0051] The energy function for generating 3D spatial attention weights is as follows:

[0052] ;

[0053] In the formula: Represents pixels, Indicates a channel. and Indicates spatial location; , This represents the mean and variance of the entire input; Indicates the bias term. , which is a coefficient used to further reflect the directionality of neuron activation values ​​(i.e., the different effects of positive and negative activation).

[0054] The adaptive convolutional kernel in channel attention is:

[0055] ;

[0056] In the formula: This represents the number of channels for the input feature; Indicates the bias term; Indicates the scaling factor; This indicates rounding down to the nearest integer.

[0057] The code flow of LSCA is as follows:

[0058]

[0059] Some bidirectional spatial pyramid feature fusion modules (PBFPN) adopt a three-layer bidirectional structure, such as... Figure 3 As shown, it includes the feature map input part (i.e. Figure 3 The left side shown), the upsampling module (i.e. Figure 3 The middle part shown) and the downsampling module part (i.e. Figure 3 (As shown on the right side), this is based on an in-depth analysis of the properties of the model's feature layers. Considering the strong heterogeneity of features generated by the rapid downsampling in the first two layers of the model, directly participating in the fusion could easily lead to the model failing to effectively focus on key features, increasing the learning difficulty and bringing additional computational burden. A three-layer bidirectional structure is adopted, which not only ensures the full fusion of multi-scale features and effectively alleviates information loss during convolution and upsampling, but also significantly reduces computational overhead, achieving a balance between performance and efficiency. The feature map input part is responsible for receiving the original features and completing the basic representation; the upsampling part improves the feature resolution through interpolation to capture fine-grained information; and the downsampling part uses convolution to reduce dimensionality to enhance global feature extraction. While constructing a multi-scale information flow, the module introduces a residual structure, directly passing the input features through shortcut connections, effectively compensating for the possible loss of detailed information during feature extraction and ensuring feature integrity.

[0060] Meanwhile, considering the redundancy among the multi-channel features extracted by the backbone network (such as... Figure 4 As shown, this invention introduces partial convolution (PConv) into the feature fusion module to replace traditional ordinary convolution; this method effectively reduces the invalid calculation of redundant features and lowers the overall computational complexity of the model.

[0061] The code flow of PBFPN is as follows:

[0062]

[0063] The Swish activation function is:

[0064] ;

[0065] This represents the hyperparameters of the Swish activation function; Curves under different values ​​are as follows Figure 5 As shown, by Figure 5 It can be seen that when When the value of is close to 0, the Swish activation function tends to be linear, and the curve changes relatively gently. At this time, the gradient is large, which helps to improve the stability of the training process, but its non-linear expressive power is relatively weak; when When the value of is close to 1, the function possesses both moderate nonlinearity and good gradient properties, and typically performs optimally in various tasks; when When the value of is greater than 1, the Swish function gradually approximates ReLU, which enhances its non-linearity and is beneficial for improving the model's feature discrimination ability. However, it may also cause problems such as gradient vanishing or training instability, and is generally suitable for deep networks or highly complex scenarios. In this embodiment, we select The value of is 1, in order to achieve a good balance between expressive power and training stability, then:

[0066] ;

[0067] Swish has better smoothness than ReLU, while ReLU has... It is not differentiable at a value of 0; Swish allows a small number of negative values ​​to pass through, and... When approaching negative infinity, it does not equal 0, but rather approaches 0. This allows the model to optimize itself more stably. At the same time, the addition of adaptive parameters makes the model less sensitive to the choice of initialization and learning rate, which helps to improve the stability of model training. Figure 6 This is a comparison chart of Swish and ReLU, by... Figure 6 It can be seen that: the Swish activation function in Within the range < 0, the output value is not 0, but rather varies with the range. As it approaches negative infinity, it gradually approaches zero; this characteristic allows negative gradients to effectively participate in model parameter optimization during training, avoiding the loss of gradient information. Furthermore, the Swish function is continuously differentiable, naturally avoiding the drawbacks of the ReLU function. The non-differentiability at =0 ensures the stability of model training and the smoothness of gradient propagation.

[0068] The SLP3D training dataset relies on an indoor monitoring system in an experimental pig farm. This system covers scenes under different lighting conditions, including daytime and nighttime, ensuring broad applicability of the data and improving the accuracy and reliability of the experimental results. The monitoring system uses a Hikvision DS-2CD3146FWD-IS hemispherical camera, mounted top-mounted directly above the pigpen at an optimal shooting height of 2 to 2.5 meters to obtain a clear and comprehensive observation view. In the data annotation stage, to ensure data quality and provide a solid foundation for subsequent model training and analysis, all images were uniformly set to a high resolution of 2560×1440 pixels. During the model training phase, to reduce the impact of environmental interference on model training and improve training efficiency, preprocessing was performed on the original video frames. Specifically, a center-cropping technique was used to retain the individual images of sows in the central region of the video frame, highlighting key targets and reducing redundant information from interfering with model training. Figure 7 As shown.

[0069] This embodiment constructs a video dataset of uterine contraction behavior from 32 sows, encompassing 2073 short video clips ranging from 3 to 15 seconds in length. Based on behavioral state, these samples are divided into two categories: contraction state and normal state (including non-contraction behaviors such as walking and lying down). To mitigate model performance bias caused by class imbalance during training, a data filtering and resampling strategy is employed to ensure a near 1:1 ratio between the two classes in the overall dataset. The dataset is divided into training, validation, and test sets in an 8:1:1 ratio to guarantee the scientific rigor and stability of the model evaluation. The cropped video resolution becomes (678, 1080), and the frame rate is changed from 30 frames per second to 20 frames per second. In pig farming scenarios (such as...), Figure 7 As shown, the upper half represents the uterine contraction state (left image is the original frame, right image is the cropped frame); the lower half represents the normal walking state (left image is the original frame, right image is the cropped frame). Two to three days before farrowing, sows often lie on their sides due to abdominal swelling, occasionally turning over, and their abdomen is continuously exposed to the overhead camera's field of view. Since uterine contraction behavior recognition requires capturing dynamic changes in the abdomen, video data collected by the overhead camera in the farrowing room provides an effective data source for this task.

[0070] Step S4, Behavior Detection and Output: The SLP3D model calculates and outputs the "confidence level of uterine contraction behavior" based on the information obtained from the previous and current frames. When the confidence level exceeds the preset threshold (adjusted according to the actual scenario of the farm, the preset threshold is 0.7 in this embodiment), it is determined that the sow's uterine contraction behavior has been detected. An early warning prompt is generated in real time on the monitoring terminal of the server (such as the computer or mobile device of the farm manager) and the corresponding information (including the time of occurrence of the uterine contraction behavior, duration, confidence level, etc.) is recorded, providing data support for the subsequent prediction of the sow's farrowing time.

[0071] Among them, confidence level calculation:

[0072] ;

[0073] In the formula: Indicates the first Categories (Logarithmic odds) output; This represents the total number of categories (e.g., 101 for UCF101); the output is a probability vector, with each value between [0,1] and a sum of 1.

[0074] To ensure that the final model can be deployed on devices with limited computing resources and applied to real-world production and daily life, this embodiment uses Mean of Accuracy (MCA), FLOPs, Parameters, and FPS as the final evaluation metrics for the model.

[0075] MCA:

[0076] ;

[0077] In the formula: TP (True Positives) represents the number of samples correctly predicted as positive by the model; FN (False Negatives) represents the number of samples incorrectly predicted as negative by the model;

[0078] FLOPs:

[0079] ;

[0080] In the formula: Indicates the number of output elements; This indicates the number of multiply-accumulate operations required for each output element;

[0081] Parameters include the Conv layer and the Liner layer:

[0082] ;

[0083] ;

[0084] Where: K H K W Indicates the height and width of the convolution kernel; , Indicates the number of input channels and the number of output channels;

[0085] FPS:

[0086] ;

[0087] In the formula: Indicates the total number of frames processed; Indicate processing The time taken to complete a frame, measured in seconds;

[0088] To more comprehensively verify the performance of the proposed model, this embodiment selected several classic and representative behavior recognition algorithms and conducted comparative experiments on a uterine contraction behavior dataset. The results are shown in Table 1:

[0089]

[0090] Table 1. Comparison of Recognition Algorithms

[0091] All the models mentioned above used pre-trained weights during training. The weights listed in the table are LRCN (Long-term Recurrent Convolutional Networks, proposed by Jeff Donahue et al. in a 2015 paper), C3D (Convolutional 3D Network, proposed by Du Tran et al. in a 2015 paper "Learning Spatiotemporal Features with 3D Convolutional Networks"), TSN (Temporal Segment Network, proposed by Limin Wang et al. in a 2016 paper "Temporal Segment Networks: Towards Good Practices for Deep Action Recognition"), I3D (Inflated 3D Network, proposed by Joao Carreira and Andrew Zisserman in a 2017 paper "Quo Vadis, Action Recognition? A New Model and the Kinetics Dataset"), and SlowFast (SlowFast Networks, proposed by Christoph Feichtenhofer et al. in a 2019 paper "SlowFast Networks for Video"). The same data augmentation methods are used in our SLP3D: random cropping and random horizontal flipping. (The following are examples of data augmentation methods: VideoSwin (Video SwinTransformer, an extension of the 2021 paper "Swin Transformer: HierarchicalVision Transformer using Shifted Windows" by Ze Liu et al., and proposed by the same team in subsequent work), UniformerV2 (Unified Transformer for Video Recognition, proposed by Kunchang Li et al. in the 2022 paper "Uniformer: Unified Transformer for Efficient Spatiotemporal Representation Learning"), VideoSwin (Video SwinTransformer, an extension of the 2021 paper "Swin Transformer: HierarchicalVision Transformer using Shifted Windows" by Ze Liu et al., and UniformerV2 (Unified Transformer for Video Recognition, proposed by Kunchang Li et al. in the 2022 paper "Uniformer: Unified Transformer for Efficient Spatiotemporal Representation Learning"), VideoSwin (Unified Transformer for Video Recognition, proposed by Kunchang Li et al. in the 2022 paper "Uniformer: Unified Transformer for Efficient Spatiotemporal Representation Learning"), and VideoSwin (Unified Transformer for Video Recognition, proposed by Kunchang Li et al. in the 2022 paper "Uniformer: Unified Transformer for Efficient Spatiotemporal Representation Learning").Video-FocalNets (Video FocalModulation Network, which was extended to the video domain by Jianwei Yang et al. in their 2023 paper "FocalNet: FocalModulation for Visual Recognition" to propose the FocalNet architecture for video modeling) and TC-CLIP (Temporal Contrastive CLIP, proposed by Mengmeng Wang et al. in their 2024 paper "TC-CLIP: Temporal Contrastive Learning for Video-TextAlignment" for video-text contrast learning) use color enhancement, grayscale perturbation, and MixUp (linearly mixing two images with their corresponding labels). TC-CLIP adds CutMix (replacing random regions of one image with corresponding regions of another image, with labels weighted proportionally to the regions) data augmentation.

[0092] As shown in the table above, the model in this embodiment achieves a maximum mean classification accuracy (MCA) of 96.40% while having a computational complexity of only 38.783 G FLOPs, 102 M parameters, and a real-time inference speed of 65.66 FPS. This performance balances model accuracy and computational efficiency, meeting the real-time requirements of real-world production environments. Furthermore, the model proposed in this embodiment exhibits the best overall performance.

[0093] To analyze the specific contributions of each of our proposed modules to the overall network performance, we designed and implemented a series of systematic ablation studies. In each experiment, we introduced or removed only one improved module, keeping other structures and hyperparameters unchanged, to evaluate the independent impact of that module on the overall performance. These experiments not only validated the effectiveness of each component but also revealed their differences in impact on various evaluation metrics (such as classification accuracy, parameter count, computational cost, and inference speed). Furthermore, by progressively stacking modules, we further analyzed the synergistic effects among multiple modules. The experimental results are shown in Table 2.

[0094]

[0095] Table 2. Comparison of Module Synergistic Effects

[0096] As shown in the table above, each module maintains high computational efficiency and good parameter controllability while improving model performance, verifying the rationality and practicality of the overall architecture design. Ultimately, the model in this embodiment achieved 96.40% MCA, 38.783G FLOPs, 102M Params, and 65.66 FPS, meeting the needs of a production environment.

[0097] To more intuitively demonstrate the differences between the baseline model and the summary model in this embodiment, we designed a visualization experiment for comparative analysis. For example... Figure 8 As shown, the images display the original image (first row), the heatmap generated by the C3D baseline model (second row), and the heatmap generated by the improved model in this embodiment (third row). The visualization results reveal that the C3D model's area of ​​interest is relatively scattered when processing images, making it difficult to focus on key areas closely related to sow uterine contractions (such as the abdominal region), and even misfocusing on the head region in some samples. In contrast, the model in this embodiment can more accurately focus on the sow's abdominal region, demonstrating strong robustness even in complex environments such as occlusion by the gestation crate or strong light interference. This improvement in the model's area of ​​interest helps enhance its ability to discriminate uterine contractions, thus explaining its improved accuracy.

[0098] Example 2:

[0099] As another preferred embodiment of the present invention, based on the scheme of Example 1, after the SLP3D model continuously outputs sow uterine contraction behavior detection data (such as the time of occurrence, frequency, duration, etc. of contractions), the farmers can carry out refined management based on the changing patterns of these data: by monitoring the dynamic trend of the number of contractions in real time, when the frequency of contractions rises to a preset threshold (for example, the number of contractions per unit time reaches 10 to 15 times, which can be adjusted according to the sow breed and gestation stage), it can be determined that the sow is about to enter the farrowing stage, and then the farrowing house preparation work can be started in advance - including debugging the farrowing equipment (such as heat lamps, disinfection of farrowing tools), preparing newborn piglet care materials (such as warming pads, colostrum supplements), arranging dedicated personnel to be on duty, etc.

[0100] Example 3:

[0101] A system for recognizing sow uterine contraction behavior includes an improved SLP3D model as described in Example 1, a high-definition camera, and a memory. The improved SLP3D model can be mounted on an NVIDIA L40 GPU hardware platform, and the memory is used to store the results output by the SLP3D model.

[0102] The preferred embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above. Steps and methods not described in detail should be understood as being implemented in a conventional manner in the art. Any person skilled in the art can make many possible variations and modifications to the technical solutions of the present invention, or modify them into equivalent embodiments, without departing from the scope of the present invention. This does not affect the essential content of the present invention. Therefore, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the present invention are still within the scope of protection of the present invention.

Claims

1. A machine vision-based method for recognizing sow uterine contraction behavior, characterized in that... include: Step S1, Data Acquisition: By installing high-definition network cameras in the breeding room, real-time capture of individual sow activity is achieved, accurately focusing on the behavioral dynamics of the sows. Step S2, Data Transmission: The camera transmits the real-time monitoring video stream it collects to the backend server via the local area network in the delivery room; Step S3, Model Inference and Processing: The pre-trained and optimized SLP3D model, deployed to the backend server, receives real-time video, extracts frames according to preset rules, and preprocesses the extracted video frames. Then, the SLP3D model accurately identifies feature patterns related to "uterine contraction behavior" by capturing the spatiotemporal dynamic features of sow behavior. The network architecture of the SLP3D model includes a backbone network, a neck network, and a head network. The backbone network is used to extract features from the input video and map the features to a high-dimensional space, which facilitates classification by the head network. The neck network is used to fuse multi-scale features to ensure that the network can obtain multi-scale information flow and realize the recognition of uterine contraction behavior of different intensities. The head network is used to classify the fused features and obtain the behavior patterns of the detected sow. Meanwhile, the SLP3D model is improved based on the C3D network. By embedding the Lightweight Spatial-Channel Attention (LSCA) module into the CoLs convolution, the model's attention to key regions is enhanced. The Bidirectional Spatial Pyramid Feature Fusion (PBFPN) module is set in the cervical network to improve the ability to recognize uterine contractions of different intensities. Combined with the Swish activation function, the model is improved in a targeted manner. The Lightweight Spatial Channel Attention Module (LSCA) adopts a two-branch structure: the upper branch is a spatial attention mechanism used to capture the spatial importance of features in the feature map; the lower branch is a channel attention mechanism used to enhance the feature information of key channels. After the upper and lower branches generate corresponding attention weights, they are weighted and fused with the original feature map respectively. Finally, the two results are integrated through an adaptive feature fusion strategy, specifically: ; In the formula: The energy function representing the generation of attention weights in 3D space; One-dimensional convolution representing an adaptive convolution kernel; Indicates global average sampling; Represents the learnable fusion weights; express The operation transforms five-dimensional data into four-dimensional data. Indicates the input feature map; The energy function for generating 3D spatial attention weights is as follows: ; In the formula: Represents pixels, Indicates a channel. and Indicates spatial location; , This represents the mean and variance of the entire input; Indicates the bias term. The coefficient is used to further reflect the directionality of neuron activation values; The adaptive convolutional kernel in channel attention is: ; In the formula: C represents the number of channels of the input feature; b represents the bias term; Indicates the scaling factor; Indicates rounding down; Step S4, Behavior Detection and Output: The SLP3D model calculates and outputs the "confidence level of uterine contraction behavior" corresponding to the current frame based on the information obtained from the previous frame and the current frame. When the confidence level exceeds the preset threshold, it is determined that the sow's uterine contraction behavior has been detected, and an early warning prompt is generated in real time on the server's monitoring terminal, and the corresponding information is recorded.

2. The method for recognizing sow uterine contraction behavior based on machine vision according to claim 1, characterized in that: In step S1, the high-definition network camera has low-light adaptability and continuous recording functions, which can capture the complete activity of a single sow in real time. Cameras are installed at key monitoring locations in the breeding room.

3. The method for recognizing sow uterine contraction behavior based on machine vision according to claim 1, characterized in that: In step S2, the local area network in the delivery room adopts a 5G / 4G wireless network, and the collected real-time monitoring video stream is processed at a frame rate of 15-25fps; a lightweight data compression protocol is used during transmission.

4. The method for recognizing sow uterine contraction behavior based on machine vision according to claim 1, characterized in that: The bidirectional spatial pyramid feature fusion module PBFPN adopts a three-layer bidirectional structure, including a feature map input part, an upsampling module part, and a downsampling module part. The feature map input part is responsible for receiving the original features and completing the basic representation. The upsampling part improves the feature resolution through interpolation to capture fine-grained information. The downsampling part reduces the dimensionality through convolution to enhance global feature extraction. While constructing a multi-scale information flow, the module introduces a residual structure and directly passes the input features through shortcut connections.

5. The method for recognizing sow uterine contraction behavior based on machine vision according to claim 1, characterized in that: The Swish activation function is: ; In the formula: This represents the hyperparameters of the Swish activation function, i.e., the denominator of the Sigmoid function. The exponent controls the shape of the function, thus affecting the nonlinear expressive power and training dynamics of the neural network.

6. The method for recognizing sow uterine contraction behavior based on machine vision according to claim 1, characterized in that: In step S3, the preset rule is to extract one valid frame every one frame interval; preprocessing includes cropping the video.

Citation Information

Patent Citations

  • Sow estrus behavior identification method and system based on multi-modal feature fusion

    CN119513697A

  • Intelligent live pig behavior recognition system and method based on multi-modal data fusion

    CN119672800A

  • Pig behavior identification method based on feature point detection

    CN119693996A

  • Live pig behavior intelligent sensing method and system based on machine vision

    CN120375461A

  • Video action segmentation by mixed temporal domain adaption

    US20210174093A1