Abstract:
In dairy-house videos, dairy cow tails are slender, frequently occluded, and easily confused with rails, shadows, and other linear background structures, leading to missed detections, false detections, and inaccurate localization. Such interference becomes more difficult to resolve when multiple cows overlap or when the visible tail shape changes with standing and lying postures. To address these problems, this study proposed an EDEL-YOLO model for automatic detection of tail-raising behavior, using YOLOv11n as the baseline. A dataset containing
2268 images and
3988 annotated tail instances was prepared from dairy-house surveillance videos. The dataset retained standing and lying postures as separate conditions, with raised and lowered tails annotated as four distinct states. Video frames were screened to reduce visually redundant samples while preserving diverse appearances and challenging backgrounds. Four modifications were incorporated: edge pyramid guided fusion (EPGF) combined multiscale edge priors with semantic features; a C2-dynamic statistical spectral (C2-DSS) module integrated token statistics self-attention, DynamicTanh, Mona, and spatial-frequency feature enhancement; CSP-EDLAN replaced C3k2 blocks in the backbone and neck to improve feature aggregation; and a lightweight shared detail-enhanced convolutional detection head (LSDECD) combined shared and differential convolutions for tail localization and classification. Together, these modifications were designed to combine low-level boundary cues, broader contextual information, and local detail enhancement within a unified detector. Ablation and model comparison experiments were conducted using consistent data partitions and evaluation metrics. On the test set, the EDEL-YOLO model achieved 88.77% precision, 82.47% recall, 86.32% mean average precision at an intersection-over-union (IoU) threshold of 0.50, and 54.82% mean average precision averaged over IoU thresholds from 0.50 to 0.95. Compared with YOLOv11n, these metrics increased by 3.45, 3.73, 2.40, and 2.81 percentage points, respectively. Introducing EPGF, C2-DSS, CSP-EDLAN, and LSDECD separately increased mean average precision at the 0.50 threshold from 83.92% to 85.04%, 85.23%, 85.33%, and 85.28%, respectively. At IoU thresholds from 0.50 to 0.95, the corresponding values were 53.86%, 53.92%, 54.19%, and 52.18%, compared with 52.01% for the baseline. Partial combinations showed different performance trade-offs. The complete model achieved the highest precision, recall, and both mean average precision measures among the evaluated ablation configurations. In comparisons with other detectors, its mean average precision across IoU thresholds from 0.50 to 0.95 exceeded Faster R-CNN and Cascade R-CNN by 9.70 and 5.17 percentage points, respectively, and YOLOv5n, YOLOv8n, YOLOv10n, and YOLOv12n by 2.90, 2.72, 2.75, and 2.93 percentage points, respectively. At an IoU threshold of 0.75, the average precision increased from 0.695 without LSDECD to 0.708 with LSDECD. The higher IoU threshold placed stricter demands on bounding-box alignment, allowing the contribution of the detection head to be examined beyond basic target identification. The proposed model required 10.1 billion floating-point operations and contained 3.14 million parameters, compared with 6.5 billion operations and 2.62 million parameters for YOLOv11n, indicating additional computational requirements. Gradient-weighted class activation mapping (Grad-CAM) visualizations of five representative scenes showed more concentrated feature responses around cow tails and fewer responses to background structures. Qualitative comparisons also showed improved detection in selected scenes involving multiple cows, partial occlusion, distant targets, railing interference, and nighttime glare. However, missed detections remained under motion blur, low illumination, and overlap between tails and railings. These results indicated that the EDEL-YOLO model improved tail-state detection under the evaluated dairy-house conditions, with higher precision, recall, and localization accuracy than the baseline. The proposed model provides a technical basis for automatic monitoring of peripartum tail-raising behavior. Future research will incorporate multiple camera views and temporal features, including tail-raising frequency and duration, to investigate their potential for automated calving warning.