| With the comprehensive promotion of China’s rural revitalization strategy,agriculture is developing rapidly,and the construction of large-scale farms is also developing rapidly.According to statistics,China’s pork consumption accounts for more than half of the world’s total pork consumption,and pigs have become a key research object in the field of precision animal husbandry in the 14 th Five-Year Plan of the new era.The recognition and detection of pig behavior can monitor the health condition of pigs and warn the occurrence of diseases,and also provide a realistic basis for the subsequent analysis and research of the pig breeding industry,which can greatly improve the breeding efficiency and the quality of final pork products.Therefore,this paper makes a study on pig behavior recognition based on deep learning,and the main contents are as follows:(1)We independently constructed a dataset containing transient behavior and time-span behavior of pigs,referred to as PBD(Pig Behavior Dataset),which makes up for the lack of open source pig behavior dataset nowadays,and made 13816 pictures annotated with pig behavior and 300 videos annotated,which can lay the foundation for subsequent research.(2)A YOLOv5 model improvement method based on the YOLOv5 model has been proposed for pig pose(transient behavior information)recognition detection.Through the lightweight model design at the YOLOv5 network structure level,the addition of the attention mechanism module and the study of data enhancement at the non-network structure level,the loss function and other improvements in many aspects,and several experimental comparisons,the finalized model parametric number is greatly compressed,and the parametric number is compressed to 67.4%of the original,and the recognition average accuracy is significantly improved by4.3%.(3)A Slow Fast model improvement method based on a spatio-temporal attention mechanism is proposed to identify and detect pig behavior categories with time span.By adding a spatial,temporal,and channel 3D spatiotemporal attention module(STC)to the Slow Fast network,the previously obtained motion and environment feature maps are extruded and stimulated from multiple dimensions to obtain attention maps of different dimensions,thus improving the average accuracy of pig behavior recognition with time span.During the experiments,the improved FB(Focal BCE)loss function is proposed by fusing the strategy of the binary crossentropy loss function(BCE Loss)and focal loss function(Focal Loss)to allocate more weights to the short-tailed data in response to the data imbalance problem appeared in PBD.Finally,this improved scheme leads to an average accuracy improvement of 8.89% for pig behavior recognition within time span. |