Improved high-density low-pixel sheep detection method under view angle of unmanned aerial vehicle based on YOLOv13 model
By improving the YOLOv13 model, introducing the TokenC3 module and a high-resolution P2 detection branch, and adopting a sparse pruning strategy, the accuracy and efficiency problems of high-density, low-pixel sheep detection in UAV images were solved, achieving efficient real-time detection in complex environments.
Patent Information
- Application Number
- CN202511763788.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-02-24
AI Technical Summary
Existing methods for automatic sheep detection in drone images have low detection accuracy in high-density, low-pixel environments and are difficult to deploy in real time on platforms with limited edge computing resources, especially lacking robustness in complex environments.
An improved YOLOv13 model is adopted, introducing the TokenC3 module and a high-resolution P2 detection branch, and combined with a modular sparse pruning strategy to improve small target detection capabilities and model deployment efficiency.
It significantly improves the detection accuracy and speed of high-density, low-pixel sheep flocks from a high-altitude perspective, making it suitable for real-time edge applications on drones. It also has good generalization ability and computational efficiency.
Smart Images

Figure CN121564587A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision processing technology, and in particular to a method for detecting high-density, low-pixel sheep flocks from the perspective of a drone based on an improved YOLOv13 model. Background Technology
[0002] With the continuous development of modern animal husbandry, precise and efficient animal monitoring methods have become an important direction for improving breeding efficiency and animal welfare management. Sheep, as a widely raised economic animal, directly affect the economic benefits and production management level of farms through their numbers and health status. Traditional sheep flock monitoring and counting methods mainly rely on manual inspections, which are not only labor-intensive and inefficient, but also prone to data errors due to subjective judgment and uncertainties in the on-site environment, making it difficult to meet the needs of large-scale, refined management.
[0003] In recent years, advancements in UAV (Unmanned Aerial Vehicle) technology and the widespread adoption of high-resolution imaging equipment have provided new avenues for automated sheep monitoring in large-scale pastures. By using UAVs equipped with cameras to conduct aerial inspections of pasture areas, large-scale raw image information can be quickly acquired, laying the foundation for subsequent intelligent analysis, data mining, and livestock management decisions. Compared to traditional manual or ground-based monitoring methods, UAV observation technology significantly reduces manpower input, minimizes disturbance to sheep flocks, and offers advantages such as adaptability to complex terrain and remote real-time monitoring.
[0004] However, there are still many challenges in the practical application of automatic sheep detection and counting based on UAV images. First, due to the limitations of the UAV's shooting angle and flight altitude, sheep often appear as small targets in images (i.e., occupying only a very small pixel area in the image), and their dense distribution makes them prone to occlusion and overlap, resulting in unclear target boundaries. Second, complex outdoor environmental factors, such as varying surface textures, lighting conditions, differences in sheep coat color, posture changes, terrain undulations, and background interference from weeds and rocks, further exacerbate the difficulty of target detection and recognition. Existing traditional target detection algorithms and early deep learning models often struggle to balance detection accuracy and computational efficiency when facing these real-world problems, especially on UAV platforms with limited edge computing resources or requiring real-time processing.
[0005] Currently, although some scholars have made some improvements to UAV livestock detection methods, such as optimizing network structure, introducing multi-scale features, improving attention mechanisms to enhance small target detection capabilities, or using image preprocessing and post-processing techniques to reduce environmental interference, problems such as large detection errors, poor robustness to high-altitude and long-distance perspectives, redundant model parameters, and difficulty in real-time deployment still exist. With the accelerating informatization, automation, and intelligentization of animal husbandry, there is an urgent need for a new method for sheep flock detection and monitoring that can be widely adapted to different environments, balances high accuracy and high efficiency, and is suitable for real-time deployment at the edge of UAVs.
[0006] The information disclosed in this background section is intended only to enhance the understanding of the overall background of the invention and should not be construed as an admission or implication in any way that such information constitutes prior art known to those skilled in the art. Summary of the Invention
[0007] The purpose of this invention is to provide a high-density, low-pixel sheep detection method based on the improved YOLOv13 model from the perspective of a drone, thereby solving the problems of difficulty in locating ripe strawberries, easy false alarms, and low detection efficiency caused by the characteristics of strawberry picking.
[0008] To achieve the above objectives, this invention provides a high-density, low-pixel sheep flock detection method based on an improved YOLOv13 model from a UAV perspective, comprising:
[0009] Step 1: Collect original images of the sheep flock and use LabelImg to label the sheep from the drone's perspective;
[0010] Step 2: Improve the YOLOv13 model by proposing the TokenC3 module and introducing a high-resolution P2 detection branch and a modular sparse pruning strategy.
[0011] Step 3: Train and improve the model to obtain high-precision, real-time detection results and generate visualized detection images;
[0012] Step 4: Conduct ablation experiments to gradually verify the effectiveness of each innovative module;
[0013] Step 5: Deploy the model on the embedded platform to visually demonstrate the application effect of this method.
[0014] Preferably, in the above technical solution, the original sheep flock images obtained in step 1 include various sheep breeds, different growth stages, and typical environmental conditions, including different flight altitudes, varying lighting, complex and varied pasture backgrounds, and multiple densities and distributions, to ensure the generalization ability and robustness of the model.
[0015] Preferably, in the above technical solution, step 1 uses LabelImg to label the sheep from the perspective of the drone. Each label box is strictly adjusted to ensure that the ripe strawberries can be completely and accurately selected.
[0016] Preferably, in the above technical solution, step 2, improving the YOLOv13 model, includes:
[0017] F large =Conv 7×7 (X),F small =Conv 3×3 (X)
[0018] F output =Fusion(α·Suppress(F) large ),β·Enhance(F small ))
[0019] W adaptive =σ(Conv 1×1 (ReLU(Conv 1×1 (GAP(X)))))
[0020] Y=CV3(Cat(Bottleneck(LSConv(X)),Conv 1×1 (X)))
[0021] (1) The TokenC3 module is integrated into the backbone and neck structure of YOLOv13. The TokenC3 module adopts a combination of adaptive local context mixing (ALCM) and dual-kernel convolution. It achieves the fusion of local and global features through parallel large kernel (e.g., 7×7) and small kernel (e.g., 3×3) branches, thereby improving the detection capability of small targets such as sheep. This module includes: processing the input feature X with large kernel convolution and small kernel convolution respectively, and fusing the output through specific weights α and β (e.g., α=0.4, β=0.6) to highlight the features of small targets; at the same time, ALCM generates input-dependent convolution weights and dynamically adjusts the local receptive field, thereby improving the discrimination capability in complex backgrounds. The process of this module is represented as follows:
[0022] (2) A high-resolution detection branch, P2, is introduced in YOLOv13. The P2 branch performs small object detection at a resolution of 160×160, providing four times the spatial granularity compared to the traditional P3 branch (e.g., 80×80), thus enhancing the model's ability to locate and classify densely packed small targets like sheep from a high-altitude perspective. The P2 branch also incorporates a top-down semantic enhancement mechanism, utilizing the global semantic information from the high-level P5 branch to assist the feature expression of the low-level high-resolution branch, achieving efficient fusion of semantic and spatial information.
[0023]
[0024] The P2 detection branch achieves effective information interaction and fusion between global and local features through a semantic enhancement mechanism. This semantic enhancement process is implemented by the HyperACE module for cross-scale feature interaction, specifically as follows:
[0025] F enhanced =Hyper ACE([F P3 ,F P4 ,F P5 ])
[0026] Finally, the P2 detection branch employs a semantically guided feature propagation mechanism, enabling high-level semantic information to be effectively transferred to low-level high-resolution features, generating optimized P2 branch feature representations:
[0027]
[0028] (4) A module-aware sparse pruning strategy is adopted, allocating differentiated pruning ratios to different modules in the network structure. For example, a 4% pruning rate is adopted for highly innovative modules such as TokenC3 and HyperACE to maintain model performance; while a 22% pruning rate is adopted for traditional convolutional layers, effectively compressing redundant parameters, reducing the computational and memory overhead of model inference, and enabling efficient real-time deployment of the model on UAV edge computing platforms. The pruning operation is evaluated by the L1 norm of the weights and low-importance weights are selectively removed:
[0029] I(w i,j )=|w i,j |
[0030] Among them, w i,j For the pruning target weights, I(w) i,j The ) indicates the importance of the weights. Pruning is performed according to the following formula:
[0031]
[0032] Preferably, in the above technical solution, step 3 trains the training set of the sheep dataset to obtain the efficient detection model after training of the improved method.
[0033] Preferably, in the above technical solution, step 3 inputs the original sheep image into the trained model to obtain the model's test results, and outputs a predicted image with target prediction boxes and confidence scores.
[0034] Preferably, in the above technical solution, step 4 involves conducting ablation experiments on a sheep dataset, including progressively adding and combining the TokenC3 module, the dual-kernel convolution LSConv module, and the P2 high-resolution detection module for training. The mAP value, efficiency (GFLOPs), and number of parameters for each combination are recorded, and the experimental results are analyzed and compared in detail to optimize the model's accuracy and computational efficiency.
[0035] Preferably, in the above technical solution, step 5 deploys the method on the UAV embedded platform, including using the Jetson Orin NX and RDK S100 platforms, optimizing with TensorRT, and verifying the model's real-time processing capability; and conducting a sheep detection deployment experiment based on the above platform to further verify the feasibility and generalization ability of the model in actual agricultural ranch scenarios.
[0036] (1) This invention is an improved method for detecting high-density, low-pixel sheep from the perspective of a UAV based on the YOLOv13 model. It innovatively proposes the TokenC3 module on top of the original YOLOv13 model, which effectively improves the detection capability for small sheep targets through adaptive local context mixing and dual-kernel convolution. The high-resolution P2 detection branch enhances the model's recognition rate for small targets in high-altitude, dense scenes. The modular sparse pruning strategy ensures deployment efficiency while maintaining detection performance, facilitating real-time application of the model on resource-constrained UAV platforms. Overall, this invention significantly improves the detection accuracy, speed, and generalization ability of sheep targets in UAV pasture scenarios, demonstrating significant practical application value.
[0037] (2) This invention is a high-density, low-pixel sheep flock detection method based on the YOLOv13 model under the perspective of UAV. When this method is deployed on UAV and applied to the real-world livestock automation, the actual effect exceeds the theoretical application. Attached Figure Description
[0038] Figure 1 This is a diagram illustrating the overall architecture of the high-density, low-pixel sheep herd detection method based on the improved YOLOv13 model from the perspective of a drone, according to the present invention.
[0039] Figure 2 This is a diagram of the improved YOLOv13 model framework;
[0040] Figure 3 This is the structure diagram of the added TokenC3 module;
[0041] Figure 4 This is a structural diagram of LSConv, LSBottlenecks, and ALCM in the TokenC3 module;
[0042] Figure 5This is a structural diagram of the improved P2 detection branch module;
[0043] Figure 6 This is a block diagram of the proposed sparse pruning strategy module;
[0044] Figure 7 This is a diagram showing the detection results of the improved method model;
[0045] Figure 8 This is a structural diagram of a drone used for detecting sheep flocks in livestock farming.
[0046] Figure 9 This is a diagram showing the implementation and effects of the improved methods. Detailed Implementation
[0047] The specific embodiments of the present invention will now be described in detail with reference to the accompanying drawings, but it should be understood that the scope of protection of the present invention is not limited to the specific embodiments.
[0048] like Figures 1 to 9 As shown in the figure, a high-density, low-pixel sheep flock detection method based on the YOLOv13 model and an improved version of the UAV perspective according to a specific embodiment of the present invention includes the following steps:
[0049] Step 1: Collect original images of the sheep flock and use LabelImg to label the sheep from the drone's perspective.
[0050] (1) Considering the challenges of using drones to detect sheep at high altitudes, our original sheep images include a variety of sheep breeds, different growth stages, and typical environmental conditions, including different flight altitudes, varying lighting, complex and varied pasture backgrounds, and multiple densities and distributions, to ensure the generalization ability and robustness of the model.
[0051] (2) Regarding the annotation and processing of the original sheep images, we invited three professionals from the sheep animal husbandry industry to use LabelImg to annotate the original sheep images. Under the operation of the professionals, the annotation boxes were strictly adjusted to accurately and completely select the sheep in the images.
[0052] Step 2: Improve the YOLOv13 model by proposing the TokenC3 module and introducing a high-resolution P2 detection branch and a modular sparse pruning strategy.
[0053] (1) The TokenC3 module is integrated into the backbone and neck structure of YOLOv13. The TokenC3 module adopts a combination of adaptive local context mixing (ALCM) and dual-kernel convolution. It achieves the fusion of local and global features through parallel large kernel (e.g., 7×7) and small kernel (e.g., 3×3) branches, thereby improving the detection capability of small targets such as sheep. This module includes: processing the input feature X with large kernel convolution and small kernel convolution respectively, and fusing the output through specific weights α and β (e.g., α=0.4, β=0.6) to highlight the features of small targets; at the same time, ALCM generates input-dependent convolution weights and dynamically adjusts the local receptive field, thereby improving the discrimination capability in complex backgrounds. The process of this module is represented as follows:
[0054] F larget =Conv 7×7 (X),F small =Conv 3×3 (X)
[0055] F output =Fusion(α·Suppress(F) large ),β·Enhance(F small ))
[0056] W adaptive =σ(Conv 1×1 (ReLU(Conv 1×1 (GAP(X)))))
[0057] Y=CV3(Cat(Bottleneck(LSConv(X)),Conv 1×1 (X)))
[0058] (2) A high-resolution detection branch, P2, is introduced in YOLOv13. The P2 branch performs small object detection at a resolution of 160×160, providing four times the spatial granularity compared to the traditional P3 branch (e.g., 80×80), thus enhancing the model's ability to locate and classify densely packed small targets like sheep from a high-altitude perspective. The P2 branch also incorporates a top-down semantic enhancement mechanism, utilizing the global semantic information from the high-level P5 branch to assist the feature expression of the low-level high-resolution branch, achieving efficient fusion of semantic and spatial information.
[0059]
[0060] The P2 detection branch achieves effective information interaction and fusion between global and local features through a semantic enhancement mechanism. This semantic enhancement process is implemented by the HyperACE module for cross-scale feature interaction, specifically as follows:
[0061] F enhanced=HyperACE([F P3 ,F P4 ,F P5 ])
[0062] Finally, the P2 detection branch employs a semantically guided feature propagation mechanism, enabling high-level semantic information to be effectively transferred to low-level high-resolution features, generating optimized P2 branch feature representations:
[0063]
[0064] (3) A module-aware sparse pruning strategy is adopted, allocating differentiated pruning ratios to different modules in the network structure. For example, a 4% pruning rate is adopted for highly innovative modules such as TokenC3 and the globally high-order related modeling module HyperACE to maintain model performance; while a 22% pruning rate is adopted for traditional convolutional layers, effectively compressing redundant parameters, reducing the computational and memory overhead of model inference, and realizing efficient real-time deployment of the model on the UAV edge computing platform. The pruning operation is evaluated by the L1 norm of the weights and low-importance weights are selectively removed:
[0065] I(w i,j )=|w i,j |
[0066] Among them, w i,j For the pruning target weights, I(w) i,j The ) indicates the importance of the weights. Pruning is performed according to the following formula:
[0067]
[0068] Step 3: Train and improve the model to obtain high-precision, real-time detection results and generate visualized detection images.
[0069] During training, the model was trained using the training set from the sheep dataset, while the validation set was used to validate the training process in real time to optimize model performance. Ultimately, a highly efficient YOLOv13 detection model was obtained that combines high accuracy with excellent inference speed in the small-target sheep detection task.
[0070] Step 4: Conduct ablation experiments to progressively verify the effectiveness of each innovative module.
[0071] Ablation experiments were conducted on the modified method to verify the effectiveness of each module and analyze the reasons for its effect. The effectiveness of each module was verified through ablation comparison. Adding the TokenC3 module slightly increased the model's GFLOPs but significantly improved the mAP value, verifying its effectiveness in enhancing the representation of small target features and improving the model's ability to detect sheep in complex environments. Adding the P2 high-resolution detection branch resulted in a smaller increase in GFLOPs but a significant improvement in the mAP value, demonstrating the importance of this module in high-altitude small target detection and its contribution to refined spatial resolution. Adopting a module-aware sparse pruning strategy significantly reduced the model's GFLOPs while maintaining a high mAP value, verifying the strategy's ability to optimize computational efficiency and making the model practically deployable and efficient on resource-constrained embedded platforms.
[0072] Step 5: Deploy the method and visualize its actual application effect.
[0073] (1) The improved DualFocus-YOLO method was deployed on a drone to test its effectiveness in modern animal husbandry. This method combines an advanced drone platform and vision module to form a sheep flock monitoring system based on high-resolution aerial imagery. The drone platform is equipped with a Jetson Nano computing module and an industrial-grade camera (HikvisionMV-CS016-10UC), which enables accurate location and counting of sheep flocks through real-time detection, ensuring monitoring efficiency while minimizing disturbance to the animals.
[0074] (2) When detecting sheep flocks, the high-resolution vision module used an optimized flight altitude to capture full coverage images of the pasture. The system performance was tested under various experimental conditions in multiple scenarios and from multiple angles, with a total of 20 experiments conducted, demonstrating consistency and high detection accuracy. The detection capability for small targets in high-density, low-pixel scenes was optimized through the TokenC3 module and the P2 high-resolution detection branch. This vision-guided monitoring system not only enables seamless large-scale deployment but also provides data support for refined livestock management, aligning with the development goals of sustainable agriculture and efficient resource utilization.
[0075] The foregoing description of specific exemplary embodiments of the invention is for illustrative and explanatory purposes. These descriptions are not intended to limit the invention to the precise forms disclosed, and it will be apparent that many changes and variations can be made in accordance with the foregoing teachings. The exemplary embodiments were chosen and described in order to explain the specific principles of the invention and its practical application, thereby enabling those skilled in the art to implement and utilize various different exemplary embodiments of the invention, as well as various different choices and variations. The scope of the invention is intended to be defined by the claims and their equivalents.
Claims
1. A high-density, low-pixel sheep detection method based on an improved YOLOv13 model from a UAV perspective, characterized in that... include: Step 1: Collect original images of the sheep flock and use LabelImg to label the sheep from the drone's perspective; Step 2: Improve the YOLOv13 model by proposing the TokenC3 module and introducing a high-resolution P2 detection branch and a modular sparse pruning strategy. Step 3: Train and improve the model to obtain high-precision, real-time detection results and generate visualized detection images; Step 4: Conduct ablation experiments to gradually verify the effectiveness of each innovative module; Step 5: Deploy the model on the embedded platform to visually demonstrate the application effect of this method.
2. The method for detecting high-density, low-pixel sheep from a UAV perspective based on the improved YOLOv13 model as described in claim 1, characterized in that, The original sheep images obtained in Step 1 contain various sheep breeds, different growth stages, and typical environmental conditions, including different flight altitudes, varying lighting, complex and varied pasture backgrounds, and multiple densities and distributions, to ensure the model's generalization ability and robustness.
3. The method for detecting high-density, low-pixel sheep from a UAV perspective based on the improved YOLOv13 model as described in claim 1, characterized in that... The labeling document in step 1 uses the LabelImg labeling tool to ensure that each sheep is accurately labeled, and the labeling results are reviewed and adjusted through a quality control process to ensure the accuracy and completeness of the training data.
4. The method for detecting high-density, low-pixel sheep from a UAV perspective based on the improved YOLOv13 model as described in claim 1, characterized in that... Step 2, improving the YOLOv13 model, includes: (1) The TokenC3 module is integrated into the backbone network and neck structure of YOLOv13. The TokenC3 module adopts a combination of adaptive local context mixing (ALCM) and dual-kernel convolution. It achieves the fusion of local and global features through parallel large kernel (e.g., 7×7) and small kernel (e.g., 3×3) branches, thereby improving the detection capability of small targets such as sheep. This module includes: performing large kernel convolution and small kernel convolution on the input feature X respectively, and fusing the output through specific weights α=0.4 and β=0.6 to highlight the features of small targets. At the same time, ALCM generates input-dependent convolution weights and dynamically adjusts the local receptive field, thereby improving the discrimination capability in complex backgrounds. The process of this module is represented as follows: F large =Conv 7×7 (X),F small =Conv 3×3 (X) F output =Fusion(α·Suppress(F large ),β·Enhance(F small )) W adaptive =σ(Conv 1×1 (ReLU(Conv 1×1 (GAP(X))))) Y=CV3(Cat(Bottleneck(LSConv(X)),Conv 1×1 (X))) (2) A high-resolution detection branch, P2, is introduced in YOLOv13. The P2 branch performs small target detection at a resolution of 160×160, which has 4 times higher spatial granularity than the traditional P3 branch (e.g., 80×80), thereby enhancing the model's ability to locate and classify dense small targets such as sheep from a high-altitude perspective. The P2 branch introduces a top-down semantic enhancement mechanism, utilizing the global semantic information of the high-level P5 branch to assist the feature expression of the low-level high-resolution branch, achieving efficient fusion of semantic and spatial information. The P2 detection branch achieves information interaction and effective fusion of global and local features through a semantic enhancement mechanism. This semantic enhancement process is implemented by the HyperACE module for cross-scale feature interaction, specifically as follows: F enhanced =HyperACE([F P3 ,F P4 ,F P5 ]) Finally, the P2 detection branch employs a semantically guided feature propagation mechanism, enabling high-level semantic information to be effectively transferred to low-level high-resolution features, generating optimized P2 branch feature representations: (3) A module-aware sparse pruning strategy is adopted, allocating differentiated pruning ratios to different modules in the network structure; for highly innovative modules such as TokenC3 and the global high-order related modeling module HyperACE, a lower pruning rate is adopted to maintain model performance; while for traditional convolutional layers, a higher pruning rate is adopted to effectively compress redundant parameters, reduce the computational and memory overhead of model inference, and realize the efficient real-time deployment of the model on the UAV edge computing platform; the pruning operation is evaluated by the L1 norm of the weights and low-importance weights are selectively removed: I(w i,j )=|w i,j | Among them, w i,j For the pruning target weights, I(w) i,j The weights () indicate their importance; pruning is performed according to the following formula:
5. The method for detecting high-density, low-pixel sheep from a UAV perspective based on the improved YOLOv13 model as described in claim 1, characterized in that, Step 3 trains the training set of the sheep dataset to obtain the improved method's trained and efficient detection model.
6. The method for detecting high-density, low-pixel sheep from a UAV perspective based on the improved YOLOv13 model as described in claim 1, characterized in that, Step 3: Input the original sheep images into the trained model to obtain the model's test results, and output the predicted image with target bounding boxes and confidence scores.
7. The method for detecting high-density, low-pixel sheep from a UAV perspective based on the improved YOLOv13 model as described in claim 1, characterized in that, Step 4 involves conducting ablation experiments on the sheep dataset, including progressively adding and combining the TokenC3 module, the dual-kernel convolution LSConv module, and the P2 high-resolution detection module during training. The mAP value, efficiency GFLOPs, and number of parameters for each combination are recorded, and the experimental results are analyzed and compared in detail to optimize the model's accuracy and computational efficiency.
8. The method for detecting high-density, low-pixel sheep from a UAV perspective based on the improved YOLOv13 model according to claim 1, characterized in that, Step 5 involves deploying the method on an embedded platform for drones, including using the Jetson Orin NX and RDK S100 platforms, optimizing with TensorRT, and verifying the model's real-time processing capabilities. Based on the above platforms, a deployment experiment for sheep detection is conducted to further verify the feasibility and generalization ability of the model in real agricultural and pastoral scenarios.