A sow uterine contraction behavior recognition method based on machine vision
By improving the SLP3D model and using lightweight processing technology, the problems of insufficient generalization ability and high computational cost in the recognition of sow uterine contraction behavior have been solved, achieving efficient recognition and low resource requirements in actual production environments, thereby improving breeding efficiency and economic benefits.
Patent Information
- Application Number
- CN202511373532.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-09-25
AI Technical Summary
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.
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.
While ensuring the accuracy of uterine contraction behavior recognition, it significantly reduces computational overhead and equipment requirements, making it suitable for actual production environments with limited computing resources and improving breeding efficiency and economic benefits.
Smart Images

Figure CN120877386B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to a sow uterine contraction behavior recognition method based on machine vision. BACKGROUND
[0002] The change of the frequency of sow uterine contraction behavior is an important physiological indicator for judging the approach of parturition, and accurately grasping the delivery opportunity is of great significance for ensuring sow health, prolonging the reproductive cycle, improving the survival rate of newborn piglets, optimizing piglet quality, improving breeding production efficiency, and reducing management costs. With the increase of breeding scale, the care of sows in labor (such as health status, monitoring of parturition state, etc.) requires a large amount of human resources, and the use of cameras combined with machine vision technology for automatic detection of sow uterine contraction behavior can reduce the burden of frontline breeders, and also monitor the health status of sows, predict the time of delivery, etc.
[0003] At present, the behavior recognition methods of the prior art are mostly applied to human behavior analysis, although they have high recognition accuracy, but they have problems such as insufficient generalization ability and high computational cost in the breeding scene, and are difficult to be directly applied to the actual production environment, which is specifically manifested as follows: (1) insufficient generalization ability: that is, the application of the current behavior recognition algorithm can realize action recognition by only a single picture in the action (such as standing, eating) for some actions with weak time correlation (such as standing, eating), and the accuracy is high, which can be verified on animals; but for actions with strong time correlation, usually some fine-grained actions (such as uterine contraction), it is impossible to judge by a single picture, and it is necessary to rely on the information of the previous and subsequent frames to make a judgment; for these behaviors with strong correlation, the accuracy will decrease during the recognition process, and the network needs to be improved to adapt to specific actions, and the adaptability to the environment is low. (2) High computational cost: for the actual production environment, the accuracy and the size of the computing resources are equally important, and the behavior recognition algorithm in the prior art often ignores the computational amount and pays too much attention to the improvement of the accuracy, which will result in a large requirement for the performance of the equipment in actual application, greatly increasing the breeding cost and failing to meet the demand of agricultural breeding. SUMMARY
[0004] In view of the problems existing in the prior art, the purpose of the present application is to provide a sow uterine contraction behavior recognition method based on machine vision, which can automatically recognize sow uterine contraction behavior, facilitate the frontline breeders to monitor the state of sows in labor, reduce the death of sows in labor and newborn piglets, and improve the economic benefit of breeding enterprises; at the same time, the method balances the accuracy of uterine contraction behavior recognition and the complexity of the model, and improves the practicability of the model.
[0005] The purpose of the present application is achieved by the following technical solutions:
[0006] A sow uterine contraction behavior recognition method based on machine vision, comprising:
[0007] Step S1, data acquisition: by installing a high-definition network camera in the breeding room, the real-time capture of the activity picture of a single sow is realized, and the behavior dynamics of the sow are accurately focused;
[0008] Step S2, data transmission: the camera transmits the collected real-time monitoring video stream to the backend server through the local area network in the delivery room;
[0009] Step S3, model inference and processing: the SLP3D model deployed in the backend server and pre-trained and optimized accepts real-time video, extracts frames according to the preset rules, and pre-processes the extracted video frames; then, the SLP3D model captures the spatiotemporal dynamic characteristics of sow behavior, accurately identifies the feature mode related to "uterine contraction behavior";
[0010] Step S4, behavior detection and output: the SLP3D model outputs the information obtained from the previous frame and the current frame through inference calculation, judges the "uterine contraction behavior confidence" corresponding to the current frame, and when the confidence exceeds the preset threshold, determines that the sow uterine contraction behavior is monitored in real time, generates a warning prompt on the server's monitoring terminal in real time, and records the corresponding information.
[0011] Based on the further optimization of the above scheme, the high-definition network camera in step S1 has low-light adaptability and continuous recording function, which can capture the complete activity picture of a single sow individual (including body posture, limb movement, abdominal change and other details) in real time; the camera is installed at the key monitoring position of the breeding room (such as the upper part of the sow limiting fence).
[0012] Based on the further optimization of the above scheme, the local area network in the delivery room in step S2 adopts 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 in the transmission process.
[0013] Based on the further optimization of the above scheme, the network architecture of the SLP3D model includes a backbone network, a neck network and a head network; wherein the backbone network is used for feature extraction of the input video, and the features are mapped to a high-dimensional space to facilitate classification by the head network; the neck network is used for fusion of multi-scale features to ensure that the network can obtain multi-scale information flow and realize recognition of uterine contraction behaviors of different intensities; the head network is used for classification of the fused features and obtaining the behavior mode of the detected sow (such as whether to contract);
[0014] Meanwhile, the SLP3D model is improved based on the C3D network, a lightweight spatial-channel attention module LSCA (Lightweight Spatial-Channel Attention) is embedded in the CoLs convolution to enhance the model's attention to key areas, a partial bidirectional feature pyramid network PBFPN (Partial Bidirectional Feature Pyramid Network) is set in the neck network to improve the recognition ability of different intensity uterine contraction behaviors, and a Swish activation function is combined to realize the targeted improvement of the model.
[0015] Based on the further optimization of the above scheme, the lightweight spatial-channel attention module LSCA adopts a double-branch structure: the upper branch is a spatial attention mechanism for capturing the importance of spatial positions in the feature map; the lower branch is a channel attention mechanism for strengthening the feature information of key channels; after the upper and lower branches generate corresponding attention weights, they are respectively weighted and fused with the original feature map, and finally the two parts of the results are integrated through an adaptive feature fusion strategy, effectively improving the network's ability to capture important features and overall expression performance, specifically as follows:
[0016] ;
[0017] In the formula: represents an energy function for generating 3D spatial attention weights; represents a one-dimensional convolution of an adaptive convolution kernel; represents global average sampling; represents a learnable fusion weight; represents an operation that converts five-dimensional data into four-dimensional data (can be realized by introducing an existing function); represents an input feature map; at the same time, a learnable parameter is introduced at the feature fusion stage to construct an adaptive weight fusion paradigm, so that the model can dynamically adjust the feature interaction mode of the spatial and channel dimensions; this design significantly improves the model's representation ability of complex spatial context and channel semantic information, providing a new solution for efficient feature extraction.
[0018] Among them, the energy function for generating 3D spatial attention weights is specifically as follows:
[0019] ;
[0020] In the formula: represents a pixel point, represents a channel, and represents a spatial position; , denotes the mean and variance of the entire input; denotes a bias term, is a coefficient for further embodying the directionality of the neuron activation value (i.e., the different influences of positive and negative activations);
[0021] The adaptive convolution kernel in channel attention is:
[0022]
[0023] In the formula: denotes the number of channels of the input feature; denotes a bias term; denotes a scaling factor; denotes a floor operation.
[0024] Based on further optimization of the above scheme, the partial bidirectional spatial pyramid feature fusion module PBFPN adopts a three-layer bidirectional structure, including a feature map input part, an up-sampling module part and a down-sampling module part, the feature map input part is responsible for receiving original features and completing basic representation, the up-sampling part improves the feature resolution by interpolation to capture fine-grained information, and the down-sampling part reduces the dimension by convolution to strengthen global feature extraction; while constructing a multi-scale information flow, the module introduces a residual structure, directly transmits the input features through a shortcut connection, effectively makes up for the possible loss of detailed information in the feature extraction process, and guarantees the integrity of the features.
[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 1 frame of effective frame every interval of 1 frame; the preprocessing includes cropping the video.
[0028] The following are the technical effects possessed by the scheme of the application:
[0029] The improved SLP3D model is used to process the real-time collected video frames, i.e., the lightweight spatial channel attention module LSCA and the partial bidirectional spatial pyramid feature fusion module PBFPN, and the Swish activation function is combined, and finally the SLP3D network for recognizing the uterine contraction behavior of sows is obtained, which not only effectively balances the expression ability and training stability of the model, but also introduces learnable parameters in the feature fusion stage, so that the model can autonomously optimize the fusion mode of spatial weights and channel weights, and further enhance the expression ability of the model to complex feature relationships; in addition, it also effectively alleviates the information loss in the convolution and up-sampling process, significantly reduces the computational overhead, and further balances the performance and efficiency.
[0030] The method balances the accuracy of uterine contraction behavior recognition and the complexity of the model, so that the model can ensure accurate recognition of uterine contraction behavior while maintaining a high FPS (Frames Per Second), and has a low FLOPs (Floating-Point Operations) and Parameters (number of parameters), so that the requirement of the model for the deployment device is reduced, and the intelligent breeding of sows is realized, which is beneficial to the supervision of the state of sows by the breeding personnel. BRIEF DESCRIPTION OF DRAWINGS
[0031] Figure 1 It is the architecture diagram of SLP3D network in the embodiment of the application; wherein, That is, partial convolution, a new type of convolution structure, is used to reduce the calculation of redundant features and improve efficiency; P1-P5 refers to feature maps of different sizes, such as: P1 refers to (56x56) size, P2 refers to (28x28) size; Upsample refers to up sampling;
[0032] Figure 2 It is the structure diagram of the lightweight spatial channel attention module LSCA in the embodiment of the application, wherein X refers to a feature map; H, W and C respectively refer to the length, width and channel number of the feature map;
[0033] Figure 3 It is the structure diagram of the partial bidirectional spatial pyramid feature fusion module PBFPN in the embodiment of the application, wherein P5, P6 and P7 refer to feature maps of different sizes;
[0034] Figure 4 It is the channel feature map in the embodiment of the application;
[0035] Figure 5 It is the curve diagram of the Swish activation function in different value in the embodiment of the application;
[0036] Figure 6 It is a comparison diagram of the Swish activation function and the ReLU activation function in the embodiment of the application;
[0037] Figure 7 It is a contrast diagram of the original frame and the corresponding cropped frame of the uterine contraction and normal walking behavior of sows in the embodiment of the application;
[0038] Figure 8 It is a heat map in the embodiment of the application. DETAILED DESCRIPTION
[0039] With reference to the drawings of the embodiments of the present application, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application.
[0040] Embodiment 1
[0041] A sow uterine contraction behavior recognition method based on machine vision, comprising:
[0042] Step S1, data acquisition: by installing a high-definition network camera in the breeding house, the camera is installed at the key monitoring position of the breeding house (such as directly above the sow limiting fence), realizing real-time capture of the activity picture of a single sow, and accurately focusing on the behavior dynamics of the sow; the high-definition network camera has low-light adaptability and continuous recording function, and can capture the complete activity picture of a single sow individual (including body posture, limb movement, abdominal change and other details).
[0043] Step S2, data transmission: the camera transmits the collected real-time monitoring video stream to the backend server through the local area network in the delivery room; wherein the local area network adopts 5G / 4G wireless network, the collected real-time monitoring video stream is processed at a frame rate of 15-25fps, and a lightweight data compression protocol (such as H.264 / H.265) is adopted in the transmission process to avoid delay caused by high network bandwidth occupation, and to ensure that the delay of video stream from collection to server reception is controlled within 1-3s.
[0044] Step S3, model inference and processing: the SLP3D model deployed in the backend server and pre-trained and optimized receives real-time video, extracts frames according to the preset rules (i.e. extracts 1 frame of effective frame every interval), and pre-processes the extracted video frames (such as cropping video); then, the SLP3D model captures the spatiotemporal dynamic characteristics of sow behavior (not only analyzes the static posture of single frame picture, but also combines the action change of continuous frames, such as the time sequence difference of abdominal fluctuation frequency and body curling amplitude), accurately identifies the feature mode related to “uterine contraction behavior” (such as the typical features of sow arching back, abdominal tension, limbs curling and keeping relatively static during uterine contraction);
[0045] As shown in Figure 1 : the network architecture of the SLP3D model includes a backbone network, a neck network and a head network; wherein the backbone network is used for feature extraction of the input video, and maps the features to a high-dimensional space, which is convenient for the head network to classify; the neck network is used for fusion of multi-scale features, which ensures that the network can obtain multi-scale information flow and realize recognition of uterine contraction behaviors of different intensities; the head network is used for classification of the fused features and obtaining the behavior mode of the detected sow (for example: whether to contract the uterus).
[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 with an 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. It refers to the preceding operate; 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 In the interval of <0, the output value is not 0, but is gradually approaching 0; this feature enables the negative gradient to effectively participate in the optimization of model parameters during the training process, avoiding the loss of gradient information. At the same time, the Swish function as a whole has continuous differentiability, naturally avoiding the non-differentiable problem of the ReLU function at =0, providing a guarantee for the stability of model training and the smoothness of gradient transmission.
[0068] The data set for SLP3D training relies on the indoor monitoring system of the experimental pig farm. This system covers different lighting conditions such as daytime and nighttime to ensure the wide applicability of the data and improve the accuracy and reliability of the experimental results. The monitoring system uses the Hikvision DS-2CD3146FWD-IS model hemisphere camera. The camera is installed in an overhead manner directly above the pigpen, with an installation height in the optimal shooting interval of 2 to 2.5 meters, thereby obtaining a clear and comprehensive observation angle. In the data labeling process, to ensure data quality and provide a solid foundation for subsequent model training and analysis, all images are set to a high resolution of 2560x1440 pixels. In the model training stage, to reduce the influence of environmental interference factors on model training and improve training efficiency, preprocessing operations are performed on the original video frames. Specifically, the center cropping technique is used to retain the sow individual image in the central region of the video frame, thereby highlighting the key target and reducing the interference of redundant information on model training, as shown in Figure 7 .
[0069] In this embodiment, a video data set containing 32 sows is constructed, covering 2073 short video segments with a duration of 3 to 15 seconds. According to the behavior state, these samples are divided into two categories: contraction state and normal state (including walking, lying, and other non-contraction behaviors). To alleviate the performance deviation of the model caused by class imbalance during training, data filtering and resampling strategies are used to make the proportion of two classes close to 1:1 in the overall data set. The data set is divided into training set, validation set, and test set according to the ratio of 8:1:1 to ensure the scientificity and stability of model evaluation. The resolution of the cropped video becomes (678, 1080), and the video frame rate is changed from the original 30 frames per second to 20 frames per second. In the pig breeding scene (as shown in Figure 7 , the upper half is in the contraction state, and the left image is the original frame and the right image is the cropped frame; the lower half is in the normal walking state, and the left image is the original frame and the right image is the cropped frame), sows are in a lying state with occasional turning movements 2-3 days before delivery, and their abdomens are continuously exposed to the field of view of the overhead camera. Since contraction behavior recognition needs to capture the dynamic changes of the abdomen, the video data collected by the overhead camera in the delivery 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] The confidence level is calculated as follows:
[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] In the formula: K H , K W Indicates the height, width of the convolution kernel; , Indicates the number of input channels, the number of output channels;
[0085] FPS:
[0086] ;
[0087] In the formula: Indicates the number of frames co-processed; Indicates the time spent by the processing Frame, unit second;
[0088] In order to verify the performance of the model more comprehensively, this embodiment selects a variety of classic and representative behavior recognition algorithms, and carries out comparative experiments on the contraction behavior data set, and the results are shown in Table 1:
[0089]
[0090] Table 1. Comparison of recognition algorithms
[0091] All the models above use pre-trained weights for training. The LRCN (Long-term Recurrent Convolutional Networks, proposed by Jeff Donahue et al. in the 2015 paper), C3D (Convolutional 3D Network, proposed by Du Tran et al. in the 2015 paper "Learning Spatiotemporal Features with 3D Convolutional Networks"), TSN (Temporal Segment Network, proposed by Limin Wang et al. in the 2016 paper "Temporal Segment Networks: Towards Good Practices for Deep Action Recognition"), I3D (Inflated 3D Network, proposed by Joao Carreira and Andrew Zisserman in the 2017 paper "Quo Vadis, Action Recognition? A New Model and the Kinetics Dataset"), SlowFast (SlowFast Networks, proposed by Christoph Feichtenhofer et al. in the 2019 paper "SlowFast Networks for Video Recognition"), VideoSwin (Video SwinTransformer, extended from the 2021 paper "Swin Transformer: Hierarchical Vision Transformer using Shifted Windows" by Ze Liu et al. and applied to video tasks 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"), and our SLP3D all use the same data augmentation method, which is random cropping and random horizontal flipping.Video-FocalNets (Video FocalModulation Network, promoted to the video field based on the paper "FocalNet: FocalModulation for Visual Recognition" by Jianwei Yang et al. in 2023, proposes a FocalNet architecture for video modeling) and TC-CLIP (Temporal Contrastive CLIP, proposed by Mengmeng Wang et al. in the paper "TC-CLIP: Temporal Contrastive Learning for Video-Text Alignment" in 2024, for video-text contrastive learning) use color enhancement, grayscale perturbation, and MixUp (linearly mix two images and corresponding labels), and TC-CLIP adds CutMix (replace a random region of one image with the corresponding region of another image, and weight the labels according to the area ratio) data augmentation.
[0092] From the above table, it can be seen that the model in this embodiment achieves the highest average classification accuracy (MCA) of 96.40%, with a computational complexity of only 38.783G FLOPs, a parameter amount of 102M, and a real-time inference speed of 65.66 FPS; this performance takes into account the accuracy and computational efficiency of the model, meeting the real-time requirements in actual production environments. At the same time, the model proposed in this embodiment has the best overall performance.
[0093] In order to more deeply analyze the specific contribution of each module we proposed to the overall network performance, we designed and implemented a series of systematic ablation experiments; in each experiment, we only introduced or removed a certain improvement module, keeping other structures and hyperparameters unchanged, in order to evaluate the independent influence of the module on the overall performance. These experiments not only verify the effectiveness of each component, but also reveal their differences in different evaluation indicators (such as classification accuracy, parameter amount, computational overhead, inference speed, etc.). In addition, by gradually stacking modules, we further analyzed the synergistic effect between multiple modules. The experimental results are shown in Table 2:
[0094]
[0095] Table 2. Comparison of module synergistic effects
[0096] From the above table, it can be seen that each module improves the model performance while maintaining high computational efficiency and good parameter controllability, verifying the rationality and practicality of the overall architecture design. Finally, the model in this embodiment achieves an MCA of 96.40%, an FLOPs of 38.783G, a Params of 102M, and an FPS of 65.66, meeting the needs of the production environment.
[0097] To more intuitively show the differences between the baseline model and the improved model in this embodiment, we designed a visualization experiment for comparative analysis. As shown in Figure 8 The original image (first row), the heat map generated by the C3D baseline model (second row), and the heat map generated by the improved model in this embodiment (third row) are shown. From the visualization results, it can be observed that the C3D model has a scattered focus area when processing images, making it difficult to focus on the key parts related to sow labor behavior (such as the abdominal region), and even misfocusing attention on the head region in some samples. However, the model in this embodiment can more accurately focus on the sow abdominal region, even in complex environments such as occlusion by limit bars or strong light interference, and still shows strong robustness. The improvement in the focus area of the model helps to improve the discrimination ability of labor behavior, which explains the performance improvement in accuracy.
[0098] Embodiment 2:
[0099] As another preferred embodiment of the present application, based on the scheme of embodiment 1, after the SLP3D model continuously outputs sow labor behavior detection data (such as labor occurrence time, frequency, and duration), the breeder can carry out fine management based on the change rule of these data: by monitoring the dynamic trend of labor frequency in real time, when the labor frequency rises to a preset threshold (for example, the number of labors per unit time reaches 10-15 times, which can be adjusted according to the sow breed and gestation stage), it can be judged that the sow is about to enter the delivery stage, and then the delivery room preparation work is started in advance, including debugging the delivery equipment (such as heat lamps, delivery tool disinfection), preparing new piglet care materials (such as heat pads, colostrum supplements), arranging personnel on duty, etc.
[0100] Embodiment 3:
[0101] A sow labor behavior recognition system includes the improved SLP3D model in embodiment 1, a high-definition camera, and a storage. The improved SLP3D model can be loaded on a NVIDIA L40 GPU hardware platform, and the storage is used to store the results output by the SLP3D model.
[0102] The preferred embodiments of the present application have been described. It is to be understood that the application is not limited to the specific embodiments described above, in which steps and methods not described in detail are to be understood as being carried out in an ordinary way in the art; any person skilled in the art, without departing from the scope of the technical solutions of the present application, can make many possible changes and modifications to the technical solutions of the present application disclosed above, or modify them into equivalent embodiments of equivalent changes, which do not affect the essential content of the present application. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present application, without departing from the content of the technical solutions of the present application, still belongs to the scope of protection of the technical solutions of the present application.
Claims
1. A sow labor behavior recognition method based on machine vision, characterized by Comprise: Step S1, data collection: by installing a high-definition network camera in the breeding house, the real-time capture of the activity picture of a single sow is realized, and the behavior dynamics of the bullet sow are accurately focused; Step S2, data transmission: the camera transmits the collected real-time monitoring video stream to the backend server through the local area network in the delivery room; Step S3, model inference and processing: the SLP3D model deployed in the backend server and pre-trained and optimized accepts real-time video, extracts frames according to the preset rules, and pre-processes the extracted video frames; then, the SLP3D model captures the spatiotemporal dynamic characteristics of the sow behavior, accurately identifies the feature mode related to "contraction behavior"; the network architecture of the SLP3D model includes a backbone network, a neck network and a head network; wherein the backbone network is used for feature extraction of the input video and mapping the features to a high-dimensional space to facilitate classification by the head network; the neck network is used for fusing multi-scale features to ensure that the network can obtain multi-scale information flow and identify contraction behaviors of different intensities; the head network is used for classifying the fused features and obtaining the behavior pattern of the detected sow; At the same time, the SLP3D model is improved based on the C3D network, by embedding the lightweight spatial channel attention module LSCA (Lightweight Spatial-Channel Attention) into the CoLs convolution to enhance the model's attention to key areas, setting part of the bidirectional spatial pyramid feature fusion module PBFPN in the neck network to improve the recognition ability of different intensity contraction behaviors, and combining with the Swish activation function to realize the targeted improvement of the model; The lightweight spatial channel attention module LSCA adopts a double-branch structure: the upper branch is a spatial attention mechanism for capturing the importance of spatial positions in the feature map; the lower branch is a channel attention mechanism for enhancing the feature information of key channels; after the upper and lower branches generate corresponding attention weights, they are respectively weighted and fused with the original feature map, and finally the two parts of the results are integrated through an adaptive feature fusion strategy, which is: ; In the formula: represents an energy function for generating 3D spatial attention weights; represents one-dimensional convolution of an adaptive convolution kernel; represents global average sampling; represents a learnable fusion weight; represents an operation, which functions to convert five-dimensional data into four-dimensional data; represents an input feature map; Wherein, the energy function for generating 3D spatial attention weights is: ; wherein: represents a pixel point, represents a channel, and represents a spatial position; , represents the mean and variance of the entire input; represents a bias term, is a coefficient for further embodying the directionality of the neuron activation value; The adaptive convolution kernel in the channel attention is: ; wherein: C represents the number of channels of input features; b represents a bias term; represents a scaling factor; represents a floor function; Step S4, behavior detection and output: the SLP3D model outputs the information obtained from the previous frame and the current frame through inference calculation, judges the "contraction behavior confidence" corresponding to the current frame, and when the confidence exceeds the preset threshold, determines that the sow contraction behavior is monitored in real time, generates a warning prompt in the server's monitoring terminal in real time, and records the corresponding information.
2. The sow labor behavior recognition method based on machine vision according to claim 1, characterized in that: The high-definition network camera in step S1 has low-light adaptability and continuous recording function, and can capture the complete activity picture of a single sow in real time; The camera is installed at the key monitoring position of the breeding house.
3. The sow labor behavior recognition method based on machine vision according to claim 1, characterized in that: In step S2, the local area network in the delivery room uses 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 in the transmission process.
4. The sow labor behavior recognition method based on machine vision according to claim 1, characterized in that: The partial bidirectional spatial pyramid feature fusion module PBFPN adopts a three-layer bidirectional structure, including a feature map input part, an up-sampling module part and a down-sampling module part, the feature map input part is responsible for receiving original features and completing basic representation, the up-sampling part improves the feature resolution through interpolation to capture fine-grained information, and the down-sampling part reduces the dimension by convolution to strengthen global feature extraction; the module introduces a residual structure while constructing a multi-scale information flow, and directly transmits the input features through a shortcut connection.
5. The sow labor behavior recognition method based on machine vision according to claim 1, characterized in that: The Swish activation function is: ; where: a hyperparameter of the Swish activation function, refers to the preceding operation, i.e. the denominator of the function exponent of the function, which controls the shape of the function and thus influences the non-linear expressivity and training dynamics of the neural network.
6. The sow labor behavior recognition method based on machine vision according to claim 1, characterized in that: The preset rule in the step S3 is to extract 1 frame of valid frame every interval of 1 frame; the 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