Abstract:In automatic monitoring of sow farrowing, the end of parturition is usually determined indirectly by identifying the birth of the last piglet. However, this approach suffers from poor real-time performance, low detection accuracy, and strong susceptibility to occlusion, making it unsuitable for production needs. To address these issues, a farrowing-end detection method that directly identified the placenta was proposed based on an improved YOLO v8s model. By incorporating the Focus module, SE attention mechanism, C2f-SCConv module, and BiFPN-P2 structure, the model was optimized in feature representation, multi-scale information fusion, and lightweight design. Ablation experiments showed that the SE attention mechanism and C2f-SCConv module significantly improved the detection accuracy of small-scale and low-contrast targets, while the BiFPN-P2 structure effectively reduced the number of parameters and computational complexity without sacrificing precision. The improved YOLO v8s model achieved 98. 1% precision, 94. 9% recall, and 98. 8% mAP, with only 7. 33 × 10 6 parameters and an inference speed of 61. 71 f / s. Compared with mainstream models such as NanoDet, RT-DETR, Faster R-CNN, YOLO v5, and the original YOLO v8s, the proposed method achieved the best detection accuracy while maintaining excellent real-time performance. Furthermore, a temporal judgment mechanism based on video frame intervals and frame-level counters was developed to accurately recognize the end of farrowing in real farrowing videos. Under a 25 f interval, the average time error was 5. 98 s, which was further reduced to 1. 84 s at a 5 f interval, significantly improving both timeliness and accuracy. The proposed method overcame the limitations of piglet-based indirect inference and extended from image-level detection to video-level temporal event recognition.