Sort:
Issue
Key point detection method for pig face fusing reparameterization and attention mechanisms
Transactions of the Chinese Society of Agricultural Engineering 2023, 39(12): 141-149
Published: 30 June 2023
Abstract PDF (4.8 MB) Collect
Downloads:1

Agricultural production efficiency is ever increasing in recent years, particularly with the continuous development of intelligent breeding technology. The production efficiency and welfare of animals have also been enhanced significantly. It is crucial to the accurate identification and management of important livestock, such as pigs. However, the traditional individual identification on the ear tags, ear notches, and color markings can easily lead to some injuries and infections in pigs, due to the labor intensity and marking time. In contrast, non-invasive individual identification methods can be expected to more conveniently, quickly, and accurately obtain the pig information, thereby improving breeding efficiency and pig welfare. Among them, facial alignment can be one of the most essential steps in pig face recognition. The prerequisite of facial alignment is to accurately locate the facial key points. However, the inaccurate extraction of the pig face key points can be resulted from the pig's movement and varying facial poses. It is a high demand to extract accurate and efficient key points for pig face detection. In this study, a precise detection model (YOLO-MOB-DFC) was proposed for the pig facial key points. The human face key points detection model YOLOv5Face was also innovatively adapted during detection. Firstly, the re-parameterized MobileOne was used as the backbone network to greatly reduce the model parameters. Then, the decoupled fully connected attention module was integrated to capture the dependency among pixels at distant spatial positions, in order to enable the model to focus more on the pig's facial region for higher detection performance. Finally, the lightweight upsampling operator CARAFE was employed to fully perceive the aggregated contextual information within the neighborhood. As such, the more accurate extraction of pig facial key points was achieved after detection. A pig face dataset was constructed using 100 sow video data and 220 images with complex backgrounds featuring multiple pigs. The SSIM structural similarity algorithm was used to filter the high-similarity images without overfitting. The Labelme was used to mark the pig's face, eyes, bilateral tips of the nose, and nose tip. Six data augmentation operations were applied to enhance the model's generalization capability for offline augmentation. The custom-built pig face dataset was used to test the improved model. The results showed that the average accuracy of pig face detection was up to 99.0%, the detection speed was 153 FPS, and the normalized mean error of key points was 2.344%. The average accuracy increased by 5.43%, the number of model parameters was reduced by 78.59%, the frame rate increased by 91.25%, and the normalized mean error was reduced by 2.774%, compared with the RetinaFace model. Meanwhile, the average accuracy was improved by 2.48%, the number of model parameters was reduced by 18.29%, and the normalized mean error was reduced by 0.567%, compared with the YOLOv5s-Face model. The YOLO-MOB-DFC model shared fewer parameters. There was a more stable Normalized Mean Error (NME) fluctuation between continuous frames. There was the reduced impact of the varying pig face poses on the accuracy of keypoint detection. The improved model can be expected to provide higher detection accuracy and efficiency, in order to quickly and accurately obtain the pig face key point data. The finding can lay the foundation to construct high-quality pig face open-set recognition datasets and non-invasive intelligent identification of pig individuals. Non-invasive intelligent identification of individual pigs can be a trend in more intelligent and sustainable animal husbandry, in order to greatly improve the welfare and production efficiency of pigs, while reducing human labor and time consumption.

Issue
Method for counting pigs using improved P2PNet
Transactions of the Chinese Society of Agricultural Engineering 2025, 41(11): 209-218
Published: 15 June 2025
Abstract PDF (3.5 MB) Collect
Downloads:2

Pig counting is a crucial task in modern pig farming, playing a key role in assessing farming scale, optimizing feeding strategies, and improving management efficiency and economic benefits. However, in real farming environments, accurate pig counting faces considerable challenges due to factors such as high pig density, severe individual occlusions, and complex lighting conditions. To overcome these difficulties, this paper proposes an improved pig counting model, PIG-P2PNet, based on the crowd counting model P2PNet, aiming to enhance the model's adaptability and counting accuracy in real-world farming scenarios. Firstly, the channel attention mechanism was introduced into the backbone network, which allows the model to more effectively capture the dependencies among different channels. The overlapping pigs were effectively recognized in the densely populated environments, where the individual animals were obscured. Secondly, a coordinate channel shuffling attention was integrated with the feature pyramid. The extraction and interaction were enhanced for the spatial location information and channel features. This integration enabled the model to better handle a variety of density scenarios by considering each situation more comprehensively. In addition, this paper designs a context-aware Hungarian matching algorithm, which incorporates mechanisms such as weighted distance penalties, uncertainty costs, and adaptive density penalties. These enhancements ensure that the algorithm can better adapt to the target distribution characteristics in different regions, thereby optimizing the matching between ground truth and predicted points. Consequently, the model significantly reduces mismatches in densely populated areas and improves pig counting accuracy in challenging high-density scenarios. Furthermore, considering the imbalance between background and target samples, Focal Loss was used to replace the cross-entropy loss function in the original model, further improving the classification accuracy of the model by effectively focusing on hard-to-classify samples. To comprehensively evaluate the model's performance, the PIG-P2PNet model was validated on a self-built dataset that includes a variety of scenes, camera perspectives, and pig density levels. The results demonstrate that the PIG-P2PNet model performed best across multiple metrics, with an average absolute error, root mean square error, and normalized absolute error of 0.873, 1.502, and 0.040, respectively. Significant improvements were achieved over the original P2PNet model, with reductions of 33.9%, 22.1%, and 39.4% for each metric, respectively. The generalization of the mode was also obtained to accurately count pigs in varying scenarios. Moreover, the PIG-P2PNet model reduced the MAE by 63.3%, 54.5%, and 26.7%, respectively, compared with the classic counting models, such as CSRNet, CANNet, and CLTR. The RMSEs of PIG-P2PNet were reduced by 49.7%, 47.1%, and 13.7%, respectively, indicating its superior precision in the counting tasks. The NAE decreased by 73.5%, 56.5%, and 35.5%, respectively, further underscoring the robustness of the model. The high accuracy of the PIG-P2PNet can be expected to serve as reliable pig counting with high density and occlusion in real-world farming conditions. In summary, the PIG-P2PNet pig counting model demonstrates practical application potential in the livestock industry, particularly in environments where traditional counting failed. The point annotation and point regression were integrated to efficiently manage the counting tasks in the dense pig populations. The adaptability of the model can be further explored on large datasets during multi-object tracking for decision-making in the livestock industry.

Issue
Multi-object tracking of pig behavior using byte algorithm
Transactions of the Chinese Society of Agricultural Engineering 2025, 41(7): 145-155
Published: 15 April 2025
Abstract PDF (7.4 MB) Collect
Downloads:37

Pig tracking has been one of the most important steps in precision livestock farming. Especially, some challenges are still remained on the multi-object tracking of pigs. Various factors also included the varying feeding environment, the rapid movements of pigs, and frequent occlusions among them. In this study, a UKFTrack algorithm was proposed using the Byte framework. An advanced unscented kalman filter (UKF) was also introduced to enhance the tracking accuracy and robustness. A multi-stage matching strategy was obtained in complex farming environments. A comprehensive dataset was constructed with the sufficient training data, in order to verify the effectiveness of the UKFTrack algorithm. Oriented bounding boxes (OBB) was then used to annotate the dataset. Diverse patterns of pig motion were observed in different feeding scenarios and densities. These scenarios were ranged from the rapid movements in the high-density farming to the sudden directional changes and nighttime feeding behaviors. The dataset with the considerable size also exceeded the quality, temporal length, and diversity of existing public datasets. Consequently, the robust data support was provided for the research on the multi-object tracking in complex environments of pig farming. A broad range of critical challenges was captured to test the tracking algorithms, such as the occlusions, lighting changes, and interactions between pigs. In terms of UKFTrack algorithm design, an improved version of the UKF was introduced to specifically tailor for the tracking tasks with the OBB annotations. The traditional state vector was extended into the new parameters, such as the angle and angular velocity. A residual function was designed to handle these angular variables. The relatively errors were effectively avoided to significantly improve the tracking accuracy. The errors were typically arisen from directly subtracting angles. Particularly, these errors often occurred when tracking pigs' irregular and abrupt movements in complex environments. Furthermore, the multi-stage matching strategy also confirmed the stable tracking performance, even in the severe occlusions or rapid movements of pigs. Trajectory association and supplementary matching were incorporated to prevent the target loss for the continuous tracking of individual pigs, even under the high levels of occlusion and disturbances. The experimental results demonstrated that the outstanding performance of the UKFTrack algorithm was achieved in the four challenging scenarios: dense pig farming during the day, extremely dense pig farming during the day, dense pig farming at night, and extremely dense pig farming at night. There were the impressive HOTA (higher order tracking accuracy) scores of 96.10%, 83.10%, 76.50%, and 84.00%, respectively, along with IDF1 (Identity F1 Score) scores of 95.70%, 78.20%, 70.10%, and 77.60%, respectively. The UKFTrack also shared the remarkable improvements, with the HOTA increasing by 1.2, 13.3, 5.9, and 6.3 percentage points in the respective scenarios, while the IDF1 increasing by 0.1, 10.9, 5.4, and7.4 percentage points, compared with the baseline StrongSORT algorithm. Especially, the high accurate and robust tracking were obtained in the high-density farming, frequent occlusions, and complex pig movements. In conclusion, the UKFTrack algorithm was effectively realized the multi-object tracking in complex farming environments. A reliable tool was also offered for the real-world applications in the pig behavior monitoring and health assessment. The superior performance of UKFTrack was greatly contributed to the smart farming technologies. Looking ahead, the scalability of this UKFTrack algorithm can also be expected to extended into the larger datasets in the potential application, particularly for tracking other animals under multi-object scenarios. The UKFTrack algorithm can also hold the promise to significantly advance the precision of livestock monitoring in the challenging environments for the more efficient and effective smart farming.

Issue
Recognizing pig behavior using feature point detection
Transactions of the Chinese Society of Agricultural Engineering 2025, 41(6): 173-184
Published: 30 March 2025
Abstract PDF (2 MB) Collect
Downloads:72

Pig farming has been shifting towards the intensive and intelligent development in recent years, particularly with the advancements in artificial intelligence, deep learning and automation technologies. The machine vision and deep learning can be integrated to realize the non-invasive individual identification and behavior monitoring. It is crucial to determine the characteristic information that generated by pigs during daily activities. However, the existing extraction of pig feature has confined to the complex and inefficient recognition on the pig behavior, due to the frequent changes in pig posture. In this study, a feature points detection model (YOLO-ASF-P2) was proposed to extract the feature points in the key areas of the pig's body. Additionally, a pig behavior recognition model (CNN-BiGRU) was also introduced to combine the temporal information from the feature points. Firstly, the video and image data of pigs were collected by multi-angle cameras that deployed in the pig house. Two datasets were then formed for the pig feature point detection and behavior recognition. Traditional extraction of pig feature was often associated with the complex calculations, redundant feature information and low model robustness. Therefore, the original YOLOv8s-Pose model was improved to result in the YOLO-ASF-P2 model. The feature information of the P2 detection layer was utilized for the small targets. The attention scale sequence fusion (ASF) architecture was combined to focus on the key feature points of live pigs. The scale sequence feature fusion module (SSFF) was used the Gaussian kernel and nearest neighbor interpolation, in order to align the multi-scale feature maps of different downsampling rates (such as P2, P3, P4, and P5 detection layers). The same resolution was obtained as the high-resolution feature map. The triple feature encoding (TFE) module was used to capture the local fine details of small targets, and then fuse the local and global feature information. The channel and position attention mechanism module (CPAM) was used to capture and refine the spatial positioning information related to small targets. The important feature was effectively extracted from the feature map in different channels. The positioning accuracy of the model was also improved. The CNN-BiGRU model was used to recognize the pig behavior. The bidirectional gated recurrent unit (BiGRU) units were also utilized to capture the forward and backward information of sequence data in a bidirectional manner. The output was then weighted using the attention mechanism module (AttentionBlock). The excellent and stable performance was achieved in the self-built dataset. The average recognition accuracy of the model reached 96% for the three behaviors of sitting, standing, and lying. Specifically, the detection accuracy of YOLO-ASF-P2 reached 92.5%, the recall rate was 90%, the average precision (AP50~95) was 68.2%, the parameter volume was only 18.4 M, and the performance was 39.6 G. These values were 1.1%, 2.3%, 1.5%, and 32.9% higher than those of the original model, respectively, where the model parameter volume was reduced by 17.5%. The average precision (AP50-95) and accuracy of YOLO-ASF-P2 were improved by 17.4% and 2.9%, respectively, compared with the MMPose. While almost the same level of recall was maintained to enhance the performance of detection. The YOLO-ASF-P2 was improved the accuracy, recall rate and average precision (AP50-95) with the reduced number of parameters, compared with the RTMPose. The similar accuracy was achieved, compared with the YOLOv5s-Pose. Both the recall rate and average precision (AP50-95) were improved, compared with the YOLOv5s-Pose and YOLOv7s-Pose. The slightly lower accuracy was also observed, compared with the YOLOv7s-Pose. The lightweight model was achieved in the better performance to recognize the pig feature points. The CNN-BiGRU model of pig behavior also shared the high average recognition accuracy and stable performance. The parameter volume was 0.151 M, and the performance was 27.1 G. In summary, the integrated YOLO-ASF-P2 and CNN-BiGRU models were significantly improved the accuracy and robustness of pig feature point detection and behavior recognition. The finding can also offer the valuable tools for the intensive and intelligent development of pig farming.

Total 4