Intelligent pig house management system and method
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-15
- Publication Date
- 2026-08-11
AI Technical Summary
[0002]从智慧生猪饲喂的技术发展现状来看,现有相关智能监测系统仍存在功能割裂、数据融合不充分等突出问题,难以满足精准饲喂与生长预测的全流程需求
[0050] This invention utilizes environmental monitoring, weight detection, feeding monitoring, and video surveillance modules to achieve multi-dimensional monitoring and integration of various data related to pigs. Based on the monitoring data, an improved YOLO11s-MGS deep learning model is used to identify pig behavior and feeding status, providing a reliable behavioral basis for subsequent feeding strategy development. Simultaneously, based on the monitoring data, an EVO-LSTM-MLP hybrid residual prediction model is used to predict residual weight, thereby calculating the predicted weight of the pig and automatically generating a personalized and precise feeding strategy. This invention achieves real-time detection of pig feeding, real-time prediction of weight, and real-time adjustment of feeding strategies to meet actual needs, establishing an intelligent feeding system and promoting the sustainable development of the pig farming industry.
Smart Images

Figure CN122536508A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent feeding system design, and particularly relates to an intelligent pigsty management system and method. Background Technology
[0002] From the perspective of the current state of technological development in intelligent pig feeding, existing intelligent monitoring systems still suffer from prominent problems such as functional fragmentation and insufficient data integration, making it difficult to meet the full-process requirements of precise feeding and growth prediction. Existing technology 1 (CN119516575A) discloses a pig body temperature detection system based on visible light and infrared thermal imaging video. Its core technology involves a main control module coordinating multiple modules such as identity recognition and temperature detection. It uses the YOLOv7-tiny algorithm for pig identification, combines it with the FOTS text recognition algorithm to parse the pig's code, and simultaneously retrieves infrared thermal imaging video to match the corresponding temperature data. Its innovation lies in achieving rapid detection and high-temperature early warning of large-scale pig body temperature, effectively reducing the cost of manual monitoring. However, the core limitation of this system is its single function, focusing only on the single scenario of pig body temperature monitoring. It does not involve the collection of key feeding data such as feeding status, feeding time, and feed intake during the pig feeding process, nor can it correlate these feeding-related data with weight data for analysis, making it difficult to support dynamic optimization of feeding programs.
[0003] Existing technology 2 (CN119919242A) discloses a method, system, device, and storage medium for intelligent weight monitoring of farmed pigs. Its core is to acquire raw data of pigs through multi-angle image acquisition, and after preprocessing such as adaptive histogram equalization and Gaussian filtering, extract the outline-skeleton features and curvature parameters of pigs. Combined with multi-source fusion of IoT data, a weight prediction model is constructed using a hierarchical-incremental prediction model and an attention mechanism. Its innovation lies in overcoming the pain points of traditional weight monitoring relying on manual labor and low efficiency, and realizing intelligent weight assessment. However, the system has obvious technical defects. It does not incorporate the feeding characteristics of pigs during the feeding process as key weight data into the growth curve and weight prediction model. It only relies on image feature parameters for prediction, resulting in insufficient adaptability of the model to the growth status of pigs. The prediction accuracy is difficult to meet the actual needs of precise feeding. At the same time, it does not design a dedicated sensing and monitoring device for the feeding scenario, and cannot realize real-time capture and data feedback of the feeding status.
[0004] The aforementioned existing technologies are either limited to a single monitoring dimension or lack effective integration and application of core feeding data, making it impossible to form a closed loop in the identification of growth status, construction of growth curves, and prediction of weight during the pig feeding process. This makes it difficult to dynamically adjust feeding strategies based on individual growth differences. Therefore, there is an urgent need for a smart feeding system that can accurately capture feeding traits and integrate multi-dimensional data to model and solve the functional shortcomings and application limitations of existing systems. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides an intelligent pigsty management system and method that enables multi-dimensional data monitoring and integration of pigs, identifies pig behavior status and predicts weight based on monitoring data, and then dynamically adjusts feeding strategies.
[0006] The present invention achieves the above-mentioned technical objectives by adopting the following technical solution:
[0007] An intelligent pigsty management system includes an environmental monitoring module, a weight detection module, a feed monitoring module, a video monitoring module, a wireless transmission module, a data processing module, an identity recognition module, a core control module, and an Internet of Things platform;
[0008] The environmental monitoring module collects key environmental parameters affecting pig growth in the pigsty in real time and transmits them to the data processing module. This includes temperature and humidity sensors, ammonia sensors, and carbon dioxide sensors. The weight detection module detects pig weight data and transmits it to the data processing module. This includes multiple weighing sensors. The feeding monitoring module detects feed weight in the trough while feeding the pigs and transmits it to the data processing module. This includes automatic feed troughs, feeding motors, and feed weight monitoring sensors. The video monitoring module collects pig image data and transmits it to the data processing module. This includes multiple depth cameras. The identification module uses RFID ear tags for identification, which, combined with machine vision matching in the data processing module, forms a dual verification method.
[0009] The data processing module is based on the improved YOLO11s-MGS deep learning model and the EVO-LSTM-MLP hybrid residual prediction model to realize pig behavior recognition and weight prediction. The IoT platform receives various monitoring data and the processing results data transmitted by the data processing module, determines the growth status of pigs, specifies feeding strategies, and controls each execution component to execute feeding instructions through the core control module.
[0010] An intelligent pigsty management method utilizing the aforementioned intelligent pigsty management system includes the following steps:
[0011] Step 1: The environmental monitoring module, weight detection module, feed monitoring module, video monitoring module, and identity recognition module are started simultaneously to achieve parallel collection of multi-source data from pig farming; the collected multi-source data is uniformly uploaded to the IoT platform and data processing module through the wireless transmission module;
[0012] Step 2: The data processing module preprocesses the collected multi-source heterogeneous data;
[0013] Step 3: The data processing module uses an internally built improved YOLO11s-MGS deep learning model to identify pig behavior and feeding status, and uploads the identification results to the IoT platform via a wireless transmission module. The improved YOLO11s-MGS deep learning model is based on the original YOLO11s. The backbone network introduces a lightweight Maple multi-branch feature extraction module to enhance the ability to capture local pose and multi-scale features. The neck network uses a lightweight GSConv fusion module to reduce the amount of computation and enhance the interaction of channel information. The detection head adds a SimAM parameterless attention mechanism to suppress background interference and highlight the main features of the pig.
[0014] Step 4: The data processing module first constructs the standard growth curve of the pig population, calculates the residual weight, performs correlation analysis based on the residual weight and the preprocessed multi-source data, and determines the model input feature vector; then, it obtains the predicted residual weight based on the internally constructed EVO-LSTM-MLP hybrid residual prediction model, and then calculates the predicted weight of the pigs, and synchronously uploads the predicted residual weight and the predicted weight of the pigs to the IoT platform.
[0015] Step 5: The IoT platform determines the growth status of pigs and formulates feeding strategies based on preset deviation thresholds; the core control module controls each execution component to execute feeding instructions.
[0016] Furthermore, in step 3, the Maple lightweight multi-branch feature extraction module replaces the traditional C3k2 module in the backbone network. It integrates the multi-scale perception mechanism of hollow spatial pyramid pooling, the depth-separable convolution strategy of MobileNet, and the channel rearrangement idea of ShuffleNet. Through parallel topology, it achieves adaptive fusion of multiple receptive field features in a single layer, reducing the number of parameters and computational overhead.
[0017] Specifically, the input feature map is set as The expected number of output channels is The number of intermediate channels is The forward propagation process of Maple's lightweight multi-branch feature extraction module is as follows:
[0018] First, channel compression is performed through the main artery:
[0019] ,
[0020] Secondly, the depthwise convolution operation of the two lobes is performed in parallel, corresponding to the local and expanded receptive fields respectively:
[0021]
[0022] Subsequently, the main pulse output and the two-lobed output are spliced together along the channel dimension, and the channels are rearranged to promote information fusion:
[0023]
[0024] Finally, through Convolutional features are fused and mapped to the output dimension:
[0025]
[0026] Among them, the number of intermediate channels Set as:
[0027]
[0028] In the formula, This represents depthwise separable convolution. This represents a parameterless channel rearrangement operator; Indicates the execution expansion rate of Depthwise separable convolution, Indicates the execution expansion rate of Depthwise separable convolution; Representing the characteristic tensor space, Indicates the number of input feature channels. Indicates the height of the input feature map. Indicates the width of the input feature map. This represents the compressed feature map output by the 1×1 convolution of the main pulse. This represents a 1×1 point convolution. This represents the output feature of a depthwise convolution branch with an inflation rate of 1. This represents the output features of a depthwise convolution branch with an inflation rate of 2. This indicates a feature concatenation operation. This represents the intermediate feature map after concatenating the three feature paths. This represents the feature map after channel rearrangement. This indicates that the module ultimately outputs a feature map. This indicates a round-down operation.
[0029] Furthermore, in step 4, the residual weight calculation process is as follows:
[0030] First, the standard growth curves for the pig population are constructed using the Gompertz mathematical model:
[0031]
[0032] In the formula: Indicates the age of pigs in days Reference weight at that time Indicates weight approaching maturity. Indicates position parameters, This represents the growth rate parameter. Indicates the age of pigs in the fattening stage;
[0033] The traditional nonlinear least squares method is used for parameter fitting, with the optimization objective being to minimize the sum of squared residuals between the predicted and actual values to obtain the fitted values. ;
[0034] The final standard growth curve for the pig herd is as follows:
[0035]
[0036] residual weight as follows:
[0037]
[0038] in: The actual weight of a single pig measured on the same day.
[0039] Further, in step 4, the model input feature vector Xt is: Xt=[Wt,FIt,NH3,CO2,Hum,ΔWt]; Wt represents body weight, FIt represents feed amount, NH3 represents ammonia concentration, CO2 represents carbon dioxide concentration, Hum represents ambient humidity, and ΔWt represents daily body weight difference.
[0040] Furthermore, in step 4, the EVO-LSTM-MLP hybrid residual prediction model uses an LSTM network as the backbone structure for temporal feature extraction. Relying on the unique gating mechanism of LSTM, it mines the long-term temporal dependence between pig growth characteristics and environmental characteristics, fully extracting the implicit effects of historical growth patterns and environmental changes. At the same time, a two-layer MLP regression head is introduced at the LSTM feature output end to replace the traditional single-layer fully connected output structure. The first fully connected layer with a nonlinear activation function completes the nonlinear transformation and spatial mapping of high-dimensional temporal features, enhancing the expressive power and discriminative power of the features. Then, the second linear fully connected layer completes feature dimensionality reduction and result output. Without significantly increasing the computational complexity, the model's ability to approximate complex residual distributions and individual growth deviation patterns is improved.
[0041] Furthermore, in step 4, the predicted weight of the pig is as follows:
[0042]
[0043] In the formula: Indicates age in days The final predicted weight; This indicates the predicted residual weight.
[0044] Furthermore, in step 5, the growth status of the pigs is determined as follows:
[0045] Low growth: ;
[0046] Even growth: ;
[0047] Growth is above average: ;
[0048] in, To set a preset deviation threshold, To predict residual body weight.
[0049] The present invention has the following beneficial effects:
[0050] This invention utilizes environmental monitoring, weight detection, feeding monitoring, and video surveillance modules to achieve multi-dimensional monitoring and integration of various data related to pigs. Based on the monitoring data, an improved YOLO11s-MGS deep learning model is used to identify pig behavior and feeding status, providing a reliable behavioral basis for subsequent feeding strategy development. Simultaneously, based on the monitoring data, an EVO-LSTM-MLP hybrid residual prediction model is used to predict residual weight, thereby calculating the predicted weight of the pig and automatically generating a personalized and precise feeding strategy. This invention achieves real-time detection of pig feeding, real-time prediction of weight, and real-time adjustment of feeding strategies to meet actual needs, establishing an intelligent feeding system and promoting the sustainable development of the pig farming industry. Attached Figure Description
[0051] Figure 1 This is a flowchart of the intelligent pigsty management method described in this invention;
[0052] Figure 2 This is a schematic diagram of the EVO-LSTM-MLP hybrid residual prediction model described in this invention. Detailed Implementation
[0053] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, but the scope of protection of the present invention is not limited thereto.
[0054] The intelligent pigsty management system of this invention includes an environmental monitoring module, a weight detection module, a feed monitoring module, a video monitoring module, a wireless transmission module, a data processing module, an identification module, a core control module, and an Internet of Things platform. These modules work collaboratively to achieve intelligent and precise management of pig farming. Specific functions and configurations are as follows:
[0055] The environmental monitoring module is used to collect key environmental parameters affecting pig growth in the pigsty in real time, including temperature and humidity sensors, ammonia sensors, and carbon dioxide sensors. The temperature and humidity sensors have a temperature detection accuracy of ±0.3℃ and a humidity detection accuracy of ±3%RH. The ammonia sensor has a range of 0~500ppm, and the carbon dioxide sensor has a range of 0~2000ppm. All sensors use the RS485 communication protocol and are uniformly connected to the data processing module to realize real-time and stable acquisition and transmission of environmental data.
[0056] The feeding monitoring module includes an automatic feed trough, a feeding motor, and a feed weight monitoring sensor. The feed weight monitoring sensor has a range of 0~60kg and a weighing accuracy of ±1g. It can monitor the remaining feed in the feed trough in real time and accurately calculate the actual feed intake of pigs. The feeding motor, together with the core control module, realizes automatic feeding and precise feeding.
[0057] The video monitoring module is equipped with multiple depth cameras, adopting a top-down, multi-camera layout to achieve full coverage of pig behavior data collection. The cameras used are Ansijiang Nuwa-HP60C real-sensing depth cameras, which can simultaneously output RGB images and depth images, support 1920×1080@30fps resolution, and have a working distance of 0.2~4m. They can adapt to complex environments such as low light, dust, and obstruction in pig houses, and can collect real-time images of five types of pig behaviors: eating, drinking, standing, lying down, and sleeping, providing a high-quality data source for behavior recognition models.
[0058] The weight detection module uses a high-precision weighbridge with weighing sensors evenly distributed at the bottom. It has a maximum weighing capacity of 200kg and a weighing accuracy of ±1g, enabling stable weighing of fattening pigs throughout their entire lifecycle. Weight data is collected through the SJ-101D_X digital weighing transmitter module, which communicates with the data processing module using the Modbus-RTU protocol. Stable sampling is completed every second, and outlier removal and time-series smoothing processes ensure that the weight data is accurate, continuous, and reliable.
[0059] The identification module adopts a dual verification method of RFID ear tag identification and machine vision individual matching. The RFID sensor is installed at the entrance of the feeding device to read the identification number of the pig's ear tag, with an identification accuracy of ≥95%. The machine vision part relies on the improved YOLO11s model of the data processing module to realize individual target detection and tracking, and complete the secondary verification of identity. Through the fusion of the two modes, the pig's identity is accurately bound to its weight, feed intake and behavior data, providing unique identification support for the construction of individual growth curves.
[0060] The wireless transmission module uses the ESP8266 Wi-Fi module to realize data communication between the device and the cloud. The system adopts the MQTT lightweight IoT protocol, uses EMQX Cloud as the message server, and uses TLS encryption to ensure transmission security. The device uploads monitoring data such as environment, weight, feed intake, and behavior at fixed intervals. It supports breakpoint resume, disconnection reconnection, and data caching, and can adapt to the complex electromagnetic and network environment of pig houses to ensure stable data transmission without loss.
[0061] The data processing module is based on the RK3588 edge computing platform (Feiling ELF2), equipped with an 8-core CPU and a dedicated NPU to meet the real-time inference requirements of deep learning models. Its core functions include data preprocessing, pig behavior recognition, multi-source data fusion, and growth curve and weight prediction. Data preprocessing involves cleaning, filling missing values, removing outliers, and standardizing time-series data on environment, weight, feed intake, and behavior. Pig behavior recognition uses an improved YOLO11s-MGS model to achieve accurate recognition of five types of behavior with an mAP@0.5 of 95%. Multi-source data fusion aligns various types of data by timestamp to construct a complete growth time-series dataset for a single pig. Growth curve and weight prediction uses a Gompertz+EVO-LSTM-MLP hybrid model to complete the fitting of the group reference curve and the prediction of individual residual weight, achieving accurate prediction of age-weight.
[0062] The core control module uses an STM32F103 embedded motherboard as the main control unit, which is responsible for coordinating the collaborative work of various hardware modules. Its main functions include receiving and parsing sensor data, driving various sensors to work, controlling the feeding motor to execute feeding instructions, bidirectional communication with the edge computing unit and wireless transmission module, and receiving feeding parameters and control instructions from the IoT platform to achieve precise automatic feeding.
[0063] The IoT platform is developed based on the MQTT protocol and a layered architecture. It has complete functions such as data visualization, remote monitoring, model inference, feeding decision-making, and report statistics. Its main capabilities include real-time display of pig house environment, pig weight, feed intake, behavioral status, and growth curve. It provides remote control, parameter configuration, historical data query, and data export services. It has a built-in growth curve model and feeding decision engine, which automatically generates personalized reference feeding plans based on predicted weight. It automatically counts key indicators such as daily weight gain, feed conversion ratio, and growth uniformity and generates breeding reports. At the same time, it supports unified access of multiple pig houses and multiple devices to meet the digital management needs of large-scale pig farms.
[0064] The intelligent pigsty management method using the above-mentioned intelligent pigsty management system is as follows: Figure 1 As shown, the specific process includes the following:
[0065] Step 1: Multi-source data acquisition;
[0066] After the system starts, the environmental monitoring module, weight detection module, feeding monitoring module, video monitoring module, and identification module start simultaneously, realizing parallel data collection across all dimensions of pig farming. The environmental monitoring module collects real-time data on temperature, humidity, ammonia concentration, and carbon dioxide concentration in the pigsty using temperature and humidity sensors, ammonia sensors, and carbon dioxide sensors, and uploads the data via RS485 bus; the weight detection module collects real-time weight data of pigs at 1-second intervals using a high-precision weighbridge located at the bottom of the feeding device; the feeding monitoring module obtains the amount of feed delivered and the amount remaining in the feed trough using a feed weight sensor, and then calculates the actual feed intake of the pigs (i.e., feeding amount); the video monitoring module collects images of pig behavior from a top-down angle using multiple depth cameras, capturing images of five types of behavior: eating, drinking, standing, lying down, and sleeping; the identification module reads the ear tag number of the pig using an RFID sensor to uniquely identify each individual. All collected data is aggregated on the device via the Modbus-RTU protocol and then encrypted and uploaded to the edge computing platform and cloud IoT platform by the wireless transmission module according to the MQTT protocol. This enables the synchronous acquisition of environmental data, weight data, feeding data, behavioral images, and identity information, providing high-quality raw data for subsequent processing.
[0067] Step 2: Data preprocessing;
[0068] The data processing module performs unified cleaning, correction, normalization, and alignment on the collected multi-source heterogeneous data. For environmental data, linear interpolation is used to fill missing values, and moving average filtering is used to remove impulse noise, ensuring continuous and stable environmental parameters. For weight data, the 3σ principle is used to identify and remove abnormal increases and decreases caused by pig shaking and uneven trampling, and then a time-series smoothing algorithm is used to correct the curve, ensuring that weight changes conform to the physiological growth pattern of pigs. For image data, it is uniformly scaled to 640×640 pixels, HSV color space enhancement and CLAHE contrast enhancement are performed, and data augmentation is completed using random flipping, Gaussian noise, and brightness perturbation to improve the robustness of the model in complex scenarios. For time-series data, the identification number, weight, feed intake, environmental parameters, and behavioral tags are strictly aligned according to the timestamp to form a standardized growth dataset for each pig, providing a unified input for behavior recognition and weight prediction.
[0069] Step 3: Construct and apply an improved YOLO11s-MGS deep learning model to identify pig behavior and feeding status;
[0070] The improved YOLO11s-MGS deep learning model is based on the original YOLO11s. It introduces the Maple multi-branch feature extraction module into the backbone network to enhance the ability to capture local pose and multi-scale features. The GSConv lightweight fusion module is used in the neck network to reduce the amount of computation and enhance the interaction of channel information. The SimAM parameterless attention mechanism is added to the detection head to suppress background interference and highlight the main features of the pig.
[0071] In addressing the challenge of recognizing fine-grained categories such as sleeping and prone positions in daily pig behavior, where appearances are highly similar and a single receptive field cannot simultaneously capture local texture details (e.g., hoof and head orientation) and global pose context (trunk and limb morphology), this embodiment introduces the Maple (Multi-scale Adaptive Parallel Leaf-structure) lightweight multi-branch feature extraction module (hereinafter referred to as the Maple module) into the backbone network to replace the traditional C3k2 module in the backbone network. The design of the Maple module integrates the multi-scale perception mechanism of Atrous Spatial Pyramid Pooling (ASPP), the depth-separable convolution strategy of MobileNet (a lightweight deep neural network), and the channel rearrangement idea of ShuffleNet (a convolutional neural network architecture). It aims to achieve adaptive fusion of multiple receptive field features within a single layer through parallel topology, while significantly reducing the number of parameters and computational overhead.
[0072] The Maple module employs a hybrid serial and parallel architecture, from main pulse to two leaflets. Input features are first processed via... The "main vein" formed by convolutions is used for channel compression, reducing the number of channels from... Mapping to an intermediate dimension not only eliminates redundant computations but also preserves direct feature paths. Subsequently, the compressed features are split into two parallel "leaf" branches, each performing dilation rate calculations. and of Depthwise Convolution. Among them, The branch focuses on capturing local edges and texture details, while The branch utilizes dilated convolution to expand the effective receptive field to approximately [value missing] without increasing downsampling or the number of parameters. This allows the module to capture a slightly larger range of limb relationships and body posture context. This dual-path parallel design enables the module to simultaneously encode micro-details and meso-level context, effectively resolving the contradiction between the loss of global information in small receptive fields and the blurring of local features in large receptive fields.
[0073] To address the information isolation issue that can arise from multi-branch parallelism, the Maple module introduces a channel shuffle operation after feature concatenation. This operation reassembles the three-way features output from the main vein and the two leaf lobes in a staggered manner along the channel dimension (number of groups). This approach breaks down the information flow barriers introduced by group convolutions, facilitating feature interaction across branches without introducing any additional parameters. Ultimately, the fused features are processed through... Convolution projection back to target output channel number It achieves full interface compatibility with the C3k2 module, facilitating plug-and-play use in backbone networks. Compared to traditional stacked residual blocks, the two-leaf Maple module, through depthwise convolution and channel compression strategies, significantly reduces the FLOPs and parameter count of the improved YOLO11s-MGS deep learning model while maintaining or even improving feature representation capabilities, making it particularly suitable for deployment scenarios sensitive to inference speed.
[0074] Specifically, the input feature map is set as The expected number of output channels is The number of intermediate channels is The forward propagation process of the Maple module is as follows:
[0075] First, channel compression is performed through the main artery:
[0076] ,
[0077] Secondly, the depthwise convolution operation of the two lobes is performed in parallel, corresponding to the local and expanded receptive fields respectively:
[0078]
[0079] Subsequently, the main pulse output and the two-lobed output are spliced together along the channel dimension, and the channels are rearranged to promote information fusion:
[0080]
[0081] Finally, through Convolutional features are fused and mapped to the output dimension:
[0082]
[0083] Among them, the number of intermediate channels Set as:
[0084]
[0085] In the formula, This represents depthwise separable convolution. This represents a parameterless channel rearrangement operator; Indicates the execution expansion rate of Depthwise separable convolution, Indicates the execution expansion rate of Depthwise separable convolution; Representing the characteristic tensor space, Indicates the number of input feature channels. Indicates the height of the input feature map. Indicates the width of the input feature map. This represents the compressed feature map output by the 1×1 convolution of the main pulse. This represents a 1×1 point convolution. This represents the output feature of a depthwise convolution branch with an inflation rate of 1. This represents the output features of a depthwise convolution branch with an inflation rate of 2. This indicates a feature concatenation operation. This represents the intermediate feature map after concatenating the three feature paths. This represents the feature map after channel rearrangement. This indicates that the module ultimately outputs a feature map. This indicates a round-down operation.
[0086] In the architecture proposed in this embodiment, the original C3k2 is replaced by Maple modules in several key stages of the backbone network, and a high-efficiency detection framework of "Maple backbone + GSConv neck + SimAM attention enhancement" is constructed. Experimental results show that this design significantly improves the ability to distinguish subtle posture changes in pigs and achieves the optimal balance between detection accuracy and inference speed.
[0087] The data processing module loads the improved YOLO11s-MGS deep learning model to process the image data preprocessed in step 2, enabling pig behavior recognition. This improved YOLO11s-MGS deep learning model can stably recognize five types of behaviors: feeding, drinking, standing, lying down, and sleeping. Simultaneously, the system automatically records key indicators such as the start and end times of feeding, duration of each feeding session, number of feedings per day, and feeding rate. These records are linked to the pig's identification number, weight, and feed intake, forming a complete feeding behavior profile. This provides a reliable behavioral basis for subsequent growth curve construction and feeding decisions.
[0088] Step 4: The data processing module uses a two-stage hybrid model to complete the construction of growth curves and accurate weight prediction;
[0089] Phase 1: Constructing standard growth curves for a pig population using the Gompertz mathematical model.
[0090]
[0091] In the formula: Indicates the age of pigs in days Reference weight at that time Indicates weight approaching maturity. Indicates position parameters, This represents the growth rate parameter. This indicates the age of pigs in the fattening stage.
[0092] This curve reflects the ideal growth trend of the pig herd and serves as a benchmark for individual predictions. The traditional nonlinear least squares (NLS) method is used for parameter fitting, with the optimization objective being to minimize the sum of squared residuals between the predicted and actual values.
[0093]
[0094] in: For the first The true weight of each sample For the corresponding age, Let be the growth curve function to be fitted. This is the set of model parameters.
[0095] Based on the NLS fitting results, we obtain:
[0096]
[0097] Based on this, the standard growth curve for the pig population is as follows:
[0098]
[0099] This reference curve is used for residual weight calculation:
[0100]
[0101] in: The weight of a single pig on that day is measured (in this embodiment, the weight of each pig is measured once a day before its first meal using a weight detection module), and the unit is kg. This represents the pig's deviation from the reference growth curve of the population on that day, also known as the residual weight, expressed in kg.
[0102] Phase Two: Reference Figure 2 As shown, weight prediction is based on the EVO-LSTM-MLP hybrid residual prediction model;
[0103] First, the Pearson correlation coefficient is used to analyze the residual weight obtained from the first stage calculation. The correlation between the data and candidate input variables (including environmental temperature, humidity, ammonia concentration, carbon dioxide concentration, body weight, and feed intake data obtained from the environmental monitoring module, weight detection module, and feeding monitoring module) is analyzed. The Pearson correlation coefficient measures the linear correlation between random variables by calculating the quotient of the product of the covariance and standard deviation between two variables. The value ranges from -1 to 1. The larger the absolute value, the stronger the correlation. A positive number represents a positive correlation, and a negative number represents a negative correlation.
[0104] Based on the comprehensive correlation analysis results, the inputs for the EVO-LSTM-MLP hybrid residual prediction model are determined to include: body weight (Wt), feed amount (FIt), ammonia concentration (NH3), carbon dioxide concentration (CO2), ambient humidity (Hum), and daily body weight difference (ΔWt). Then, the input feature vector Xt at time t is defined as: Xt=[Wt,FIt,NH3,CO2,Hum,ΔWt]; where daily body weight refers to the difference between the measured body weight of the previous day and the measured body weight of the current day.
[0105] To address the challenges of complex individual growth deviation patterns, strong non-stationarity of original growth sequences, and insufficient nonlinear fitting ability of traditional time-series models in pig weight prediction, this embodiment constructs an EVO-LSTM-MLP hybrid residual prediction model for pig weight prediction research. This model uses an LSTM network as the backbone structure for temporal feature extraction, leveraging the unique gating mechanism of LSTM to uncover the long-term temporal dependencies between pig growth characteristics and environmental characteristics, fully extracting the implicit influences of historical growth patterns and environmental changes. Simultaneously, a two-layer MLP regression head is introduced at the LSTM feature output end to replace the traditional single-layer fully connected output structure. The first fully connected layer with a nonlinear activation function completes the nonlinear transformation and spatial mapping of high-dimensional temporal features, enhancing the expressive power and discriminative power of the features. The second linear fully connected layer then completes feature dimensionality reduction and result output. Without significantly increasing computational complexity, this model significantly improves its ability to approximate complex residual distributions and individual growth deviation patterns.
[0106] The prediction dataset (i.e., the input feature vector Xt) constructed in this invention contains 6-dimensional growth and environmental input features, with the predicted residual weight of pigs as the sole output label. After data cleaning and residual label construction, all input features are standardized to eliminate dimensional differences. Subsequently, the dataset is divided into training, validation, and test sets in a 7:2:1 ratio, used for parameter training, hyperparameter tuning, and final performance evaluation of the EVO-LSTM-MLP hybrid model, respectively. The model's temporal input window is uniformly set to 14, meaning that multi-dimensional temporal feature data from 14 consecutive days is used to achieve a single-step prediction of the residual weight of pigs for the next day. To address the issues of subjective nature and limited generalization ability in manual hyperparameter tuning, this invention introduces the EVO (Energy Valley Optimizer) algorithm to perform global iterative optimization of key hyperparameters. The algorithm uses the mean absolute error (MAE) under a recursive prediction strategy as the fitness function and automatically iteratively searches for the optimal hyperparameter combination. The optimized hyperparameters cover core parameters such as the number of neurons in the LSTM hidden layer, the number of network stack layers, the probability of random inactivation, the learning rate, and the weight decay coefficient. At the same time, it combines an early stopping strategy and a fixed training budget to suppress model overfitting while ensuring the effectiveness and stability of hyperparameter search. Finally, the optimal hyperparameter combination is selected and the model is retrained and the weights are saved.
[0107] In the model testing and evaluation phase, a Rollout stepwise recursive prediction strategy was adopted to achieve long-term pig weight prediction. During testing, the model was first warmed up and started using real historical residual data. Then, the residual results of the model's single-step predictions were backfilled into the time-series input window, iterating continuously to complete the recursive prediction, effectively simulating the dynamic prediction needs of actual farming scenarios. The predicted residual weight output by the model, combined with the Gompertz theoretical reference weight, can be used to reconstruct the actual predicted weight of the pig, achieving a complete weight prediction closed loop. To quantitatively evaluate the model's predictive performance, this invention selected Mean Absolute Error (MAE), Root Mean Square Error (RMSE), and Coefficient of Determination (R²) as core evaluation indicators. MAE reflects the overall prediction error level of the model, RMSE measures the model's prediction accuracy and data dispersion for extreme data, and R² characterizes the model's fit to the actual growth pattern. By combining these three indicators with a visual comparison of pig growth curves, the accuracy and stability of the EVO-LSTM-MLP model in the pig weight residual prediction task were comprehensively verified.
[0108] Final weight prediction: The reference curve is added to the residual weight predicted by the EVO-LSTM-MLP hybrid model to obtain the final predicted weight.
[0109]
[0110] In the formula: Indicates age in days The final predicted weight, in kg; This indicates the predicted residual weight, expressed in kg.
[0111] The EVO-LSTM-MLP hybrid model performed well on the test set with a mean absolute error (MAE) of 0.85 kg and a coefficient of determination (R²) of 0.95, enabling high-precision individual weight prediction.
[0112] Step 5: Feeding strategy analysis and decision-making based on growth status;
[0113] The data detected by each detection module, along with the pig behavior and feeding status identification results, final predicted weight results, and predicted residual weight data processed by the data processing module, are all sent to the IoT platform for storage. The IoT platform determines the pig's growth status based on the predicted residual weight and a preset deviation threshold, then automatically generates a personalized, precise feeding strategy, issues feeding instructions, and controls the various execution components to execute the feeding instructions based on the core control module. Specifically:
[0114] (1) Determination of growth status:
[0115] Low growth: Predicted body weight is significantly lower than the reference curve, i.e. ;
[0116] Even growth: The predicted weight is basically consistent with the reference curve, that is... ;
[0117] Taller than average: Predicted weight is higher than the reference curve, i.e. ;
[0118] in, The preset deviation threshold (taken in this embodiment) is =2 kg).
[0119] (2) Feeding strategy formulation:
[0120] Slow growth: Increase feed intake appropriately to promote daily weight gain;
[0121] Uniform growth: Maintain standard feeding amounts and stabilize growth rate;
[0122] Excessive growth: Reduce feed intake appropriately, optimize feed conversion ratio, and lower costs.
[0123] (3) Strategy execution and iterative optimization
[0124] The core control module automatically drives the feeding motor to achieve precise feeding based on feeding decisions. Every 7 days, the system updates the dual-stage hybrid model using measured body weight, corrects the growth curve, and recalculates feeding parameters. When environmental temperature, humidity, ammonia, or carbon dioxide levels are abnormal, the feeding rhythm is automatically adjusted to reduce stress. This closed-loop decision-making significantly reduces the feed conversion ratio, improves feed utilization, and achieves refined, intelligent, and precise feeding throughout the entire process. This invention innovatively combines the traditional growth model (Gompertz) with machine learning (LSTM) to construct a hybrid prediction model of "baseline growth term + dynamic environmental correction term." This model can dynamically correct growth predictions based on environmental factors (humidity, harmful gases) and feed intake, improving the accuracy and interpretability of body weight prediction.
[0125] The embodiments described above are preferred embodiments of the present invention, but the present invention is not limited to the above embodiments. Any obvious improvements, substitutions or modifications that can be made by those skilled in the art without departing from the essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. An intelligent pig house management system, characterized in that, It includes an environmental monitoring module, a weight detection module, a food intake monitoring module, a video surveillance module, a wireless transmission module, a data processing module, an identity recognition module, a core control module, and an Internet of Things platform; The environmental monitoring module is used to collect key environmental parameters affecting pig growth in the pigsty in real time and transmit them to the data processing module. This includes temperature and humidity sensors, ammonia sensors, and carbon dioxide sensors. The weight detection module is used to detect the weight data of pigs and transmit it to the data processing module. The feeding monitoring module is used to detect the weight of feed in the feed trough while feeding pigs and transmit it to the data processing module. This includes automatic feed troughs, feeding motors, and feed weight monitoring sensors. The video monitoring module is used to collect image data of pigs and transmit it to the data processing module. The identity recognition module uses RFID ear tag identification, which, together with the machine vision individual matching of the data processing module, constitutes a dual verification method. The data processing module is based on the improved YOLO11s-MGS deep learning model and the EVO-LSTM-MLP hybrid residual prediction model to realize pig behavior recognition and weight prediction. The IoT platform receives various monitoring data and the processing results data transmitted by the data processing module, determines the growth status of pigs, specifies feeding strategies, and controls each execution component to execute feeding instructions through the core control module.
2. A method for managing an intelligent pig house using the intelligent pig house management system according to claim 1, characterized in that, The process includes the following: Step 1: The environmental monitoring module, weight detection module, feed monitoring module, video monitoring module, and identity recognition module are started simultaneously to achieve parallel collection of multi-source data from pig farming; the collected multi-source data is uniformly uploaded to the IoT platform and data processing module through the wireless transmission module; Step 2: The data processing module preprocesses the collected multi-source heterogeneous data; Step 3: The data processing module uses an internally built improved YOLO11s-MGS deep learning model to identify pig behavior and feeding status, and uploads the identification results to the IoT platform via a wireless transmission module. The improved YOLO11s-MGS deep learning model is based on the original YOLO11s. The backbone network introduces a lightweight Maple multi-branch feature extraction module to enhance the ability to capture local pose and multi-scale features. The neck network uses a lightweight GSConv fusion module to reduce the amount of computation and enhance the interaction of channel information. The detection head adds a SimAM parameterless attention mechanism to suppress background interference and highlight the main features of the pig. Step 4: The data processing module first constructs the standard growth curve of the pig population, calculates the residual weight, performs correlation analysis based on the residual weight and the preprocessed multi-source data, and determines the model input feature vector; then, it obtains the predicted residual weight based on the internally constructed EVO-LSTM-MLP hybrid residual prediction model, and then calculates the predicted weight of the pigs, and synchronously uploads the predicted residual weight and the predicted weight of the pigs to the IoT platform. Step 5: The IoT platform determines the growth status of pigs and formulates feeding strategies based on preset deviation thresholds; the core control module controls each execution component to execute feeding instructions. 3.The intelligentized pig house management method according to claim 2, characterized in that, In step 3, the Maple lightweight multi-branch feature extraction module replaces the traditional C3k2 module in the backbone network. It integrates the multi-scale perception mechanism of hollow spatial pyramid pooling, the depth-separable convolution strategy of MobileNet, and the channel rearrangement idea of ShuffleNet. Through parallel topology, it achieves adaptive fusion of multiple receptive field features in a single layer, reducing the number of parameters and computational overhead. Specifically, the input feature map is set as The expected number of output channels is The number of intermediate channels is The forward propagation process of Maple's lightweight multi-branch feature extraction module is as follows: First, channel compression is performed through the main artery: , Secondly, the depthwise convolution operation of the two lobes is performed in parallel, corresponding to the local and expanded receptive fields respectively: Subsequently, the main pulse output and the two-lobed output are spliced together along the channel dimension, and the channels are rearranged to promote information fusion: Finally, through Convolutional features are fused and mapped to the output dimension: wherein the number of intermediate channels is set to: In the formula, This represents a parameterless channel rearrangement operator; Indicates the execution expansion rate of Depthwise separable convolution, Indicates the execution expansion rate of Depthwise separable convolution; Representing the characteristic tensor space, Indicates the number of input feature channels. Indicates the height of the input feature map. Indicates the width of the input feature map. This represents the compressed feature map output by the 1×1 convolution of the main pulse. This represents a 1×1 point convolution. This represents the output feature of a depthwise convolution branch with an inflation rate of 1. This represents the output features of a depthwise convolution branch with an inflation rate of 2. This indicates a feature concatenation operation. This represents the intermediate feature map after concatenating the three feature paths. This represents the feature map after channel rearrangement. This indicates that the module ultimately outputs a feature map. This indicates the floor function. 4.The intelligentized pig house management method according to claim 2, characterized in that, In step 4, the residual weight calculation process is as follows: First, the standard growth curves for the pig population are constructed using the Gompertz mathematical model: In the formula: Indicates the age of pigs in days Reference weight at that time Indicates weight approaching maturity. Indicates position parameters, This represents the growth rate parameter. Indicates the age of pigs in the fattening stage; The traditional nonlinear least square method is used for parameter fitting, and the optimization objective is to minimize the residual sum of squares between the predicted value and the true value to obtain the fitting value: ; The final standard growth curve for the pig herd is as follows: Residual body weight As follows: wherein: was the actual body weight of the single pig on the day of measurement. 5.The intelligentized pig house management method according to claim 2, characterized in that, In step 4, the model input feature vector Xt is: Xt=[Wt,FIt,NH3,CO2,Hum,ΔWt]; Wt represents body weight, FIt represents feed amount, NH3 represents ammonia concentration, CO2 represents carbon dioxide concentration, Hum represents ambient humidity, and ΔWt represents daily body weight difference. 6.The intelligentized pig house management method according to claim 2, characterized in that, In step 4, the EVO-LSTM-MLP hybrid residual prediction model uses an LSTM network as the backbone structure for temporal feature extraction. Relying on the unique gating mechanism of LSTM, it mines the long-term temporal dependence between pig growth characteristics and environmental characteristics, fully extracting the implicit effects of historical growth patterns and environmental changes. At the same time, a two-layer MLP regression head is introduced at the LSTM feature output end to replace the traditional single-layer fully connected output structure. The first fully connected layer with a nonlinear activation function completes the nonlinear transformation and spatial mapping of high-dimensional temporal features, enhancing the expressive power and discriminative power of the features. Then, the second linear fully connected layer completes feature dimensionality reduction and result output. Without significantly increasing the computational complexity, the model's ability to approximate complex residual distributions and individual growth deviation patterns is improved.
7. The intelligent pigsty management method according to claim 2, characterized in that, In step 4, the predicted weight of the pigs is as follows: In the formulae: represents the final predicted body weight at the age of represents the predicted residual body weight. 8.The intelligentized pig house management method according to claim 2, characterized in that, In step 5, the growth status of the pigs is determined as follows: Growth is low: ; Even growth: ; Growth is too high: ; wherein, is a preset bias threshold, is a predicted residual body weight.
Citation Information
Patent Citations
Pig body temperature detection system and detection method based on visible light and infrared thermal imaging video
CN119516575A
Intelligent weight monitoring method, system and device for bred pigs and storage medium
CN119919242A