Pig farm anomaly detection system based on multi-sensor data fusion
Through multi-sensor data fusion technology, RFID tags and particle filtering algorithms are used to predict the movement trajectory of pigs, and a global anomaly detection model is built, which solves the problems of extensive environmental regulation and lag in the epidemic warning in the traditional breeding model, and achieves the efficiency and accuracy of abnormal detection of pig farms, and improves production efficiency and safety.
Patent Information
- Application Number
- CN202510609042.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-13
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2045-05-13
AI Technical Summary
The traditional breeding model relies on manual experience management, with extensive environmental regulation, lagging epidemic warning, and insufficient identification of abnormal behaviors, resulting in low production efficiency and high risks. The false alarm rate of a single sensor system is high in complex environments, making it difficult to fully reflect the pig farm conditions.
Multi-sensor data fusion technology is adopted to bind spatiotemporal anchor points through RFID tags, and a particle filtering algorithm is used to predict the movement trajectory of pigs, and a global anomaly detection model is built. Combined with a dynamic perception network and behavior fingerprint library, pig behavior and environmental parameters are monitored in real time to realize multi-dimensional data fusion and abnormal detection.
It improves the accuracy and reliability of abnormal detection in pig farms, can promptly detect abnormalities that are difficult to detect in a single data, realize group and individual abnormality warnings, reduce false alarms, and improve breeding efficiency and safety.
Smart Images

Figure CN120123958B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multi-sensor fusion anomaly detection technology, and in particular to a pig farm anomaly detection system using multi-sensor data fusion. Background Art
[0002] Animal husbandry is an important part of agricultural production, among which pig farming occupies a core position in ensuring meat supply and promoting the agricultural economy. However, the traditional farming model relies on manual experience management, and has problems such as extensive environmental control, delayed disease warning, and insufficient identification of abnormal behavior, resulting in low production efficiency and high risks. With the development of smart agriculture, the intelligent transformation of animal husbandry has become an inevitable trend. By introducing multi-sensor data fusion technology, real-time monitoring and anomaly detection of the breeding environment, pig behavior and health status can be achieved, which can significantly improve breeding efficiency, reduce the risk of disease transmission, and promote the development of animal husbandry in a refined and scientific direction. Traditional breeding monitoring mostly relies on a single sensor with limited data dimensions, which makes it difficult to fully reflect complex breeding scenarios. The single sensor system has a response delay and a high false alarm rate in complex environments. Summary of the Invention
[0003] The present invention aims to solve the technical problems existing in the prior art and provides a pig farm anomaly detection system based on multi-sensor data fusion.
[0004] The technical solution of the present invention to solve the above technical problems is as follows: a pig farm anomaly detection system based on multi-sensor data fusion, comprising:
[0005] Multi-source data acquisition and fusion module: Continuously collects data through sensors, binds unique spatiotemporal anchor points to RFID tags, and uses particle filtering algorithms to predict the movement trajectory of pigs between different sensor fields of view;
[0006] Anomaly detection model construction module: Each node performs local model training based on its own data, and then uploads the local model parameters to the central node for fusion through the gradient aggregation strategy to generate a global anomaly detection model;
[0007] Anomaly Detection Module: A dynamic sensing network is divided within the piggery. Each grid unit collects multimodal data features in real time and calculates the entropy value of the grid unit to assess the degree of data chaos and the possibility of anomalies.
[0008] Abnormal warning module: establish a behavioral fingerprint library for each pig, monitor the pig behavior data in real time, and calculate the matching degree with the behavioral fingerprint.
[0009] In a preferred embodiment, the multi-source data acquisition and fusion module continuously collects data at a set frequency through various sensors, including pig behavior, movement, physiological data and environmental data, and obtains pig ID and location information through RFID readers. The collected data is preliminarily cleaned, and a unique spatiotemporal anchor point is assigned to each RFID tag. The initial spatiotemporal coordinates are determined for each tag in combination with the camera frame timestamp and the weight sensor sampling period. A unified time reference is established, and the time of the camera, weight sensor and RFID reader is calibrated with the reference time. The network time protocol is used to regularly synchronize the time of each device to reduce time error. The particle filter algorithm is used to predict the pig's motion trajectory. The location information obtained by the RFID tag is used as observation data. In combination with the pig's historical motion status, a motion trajectory prediction model is established. The specific steps of the motion trajectory prediction model are as follows:
[0010] S1. Based on the known initial position and state information of the pig, a group of particles are randomly generated and each particle is given the same weight. Suppose the state space of the pig is , respectively represent the position of the pig in the two-dimensional space and speed At the initial time t=0, the initial position of the pig is known and speed , randomly generate N particles, the initial state of each particle is for:
[0011]
[0012] Where i represents the index of the particle, Represents the state of the i-th particle at the initial time t=0, including the initial position of the particle and initial velocity , Indicates that the initial position and velocity of the i-th particle are respectively subject to the initial position and velocity of the pig as the mean, represents the normal distribution of variance;
[0013] S2. Based on the pig's motion model, taking into account the pig's speed and acceleration factors, the state of each particle is predicted to obtain the position and velocity information of the particle at the next moment;
[0014] S3, compare the predicted particle state with the actual observed RFID tag position information, and update the weight of each particle by calculating the observation likelihood function. The weight reflects the degree of match between the particle and the observed data;
[0015] S4. Resample according to the weight of the particles, delete the particles with smaller weights, and copy the particles with larger weights to ensure that the particle set can better approximate the true probability distribution;
[0016] S5. Calculate the estimated position and motion trajectory of the pig based on the resampled particle states and weights, and obtain the final trajectory prediction result through weighted averaging.
[0017] When a pig moves from the identification range of one RFID reader to another, its movement trajectory between the two readers is predicted using a particle filter algorithm to fill the data collection gap and ensure the continuity and integrity of the pig's movement trajectory. The predicted movement trajectory is compared and corrected with the pig's behavior captured by the camera. Based on the spatiotemporal anchor point and time synchronization information, the data collected by different types of sensors are mapped into a unified spatiotemporal coordinate system.
[0018] In a preferred embodiment, the anomaly detection model construction module continuously collects multi-source data in the pig farm through edge nodes, including cameras collecting pig behavior images, RFID obtaining pig location and motion trajectory data in real time, and temperature and humidity sensors collecting environmental parameters in the pig farm. The collected data is preprocessed, and a small batch gradient descent algorithm is used to divide the preprocessed data into small batches. The local anomaly detection model is trained based on the cross entropy loss combined with the mean square error as the loss function. The local model training includes dividing the preprocessed data into small batches according to the time window, each batch contains a first preset number of samples, and calculating the gradient through the back propagation algorithm. The model parameters are updated to learn normal behavior patterns and environmental fluctuation characteristics. When the training round reaches the second preset threshold, the gradient upload operation is triggered. During the training process, the back propagation algorithm is used to calculate the gradient. The propagation algorithm calculates the gradient and continuously adjusts the model parameters to enable the model to learn the normal behavior patterns, movement patterns and normal fluctuation range characteristics of pigs and environmental parameters. The local model training round threshold is set to 10 rounds. When the edge node completes 10 rounds of training, the gradient upload operation is triggered, and the gradient information recorded during the training process is encapsulated. The edge node identifier, training round, and data source identifier, such as the camera in pig house area A and the temperature and humidity sensor data in pig house area B, are added and uploaded to the central node. After the central node receives the gradient information uploaded by each edge node, it first extracts the node identifier, data source identifier, and data volume information, and assigns weights according to the node data volume ratio and computing power score. After the central node completes the weight calculation of each edge node, it uses the gradient weighted average formula to aggregate the local gradients uploaded by each node. The specific calculation formula is as follows:
[0019]
[0020] in, The local gradient of node k is the gradient information calculated by the edge node based on the pig behavior images, RFID location trajectory and environmental parameter data collected by itself after local model training. represents the weight of node k, which is obtained based on the weighted distribution mechanism of node data volume ratio and computing power score. N represents the total number of edge nodes participating in federated learning. The central node is based on the aggregated gradient , Adam optimization algorithm is used to update the global anomaly detection model parameters , the specific calculation formula is as follows:
[0021]
[0022] in, represents the updated parameters, Represents the learning rate. The updated parameters are packaged and sent to each edge node. After receiving the parameter package, the edge node replaces the local model parameters with the updated parameters to prepare for the next round of training based on local data. The specific steps of the new round of training cycle are as follows:
[0023] S1. The edge node uses the updated global model parameters and combines them with the newly collected multi-source data to continue the next round of local model training. It repeats the process of gradient calculation, gradient upload, central node gradient aggregation, and model update. In each round of iteration, the model continuously learns the features of the new data.
[0024] S2. During each iteration, the central node monitors the convergence of the global model using the following two-condition judgment mechanism: First, the change in the loss function over multiple consecutive iterations is calculated. When the change in the loss function is less than 0.001, it indicates that the model parameter update is stabilizing and the training is close to convergence. Second, the maximum number of training rounds is set to 100. When this number is reached, training is terminated regardless of whether the loss function change meets the threshold.
[0025] S3. When any of the above termination conditions is met, the final global anomaly detection model is output, which has the ability to accurately detect anomalies in the actual pig farm environment.
[0026] The final trained global anomaly detection model is deployed in the pig farm's real-time monitoring system and connected to the data collection of each sensor to ensure that pig behavior images, RFID location trajectories, and environmental parameter data can be obtained in real time. When new data is input into the model, the model analyzes and judges the data based on the normal behavioral characteristics, movement patterns, and normal ranges of environmental parameters of pigs learned during the training process. If the data does not conform to the normal pattern and differs significantly from the historical normal behavior pattern, the model outputs abnormal results, including the type of abnormality, and reminds the pig farm managers in the form of an alarm. The managers take corresponding measures in a timely manner based on the alarm information.
[0027] In a preferred embodiment, the anomaly detection module divides the dynamic perception network in the pig house, and divides the pig house into several grid units of uniform size according to the actual physical space layout of the pig house. Each grid unit serves as an independent data collection and analysis unit to ensure coverage of all areas in the pig house. A unique identification ID is assigned to each grid unit, and a mapping relationship between the grid unit and the sensor data is established. The sensors contained in each grid unit are clarified, and multimodal data is collected through the sensors. The multimodal data collected by each grid unit is pre-processed, and the entropy value of each grid unit is calculated to evaluate the degree of chaos and the possibility of anomalies of the data. Assume that there are n different types of sensor data in the grid unit, and the probability distribution of each data is , then the entropy value calculation formula of the grid unit is as follows:
[0028]
[0029] in, It represents the distribution probability density of the i-th type of sensor data in the grid, sets the time window length, and when the entropy value increment of the grid unit exceeds the preset threshold within three consecutive time windows, it is determined that an abnormal event has occurred in the area.
[0030] In a preferred embodiment, the abnormal warning module establishes a behavioral fingerprint library for each pig, integrates and stores the extracted movement patterns, feeding characteristics, and social behavior information, and uses the RFID tag ID of each pig as a unique identifier to obtain pre-processed pig behavior data in real time, match the real-time monitored pig behavior data with the behavior fingerprint library of the pig, and use the Euclidean distance to calculate the distance between the real-time data and the data in the behavior fingerprint library. A closer distance indicates a higher degree of matching. There are two feature vectors. and , the specific calculation formula of Euclidean distance is as follows:
[0031]
[0032] The feature vector of the pig behavior data monitored in real time is matched with the feature vector of the pig in the behavior fingerprint library, and a matching threshold is set. When the calculated distance is less than the threshold, it is considered that the real-time data matches the behavior fingerprint library well and the pig behavior is normal. When the distance is greater than the threshold, it is determined that the pig has abnormal behavior and an early warning is triggered.
[0033] The beneficial effects of the present invention are: the present invention widely deploys various types of sensors, including high-definition cameras, weight sensors, RFID devices and environmental monitoring equipment, which can comprehensively collect multi-dimensional information such as pig behavior, movement, physiological data and environmental parameters, ensuring all-round perception of the pig farm conditions, and providing a rich and accurate data basis for subsequent analysis, avoiding omissions of abnormal detection due to data loss, and through spatiotemporal alignment and data fusion operations, accurately aligning different types of sensor data in time and space dimensions, and integrating their advantages to form a more comprehensive and accurate data set, which enables abnormal detection to comprehensively consider multiple factors to improve the accuracy and reliability of detection, and can discover abnormal situations that are difficult to detect with single data, establish a behavioral fingerprint library for each pig, monitor in real time and match it with the fingerprint library, which can trigger individual abnormality warnings in time, and realize group abnormality warnings through group data entropy monitoring, and can discover potential problems in time. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 is a flow chart of the present invention;
[0035] Figure 2 This is a system block diagram of the present invention. DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0037] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Therefore, a feature specified as "first" or "second" may explicitly or implicitly include one or more of the described features. In the description of this application, "plurality" means two or more, unless otherwise specifically specified.
[0038] In the description of this application, the term "for example" is used to mean "used as an example, illustration or explanation". Any embodiment described as "for example" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is given to enable any person skilled in the art to implement and use the present invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art will recognize that the present invention can be implemented without using these specific details. In other examples, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in this application.
[0039] like Figure 1-2 This embodiment provides: a pig farm anomaly detection system based on multi-sensor data fusion, including:
[0040] Multi-source data acquisition and fusion module: Continuously collects data through sensors, binds unique spatiotemporal anchor points to RFID tags, and uses particle filtering algorithms to predict the movement trajectory of pigs between different sensor fields of view;
[0041] In this embodiment, it should be noted that the multi-source data acquisition and fusion module continuously collects data at a set frequency through various sensors, including pig behavior, movement, physiological data and environmental data, and obtains pig ID and location information through RFID readers, performs preliminary cleaning on the collected data, assigns a unique spatiotemporal anchor point to each RFID tag, and determines the initial spatiotemporal coordinates for each tag in combination with the camera frame timestamp and the weight sensor sampling period. For example, when the RFID tag is first recognized by the reader, the camera timestamp and the sampling time of the weight sensor are recorded at this time. Based on this, the initial position of the tag in space is calculated to form a spatiotemporal anchor point, establish a unified time reference, calibrate the time of the camera, weight sensor and RFID reader with the reference time, ensure that all data are consistent in the time dimension, use the network time protocol to regularly synchronize the time of each device to reduce time error, use the particle filter algorithm to predict the pig's movement trajectory, use the position information obtained by the RFID tag as observation data, and combine the pig's historical movement status to establish a movement trajectory prediction model. The specific steps of the movement trajectory prediction model are as follows:
[0042] S1. Based on the known initial position and state information of the pig, a group of particles are randomly generated and each particle is given the same weight. Suppose the state space of the pig is , respectively represent the position of the pig in the two-dimensional space and speed At the initial time t=0, the initial position of the pig is known and speed , randomly generate N particles, the initial state of each particle is for:
[0043]
[0044] Where i represents the index of the particle, Represents the state of the i-th particle at the initial time t=0, including the initial position of the particle and initial velocity , Indicates that the initial position and velocity of the i-th particle are respectively subject to the initial position and velocity of the pig as the mean, represents the normal distribution of variance;
[0045] S2. According to the pig's motion model, the pig's motion model can be expressed as:
[0046]
[0047] Among them, t represents the current time, t-1 represents the previous time, Indicates the time interval, They represent the pig's acceleration in the x and y directions, It represents the weight of the particle's position in the x-direction at time t, which reflects the degree of match between the particle's position in the x-direction and the observed data. The larger the weight, the higher the possibility that the particle's position in the x-direction is closer to the pig's true position. It represents the weight of the particle's position in the y direction at time t, and is used to measure the degree of conformity between the particle's position in the y direction and the actual observation. It represents the weight of the particle's velocity in the x-direction at time t. It reflects the consistency between the x-direction velocity represented by the particle and the velocity inferred by the observation data and the motion model. The higher the weight, the more likely the x-direction velocity corresponding to the particle is the true velocity of the pig. It represents the weight of the particle's velocity in the y direction at time t. It is used to evaluate the matching degree between the particle's velocity in the y direction and the actual situation. Taking into account the pig's speed and acceleration factors, the state of each particle is predicted to obtain the position and velocity information of the particle at the next moment:
[0048]
[0049] in, represents the position of particle i in the x direction at time t-1, represents the position of particle i in the y direction at time t-1, represents the velocity of particle i in the x direction at time t-1, represents the velocity of particle i in the y direction at time t-1, represents the predicted position of particle i in the x direction at time t, represents the predicted position of particle i in the y direction at time t, represents the predicted velocity of particle i in the x direction at time t, represents the predicted velocity of the particle in the y direction at time t, represents the noise that affects the position prediction of particle i in the x direction at time t, represents the noise that affects the position prediction of particle i in the y direction at time t, It represents the noise that affects the prediction of particle i’s velocity in the x direction at time t, and represents the interference of other random factors on the particle’s velocity in the x direction in addition to the influence of acceleration and time interval on the velocity. It indicates that at time t, the noise that affects the prediction of particle i’s velocity in the y direction is other random factors that affect the particle’s velocity in the y direction;
[0050] S3. Compare the predicted particle state with the actual observed RFID tag position information, and update the weight of each particle by calculating the observation likelihood function. The weight reflects the degree of matching between the particle and the observed data. Suppose the observation model is ,in, represents the observation data, According to the pig's status The calculated observation value, Represents observation noise, which has a mean of 0 and a Gaussian distribution:
[0051]
[0052] in, Indicates the state of the i-th particle Observed data The probability of , that is, the observation likelihood function, updates the particle weight according to the observation likelihood function:
[0053]
[0054] in, Represents the weight of the i-th particle after updating at time t, which is the weight of the previous moment and the observation likelihood function Calculate and then normalize the weights:
[0055]
[0056] in, represents the normalized weight of the i-th particle at time t, which is used to make the sum of all particle weights equal to 1;
[0057] S4, resample according to the weight of the particles, delete the particles with smaller weights, and copy the particles with larger weights to ensure that the particle set can better approximate the true probability distribution. The polynomial resampling method is used according to the normalized weight of the particles. Resample and calculate the cumulative distribution function , generate N random numbers uniformly distributed in the interval [0,1] , for each random number , find satisfaction j, then the kth resampled particle is the jth particle in the far subset, that is , its weight ;
[0058] S5. Calculate the estimated position and trajectory of the pig based on the resampled particle states and weights, and obtain the final trajectory prediction result through weighted averaging:
[0059]
[0060]
[0061]
[0062]
[0063] in, represents the estimated position of the pig in the x-axis direction at time t, represents the estimated position of the pig in the y-axis direction at time t, represents the estimated speed of the pig in the x-axis direction at time t, represents the estimated speed of the pig in the y-axis direction at time t, N represents the total number of particles, represents the weight of the i-th particle at time t, represents the position of the i-th particle in the x-axis direction at time t, represents the position of the i-th particle in the y-axis direction at time t, represents the velocity of the i-th particle in the x-axis direction at time t, represents the velocity of the i-th particle in the y-axis direction at time t, and the estimated motion trajectory of the pig is given by A sequence composed at different times t.
[0064] When a pig moves from the identification range of one RFID reader to another, its movement trajectory between the two readers is predicted using a particle filter algorithm to fill the data collection gap and ensure the continuity and integrity of the pig's movement trajectory. The predicted movement trajectory is compared and corrected with the pig's behavior captured by the camera to improve the accuracy of trajectory prediction. Based on the spatiotemporal anchor points and time synchronization information, the data collected by different types of sensors are mapped into a unified spatiotemporal coordinate system.
[0065] It should be noted that various sensors are installed according to the actual layout and monitoring needs of the pig farm. High-definition cameras are installed on the top of the pig house to ensure coverage without dead angles. Weight sensors are embedded in the ground in areas where pigs often move. RFID readers are arranged at key locations such as entrances and exits of pig houses and passages. Environmental sensors such as temperature, humidity, and ammonia concentration are evenly distributed in the pig house to ensure the comprehensiveness and representativeness of data collection. Appropriate sampling frequencies are set for different types of sensors. Appropriate collection frequencies are set for different types of sensors. High-definition cameras collect video data at a frequency of 30 frames per second to capture the details of pig behavior in real time. Weight sensors collect pressure data 10 times per second to accurately record pressure changes when pigs are active and eating. RFID readers read RFID tag information 5 times per second to track the position of pigs in real time. Environmental sensors collect environmental parameters once a minute to continuously monitor the environmental conditions of the pig house. Various sensors are started and data collection begins at the set frequency. The camera generates video stream data, the weight sensor outputs a pressure sequence, and the RFID reader obtains the pig ID The system collects temperature, humidity, ammonia concentration and other data through environmental sensors, performs preliminary cleaning on the collected raw data, uses filtering algorithms to remove noise and interference in the video stream, and eliminates invalid data that exceeds the reasonable range from weight sensors and environmental sensors through data range judgment and outlier detection. For example, if temperature and humidity have extremely unreasonable values, the system deduplicates and performs integrity checks on RFID data to ensure data accuracy and validity.
[0066] Anomaly detection model construction module: Each node performs local model training based on its own data, and then uploads the local model parameters to the central node for fusion through the gradient aggregation strategy to generate a global anomaly detection model;
[0067] In this embodiment, what needs to be specifically explained is the anomaly detection model construction module. The anomaly detection model construction module continuously collects multi-source data in the pig farm through edge nodes, including cameras collecting pig behavior images, RFID obtaining pig location and motion trajectory data in real time, and temperature and humidity sensors collecting environmental parameters in the pig farm. The collected data is preprocessed, including image data denoising and normalization, time series data filling missing values, removing abnormal discrete points, graying and cropping the pig behavior images, and converting the temperature, humidity, and ammonia concentration data into a unified numerical type. A small batch gradient descent algorithm is used to divide the preprocessed data into small batches, and the local anomaly detection model is trained based on the cross entropy loss combined with the mean square error as the loss function. The local model training includes dividing the preprocessed data into small batches according to the time window, each batch contains a first preset number of samples, calculating the gradient through the back propagation algorithm, and updating the model parameters to learn the normal behavior pattern and Environmental fluctuation characteristics. When the training round reaches the second preset threshold, the gradient upload operation is triggered. During the training process, the gradient is calculated by the back propagation algorithm, and the model parameters are continuously adjusted to enable the model to learn the normal behavior patterns, movement laws and normal fluctuation range characteristics of pigs. The local model training round threshold is set to 10 rounds. When the edge node completes 10 rounds of training, the gradient upload operation is triggered. The gradient information recorded during the training process is encapsulated, and the edge node identification, training round, and data source identification such as the camera in area A of the pig house and the temperature and humidity sensor data in area B of the pig house are added. The data is uploaded to the central node. After the central node receives the gradient information uploaded by each edge node, it first extracts the node identification, data source identification, and data volume information, and assigns weights according to the node data volume ratio and computing power score. After the central node completes the weight calculation of each edge node, the gradient weighted average formula is used to aggregate the local gradients uploaded by each node. The specific calculation formula is as follows:
[0068]
[0069] in, The local gradient of node k is the gradient information calculated by the edge node based on the pig behavior images, RFID location trajectory and environmental parameter data collected by itself after local model training. represents the weight of node k, which is obtained based on the weighted distribution mechanism of node data volume ratio and computing power score. N represents the total number of edge nodes participating in federated learning. The central node is based on the aggregated gradient , Adam optimization algorithm is used to update the global anomaly detection model parameters , the specific calculation formula is as follows:
[0070]
[0071] in, represents the updated parameters, Represents the learning rate. The updated parameters are packaged and sent to each edge node. After receiving the parameter package, the edge node replaces the local model parameters with the updated parameters to prepare for the next round of training based on local data. The specific steps of the new round of training cycle are as follows:
[0072] S1. The edge node uses the updated global model parameters and combines them with the newly collected multi-source data to continue the next round of local model training. It repeats the process of gradient calculation, gradient upload, central node gradient aggregation, and model update. In each round of iteration, the model continuously learns the features of the new data.
[0073] S2. During each iteration, the central node monitors the convergence of the global model using the following two-condition judgment mechanism: First, the change in the loss function over multiple consecutive iterations is calculated. When the change in the loss function is less than 0.001, it indicates that the model parameter update is stabilizing and the training is close to convergence. Second, the maximum number of training rounds is set to 100. When this number is reached, training is terminated regardless of whether the loss function change meets the threshold.
[0074] S3. When any of the above termination conditions is met, the final global anomaly detection model is output, which has the ability to accurately detect anomalies in the actual pig farm environment.
[0075] It should be noted that the first preset number of samples refers to the number of library samples contained in each batch when the preprocessed data is divided into small batches according to the time window. In the machine learning training process, small batches of data are used for training. For example, the data in the time window is divided into multiple batches, and each batch contains multiple samples. This can take advantage of batch computing to accelerate the model training process and avoid the problem of insufficient memory due to processing too much data at one time. The second preset threshold refers to the upper limit of the iteration rounds when the edge node performs local model training.
[0076] The final trained global anomaly detection model is deployed in the pig farm's real-time monitoring system and connected to the data collection of each sensor to ensure that pig behavior images, RFID location trajectories, environmental parameters and other data can be obtained in real time. When new data is input into the model, the model analyzes and judges the data based on the normal behavioral characteristics, movement patterns and normal range of environmental parameters of pigs learned during the training process. If the data does not conform to the normal pattern, for example, a pig remains motionless for a long time during the normal activity period and differs greatly from the historical normal behavior pattern, or the temperature, humidity and ammonia concentration in a certain area exceed the normal fluctuation range, the model will identify it as an abnormal situation. The model outputs abnormal results, including detailed information such as the type of abnormality (such as abnormal pig behavior, abnormal environmental parameters), the location of the abnormality (determined by RFID or sensor location), etc., and reminds the pig farm manager in the form of an alarm. The manager takes corresponding measures in a timely manner based on the alarm information, such as conducting health checks on abnormal pigs, increasing ventilation in areas with abnormal environment, and adjusting temperature and humidity.
[0077] Anomaly Detection Module: A dynamic sensing network is divided within the piggery. Each grid unit collects multimodal data features in real time and calculates the entropy value of the grid unit to assess the degree of data chaos and the possibility of anomalies.
[0078] In this embodiment, it should be noted that the anomaly detection module divides the dynamic perception network in the pig house. According to the actual physical space layout of the pig house, the pig house is divided into several grid units of uniform size. Each grid unit serves as an independent data collection and analysis unit to ensure that all areas in the pig house are covered. A unique identification ID is assigned to each grid unit, and a mapping relationship between the grid unit and the sensor data is established. The sensors contained in each grid unit are clarified, and multimodal data such as camera coverage, RFID reader sensing area, and environmental sensor position are collected through sensors to accurately collect multimodal data of the area. The camera corresponding to each grid unit collects image data at a frequency of 30 frames per second, and extracts visual features such as the posture, number, and activity status of the pigs through computer vision algorithms. For example, it identifies whether the pigs are lying, eating, walking, etc., counts the number of pigs, and uses RFID The reader collects the location information and movement trajectory data of the pigs in the grid unit, records the time when the pigs enter and leave the grid unit and the movement path within the grid. The environmental sensor collects the temperature, humidity, and ammonia concentration environmental parameters in the grid unit in real time. The collection frequency is once per minute to ensure timely acquisition of environmental change information. The multimodal data collected by each grid unit is preprocessed, and the entropy value of each grid unit is calculated to evaluate the degree of data chaos and the possibility of abnormality. Assume that there are n different types of sensor data in the grid unit, and the probability distribution of each data is , then the entropy value calculation formula of the grid unit is as follows:
[0079]
[0080] in, Identify the distribution probability density of the i-th type of sensor data in the grid, set the time window length, and when the entropy value increment of the grid unit exceeds the preset threshold within three consecutive time windows, it is determined that an abnormal event has occurred in the area.
[0081] Abnormal warning module: establish a behavioral fingerprint database for each pig, monitor pig behavior data in real time, and calculate the matching degree with the behavioral fingerprint;
[0082] In this embodiment, it is necessary to specifically explain the abnormal warning module. The abnormal warning module establishes a behavioral fingerprint library for each pig, integrates and stores the extracted movement patterns, feeding characteristics, and social behavior information, and uses the RFID tag ID of each pig as a unique identifier to obtain the pre-processed pig behavior data in real time. The real-time monitored pig behavior data is matched with the behavior fingerprint library of the pig, and the Euclidean distance is used to calculate the distance between the real-time data and the data in the behavior fingerprint library. A closer distance indicates a higher matching degree. There are two feature vectors. and , the specific calculation formula of Euclidean distance is as follows:
[0083]
[0084] The feature vector of the pig behavior data monitored in real time is matched with the feature vector of the pig in the behavior fingerprint library, and a matching threshold is set. When the calculated distance is less than the threshold, it is considered that the real-time data matches the behavior fingerprint library well and the pig behavior is normal. When the distance is greater than the threshold, it is determined that the pig has abnormal behavior and an early warning is triggered.
[0085] It should be noted that, in the above embodiments, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0086] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0087] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded computer, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0088] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0089] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0090] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0091] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. The pig farm anomaly detection system based on multi-sensor data fusion is characterized by: include: Multi-source data acquisition and fusion module: Continuously collects data through sensors, binds unique spatiotemporal anchor points to RFID tags, combines camera frame timestamps with weight sensor sampling periods, uses network time protocols to regularly synchronize the time of each device, and uses particle filtering algorithms to predict the movement trajectory of pigs between different sensor fields of view; Anomaly detection model construction module: Each node performs local model training based on its own data, using cross-entropy loss combined with mean square error as the loss function. Through a gradient aggregation strategy, weights are assigned according to the node data volume ratio and computing power score. Local model parameters are uploaded to the central node for fusion to generate a global anomaly detection model. The final trained global anomaly detection model is deployed into the pig farm's real-time monitoring system and connected to the data collection of various sensors to ensure real-time acquisition of pig behavior images, RFID location trajectories, and environmental parameter data. When new data is input into the model, the model analyzes and judges the data based on the normal pig behavior characteristics, movement patterns, and normal ranges of environmental parameters learned during the training process. The model outputs abnormal results, including the type of abnormality, and alerts the pig farm management in the form of an alarm. The management takes timely measures based on the alarm information. Anomaly Detection Module: This module divides the pigsty into a dynamic perception network, based on the actual physical layout of the pigsty, into several evenly sized grid cells. Each grid cell collects multimodal data features in real time and calculates the entropy value of the grid cell to assess the degree of data chaos and the possibility of anomalies. Abnormal warning module: establish a behavioral fingerprint library for each pig, integrate and store the extracted movement patterns, feeding characteristics, and social behavior information, match and calculate the feature vector of the pig behavior data monitored in real time with the feature vector of the pig in the behavioral fingerprint library, set the matching threshold, and when the calculated distance is less than the threshold, it is considered that the real-time data matches the behavioral fingerprint library well and the pig behavior is normal. When the distance is greater than the threshold, it is determined that the pig has abnormal behavior and triggers an early warning.
2. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 1 is characterized in that: The multi-source data acquisition and fusion module continuously collects data at a set frequency through various sensors, including pig behavior, movement, physiological data and environmental data, and obtains pig ID and location information through RFID readers. The collected data is preliminarily cleaned, and a unique spatiotemporal anchor point is assigned to each RFID tag. Combined with the camera frame timestamp and the weight sensor sampling period, the initial spatiotemporal coordinates are determined for each tag, and a unified time base is established. The time of the camera, weight sensor and RFID reader is calibrated with the time base. The network time protocol is used to regularly synchronize the time of each device to reduce time error. The particle filter algorithm is used to predict the pig's movement trajectory. The location information obtained by the RFID tag is used as observation data, and combined with the pig's historical movement status, a movement trajectory prediction model is established.
3. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 2 is characterized in that: The specific steps of the motion trajectory prediction model are as follows: S1. Based on the known initial position and state information of the pig, a group of particles are randomly generated and each particle is given the same weight. Suppose the state space of the pig is , respectively represent the position of the pig in the two-dimensional space and speed At the initial time t=0, the initial position of the pig is known and speed , randomly generate N particles, the initial state of each particle is for: Where i represents the index of the particle, Represents the state of the i-th particle at the initial time t=0, including the initial position of the particle and initial velocity , Indicates that the initial position and velocity of the i-th particle are respectively subject to the initial position and velocity of the pig as the mean, is a normal distribution with a variance of S2. Based on the pig's motion model, taking into account the pig's speed and acceleration factors, the state of each particle is predicted to obtain the position and velocity information of the particle at the next moment; S3, compare the predicted particle state with the actual observed RFID tag position information, and update the weight of each particle by calculating the observation likelihood function. The weight reflects the degree of match between the particle and the observed data; S4, resampling according to the particle weight; S5. Calculate the estimated position and motion trajectory of the pig based on the resampled particle states and weights, and obtain the final trajectory prediction result through weighted averaging.
4. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 3 is characterized in that: The particle filter algorithm is used to predict the pig's motion trajectory between the two readers, fill the data collection gap, ensure the continuity and integrity of the pig's motion trajectory, compare and correct the predicted motion trajectory with the pig's behavior captured by the camera, and map the data collected by different types of sensors into a unified spatiotemporal coordinate system based on the spatiotemporal anchor points and time synchronization information.
5. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 1 is characterized in that: The anomaly detection model construction module continuously collects multi-source data in the pig farm through edge nodes, including cameras collecting pig behavior images, RFID obtaining pig location and movement trajectory data in real time, and temperature and humidity sensors collecting environmental parameters in the pig farm. The collected data is preprocessed and divided into small batches. The local anomaly detection model is trained based on cross entropy loss combined with mean square error as the loss function. The gradient information recorded during the training process is encapsulated and uploaded to the central node. After the central node receives the gradient information uploaded by each edge node, it first extracts the node identifier, data source identifier, and data volume information, and assigns weights according to the node data volume ratio and computing power score. After the central node completes the weight calculation of each edge node, it uses the gradient weighted average formula to aggregate the local gradients uploaded by each node. The specific calculation formula is as follows: in, The local gradient of node k is the gradient information calculated by the edge node based on the pig behavior images, RFID location trajectory and environmental parameter data collected by itself after local model training. represents the weight of node k, which is obtained based on the weighted distribution mechanism of node data volume ratio and computing power score. N represents the total number of edge nodes participating in federated learning. The central node is based on the aggregated gradient. , Adam optimization algorithm is used to update the global anomaly detection model parameters , the specific calculation formula is as follows: in, represents the updated parameters, Represents the learning rate. The updated parameters are packaged and sent to each edge node. After receiving the parameter package, the edge node replaces the local model parameters with the updated parameters to prepare for the next round of training based on local data.
6. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 5 is characterized in that: The specific steps of a new round of training cycle are as follows: S1. The edge node uses the updated global model parameters and combines them with the newly collected multi-source data to continue the next round of local model training. It repeats the process of gradient calculation, gradient upload, central node gradient aggregation, and model update. In each round of iteration, the model continuously learns the features of the new data. S2. During each iteration, the central node monitors the convergence of the global model using the following two-condition judgment mechanism: First, the change in the loss function over multiple consecutive iterations is calculated. When the change in the loss function is less than 0.001, it indicates that the model parameter update is stabilizing and the training is close to convergence. Second, the maximum number of training rounds is set to 100. When this number is reached, training is terminated regardless of whether the loss function change meets the threshold. S3. When any of the above conditions is met, the training is terminated and the final global anomaly detection model is output.
7. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 5 is characterized in that: Local model training involves dividing the preprocessed data into small batches according to time windows. Each batch contains a first preset number of samples. The gradient is calculated through the backpropagation algorithm, and the model parameters are updated to learn normal behavior patterns and environmental fluctuation characteristics. When the training round reaches the second preset threshold, the gradient upload operation is triggered.
8. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 1 is characterized in that: In the anomaly detection module, each grid unit serves as an independent data collection and analysis unit to ensure coverage of all areas in the pig house. A unique identification ID is assigned to each grid unit, and a mapping relationship between the grid unit and the sensor data is established. The sensors contained in each grid unit are clearly defined, and multimodal data is collected through the sensors. The multimodal data collected by each grid unit is preprocessed, and the entropy value of each grid unit is calculated to evaluate the degree of data chaos and the possibility of anomalies. Assuming that there are n different types of sensor data in the grid unit, the entropy value calculation formula of the grid unit is as follows: in, It represents the distribution probability density of the i-th type of sensor data in the grid, sets the time window length, and when the entropy value increment of the grid unit exceeds the preset threshold within three consecutive time windows, it is determined that an abnormal event has occurred in the area.
9. The pig farm anomaly detection system based on multi-sensor data fusion according to claim 1 is characterized in that: The behavioral fingerprint library of each pig uses the pig's RFID tag ID as a unique identifier, obtains pre-processed pig behavior data in real time, matches the real-time monitored pig behavior data with the pig's behavioral fingerprint library, and uses the Euclidean distance to calculate the distance between the real-time data and the data in the behavioral fingerprint library. There are two feature vectors and , the specific calculation formula of Euclidean distance is as follows: 。
Citation Information
Patent Citations
Pig breeding intelligent decision management system based on multi-modal information monitoring
CN118735202A
Intelligent cattle herd health analysis and prevention and control system
CN118969274A
Multi-source data fusion system
CN119293727A