Abstract:Sheep instance segmentation is an important prerequisite for sheep identification and tracking, behavior analysis and management, and disease monitoring. Aiming at the problem of false detection and missed detection of sheep instance detection caused by the occlusion of sheep individuals, dim light, and the similarity of individual color and background in the complex breeding environment of large-scale sheep farms, a sheep instance segmentation method based on improved YOLO v8n-seg was proposed. The YOLO v8n-seg network was used as the basic model for the individual sheep segmentation task. Firstly, the large separable kernel attention module was introduced to enhance the ability of the model to capture important feature information of the instance, which improved the representativeness of the features and the robustness of the model. Secondly, the bottleneck module in C2f was replaced by the expansion-wise residual module in DWR-Seg, a hyperreal-time semantic segmentation model, to optimize the ability of the model to extract high-level network features, expanding the receptive field of the model, and enhanced the relationship between context semantics. Generate new feature maps with rich feature information. Finally, the dilated reparam block module was used to further improve C2f, and the feature information extracted from the high level of the network was fused several times to enhance the understanding ability of the model. The experimental results showed that the average segmentation accuracy of the improved YOLO v8n-LDD-seg for sheep cases reached 92.08% at mAP50 and 66.54% at mAP50:90. Compared with YOLO v8n-seg, mAP50 and mAP50:95 were improved by 3.06 percentage points and 3.96 percentage points, respectively. YOLO v8n-LDD-seg effectively improved the detection accuracy of individual sheep, improved the segmentation effect of sheep instances, and provided technical support for the detection and segmentation of sheep instances in complex breeding environments.