Method and system for identifying ingestion behaviors of group pigs

Through the improved YOLOv8-Pose network and spatiotemporal feature analysis algorithm, the accurate identification problem of feeding behavior in the environment of group pig farming is solved, and the identification efficiency and management benefits are improved.

CN120544282APending Publication Date: 2025-08-26SHANDONG JIALEJIA AGRI & ANIMAL HUSBANDRY TECH CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510773321.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-11
Publication Date
2025-08-26

AI Technical Summary

Technical Problem

The prior art is difficult to accurately distinguish between feeding and foraging behavior in the environment of pig farming. The traditional method relies on vertical top view data to have poor compatibility with existing monitoring perspectives, and the pig feeding and foraging behavior are similar in static pictures, resulting in low recognition efficiency.

Method used

The improved YOLOv8-Pose network is used for target recognition and key point detection. By calculating the distance between the four vertices of the pig target detection box and the key point, combining the positional relationship of the feeding trough area, a spatiotemporal feature analysis algorithm is designed to distinguish feeding and foraging behaviors.

Benefits of technology

It realizes accurate identification of the feeding behavior of group pig farms, improves feed utilization efficiency, reduces breeding costs, and provides real-time adjustment strategy reference for farm management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120544282A_ABST
    Figure CN120544282A_ABST
Patent Text Reader

Abstract

The invention discloses a group pig feeding behavior identification method and system. The method comprises the following steps: acquiring a pig video in a daily actual production environment and constructing a pig target detection data set; performing target identification and key point detection on the pig target detection data set by using an improved YOLOv8-Pose network to obtain position information of a standing pig; calculating distances between four vertexes of a pig target detection frame and key points according to the coordinates of the key points in the position information, and selecting the vertex with the closest distance as a near-head point; according to the position relation between the position of the point close to the head and the feeding trough area, the feeding series pigs and the non-feeding pigs are divided; and analyzing the spatial-temporal characteristics of the ingestion series of pigs to realize the identification of the ingestion pigs. According to the method, the moving phenomenon of the standing pigs is judged in combination with time and space information, so that ingestion and foraging behaviors are accurately distinguished, the recognition accuracy and the feed utilization efficiency are improved, and the breeding cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of group-raised pig behavior recognition, and in particular to a group-raised pig feeding behavior recognition method and system. Background Art

[0002] Pig farming is an important part of modern animal husbandry. Pig behavior recognition not only comprehensively understands pigs' activity patterns and health status, but also promptly detects abnormal behavior, reduces the risk of disease transmission, and improves farming efficiency. However, the current pig farming industry is large-scale, with high pig density and complex site environments. Traditional manual monitoring methods are labor-intensive and inefficient.

[0003] With the development of artificial intelligence (AI), deep learning techniques have provided new insights into animal behavior recognition. Single-frame static recognition techniques based on the YOLO family of algorithms have achieved some success in detecting daily pig behaviors. However, these methods often rely on vertical overhead data collection, which is incompatible with existing farm monitoring perspectives. Furthermore, pigs' feeding activities include both eating and foraging, which are very similar in static images and difficult to distinguish.

[0004] Therefore, how to accurately identify the feeding behavior of group-raised pigs is a technical problem that urgently needs to be solved in this field. Summary of the Invention

[0005] In order to solve the above technical problems, this application proposes the following technical solutions: In a first aspect, an embodiment of the present application provides a method for identifying feeding behavior of group-raised pigs, comprising: Obtain pig videos in daily production environments and build a pig target detection dataset; Use the improved YOLOv8-Pose network to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of the standing pigs; According to the coordinates of the key points in the position information, the distances between the four vertices of the pig target detection frame and the key points are calculated, and the vertex with the closest distance is selected as the near-head point; According to the position relationship between the near-head point and the feeding trough area, the feeding series pigs and the non-feeding series pigs are divided; The temporal and spatial characteristics of the feeding series of pigs are analyzed to identify the feeding pigs.

[0006] In one possible implementation, obtaining pig videos in a daily actual production environment and constructing a pig target detection dataset includes: Use cameras to collect videos of pigs in daily production environments and capture static images at frame intervals; After manually screening the captured static image, the screened image is expanded by data enhancement; After using the X-Anylabeling annotation tool to annotate the standing pigs in the image with rectangular frames, the key points of the heads of the standing pigs are annotated to form a pig target detection dataset.

[0007] In one possible implementation, the improved YOLOv8-Pose network includes: The pose detection head is lightweight, using GNConv to replace traditional convolution and combining 1×1 convolution to compress the channels of the input feature map. Shared convolution, convolution normalization module and multi-scale adaptation module are introduced. The multi-scale adaptation module processes the decoding process of key point prediction through adaptive scaling factors. A scaling factor is calculated for each input image size and the decoding result is adjusted according to the scaling factor to ensure that the model stably outputs the correct key point position under input images of different sizes.

[0008] In one possible implementation, the improved YOLOv8-Pose network is used to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of the standing pigs, including: The improved YOLOv8-Pose network is trained using the pig target detection dataset to obtain a standing pig target detection model; The Bytetrack algorithm is used to assign IDs to target pigs and track them. The coordinates of the four vertices and key points of the pig target detection box in each frame are calculated based on the ID information. In a possible implementation, the feeding series pigs and the non-feeding series pigs are divided according to the positional relationship between the near-head point and the feeding trough area, including: When the head-proximal point is within the predefined feeding trough area, the pig is classified as a pig in a feeding series activity; or, When the head-proximal point is not in the predefined feeding trough area, the pig is classified as a non-feeding pig.

[0009] In a possible implementation, analyzing the spatiotemporal characteristics of a series of pigs eating to identify the pigs eating includes: Obtain the target detection frame position information of the pigs in the feeding activity series and extract the center point coordinates; The Euclidean distance value of the center point of the target detection frame is calculated using the displacement calculation strategy of the preset interval frame; The displacement threshold is used to determine whether the pig target has moved; When the distance value is greater than the displacement threshold, it is determined that the pig target has moved, and the pig is a foraging pig; or, When the distance value is less than the displacement threshold, it is determined that the pig target has not moved, and the pig is a feeding pig.

[0010] In a possible implementation, when the distance value is less than the displacement threshold, it is determined that the pig target has not moved, and the pig is a feeding pig, including: Set the parameters for the number of consecutive frames used to record the pig maintaining a stable posture without significant displacement; When a pig enters the feeding area, the parameter counter is initialized and the distance value of the center point of the target detection frame in consecutive frames is calculated; If the distance between the two frames is less than the displacement threshold, it is determined that the target pig has not moved significantly. When the parameter counter reaches the preset number of times, it is determined that the target pig is in the feeding behavior.

[0011] In one possible implementation, the displacement threshold is the average of the ability to correctly identify feeding behavior samples and the ability to correctly identify foraging behavior samples, and is calculated as follows: .

[0012] In a second aspect, an embodiment of the present application provides a group-raised pig feeding behavior recognition system, comprising: The acquisition module is used to obtain pig videos in daily actual production environments and build a pig target detection dataset; The target recognition and key point detection module uses the improved YOLOv8-Pose network to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of standing pigs; A calculation and selection module is used to calculate the distances between the four vertices of the pig target detection frame and the key points according to the coordinates of the key points in the position information, and select the vertex with the closest distance as the near-head point; A division module, for dividing the feeding series pigs and the non-feeding series pigs according to the position relationship between the near-head point and the feeding trough area; The recognition module is used to analyze the spatiotemporal characteristics of a series of pigs eating and to identify the pigs eating.

[0013] Compared with the prior art, the present invention has the following advantages: This application uses the YOLOv8-Pose algorithm to perform target recognition and key point detection on group-raised pig videos to obtain pig position information. The orientation characteristics of the target detection frame are used to divide pigs in the feeding series of activities from non-feeding pigs. At the same time, a spatiotemporal feature analysis algorithm is designed to distinguish between feeding and foraging pigs, realizing the recognition of pig feeding behavior. By establishing a feeding behavior database, it helps farm managers adjust feed delivery strategies in real time, thereby improving feed utilization efficiency and reducing breeding costs. This application can be applied to the management of group-raised pig farms, providing an effective technical means for real-time detection of pig feeding behavior, and also providing a reference for further improving the welfare of group-raised pig farming. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 A flow chart of a method for identifying feeding behavior of group-raised pigs provided in an embodiment of the present application; Figure 2 A schematic diagram of the improved YOLOv8-Pose structure provided in an embodiment of the present application; Figure 3 A schematic diagram of the process of obtaining a detection frame and key point visualization information image using the improved YOLOv8-Pose network provided in an embodiment of the present application; Figure 4 A schematic diagram of the pig feeding area provided in the embodiment of the present application; Figure 5 A schematic diagram of the pig feeding behavior recognition effect provided in an embodiment of the present application; Figure 6 Schematic diagram of the group-raised pig feeding behavior recognition system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0015] The present invention will be described below with reference to the accompanying drawings and specific implementation methods.

[0016] Figure 1 This is a flow chart of a method for identifying feeding behavior of group-raised pigs provided in an embodiment of the present application, see Figure 1 In this embodiment, a method for identifying feeding behavior of group-raised pigs includes: S101, obtain pig videos in daily actual production environment and build a pig target detection dataset.

[0017] In this embodiment, a video of pigs raised in a group under an actual production environment is collected from a daily monitoring perspective, and static images are intercepted at intervals of 250 frames. The intercepted images are manually screened to remove samples with poor image quality or high similarity, and finally 1300 valid images are obtained. In order to improve the generalization ability of the model, this embodiment adopts data enhancement methods such as random flipping, rotation, cropping and adding noise to expand the data set to 2600 images. The X-Anylabeling annotation tool is used to annotate the pigs in the standing posture in the data set, and the connection between the neck and the trunk is marked as the key point Head. For partial occlusion, if the key point position can be inferred by the adjacent body structure, it is estimated and annotated. If it is completely invisible, it is not annotated, and the annotation results are saved in json format. The pig target detection data set is randomly divided into training set, validation set and test set according to the ratio of 8:1:1, containing 2080, 260 and 260 images respectively.

[0018] S102: Use the improved YOLOv8-Pose network to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of the standing pigs.

[0019] See also Figure 2 In this embodiment, based on the existing YOLOv8-Pose network, a lightweight design of the Pose detection head is implemented, introducing shared convolution, a convolution normalization module (GNConv), and a multi-scale adaptation mechanism (Scale). In this embodiment, to reduce the amount of computation per layer, the detection head is improved by using GNConv instead of traditional convolution, and 1×1 convolution is combined to compress the channels of the input feature map. Specifically, the input high-dimensional feature map is reduced in dimension through 1×1 convolution, reducing the number of parameters and alleviating the computational burden. Subsequently, features are extracted through 3×3 convolution, and then 1×1 convolution is used to output the prediction results of target detection. This design helps improve computational efficiency while ensuring accuracy and reduces the amount of computation during inference. The improved Pose inherits the improved Detect foundation and further optimizes it.

[0020] In terms of the shared convolution mechanism, in traditional pose estimation models, the detection branch and the key point prediction branch usually need to calculate features separately, resulting in redundant calculation processes. To solve this problem, the improved Pose in this embodiment adopts a shared convolution mechanism, and all branches share the same convolution kernel, thereby avoiding repeated calculations in the feature extraction process and significantly improving the inference efficiency. In terms of the dynamic decoding mechanism, the traditional decoding method may cause inconsistent accuracy on some hardware platforms, especially when the model is deployed to different platforms. To solve this problem, the improved Pose in this embodiment introduces a multi-scale adaptation module. This module handles the decoding process of key point prediction through an adaptive scaling factor. Specifically, a scaling factor is calculated for the size of each input image, and the decoding result is adjusted according to the factor to ensure that the model can stably output the correct key point position under input images of different sizes.

[0021] Compared to the original network, the improved YOLOv8-Pose significantly improves computational efficiency and keypoint localization accuracy by introducing lightweight shared convolutions, a dynamic decoding mechanism, and multi-scale feature fusion. The improved network can more flexibly adapt to varying input sizes, accurately locate small objects and details, and particularly excels in keypoint detection in complex scenes. Furthermore, the network's shared convolutional layers and dynamic feature fusion strategy effectively reduce computational redundancy and improve overall performance.

[0022] The improved YOLOv8-Pose network is trained using the pig target detection dataset to obtain a standing pig target detection model. The model recognition process is as follows: Figure 3 As shown in the figure, the input image first undergoes multi-scale feature extraction via the backbone of the improved YOLOv8-Pose network. The image is then sequentially downsampled through convolutional layers and C2f modules, generating feature maps at five levels, P1 to P5. The resolution is gradually reduced to 1 / 32 of the original image. The SPPF layer further enhances high-level semantic features through multi-scale pooling. The head then concatenates deep features with shallow features through an upsampling operation. The C2f module then fuses multi-scale information, gradually reconstructing the detailed feature pyramids P3, P4, and P5. P3 has a resolution of 1 / 8, P4 has a resolution of 1 / 16, and P5 has a resolution of 1 / 32. Finally, the three feature maps are fed into the Pose_LSCD detection head, which uses shared convolution and a dynamic anchor mechanism to simultaneously predict object bounding boxes, class probabilities, and keypoint coordinates. The final output is an image containing the detection boxes and keypoint visualization information. Throughout the process, the improved lightweight shared convolution and dynamic feature integration significantly improved the key point positioning accuracy and computational efficiency.

[0023] The Bytetrack algorithm is used to assign IDs to target pigs and track them. The coordinates of the four vertices and key points of the pig target detection box in each frame are calculated based on the ID information.

[0024] S103, calculating the distances between the four vertices of the pig target detection frame and the key points according to the key point coordinates in the position information, and selecting the vertex with the closest distance as the near-head point.

[0025] In this embodiment, Figure 4 The blue area is the area to be tested, and the green area is the feeding area. Figure 4 Target detection is performed on the standing pig within the blue area in the image, and the positions of the detection box and key points are determined. The Euclidean distance between the four vertices of the target detection box and the Head key point is then calculated, and the vertex with the closest distance is selected as the near-head point.

[0026] S104, dividing the feeding series pigs into the non-feeding series pigs according to the position relationship between the near-head point and the feeding trough area.

[0027] In this embodiment, the pigs in the pens were observed for 4 hours in the farm. During this period, 60 pigs were close to the trough and did not move for a long time. Among them, only 57 pigs engaged in feeding behavior. Therefore, identifying whether the pigs are stationary near the trough is an effective method for judging feeding behavior. According to the pig's body length, the position of the trough and the movement characteristics when feeding, the trough and the area around it that is half the pig's body length are defined as the feeding area. This area can cover the range of head movement of the pig when naturally feeding. Combined with the positional relationship between the near-head point and the trough area, it is judged whether the pig is in a feeding-related behavior state. When the near-head point is in the predefined trough area feeding area, it is classified as a pig in a feeding series of activities and subsequent analysis is performed. In this embodiment, the pigs in the feeding series of activities include feeding pigs and foraging pigs. When the near-head point is not in the predefined trough area, it is determined to be a non-feeding pig and no subsequent analysis is performed.

[0028] S105, analyzing the spatiotemporal characteristics of the feeding series of pigs to identify the feeding pigs.

[0029] See also Figure 5In this embodiment, the feeding behavior of pigs usually lasts for at least 2 seconds. Therefore, in order to determine whether the pigs are in a stable feeding state, a continuous frame number parameter is defined. The coordinates of the center point of the target detection frame of the pigs in the feeding series are extracted, and the Euclidean distance between the current frame and the target center point of the previous 10 frames is calculated. This value represents the displacement of the pig between these ten frames. And by statistically analyzing the displacement data distribution of pigs during feeding and non-feeding, the displacement threshold δth with the highest classification accuracy is determined. When the displacement is less than the threshold and lasts for more than 2 seconds, the pig is in the feeding state. When it is greater than the threshold or less than 2 seconds, it is in the foraging state.

[0030] To determine the optimal displacement threshold, the following metrics were used for analysis: TPR measures the model's ability to correctly identify feeding behavior samples. TNR measures the model's ability to correctly identify foraging behavior samples. These two metrics reflect the model's ability to identify feeding and foraging behaviors, respectively. Average Metrics is the average of TPR and TNR. Ultimately, the intersection of TNR and TPR was used as the optimal displacement threshold. This value provides the most balanced classification capabilities for feeding and foraging behaviors. The calculation formula is: Furthermore, before monitoring pig feeding behavior, the system initializes a feeding behavior data management database to record and track each pig's individual feeding behavior. By updating each pig's feeding time and frequency in real time, the system dynamically monitors the feeding status of each pig in the group. Based on this data analysis, managers can adjust feed delivery strategies for pigs with short feeding times or low feeding frequency, such as increasing feed amounts, adjusting feed formulas, or optimizing feeding schedules, thus achieving personalized management.

[0031] Corresponding to the method for identifying the feeding behavior of group-raised pigs provided in the above embodiment, the present application also provides an embodiment of a system for identifying the feeding behavior of group-raised pigs.

[0032] See also Figure 6 The embodiment of the present application provides a group-raised pig feeding behavior recognition system 20, which includes: an acquisition module 201, a target recognition and key point detection module 202, a calculation and selection module 203, a division module 204 and a recognition module 205.

[0033] Among them, the acquisition module 201 is used to obtain pig videos in daily actual production environments and construct a pig target detection dataset. The target recognition and key point detection module 202 is used to use the improved YOLOv8-Pose network to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of the standing pigs. The calculation and selection module 203 is used to calculate the distance between the four vertices of the pig target detection frame and the key points based on the key point coordinates in the position information, and select the vertex with the closest distance as the near-head point. The division module 204 is used to divide the feeding series pigs and non-feeding pigs according to the position relationship between the near-head point and the feeding trough area. The identification module 205 is used to analyze the spatiotemporal characteristics of the feeding series pigs to realize the identification of feeding pigs.

[0034] In the embodiments of this application, "plurality" refers to two or more. "and / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean that A exists alone, A and B exist simultaneously, or B exists alone. A and B can be singular or plural. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0035] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0036] The above description is merely a specific embodiment of the present application. Any person skilled in the art may easily conceive of variations or substitutions within the technical scope disclosed in this application, and such variations or substitutions shall be within the scope of protection of this application. The scope of protection of this application shall be subject to the scope of protection of the claims.

Claims

1. A method for identifying feeding behavior of group-raised pigs, characterized in that: include: Obtain pig videos in daily production environments and build a pig target detection dataset; Use the improved YOLOv8-Pose network to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of the standing pigs; According to the coordinates of the key points in the position information, the distances between the four vertices of the pig target detection frame and the key points are calculated, and the vertex with the closest distance is selected as the near-head point; According to the position relationship between the near-head point and the feeding trough area, the feeding series pigs and the non-feeding series pigs are divided; The temporal and spatial characteristics of the feeding series of pigs are analyzed to identify the feeding pigs.

2. The method for identifying feeding behavior of group-raised pigs according to claim 1, characterized in that: The method of obtaining pig videos in a daily actual production environment and constructing a pig target detection dataset includes: Use cameras to collect videos of pigs in daily production environments and capture static images at frame intervals; After manually screening the captured static image, the screened image is expanded by data enhancement; After using the X-Anylabeling annotation tool to annotate the standing pigs in the image with rectangular frames, the key points of the heads of the standing pigs are annotated to form a pig target detection dataset.

3. The method for identifying feeding behavior of group-raised pigs according to claim 1, characterized in that: The improved YOLOv8-Pose network includes: The pose detection head is lightweight, using GNConv to replace traditional convolution and combining 1×1 convolution to compress the channels of the input feature map. Shared convolution, convolution normalization module and multi-scale adaptation module are introduced. The multi-scale adaptation module processes the decoding process of key point prediction through adaptive scaling factors. A scaling factor is calculated for each input image size and the decoding result is adjusted according to the scaling factor to ensure that the model stably outputs the correct key point position under input images of different sizes.

4. The method for identifying feeding behavior of group-raised pigs according to claim 1, characterized in that: The improved YOLOv8-Pose network is used to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of the standing pigs, including: The improved YOLOv8-Pose network is trained using the pig target detection dataset to obtain a standing pig target detection model; The Bytetrack algorithm is used to assign IDs to target pigs and track them. The coordinates of the four vertices and key points of the pig target detection box in each frame are calculated based on the ID information.

5. The method for identifying feeding behavior of group-raised pigs according to claim 1, characterized in that: According to the positional relationship between the near-head point and the feeding trough area, the feeding series pigs and the non-feeding series pigs are divided into: When the head-proximal point is within the predefined feeding trough area, the pig is classified as a pig in a feeding series activity; or, When the head-proximal point is not in the predefined feeding trough area, the pig is classified as a non-feeding pig.

6. The method for identifying feeding behavior of group-raised pigs according to claim 1, characterized in that: The analysis of the spatiotemporal characteristics of the feeding series of pigs to identify the feeding pigs includes: Obtain the target detection frame position information of the pigs in the feeding activity series and extract the center point coordinates; The Euclidean distance value of the center point of the target detection frame is calculated using the displacement calculation strategy of the preset interval frame; The displacement threshold is used to determine whether the pig target has moved; When the distance value is greater than the displacement threshold, it is determined that the pig target has moved, and the pig is a foraging pig; or, When the distance value is less than the displacement threshold, it is determined that the pig target has not moved, and the pig is a feeding pig.

7. The method for identifying feeding behavior of group-raised pigs according to claim 6, characterized in that: When the distance value is less than the displacement threshold, it is determined that the pig target has not moved, and the pig is a feeding pig, including: Set the parameters for the number of consecutive frames used to record the pig maintaining a stable posture without significant displacement; When a pig enters the feeding area, the parameter counter is initialized and the distance value of the center point of the target detection frame in consecutive frames is calculated; If the distance between the two frames is less than the displacement threshold, it is determined that the target pig has not moved significantly. When the parameter counter reaches the preset number of times, it is determined that the target pig is in the feeding behavior.

8. The method for identifying feeding behavior of group-raised pigs according to claim 6, characterized in that: The displacement threshold is the average of the ability to correctly identify feeding behavior samples and the ability to correctly identify foraging behavior samples, and the calculation formula is: 。 9. A system for identifying feeding behavior of group-raised pigs, characterized in that: include: The acquisition module is used to obtain pig videos in daily actual production environments and build a pig target detection dataset; The target recognition and key point detection module uses the improved YOLOv8-Pose network to perform target recognition and key point detection on the pig target detection dataset to obtain the position information of standing pigs; A calculation and selection module is used to calculate the distances between the four vertices of the pig target detection frame and the key points according to the coordinates of the key points in the position information, and select the vertex with the closest distance as the near-head point; A division module, for dividing the feeding series pigs and the non-feeding series pigs according to the position relationship between the near-head point and the feeding trough area; The recognition module is used to analyze the spatiotemporal characteristics of a series of pigs eating and to identify the pigs eating.