XUE Yueju, SUN Aoshen, YANG Yuqing, et al. Detecting piglet crushing events using amodal instance segmentation[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2025, 41(12): 219-229. DOI: 10.11975/j.issn.1002-6819.202412213
Citation: XUE Yueju, SUN Aoshen, YANG Yuqing, et al. Detecting piglet crushing events using amodal instance segmentation[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2025, 41(12): 219-229. DOI: 10.11975/j.issn.1002-6819.202412213

Detecting piglet crushing events using amodal instance segmentation

More Information
  • Received Date: December 26, 2024
  • Revised Date: April 22, 2025
  • Piglet crushing by sows is one of the primary causes of piglet mortality before weaning. The occlusion of piglets by sows can make it highly challenging to detect the crushing events using existing computer vision. In this study, an accurate and rapid detection of piglet crushing events was proposed using amodal instance segmentation (AIS). Firstly, an improved AIS model, BCNet-FF (bilayer convolutional network-focused fusion), was developed by enhancing the baseline bilayer convolutional network (BCNet). The FLA-DSC (focused linear attention-depthwise separable convolution) module, an enhanced version with focused linear attention was integrated into the backbone network in order to improve the feature extraction for the occluded objects. Additionally, the FreqFusion feature fusion enhancement module was introduced into the feature pyramid networks (FPN), which strengthened multi-scale feature representation and enhanced feature extraction and fusion for occluded object contours. Consequently, high-precision segmentation was achieved. Secondly, a custom dataset was constructed, and the video sequences were processed using BCNet-FF. Sow posture information and pig instance segmentation results was extracted. Among them, the dorsal region of the sow was detected when the posture of the sow was identified as the lateral lying. A regression equation was formulated to estimate the actual contact contour between the sow and the ground. According to this contour, a risk region was delineated to highlight the areas with a high likelihood of piglet crushing. Thirdly, a multi-object tracking algorithm was applied using the target mask intersection over union (IoU) between adjacent frames. The piglets within the risk region were tracked. Finally, the risk region overlap ratio of piglets was calculated to determine whether a crushing event had occurred. The results show that the BCNet-FF was achieved in the precision rates of 97.8%, 98.2%, and 99.5% for the standing, sternal lying, and lateral lying postures, respectively, with the recall rates of 98.2%, 97.2%, and 97.8%, respectively. Segmentation ablation experiments showed that there was an improvement of 2.2 percentage points in the mAP@50, 2.5 percentage points in the mIoU, and an increase of 3.1 percentage points in the AP@50 for piglets using BCNet-FF, compared with the BCNet. The model size increased by 47.5 MB, and the inference speed was 11.4 frames per second. In the comparative experiments, BCNet-FF demonstrated superior performance in instance segmentation of sows and piglets, achieving an AP@50 of 97.4% in piglet segmentation, thereby exceeding Mask R-CNN, CenterMask2, Transfiner, YOLOv11x-seg, and BCNet by 7.8, 4.6, 5.6, 2.3, and 3.1 percentage points, respectively. In the evaluation of 90 video samples, the multi-object tracking method for piglets achieved an average IDF1 of 94.5% and MOTA of 93.8%. The proposed method achieved an accuracy of 91.1% in detecting piglet crushing events, with a sensitivity of 90.6%, a specificity of 91.9%, and an average inference speed of 8.9 frames per second. The better performance of the BCNet-FF model was highlighted to segment the sows and piglets in the occlusion scenarios, particularly for the segmentation accuracy of occluded piglet masks. The multi-object tracking with the target mask IoU can be expected to accurately track the occluded piglets. The constructed regression equation and risk region enabled accurate differentiation between occluded and crushed piglets, which significantly improved piglet crushing event detection accuracy. The practicality and reliability can be achieved to detect the piglet crushing events. The finding can provide an effective approach to monitor the piglet crushing events using computer vision.

  • [1]
    杨焱鑫. 规模猪场仔猪死亡原因及防控措施[J]. 畜禽业,2020,31(6):28-29.
    [2]
    MARCHANT J N, BROOM D M, CORNING S. The influence of sow behaviour on piglet mortality due to crushing in an open farrowing system[J]. Animal Science, 2001, 72(1): 19-28. DOI: 10.1017/S135772980005551X
    [3]
    CHIDGEY L K, MOREL C P, STAFFORD J K, et al. Sow and piglet behavioral associations in farrowing pens with temporary crating and in farrowing crates[J]. Journal of Veterinary Behavior: Clinical Applications and Research, 2017, 20: 91-101. DOI: 10.1016/j.jveb.2017.01.003
    [4]
    WEARY D, PAJOR E, FRASER D, et al. Sow body movements that crush piglets: A comparison between two types of farrowing accommodation[J]. Applied Animal Behaviour Science, 1996, 49(2): 149-158. DOI: 10.1016/0168-1591(96)01042-8
    [5]
    PACHECO V M, BROWN-BRANDL T M, ROHRER G A, et al. Impacts of farrowing pen design, season, and sow parity on litter performance and piglet mortality[J]. Animals, 2024, 14(2): 325. DOI: 10.3390/ani14020325
    [6]
    MELIŠOVÁ M, ILLMANN G, ANDERSEN I L, et al. Can sow pre-lying communication or good piglet condition prevent piglets from getting crushed?[J]. Applied Animal Behaviour Science, 2011, 134(3): 121-129.
    [7]
    董力中,孟祥宝,潘明,等. 基于姿态与时序特征的猪只行为识别方法[J]. 农业工程学报,2022,38(5):148-157. DOI: 10.11975/j.issn.1002-6819.2022.05.018

    DONG Lizhong, MENG Xiangbao, PAN Ming, et al. Recognizing pig behavior on posture and temporal features using computer vision[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2022, 38(5): 148-157. (in Chinese with English abstract) DOI: 10.11975/j.issn.1002-6819.2022.05.018
    [8]
    曾繁国,朱君,王海峰,等. 改进帧间差分-深度学习识别群养猪只典型行为[J]. 农业工程学报,2022,38(15):170-178. DOI: 10.11975/j.issn.1002-6819.2022.15.018

    ZENG Fanguo, ZHU Jun, WANG Haifeng, et al. Typical behavior recognition of herd pigs based on improved frame difference and deep learning[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2022, 38(15): 170-178. (in Chinese with English abstract) DOI: 10.11975/j.issn.1002-6819.2022.15.018
    [9]
    漆海霞,冯发生,尹选春,等. 轻量级多场景群养猪只行为识别模型研究[J]. 农业机械学报,2024,55(10):306-317. DOI: 10.6041/j.issn.1000-1298.2024.10.029

    QI Haixia, FENG Fasheng, YIN Xuanchun, et al. Research of lightweight multi-scene group pig behavior recognition model[J]. Transactions of the Chinese Society for Agricultural Machinery, 2024, 55(10): 306-317. (in Chinese with English abstract) DOI: 10.6041/j.issn.1000-1298.2024.10.029
    [10]
    GAO Y, YAN K, DAI B S, et al. Recognition of aggressive behavior of group-housed pigs based on CNN-GRU hybrid model with spatio-temporal attention mechanism[J]. Computers & Electronics in Agriculture, 2023, 205: 107606.
    [11]
    陆舟,沈明霞,刘龙申,等. 基于轻量化网络与注意力机制的育肥猪采食行为识别方法研究[J]. 南京农业大学学报,2023,46(4):802-812. DOI: 10.7685/jnau.202208023

    LU Zhou, SHEN Mingxia, LIU Longshen, et al. Study on feeding behavior recognition method of fattening pigs based on lightweight networks and attention mechanism[J]. Journal of Nanjing Agricultural University, 2023, 46(4): 802-812. (in Chinese with English abstract) DOI: 10.7685/jnau.202208023
    [12]
    HUANG L, XU L J, WANG Y C, et al. Efficient detection method of pig-posture behavior based on multiple attention mechanism[J]. Computational Intelligence and Neuroscience, 2022, 2022(1): 1759542.
    [13]
    ZHANG Y, YANG X, LIU Y, et al. A time-series neural network for pig feeding behavior recognition and dangerous detection from videos[J]. Computers and Electronics in Agriculture, 2024, 218: 108710. DOI: 10.1016/j.compag.2024.108710
    [14]
    李艳文,李菊霞,纳腾潇,等. 基于YOLOX-NGS的群养猪只攻击行为识别[J]. 农业工程学报,2023,39(24):177-184. DOI: 10.11975/j.issn.1002-6819.202308132

    LI Yanwen, LI Juxia, NA Tengxiao, et al. Recognizing attack behavior of herd pigs using improved YOLOX[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2023, 39(24): 177-184. (in Chinese with English abstract) DOI: 10.11975/j.issn.1002-6819.202308132
    [15]
    王亚彬,徐爱俊,周素茵,等. 基于Byte的生猪多目标跟踪算法[J]. 农业工程学报,2025,41(7):145-155. DOI: 10.11975/j.issn.1002-6819.202410150

    WANG Yabin, XU Aijun, ZHOU Suyin, et al. Multi-object tracking of pig behavior using byte algorithm[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2025, 41(7): 145-155. (in Chinese with English abstract) DOI: 10.11975/j.issn.1002-6819.202410150
    [16]
    林华浦,张凯,李浩,等. 基于多尺度融合注意力机制的群猪检测方法[J]. 农业工程学报,2023,39(21):188-195. DOI: 10.11975/j.issn.1002-6819.202306166

    LIN Huapu, ZHANG Kai, LI Hao, et al. Detecting herd pigs using multi-scale fusion attention mechanism[J]. Transactions of the Chinese Society of Agricultural Engineering (Transactions of the CSAE), 2023, 39(21): 188-195. (in Chinese with English abstract) DOI: 10.11975/j.issn.1002-6819.202306166
    [17]
    张伟,沈明霞,刘龙申,等. 基于CenterNet搭配优化DeepSORT算法的断奶仔猪目标跟踪方法研究[J]. 南京农业大学学报,2021,44(5):973-981.

    ZHANG Wei, SHEN Mingxia, LIU Longshen, et al. Research on weaned piglet target tracking method based on CenterNet collocation optimized DeepSORT algorithm[J]. Journal of Nanjing Agricultural University, 2021, 44(5): 973-981. (in Chinese with English abstract)
    [18]
    QI L, JIANG L, LIU S, et al. Amodal instance segmentation with kins dataset[C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Long Beach, CA, USA: IEEE, 2019: 3014-3023.
    [19]
    HUANG E, HE Z, MAO A, et al. A semi-supervised generative adversarial network for amodal instance segmentation of piglets in farrowing pens[J]. Computers and Electronics in Agriculture, 2023, 209: 107839. DOI: 10.1016/j.compag.2023.107839
    [20]
    CECILIE K, JUUL L P, VESTBJERG L M L. Behavioural characteristics of fatal piglet crushing events under outdoor conditions[J]. Livestock Science, 2023, 268: 105164. DOI: 10.1016/j.livsci.2023.105164
    [21]
    HUANG X, YAN H, WANG T, et al. Effects of the maternal behavioral characteristics of lying down on piglet crushing in Minpig and Yorkshire sows[J]. Applied Animal Behaviour Science, 2021, 240: 105357. DOI: 10.1016/j.applanim.2021.105357
    [22]
    WEARY D M, PHILLIPS P A, PAJOR E A, et al. Crushing of piglets by sows: Effects of litter features, pen features and sow behaviour[J]. Applied Animal Behaviour Science, 1998, 61(2): 103-111. DOI: 10.1016/S0168-1591(98)00187-7
    [23]
    JARVIS S, D'EATH R B, FUJITA K. Consistency of piglet crushing by sows[J]. Animal Welfare, 2005, 14(1): 43-51. DOI: 10.1017/S0962728600028918
    [24]
    KE L, TAI Y W, TANG C K. Deep occlusion-aware instance segmentation with overlapping bilayers[C]// Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Virtual: IEEE, 2021: 4019-4028.
    [25]
    HU Y, WANG J, WANG X, et al. Efficient virtual-to-real dataset synthesis for amodal instance segmentation of occlusion-aware rockfill material gradation detection[J]. Expert Systems with Applications, 2024, 238: 122046. DOI: 10.1016/j.eswa.2023.122046
    [26]
    HAN D, PAN X, HAN Y, et al. Flatten transformer: Vision transformer using focused linear attention[C]// Proceedings of the IEEE/CVF International Conference on Computer Vision. Paris, France: ICCV, 2023: 5938-5948.
    [27]
    CHEN L, FU Y, GU L, et al. Frequency-aware feature fusion for dense image prediction[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2024, 46(12): 1-18.
    [28]
    TU S, CAI Y, LIANG Y, et al. Tracking and monitoring of individual pig behavior based on YOLOv5-Byte[J]. Computers and Electronics in Agriculture, 2024, 221: 108997. DOI: 10.1016/j.compag.2024.108997
    [29]
    HE K, GKIOXARI G, DOLLAR P, et al. Mask R-CNN[C]// Proceedings of the IEEE International Conference on Computer Vision. Venice, Italy: IEEE, 2017: 2961-2969.
    [30]
    LEE Y, PARK J. CenterMask: Real-time anchor-free instance segmentation[C]// Proceedings of the IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR). Seattle, WA, USA: IEEE, 2020: 13903-13912.
    [31]
    KE L, DANELLJAN M, LI X, et al. Mask transfiner for high-quality instance segmentation[C]// Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR). New Orleans, LA, USA: IEEE, 2022: 4402-4411.

Catalog

    Article views (5) PDF downloads (0) Cited by()

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return