Figures
Abstract
Precise livestock detection is fundamental to smart agriculture; however, real-world environments often present challenges such as high object density, severe occlusion, and ambiguous boundaries. To address feature integrity degradation under such conditions, this paper proposes DOLD-Net: a model for densely occluded livestock detection utilizing global–local feature collaboration. First, this paper develops a Dual-Branch Occlusion-Aware Network (DBOAN) backbone to mitigate feature confusion stemming from object aggregation. The DBOAN models both local gradient flows and global topological structures. By integrating these two aspects, the network preserves fine-grained details while maintaining coherent spatial relationships. To further resolve semantic discontinuities in occluded regions, a Context-Guided Focus Propagation (CGFP) mechanism is designed. The CGFP constructs a global core representation through long-range dependency modeling. This representation propagates discriminative semantic priors in a top-down manner across feature hierarchies. Furthermore, a Frequency–Spatial Anti-occlusion Module (FSAM) decouples entangled representations in the frequency domain to sharpen ambiguous boundaries. Additionally, a Context-Aware Occlusion Fusion Module (CAOFM) compensates for local information loss through adaptive cross-scale feature interactions. Extensive experiments on four public datasets demonstrate that DOLD-Net achieves a superior balance between accuracy and efficiency, attaining AP scores of 57.7%, 67.5%, 52.5%, and 62.5%, respectively. The source code is publicly available at https://github.com/Jiakaida/DOLD-Net.
Citation: Jia K, Chai Y, Chen B, Gao Z (2026) DOLD-Net: Dense occluded livestock detection via global-local feature collaboration. PLoS One 21(8): e0356771. https://doi.org/10.1371/journal.pone.0356771
Editor: Yufeng Zhou, Chongqing Medical University, CHINA
Received: April 29, 2026; Accepted: August 8, 2026; Published: August 25, 2026
Copyright: © 2026 Jia et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Data Availability: The datasets used in this study are publicly available at the following locations: GooseDetect (https://doi.org/10.57760/sciencedb.14382); SheepCounter (https://doi.org/10.34740/kaggle/dsv/18048329); ChickenFlow (https://doi.org/10.34740/kaggle/dsv/18045150); and CherryChèvre (https://doi.org/10.57745/QEZBNA).
Funding: This work was supported by the ESI Disciplines Development Program of Wuhan Polytechnic University (Grant No. 01003009); the Scientific Research Startup Foundation for Introduced (Cultivated) Talents of Wuhan Polytechnic University (Grant No. 2024K2029); and the Open Research Fund (General Project) of Hubei Key Laboratory of Digital Finance Innovation (Grant No. DFIK2025D13). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.
Competing interests: The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.
Introduction
Accurate livestock detection is a pivotal supporting technology within smart agriculture systems, essential for optimizing farm management decisions, disease prevention, early-warning protocols, and resource allocation [1]. Global demand for animal products continues to grow. Meanwhile, increasing societal attention to environmental sustainability and animal welfare standards is reshaping the livestock industry. As a result, the industry is transitioning toward efficient and sustainable intelligent management models. In recent years, computer vision has emerged as a key enabling technology for achieving precise livestock management [2–4]. The vision-based non-contact monitoring paradigm offers significant advantages. Specifically, it effectively mitigates animal stress responses induced by human intervention, thereby improving animal welfare. Furthermore, this approach can be integrated with automated monitoring systems. It enables real-time perception and intelligent decision-making within the production process, thereby significantly improving efficiency and resource utilization.
However, in practical farming scenarios, factors such as dense aggregation, severe inter-individual occlusions, complex backgrounds, and variable postures present significant challenges for robust target detection. Conventional detection methods—including Histogram of Oriented Gradients [5], the Gaussian Mixture Model [6], and Deformable Part Models [7]—primarily relied on handcrafted feature extractors. These approaches struggle to adapt to random appearance variations in complex environments. In addition, they exhibit limited efficacy in handling severe occlusions and densely distributed targets.
In recent years, architectures based on Convolutional Neural Networks (CNNs) and Transformers [8] have yielded substantial advancements in object detection. Prominent frameworks, including two-stage detectors (e.g., the R-CNN series [9]), single-stage detectors (e.g., the YOLO series [10]), and Transformer-based models (e.g., DETR [11]), have significantly advanced livestock detection capabilities. Guo et al. [12] enhanced pig re-identification by using a weighted association algorithm that combines IoU distance with appearance embeddings. Noe et al. [13] proposed an instance segmentation approach based on the Mask R-CNN framework and further incorporated a lightweight object tracking algorithm as a post-processing module to enable automatic detection and continuous tracking of cattle mounting behaviors. Tian et al. [14] proposed GCS-MUL, a lightweight CNN predicated on multi-task learning. The architecture integrates a GhostConv-based backbone with the CBAM attention mechanism. It utilizes a segmentation head to achieve high-precision, real-time detection and semantic segmentation of heterogeneous targets in dairy farms. However, during collective feeding, head occlusions often cause multiple instances to be detected as a single target, thereby increasing the missed detection rate. Mar et al. [15] proposed a vision-based cattle detection and tracking framework that integrates instance segmentation with multi-feature association. By combining spatial location, color, texture, and deep appearance features, this method improves the robustness of multi-cow tracking under complex farm environments. Xiao et al. [16] developed DHSW-YOLO for monitoring duck group behavior, achieving a 94.4% mAP. However, the method was validated only under two fixed lighting conditions and does not consider dynamic natural light variations. Similarly, Guo et al. [3] developed YOLO-SDD, which integrated wavelet-enhanced convolution and an occlusion-aware attention mechanism to achieve an 84.27% AP under dense occlusion. Despite these gains, its high computational complexity precludes efficient deployment on computationally limited edge devices. Furthermore, Li et al. [17] introduced EMSC-DETR, leveraging SDTM and CoT modules for multi-scale chicken detection in complex environments. Although the model shows robust generalization, it still has a high parameter count and computational overhead, limiting its deployment.
Notable progress has been achieved in livestock detection within dense environments. However, substantial challenges still persist. These challenges are particularly evident in scenarios with severe occlusion and dense aggregation. Existing methods often enhance performance by stacking increasingly complex modules. However, this strategy significantly increases model parameters and computational overhead, which hinders large-scale deployment in real-world applications. To balance the trade-off between model complexity and detection accuracy, this paper proposes the Dense Occluded Livestock Detection Network (DOLD-Net). DOLD-Net employs a progressive “global-to-local” refinement paradigm to systematically address challenges arising from occlusion and aggregation. The proposed architecture comprises three tightly coupled stages: the Backbone, Neck, and Head. To facilitate robust feature extraction, this paper develops a Dual-Branch Occlusion-Aware Network (DBOAN). Recognizing that single-view features are insufficient for discriminating crowded objects, the DBOAN establishes a collaborative learning mechanism integrating local gradient flows with global topological modeling. This synergy provides a robust feature foundation that effectively separates overlapping instances during the initial stages of representation learning. To bridge the semantic gaps caused by occlusion, a Context-Guided Focus Propagation (CGFP) framework is designed in the Neck stage. Different from simple feature aggregation, the CGFP injects global semantics to guide local feature restoration. Specifically, a Cross-Scale Feature Enhancer (CSFE) extracts key semantic cues to build a global core prior. This prior provides top-down guidance, enabling the inference of occluded targets using global context. A Frequency–Spatial Anti-occlusion Module (FSAM) is integrated into this propagation pathway to address boundary blurring within dense clusters. The FSAM incorporates frequency-domain analysis to decouple entangled features. This process sharpens distinctions between overlapping objects that may be missed by purely spatial modeling. Finally, to ensure cross-scale feature consistency, this paper proposes a Context-Aware Occlusion Fusion Module (CAOFM). By exploiting contextual complementarity between adjacent feature levels via pairwise interactions, the CAOFM recovers missing feature details. It also repairs spatial discontinuities in the features. To translate these refined features into accurate predictions, the D-FINE [18] architecture is employed as the detection head. The detection head reformulates bounding box regression as an iterative optimization process over probability distributions. It also incorporates global optimal localization self-distillation. This design ensures that enhanced features are mapped to precise bounding boxes with high accuracy and minimal training overhead.
This study validated the effectiveness of DOLD-Net using four publicly available livestock detection datasets. Experimental results showed that DOLD-Net achieved AP scores of 57.7%, 67.5%, 52.2%, and 62.5% on the four datasets, surpassing state-of-the-art methods. Fig 1 compares different models in terms of parameter count, computational cost, and model accuracy. Meanwhile, the N variant achieves a lightweight design with only 6.9 GFLOPs and 3.4 M parameters. It maintains competitive performance, demonstrating significant potential for practical application.
(a) Model Parameters. (b) Computational Cost (FLOPs).
Materials and methods
Dataset
To validate the effectiveness of the DOLD-Net in handling occlusion and dense targets, this work conducted extensive experimental evaluations across four public datasets: GooseDetect [19], SheepCounter, CherryChèvre [20], and ChickenFlow [3]. These datasets encompass diverse challenges, including varying scenes, lighting conditions, and livestock species. They facilitate a comprehensive assessment of the model’s robustness and generalization capabilities for dense occlusion livestock detection.
The GooseDetect dataset consists of two subsets: one containing only adult geese () and the other focusing on goslings (
). This dataset is characterized by severe occlusion and high-density environments. Daytime and nighttime lighting variations further pose challenges to accurate detection. The SheepCounter dataset was collected from an aerial perspective using UAVs. Occlusion is relatively moderate in this dataset. Nevertheless, the top-down perspective produces many small targets, which requires the model to perform precise small object detection. Moreover, the ChickenFlow dataset presents severe occlusion and density-related problems. Rapid movement of chickens introduces motion blur, further increasing detection challenges. In contrast, the CherryChèvre dataset features moderate occlusion. It also exhibits significant environmental variability. This variability includes domain shifts between indoor and outdoor scenes, complex backgrounds, and varying illumination conditions. Additionally, significant variations in coat color among individual goats further augment the detection difficulty. The diversity of these four datasets ensures rigorous validation across a wide range of real-world scenarios.
Model of DOLD-Net
To address the issues of detail loss and semantic discontinuity in dense livestock detection, this paper proposes DOLD-Net. As shown in Fig 2, the model is built upon the principle of collaborative perception and progressive restoration. Specifically, the model aims to mitigate occlusion effects through a three-stage process. First, the DBOAN backbone establishes a robust feature representation by collaboratively encoding local texture details and global topological structures. Second, the CGFP framework serves as the core restoration engine. A global semantic prior is first constructed via CSFE, and the boundaries of occluded objects are subsequently refined in the frequency domain through FSAM. It also repairs cross-scale feature inconsistencies using CAOFM. Finally, the D-FINE head transforms these refined features into precise probability distributions for accurate final detection.
The DBOAN backbone extracts hierarchical multi-scale features (B2–B5), the CGFP integrates and fuses them through the CSFE, FSAM, and CAOFM to generate the feature pyramid (P2–P5), and the Decoder performs object classification and bounding box prediction.
DBOAN
In dense and occluded livestock detection, conventional backbone networks encounter significant limitations. First, livestock typically exhibit strong morphological similarity within the same class. Therefore, differentiating individual boundaries solely through stacked convolutional layers is difficult under dense aggregation. This results in feature confusion. Second, severe occlusion induces significant feature degradation. Consequently, the model must infer complete object structures from fragmented local cues. To address these bottlenecks, this paper proposes the DBOAN architecture. The DBOAN comprises a stem and multiple Double-Branch Occlusion-Aware Blocks (DBOB). In the stem stage, this paper adopts a structure consistent with Hgnetv2 [21] for initial feature extraction. The extracted feature maps are subsequently processed by multiple DBOB to model occlusion structures at different scales. This process generates a multi-scale feature representation. The detailed configuration is shown in Fig 3.
The local branch of the DBOAN partitions the gradient tensor into non-overlapping channels. These feature maps are processed through diverse convolutional blocks. This architecture ensures that each intermediate feature map is supervised by independent gradient signals. Specifically, it establishes n parallel backpropagation pathways extending to the input layer. In this configuration, the direct concatenation path mitigates gradient vanishing, while the pathways through convolutional layers supply additional gradient components. This multi-path gradient flow mechanism facilitates optimization stability and strengthens the discriminative capacity of local representations.
The global branch captures target geometry and spatial relationships, enabling effective separation of densely occluded instances. Although transformers excel at capturing long-range dependencies, they incur high computational complexity. Moreover, in multi-head attention, individual heads frequently learn similar linear projections, resulting in significant redundancy within the attention maps. Cascaded Group Attention (CGA) [22] decomposes the computation of each attention head by feeding distinct feature subsets. This approach effectively mitigates computational redundancy inherent in the multi-head attention mechanism. Additionally, CGA augments the model’s representational capacity by facilitating increased network depth. Consequently, this paper incorporates CGA within the global branch to minimize feature redundancy. The attention formula for this mechanism is given by Eq. (1).
where h represents the total number of heads, and ,
, and
are projection layers that map the input feature segments to different subspaces.
is a linear layer that projects the concatenated output features back to a dimension that matches the input dimension. Furthermore, the cascaded structure encourages the Q, K, and V layers to learn projections on features with richer information, thus enhancing the expressiveness of the attention mechanism. The mathematical expression for this mechanism is given by Eq. (2).
In summary, the DBOAN enhances feature representation in complex occlusion scenarios through the integration of local and global modeling. The local branch facilitates stable extraction of fine-grained details through a multi-path gradient flow mechanism. Concurrently, the global branch employs CGA to reduce computational redundancy by decomposing feature interactions in multi-head attention. This enhances the model’s capacity to capture long-range dependencies and spatial relationships between targets. The synergy of the two branches enables DBOAN to accurately represent and separate densely occluded targets while maintaining computational efficiency.
CGFP
To effectively mitigate semantic fragmentation and detail loss caused by severe occlusion, this paper develops the CGFP framework. Unlike conventional feature aggregation strategies, the CGFP functions as a systematic feature restoration module. Specifically, to mitigate the limited receptive field of local features, the CSFE constructs a comprehensive global core representation. This representation acts as a semantic prior, providing essential global context to the feature pyramid through a top-down propagation mechanism. This enables the model to effectively infer occluded target regions. Subsequently, the FSAM leverages the global context from CSFE and the robust representations from DBOAN to decouple densely adjacent object boundaries through frequency-domain analysis. Finally, the CAOFM is employed to exploit the complementary features provided by adjacent feature maps. By exploiting the inherent complementarity between adjacent feature levels, the CAOFM repairs spatial discontinuities and bridges semantic gaps, thereby yielding robust feature representations for the final prediction stage.
CSFE.
Standard object detectors, such as YOLO and DETR families, predominantly employ FPN-based architectures for multi-level feature fusion. However, this layer-by-layer information propagation paradigm has a critical limitation in dense livestock detection. Specifically, it cannot construct feature representations that capture the global semantic context explicitly. In FPNs, inter-layer interactions are indirect. Moreover, information from distant layers is susceptible to degradation during propagation, which hinders the formation of an effective global receptive field [23]. Due to the absence of a global context, the model must rely on the unoccluded local information to infer targets. However, these unoccluded regions often provide limited cues in densely populated scenes. To address this limitation, this paper proposes the Context-Scale Feature Enhancer (CSFE). Rather than passively aggregating features, the CSFE is designed to actively generate a comprehensive global core feature representation. This unified representation serves as a semantic prior, establishing a strong global contextual foundation that is subsequently injected across all feature scales. By employing a global-to-local reasoning mechanism, CSFE enables the model to infer missing target details when occlusion degrades local features. This inference is guided by the overall contextual distribution of the livestock, which ensures robust perception in challenging scenes. The architecture of the CSFE is shown in Fig 4.
Let be the input set of four feature maps, where
. The first step performs channel mapping and scale alignment across the layers, as shown in Eq. (3).
where denotes a convolution operation with a kernel size of k. These operations unify the spatial size and channel dimension of feature maps across different scales. Subsequently, the aligned feature maps are concatenated as
. To fully leverage the semantic information across different scales, a multi-scale depthwise separable convolution is employed to expand the receptive field of the fused feature
. This operation can be expressed as
. Furthermore, residual connections and
convolutions are applied to enhance feature propagation while further fusing the different features. Finally, a Visual State Space Model (VSSM) [24] is utilized to construct a global core feature representation.
The core mechanism of VSSM is rooted in State Space Models (SSM). Traditionally, SSM are employed to represent linear time-invariant systems [25], effectively mapping one-dimensional input sequences to output sequences via latent hidden states to capture temporal dynamic relationships. Recently, the Mamba architecture [26] has successfully leveraged SSM for long-sequence modeling, demonstrating superior representation capabilities while maintaining linear time complexity.
However, the inherent differences between two-dimensional (2D) visual data and one-dimensional (1D) sequence data hinder the direct application of the Mamba model to visual tasks. Visual tasks rely on 2D spatial information. Due to its limited receptive field, traditional 1D sequence modeling is insufficient for capturing latent dependencies in the spatial domain. To address this issue, the Visual State Space Model (VSSM) [24] introduces a two dimensional selective scanning mechanism (SS2D) as its core module, and Fig 5 shows its architecture. SS2D first extends the image blocks in four directions to generate four independent sequences. This multi-directional scanning strategy allows each element in the feature map to integrate global information from different directions. In this way, a global receptive field is constructed while maintaining linear computational complexity. After processing by the Selective Scanning State Space Model (S6), the feature sequences are merged back into a 2D feature map via a scanning merge operation, enabling effective visual modeling. The output features of SS2D are given by the Eq. (4).
where represents one of the four scanning directions, and the functions expand() and merge() correspond to the scanning expansion and scanning merge operations, respectively. The S6 block is the core VSSM operator in SS2D, facilitating interactions between each element and any previously scanned sample through a hidden state.
Image sourced from [20] under the French Open License 2.0 license.
FSAM.
Following global semantic injection by the CSFE, an unresolved challenge remains: spatial feature entanglement. In high-density regions, adjacent livestock often exhibit ambiguous boundaries and similar texture. This characteristic limits the ability of spatial convolutions to discriminate between individual instances. To address this limitation, the FSAM is proposed to enhance boundary delineation and feature separation through a dual-domain analysis strategy, as shown in Fig 6. Specifically, the frequency-decoupling branch integrates discrete wavelet transforms with the VSSM to extract high-frequency edge information while preserving contextual consistency. Concurrently, the spatial branch leverages local convolutions to retain fine-grained details. Meanwhile, the redundancy-control branch employs identity mapping to preserve feature integrity. This design also helps minimize computational overhead. This multi-branch architecture separates densely occluded targets for precise detection.
The long-range wavelet transformation enhances VSSM by effectively distinguishing the boundaries of tightly adjacent individuals. The wavelet transform decomposes the features into low-frequency and high-frequency components. Among different wavelet families, the Haar wavelet is adopted because its shortest support preserves sharp local intensity transitions with minimal smoothing, making it more suitable for maintaining object boundaries in densely occluded livestock scenes than higher-order wavelets. The low-frequency component preserves the overall spatial layout and structural information of the livestock distribution, whereas the high-frequency component captures fine-grained boundary details. At the same time, VSSM is used to learn the global information representation. For the input feature map , where
represents the channel scaling factor, it is first transformed to obtain the feature map
. In the FSAM module, the Haar wavelet transform first decomposes the input feature into one low-frequency sub-band
and three high-frequency sub-bands, namely
,
, and
. These high-frequency sub-bands explicitly capture horizontal, vertical, and diagonal structural details. These four sub-bands are concatenated along the channel dimension to form
. Subsequently, a convolution is introduced for spatial modeling and feature fusion. To explicitly prioritize boundary sharpening, an independent, learnable channel-wise scaling factor
is applied to adaptively recalibrate the response of each channel. Finally, the feature map is restored to its original spatial resolution through the Inverse Wavelet Transform (IWT), yielding
, as shown in Eq. (5).
where denotes concatenation along the channel dimension, ⊙ represents element-wise multiplication along the channel dimension, and
is the learnable scaling vector.
Similarly, for the feature map , VSSM is used to extract global information, i.e.,
. The final output feature map of this part is obtained by adding the output of the VSSM module to the output of the local information branch, as shown in Eq. (6). The resulting feature map is denoted as
.
The cascade of local convolution blocks enhances the ability to extract local features. The remaining feature map , where
, is processed through multiple cascaded convolutional blocks for local feature extraction. Finally, the outputs from each convolutional block are concatenated to produce the output feature map
, as shown in Eq. (7)
Finally, to address feature redundancy in high dimensional space, the residual part adopts identity mapping in this work. This approach minimizes unnecessary computational overhead while enhancing computational efficiency. Therefore, the final output of the FSAM module can be represented as shown in Eq. (8).
The FSAM utilizes a three-branch parallel architecture to facilitate deep synergy between the frequency and spatial domains. The wavelet-enhanced VSSM branch sharpens ambiguous boundaries of overlapping targets through frequency-domain decomposition. This design overcomes the limitations of spatial convolutions. Concurrently, the local convolution and identity mapping branches retain fine-grained details while preserving feature consistency. This multi-domain design separates dense clusters into separable instances, generating boundary-aware features for fusion while maintaining computational efficiency.
CAOFM.
Considering that adjacent feature maps provide complementary information, the CAOFM is designed to further enhance the boundary discrimination performed by the FSAM, as shown in Fig 7. Conventional architectures like FPN or PAN rely on top-down or bottom-up propagation. However, indirect information transfer across multiple intermediate layers can cause feature misalignment. This often results in the loss of small and occluded targets during scale transformations. In contrast, the CAOFM emphasizes fully leveraging the strong complementarity among adjacent feature maps instead of focusing on long-range fusion. The CAOFM leverages the extensive overlap of receptive fields across adjacent layers. Through pairwise interactions, the module effectively leverages the complementary information of adjacent feature maps. Consequently, this mechanism maintains the semantic integrity of high-density instances before the prediction stage.
Specifically, the feature maps of different scales are unified to the same spatial dimensions, denoted as . CAOFM first models the dependency features between channel and spatial attention adaptively. The spatial attention is generated by concatenating the average pooling and max pooling features, as shown in Eq. (9).
The channel attention captures the dependencies between channels through global average pooling and MLP, as shown in Eq. (10).
where GAP denotes global average pooling, Concat denotes channel-wise concatenation, and Linear represents a fully connected layer. and
denote the Sigmoid and ReLU activation functions, respectively.
Subsequently, the two types of attention are fused using a learnable factor B to dynamically balance their contributions. Finally, cross-scale feature interaction is achieved through weighted addition and concatenation operations, as shown in Eq. (11).
This module effectively fuses complementary information across multiple scales by adaptively integrating spatial and channel-wise attention, thereby mitigating feature misalignment. Additionally, for severely occluded livestock, the module recovers missing feature representations by leveraging information from adjacent scales, thereby enhancing detection performance.
Experiments
Experimental setup
In this study, model training was conducted on a server equipped with an NVIDIA GeForce RTX 3090 GPU. The training environment uses CUDA 11.8 and Python 3.10. The AdamW optimizer was used with a default learning rate of 0.0008, weight decay, and a batch size of 8, training for a total of 160 epochs. Three different versions of DOLD-Net were designed: DOLD-Net-N (lightweight version), DOLD-Net-S (small-scale version), and DOLD-Net-M (medium-scale version). These variants differ in model size and computational complexity to suit different application scenarios. Specifically, DOLD-Net-N is designed for resource-constrained environments, DOLD-Net-S achieves a balance between model accuracy and size, and the DOLD-Net-M is suitable for scenarios with higher accuracy requirements. The Average Precision (AP) metric from the COCO evaluation framework [27] was chosen as the primary performance evaluation metric in this study.
Experimental results
Table 1 presents a performance comparison of different models on the dataset. Compared with D-FINE, the proposed DOLD-Net improves AP by 1.0%, 1.2%, and 1.8% for the N, S, and M variants, respectively. It also reduces the number of parameters by 8%, 16%, and 13%, and lowers the computational cost by 2%, 10%, and 7%. These results indicate that DOLD-Net substantially reduces model complexity while enhancing detection performance. Comparison with the YOLO series, DOLD-Net also demonstrates strong performance. Specifically, DOLD-Net-N achieves a 2.0% AP improvement over YOLOv8 while reducing computational cost by 21%. DOLD-Net-S improves AP by 3.4% compared with YOLOv9-S and reduces computational cost by 17%. DOLD-Net-M achieves a 2.0% higher AP than YOLOv12-M while reducing computational cost by 23% and the number of parameters by 18%. This improvement can be attributed to the CGFP module, which minimizes computational overhead while enhancing detection capability for densely occluded livestock. These results further validate the effectiveness of DOLD-Net for dense occlusion livestock detection.
Table 2 presents the quantitative results on the subset, while Table 3 illustrates the model performance on the CherryChèvre dataset. DOLD-Net achieves outstanding performance on both datasets. Specifically, DOLD-Net-N, DOLD-Net-S, and DOLD-Net-M achieve AP improvements of 1.2%, 3.9%, and 7.2% over DEIM on the
subset, respectively.
Table 4 reports the performance comparison of different models on the SheepCounter dataset, while Table 5 presents the corresponding results on the ChickenFlow dataset. DOLD-Net achieves outstanding performance on both datasets. Specifically, on the SheepCounter dataset, DOLD-Net-N, DOLD-Net-S, and DOLD-Net-M achieve AP gains of 0.8%, 0.5%, and 1.2% over DEIM, respectively. On the ChickenFlow dataset, DOLD-Net-N and DOLD-Net-S achieve AP improvements of 0.8% over DEIM. Overall, these experimental results demonstrate the strong generalization ability and robustness of DOLD-Net across different livestock species, occlusion levels, and environmental conditions, highlighting its effectiveness in a wide range of livestock detection tasks.
Ablation experiment
To validate the effectiveness of each module proposed in this paper for livestock detection under dense occlusion, this section conducts detailed ablation experiments on each module. Furthermore, a detailed analysis and comparison of the design components within each module are provided. Table 6 presents the ablation results of the individual modules across different datasets. First, the Dual-Branch Occlusion-Aware Network (DBOAN) improves AP across all datasets consistently. This suggests that local convolutions are inadequate for processing densely distributed targets during the early stages of feature extraction. In contrast, the dual-branch mechanism establishes a robust feature representation that incorporates global topological information. Notably, these improvements are achieved with only a negligible increase in the number of parameters. Moreover, the Context-Guided Focus Propagation (CGFP) framework improves AP and decreases both parameter count and computational cost. These results indicate that constructing a global semantic prior effectively compensates for missing information in multi-scale features while improving efficiency.
To further investigate the effectiveness of the individual components within the CGFP module, a systematic ablation study was conducted (Table 7). The results demonstrate that the Cross-Scale Feature Enhancer (CSFE) module plays a primary role in enhancing detection precision; specifically, the AP increased from 49.0% to 51.1% on the dataset and by 0.6% on the CherryChèvre dataset. This improvement is attributed to the integration of global semantic priors via the CSFE, which compensates for the limitations of local feature representation and enhances model robustness in complex scenarios. Notably, the model achieves optimal performance when CSFE, FSAM, and CAOFM are integrated, validating the complementarity and synergistic potential of the sub-modules in boosting overall detection capability.
To investigate the impact of kernel sizes within the CSFE module on model performance, this paper conducted ablation experiments as shown in Table 8. The experimental results demonstrate that using fixed-size kernel sequences leads to varying degrees of performance degradation compared to the multi-scale kernel combination (5, 7, 9, 11). Single-scale kernels struggle to capture cross-scale spatial information within feature maps. This shortcoming limits the construction of global core priors. Ultimately, it weakens the model’s capacity to leverage global context for effective object detection.
To further investigate the impact of different propagation counts and locations on model performance in CGFP, an ablation study of the propagation strategy was conducted. Table 9 presents the effects of varying propagation counts and locations on model performance. Specifically, “First Propagation” refers to the propagation operation applied after the backbone, “Second Propagation” denotes the propagation operation inserted after the CAOFM module. The results show that both propagation stages effectively improve model performance on the SheepCounter and datasets. This improvement arises from the first propagation, which injects global contextual information into multi-scale feature maps. Consequently, the model better identifies targets under densely occluded conditions. In contrast, the second propagation further refines the feature representations derived from the first stage. This demonstrates the effectiveness of multi-stage propagation in capturing and exploiting global contextual information. Furthermore, the impact of employing three propagation stages on model performance was also examined. However, the experimental results indicate that increasing the number of propagations does not lead to significant improvement. In fact, it may lead to performance stagnation or even degradation. This phenomenon stems from redundant feature accumulation due to excessive propagation, which degrades learning efficiency and generalization. In conclusion, the proposed dual-propagation mechanism demonstrates clear advantages in dense occlusion livestock detection tasks, improving overall detection performance effectively.
To verify the effectiveness of the proposed Context-Aware Occlusion Fusion Module (CAOFM) in handling dense occlusion, this study compares CAOFM with several alternative fusion strategies. The performance of each fusion method is presented in Table 10. The results show that CAOFM outperforms all other fusion methods, demonstrating its effectiveness in capturing complex features under densely occluded conditions. These experiments further confirm that the proposed fusion approach improves model performance, particularly in scenarios involving severe occlusion.
Moreover, to verify the effectiveness of the proposed Frequency-Spatial Anti-occlusion Module (FSAM) module in addressing dense occlusion, this study conducts comparative experiments between FSAM and several commonly used feature extraction modules. Table 11 compares the performance of different feature extraction modules. The comparison results show that the FSAM module has a clear advantage in extracting information related to occluded regions, especially under dense occlusion. Under such conditions, it captures critical information from occluded targets more effectively. The global–local feature extraction mechanism of FSAM enhances the model’s ability to distinguish objects in complex environments. This leads to improved performance on densely occluded detection tasks.
To further justify the choice of the Haar wavelet in the FSAM module, we compared it with several higher-order orthogonal wavelets, including db2, db4, and db8, on the dataset. As shown in Table 12, the Haar wavelet achieves the best detection performance with the lowest computational cost. Owing to its compact support, Haar provides accurate spatial localization and preserves sharp object boundaries. In contrast, higher-order Daubechies wavelets have broader support regions. This often causes excessive smoothing and feature leakage between neighboring instances in densely populated scenes. Consequently, the overall performance degrades. Among them, db4 performs better than db2 and db8 because its increased vanishing moments enhance local texture representation and partially alleviate boundary blurring. However, the larger support width of db8 leads to more severe inter-object feature contamination, outweighing the benefits of its richer frequency representation and consequently reducing detection accuracy.
To assess the core CSFE operator, VSSM was replaced with the Transformer’s Multi-Head Self-Attention (MHSA) module. As shown in Table 13, the Transformer variant exhibited a performance decline. The experiment indicates that they remain susceptible to interference from background noise in dense scenarios. In contrast, VSSM effectively highlights target regions and mitigates feature loss caused by occlusion via dynamic context modeling. Furthermore, the Transformer still surpasses other comparative models, thereby validating the effectiveness of the proposed global core feature construction and propagation mechanism.
Visualization analysis
To evaluate detection performance for densely occluded livestock qualitatively, Fig 8 shows the results of YOLO series models and DETR-based models on different datasets. It can be observed that all models are able to accurately detect the targets, whereas in densely occluded areas, a large number of missed and false detections occur. Compared with existing methods, DOLD-Net achieves the lowest miss and false detection rates. The remaining false detections mainly occur in regions where object boundaries are ambiguous and heavily occluded. This indicates that the proposed method is overall significantly superior to existing state-of-the-art methods. It also demonstrates strong capability in livestock detection under dense occlusion.
Green boxes denote correctly detected targets (TP), red boxes denote falsely detected targets (FP), and blue boxes denote missed targets (FN). Images in rows 1, 4, 5 and 8 sourced from [19], available under the CC0 public domain dedication. Images in rows 2 and 6 sourced from [43] under the CC BY 4.0 license. Images in rows 3 and 7 sourced from [3] under the CC BY 4.0 license.
This study employs heatmaps to perform a visual analysis of the model’s attention regions. Fig 9 compares the original images with heatmaps generated by the DEIM and DOLD-Net models across different datasets. The heatmaps of DOLD-Net show concentrated activations within target regions, particularly on discriminative areas such as the heads of geese. This focus enables DOLD-Net to more effectively distinguish individual animals under dense occlusion. In contrast, the heatmaps of the DEIM model exhibit more dispersed activations within the target regions. It also fails to maintain sufficient focus on certain individuals. As a result, this limitation may lead to missed detections or false positives. Overall, the heatmap analysis further validates the advantages of DOLD-Net for livestock detection under dense occlusion. By focusing on critical discriminative regions, the model effectively enhances detection performance.
Warmer colors indicate stronger model responses or attention, whereas cooler colors indicate weaker responses. Images in rows 1, 2 and 3 sourced from [19], available under the CC0 public domain dedication. Images in rows 4 sourced from [3] under a CC BY 4.0 license. Images in rows 5 and 6 sourced from [43] under the CC BY 4.0 license.
Moreover, to assess the effectiveness of the global representations learned by the proposed CSFE in dense-occlusion livestock detection, a heatmap-based comparison is performed. Feature maps generated with and without CSFE are compared, as shown in Fig 10. The model without CSFE attends to target regions but suffers from substantial noise, which hinders accurate detection. In contrast, the model with CSFE can effectively guide the network to focus on target regions using the encoded global contextual information. It also significantly suppresses background noise. Consequently, the model is able to learn the feature representations of individual animals more accurately. This further validates the effectiveness of CSFE in improving performance on dense-occlusion livestock detection tasks.
Image sourced from [19], available under the CC0 public domain dedication.
Conclusions and discussion
This study proposes DOLD-Net, an efficient detection framework. The framework is tailored to tackle the challenges of high density, severe occlusion, and ambiguous boundaries in livestock monitoring. DOLD-Net adopts a “global-local” feature collaboration paradigm to systematically reduce feature degradation in complex environments. Specifically, the Dual-Branch Occlusion-Aware Network (DBOAN) serves as a robust backbone by jointly modeling local gradient flows and global topological structures to separate adhered individuals.Furthermore, the Context-Guided Focus Propagation (CGFP) mechanism leverages the VSSM to construct global semantic priors, inferring occluded regions via top-down propagation. To resolve feature entanglement, the Frequency-Spatial Anti-occlusion Module(FSAM) decouples features in the frequency domain to sharpen blurred boundaries. Meanwhile, the Context-Aware Occlusion Fusion Module (CAOFM) bridges semantic gaps by exploiting cross-scale complementarity.
Extensive experiments on four public datasets demonstrate that DOLD-Net achieves a superior balance between accuracy, parameter efficiency, and computational cost. Compared with state-of-the-art methods such as YOLO-v12 and D-FINE, DOLD-Net exhibits stronger robustness and generalization capabilities.
Although the proposed model achieves promising detection performance, several limitations remain. Large pose variations pose a challenge to the model and can adversely affect feature representation. Consequently, false positive predictions may occur, as shown in Fig 11. The goose undergoes large-amplitude wing movements. This results in substantial appearance changes in the upper-right region. Such variations mislead the model and cause the moving wing area to be mistakenly detected as a separate goose instance. Extreme pose variations disrupt the original global topological structure of livestock targets. This disruption causes them to deviate from the typical shape distribution learned by the model during training. SSM captures long-range dependencies by recursively propagating historical information through the hidden state . Under regular livestock poses, semantic sequences generated by different scanning directions exhibit high semantic consistency. Therefore, SS2D can effectively learn stable state-transition patterns and establish a global semantic prior.
Image sourced from [19], available under the CC0 public domain dedication.
However, extreme pose variations introduce significant non-rigid deformations to the target’s spatial structure. As shown in Fig 12, SS2D learns stable state-transition patterns from the semantic order of the head, torso, and limbs under normal poses. Large pose changes disrupt this semantic order, causing a mismatch between the learned transitions and the input sequence. As a result, the CSFE module fails to effectively aggregate global contextual information, weakening global semantic modeling and leading to erroneous predictions.
Image sourced from [19], available under the CC0 public domain dedication.
Future work targets two directions: optimizing model inference efficiency and embedding skeletal geometric priors to model inter-instance topological correlations. Training corpus will be augmented with extreme pose deformation samples to enrich intra-class diversity, strengthen out-of-distribution robustness, and boost generalization against severe morphological perturbations.
References
- 1. Frost AR, Schofield CP, Beaulah SA, Mottram TT, Lines JA, Wathes CM. A review of livestock monitoring and the need for integrated systems. Computers and Electronics in Agriculture. 1997;17(2):139–59.
- 2. Wang H, Zhao R. Knowledge graph of agricultural engineering technology based on large language model. Displays. 2024;85:102820.
- 3. Guo Y, Wu Z, You B, Chen L, Zhao J, Li X. YOLO-SDD: An Effective Single-Class Detection Method for Dense Livestock Production. Animals (Basel). 2025;15(9):1205. pmid:40362020
- 4. Wang J, Zhai Y, Zhu L, Xu L, Yuan H. PD-YOLO: A study of daily behavioural detection in housed sheep. PLoS One. 2024;19(11):e0313412. pmid:39509440
- 5.
Dalal N, Triggs B. Histograms of Oriented Gradients for Human Detection. In: 2005 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR’05). 886–93. https://doi.org/10.1109/cvpr.2005.177
- 6.
Stauffer C, Grimson WEL. Adaptive background mixture models for real-time tracking. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, 1999. 246–52. https://doi.org/10.1109/CVPR.1999.784637
- 7.
Felzenszwalb P, McAllester D, Ramanan D. A discriminatively trained, multiscale, deformable part model. In: 2008 IEEE Conference on Computer Vision and Pattern Recognition, 2008. 1–8. https://doi.org/10.1109/cvpr.2008.4587597
- 8.
Vaswani A, Shazeer N, Parmar N, Uszkoreit J, Jones L, Gomez AN, et al. Attention is all you need. In: Proceedings of the International Conference on Neural Information Processing Systems, 2017. 6000–10. https://doi.org/10.5555/3295222.3295349
- 9.
Girshick R, Donahue J, Darrell T, Malik J. Rich Feature Hierarchies for Accurate Object Detection and Semantic Segmentation. In: 2014 IEEE Conference on Computer Vision and Pattern Recognition, 2014. 580–7. https://doi.org/10.1109/cvpr.2014.81
- 10.
Wang A, Chen H, Liu L, Chen K, Lin Z, Han J, et al. YOLOv10: Real-Time End-to-End Object Detection. In: Advances in Neural Information Processing Systems 37, 2024. 107984–8011. https://doi.org/10.52202/079017-3429
- 11.
Carion N, Massa F, Synnaeve G, Usunier N, Kirillov A, Zagoruyko S. End-to-End Object Detection with Transformers. Lecture Notes in Computer Science. Springer International Publishing. 2020. 213–29. https://doi.org/10.1007/978-3-030-58452-8_13
- 12. Guo Q, Sun Y, Orsini C, Bolhuis JE, de Vlieg J, Bijma P, et al. Enhanced camera-based individual pig detection and tracking for smart pig farms. Computers and Electronics in Agriculture. 2023;211:108009.
- 13.
Myat Noe S, Zin TT, Tin P, Kobayashi I. Automatic detection and tracking of mounting behavior in cattle using a deep learning-based instance segmentation model. International Journal of Innovative Computing, Information and Control. 2022;:211–20. https://doi.org/10.24507/ijicic.18.01.211
- 14. Tian F, Hu G, Yu S, Wang R, Song Z, Yan Y, et al. An efficient multi-task convolutional neural network for dairy farm object detection and segmentation. Computers and Electronics in Agriculture. 2023;211:108000.
- 15. Mar CC, Zin TT, Tin P, Honkawa K, Kobayashi I, Horii Y. Cow detection and tracking system utilizing multi-feature tracking algorithm. Sci Rep. 2023;13(1):17423. pmid:37833436
- 16. Xiao D, Wang H, Liu Y, Li W, Li H. DHSW-YOLO: A duck flock daily behavior recognition model adaptable to bright and dark conditions. Computers and Electronics in Agriculture. 2024;225:109281.
- 17. Li X, Cai M, Tan X, Yin C, Chen W, Liu Z, et al. An efficient transformer network for detecting multi-scale chicken in complex free-range farming environments via improved RT-DETR. Computers and Electronics in Agriculture. 2024;224:109160.
- 18.
Peng Y, Li H, Wu P, Zhang Y, Sun X, Wu F. D-FINE: Redefine Regression Task in DETRs as Fine-grained Distribution Refinement. In: 2024. https://arxiv.org/abs/2410.13842
- 19. Feng Y, Li W, Guo Y, Wang Y, Tang S, Yuan Y, et al. GooseDetectlion: A Fully Annotated Dataset for Lion-head Goose Detection in Smart Farms. Sci Data. 2024;11(1):980. pmid:39244605
- 20. Vayssade J-A, Arquet R, Troupe W, Bonneau M. CherryChèvre: A fine-grained dataset for goat detection in natural environments. Sci Data. 2023;10(1):689. pmid:37821512
- 21.
Chen Z, Tang C, Xiong L. HGNET: A Hierarchical Feature Guided Network for Occupancy Flow Field Prediction. ArXiv preprint. 2024. https://arxiv.org/abs/2407.01097
- 22.
Liu X, Peng H, Zheng N, Yang Y, Hu H, Yuan Y. EfficientViT: Memory Efficient Vision Transformer with Cascaded Group Attention. In: 2023 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2023. 14420–30. https://doi.org/10.1109/cvpr52729.2023.01386
- 23.
Wang C, He W, Nie Y, Guo J, Liu C, Wang Y, et al. Gold-YOLO: Efficient Object Detector via Gather-and-Distribute Mechanism. In: Advances in Neural Information Processing Systems 36, 2023. 51094–112. https://doi.org/10.52202/075280-2224
- 24.
Liu Y, Tian Y, Zhao Y, Yu H, Xie L, Wang Y, et al. VMamba: Visual State Space Model. In: Advances in Neural Information Processing Systems 37, 2024. 103031–63. https://doi.org/10.52202/079017-3273
- 25. Zhao S, Chen H, Zhang X, Xiao P, Bai L, Ouyang W. RS-Mamba for Large Remote Sensing Image Dense Prediction. IEEE Trans Geosci Remote Sensing. 2024;62:1–14.
- 26.
Gu A, Dao T. Mamba: Linear-Time Sequence Modeling with Selective State Spaces. In: 2024. https://arxiv.org/abs/2312.00752
- 27.
Lin T-Y, Maire M, Belongie S, Hays J, Perona P, Ramanan D, et al. Microsoft COCO: Common Objects in Context. Lecture Notes in Computer Science. Springer International Publishing. 2014. p. 740–55. https://doi.org/10.1007/978-3-319-10602-1_48
- 28.
Varghese R, M S. YOLOv8: A Novel Object Detection Algorithm with Enhanced Performance and Robustness. In: Proceedings of the International Conference on Advances in Data Engineering and Intelligent Computing Systems, 2024. 1–6. https://doi.org/10.1109/ADICS58448.2024.10533619
- 29.
Wang CY, Yeh IH, Liao HY. YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information. In: Proceedings of the European Conference on Computer Vision, 2024. 1–21. https://doi.org/10.1007/978-3-031-72751-1_1
- 30.
Khanam R, Hussain M. YOLOv11: An Overview of the Key Architectural Enhancements. ArXiv preprint. 2024. https://arxiv.org/abs/2410.17725
- 31.
Tian Y, Ye Q, Doermann D. YOLOv12: Attention-Centric Real-Time Object Detectors. In: ArXiv preprint, 2025. https://arxiv.org/abs/2502.12524
- 32.
Zhao Y, Lv W, Xu S, Wei J, Wang G, Dang Q, et al. DETRs Beat YOLOs on Real-time Object Detection. In: 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2024. 16965–74. https://doi.org/10.1109/cvpr52733.2024.01605
- 33.
Huang S, Lu Z, Cun X, Yu Y, Zhou X, Shen X. DEIM: DETR with Improved Matching for Fast Convergence. In: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2025. 15162–71. https://doi.org/10.1109/cvpr52734.2025.01412
- 34. Ren S, He K, Girshick R, Sun J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Trans Pattern Anal Mach Intell. 2017;39(6):1137–49. pmid:27295650
- 35.
Lyu C, Zhang W, Huang H, Zhou Y, Wang Y, Liu Y. RTMDet: An empirical study of designing real-time object detectors. ArXiv preprint. 2022. https://arxiv.org/abs/2212.07784
- 36. Xu W, Zheng S, Wang C, Zhang Z, Ren C, Xu R, et al. SAMamba: Adaptive state space modeling with hierarchical vision for infrared small target detection. Information Fusion. 2025;124:103338.
- 37.
Zhang Y, Zhou S, Li H. Depth Information Assisted Collaborative Mutual Promotion Network for Single Image Dehazing. In: 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2024. 2846–55. https://doi.org/10.1109/cvpr52733.2024.00275
- 38.
Zhou Z, He A, Wu Y, Yao R, Xie X, Li T. Spatial-Frequency Dual Domain Attention Network For Medical Image Segmentation. In: 2024 IEEE International Conference on Bioinformatics and Biomedicine (BIBM), 2024. 4076–81. https://doi.org/10.1109/bibm62325.2024.10822613
- 39.
Li W, Guo H, Liu X, Liang K, Hu J, Ma Z, et al. Efficient Face Super-Resolution via Wavelet-based Feature Enhancement Network. In: Proceedings of the 32nd ACM International Conference on Multimedia, 2024. 4515–23. https://doi.org/10.1145/3664647.3681088
- 40.
Wang A, Chen H, Lin Z, Han J, Ding G. Rep ViT: Revisiting Mobile CNN From ViT Perspective. In: 2024 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2024. 15909–20. https://doi.org/10.1109/cvpr52733.2024.01506
- 41.
Feijoo D, Benito JC, Garcia A, Conde MV. DarkIR: Robust Low-Light Image Restoration. In: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2025. 10879–89. https://doi.org/10.1109/cvpr52734.2025.01016
- 42.
He H, Zhang J, Cai Y, Chen H, Hu X, Gan Z, et al. MobileMamba: Lightweight Multi-Receptive Visual Mamba Network. In: 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 2025. 4497–507. https://doi.org/10.1109/cvpr52734.2025.00424
- 43.
Nolan G. SheepCounter Dataset. Roboflow. 2023. https://universe.roboflow.com/tarumt-ozaou/sheep-counting-6tost