The group-housed pigs attacking and daily behaviors detection and tracking based on improved YOLOv5s and DeepSORT

T Tianyu Cheng F Fujie Sun L Liang Mao (State Key Laboratory of Oral & Maxillofacial Reconstruction and Regeneration, Key Laboratory of Oral Biomedicine Ministry of Education, Hubei Key Laboratory of Stomatology, School & Hospital of Stomatology, Wuhan University) H Haoxuan Ou S Shuqin Tu F Fang Yuan H Hairan Yang

Abstract

Automatic detection and tracking of pig behaviors through video surveillance remain challenges due to farm demanding conditions, e.g., illumination conditions and occlusion of one pig from another. The main goal of this study is to develop a deep learning method based on the improved YOLOv5s and DeepSORT to detect and track the behaviors of pigs, which has the advantages of stability and high accuracy. Firstly, YOLOv5s with the attention mechanism is used for pig detection and behavior recognition. To deal with the missed detection and false detection due to occlusion and overlapping between pigs and pigs, the improved YOLOv5s adopts the Shape-IoU to optimize the bounding box regression loss function, which improves the robustness of the model. Then, the improved DeepSORT model is proposed to track each pig behaviors including eat, stand, lie and attack four behavior types. Finally, we conduct a comparison test under different lighting and density conditions for pig detection and behavior tracking on special dataset. Experimental results show that the mAP@0.5% of improved YOLOv5s algorithm increases from 92.7% to 99.3%, which means 6.6% accuracy improvement compared with the YOLOv5s model. In terms of tracking, the values of MOTA and MOTP in all test videos are 94.5% and 94.9% respectively. These experiments demonstrate that the improved YOLOv5s and DeepSORT achieves high accuracy for both pig detection and behavior tracking. The proposed approach provides scalable technical support for contactless automatic pig monitoring.

Article Details

Journal PLoS ONE
Volume / Issue Vol. 20, Issue 10
Published October 31, 2025
Pages e0334783
ISSN 1932-6203
Publisher Public Library of Science

Journal Info

PLoS ONE

Public Library of Science

ISSN: 1932-6203 Open Access Health Sciences

Authors (7)

T

Tianyu Cheng

F

Fujie Sun

L

Liang Mao

State Key Laboratory of Oral & Maxillofacial Reconstruction and Regeneration, Key Laboratory of Oral Biomedicine Ministry of Education, Hubei Key Laboratory of Stomatology, School & Hospital of Stomatology, Wuhan University

H

Haoxuan Ou

S

Shuqin Tu

F

Fang Yuan

H

Hairan Yang