In the ever-evolving landscape of intelligent agriculture, researchers from Ningxia University have made a significant stride in addressing one of the industry’s persistent challenges: accurate detection of beef cattle in crowded and occluded environments. Published in the journal *智慧农业*, the study introduces an improved object detection algorithm, YOLOv12s-ASR, which promises to revolutionize livestock monitoring and management.
The problem of occlusion in beef cattle detection has long plagued farmers and agricultural technologists alike. Traditional methods, whether manual or algorithmic, often fall short in real-world scenarios where cattle tend to cluster together. “Manual counting is not only labor-intensive but also prone to errors,” explains lead author Liu Yiheng. “Existing deep learning models struggle with occlusion, leading to missed detections and false positives, which can significantly impact farm management decisions.”
The YOLOv12s-ASR algorithm, developed by Liu Yiheng and co-author Liu Libo, tackles this issue head-on. By introducing three key improvements to the baseline YOLOv12s model, the researchers have enhanced the algorithm’s ability to detect and count cattle accurately, even in the most challenging conditions. The first improvement involves replacing part of the standard convolution layers with a modifiable kernel convolution module (AKConv). This allows the model to dynamically adjust the shape and size of the convolution kernel based on the input image content, capturing local features more effectively.
The second enhancement integrates a self-ensembling attention mechanism (SEAM) into the Neck structure. SEAM combines spatial and channel attention through depthwise separable convolutions and consistency regularization, enabling the model to learn more robust and discriminative features. “This mechanism helps the model perceive global contextual information, which is crucial for inferring the presence and location of occluded targets,” Liu Libo adds.
The third improvement introduces a repulsion loss function, which includes two components: RepGT and RepBox. This loss function reduces the overlap between adjacent predictions, mitigating the negative effects of non-maximum suppression (NMS) in crowded scenes. As a result, the model achieves higher localization accuracy and fewer missed detections.
The researchers conducted extensive experiments on a self-constructed beef cattle dataset containing 2,458 images collected from 13 individual farms in Ningxia, China. The results were impressive: YOLOv12s-ASR achieved a mean average precision (mAP) of 89.3% on the test set, outperforming the baseline YOLOv12s by 1.3 percent points. The model size was only 8.5 MB, and the detection speed reached 136.7 frames per second, demonstrating a good balance between accuracy and efficiency.
The commercial implications of this research are substantial. Accurate and efficient cattle detection can lead to improved breeding efficiency, better animal health monitoring, and more precise distribution of government subsidies. “This technology has the potential to transform intelligent farm management, making it more efficient and data-driven,” says Liu Yiheng.
The study also highlights the model’s robustness across varying occlusion conditions, making it a reliable tool for real-time applications in resource-constrained environments. As the agriculture sector continues to embrace smart technologies, the YOLOv12s-ASR algorithm could play a pivotal role in shaping the future of livestock management.
Published in *智慧农业*, the research was led by Liu Yiheng and Liu Libo from the School of Information Engineering at Ningxia University and the Ningxia Key Laboratory of Artificial Intelligence and Information Security for Channeling Computing Resources from the East to the West. Their work not only addresses a critical need in the agriculture sector but also sets a new benchmark for object detection in complex environments. As the industry moves towards greater automation and intelligence, innovations like YOLOv12s-ASR will be instrumental in driving progress and efficiency.

