MSPFormer: An enhanced multi-scale and semantic-preserving transformer for sheep ownership identification in precision livestock farming - Yaosheng Han; Chunmei Li; Xiangjie Huang; Qing Dong; Hao Wang (PLoS ONE, 2026)
Overgrazing is a major driver of grassland degradation on the Qinghai–Tibet Plateau, posing significant challenges for sustainable livestock management. To mitigate this issue, intelligent technologies that can effectively recognize and manage different herders’ sheep flocks are essential for achieving balanced grass–livestock management and reducing overgrazing. This study aims to develop a robust and efficient model for intelligent sheep ownership recognition by leveraging sheep back color features, facilitating scientific grazing management, and supporting herder conflict resolution. A dedicated dataset was constructed, capturing diverse color distributions under variable lighting and complex backgrounds. We propose MSPFormer, a multi-scale and semantic-preserving Transformer model, which builds upon Mask2Former by integrating three key modules: (1) an Atrous Spatial Pyramid Pooling (ASPP) module between the Pixel Decoder and Transformer Decoder to enhance multi-scale feature extraction; (2) a Dynamic Prompt Attention (DPA) module to improve semantic consistency; and (3) a Content-Aware ReAssembly of Features (CARAFE) upsampling module after the Transformer Decoder to optimize spatial detail recovery. Experimental results show that MSPFormer achieves superior segmentation performance, increasing the mIoU from 82.46% to 83.81% (a relative improvement of approximately 1.35%), the mF1-score from 90.08% to 90.92% (an improvement of approximately 0.84%), the mPrecision from 89.50% to 91.52% (an improvement of approximately 2.02%), and the mRecall from 90.74% to 90.92% (an improvement of approximately 0.18%). Validation on the public VOC2012 dataset and several small-sample subsets further demonstrates the model’s strong generalization capability and stability. This study provides an effective and intelligent solution for sheep ownership recognition, contributing to sustainable grazing management and conflict resolution among herders on the Qinghai–Tibet Plateau. Future work will focus on lightweighting the model through pruning and knowledge distillation to facilitate practical deployment.