# YOLOv5 DA: An Improved YOLOv5 Model for Posture Detection of Grouped Pigs
## 1 Introduction  
The behaviors of pigs can reflect their growth conditions and comfort in the growing environment. Detecting pig behaviors can provide early warning of pig diseases, identify the factors affecting pig health, and prevent economic losses caused by widespreadinfection [1]. The accurate identification of pig postures serves as a crucial indicator of their behavior. Pig posture detection can help predict the health and comfort of a pig [2], which can avoid the spread of disease and improve the profitability of pigs. Besides that, pig posture detection can improve the accuracy of pig body size measurement [3]. The change in temperature affects the posture of the pig. In general, pigs prefer to lie down under comfortable conditions, and at high ambient temperatures, they may be in postures of side lying [4]. Traditionally, identification of pig postures is often based on manual direct observation, which is not only cumbersome and inefficient but also easily causes stress in pigs. With the development of computer technologies, non-contact vision technology has been gradually applied in pig farming, and deep learning methods have been widely used in animal detection and tracking [5; 6; 7; 8], which are accurate, low-cost, and stress-free methods. In traditional posture detection methods, the collection of pigs' posture and location information primarily relies on on-site observation or surveillance systems [9]. However, during the evaluation process, differences in the interpretation of postures inevitably arise due to the subjectivity of individual evaluators [10]. With the evolution of computer vision, object detection serves as a common method for posture detection. The goal of object detection is to accurately identify and enclose all the visible pigs within minimal bounding boxes, while simultaneously classifying each bounding box based on the specific behavior that needs to be extracted [11; 12; 13; 14]. The R-FCN ResNet101 [15] method and the Faster R-CNN [16; 17] technology can effectively detect the three basic postures of pigs--standing, lying on the side, and lying on the belly--with high accuracy. Additionally, Faster R-CNN [16] is capable of precisely identifying the sitting and steral recumbent postures. The two-stage algorithmic framework, while exhibiting excellent precision, is comparatively slower in processing speed. Therefore, there is a growing preference for single-stage methods. These methods simultaneously estimate object positions and classify categories in a single computational process, thereby significantly enhancing processing speed. The widely used YOLO series has achieved a superior balance between speed and accuracy among single-stage detection algorithms [18]. The YOLOv5 algorithm is utilized for initial pig detection, with the EfficientNet model then classifying pigs as \"lying\" or \"not lying\" [19]. YOLOX's enhancements have notably boosted the detection and recognition of pigs' various postures, day or night [20]. Additionally, the HE-Yolo model, an advanced version of YOLOv5, accurately identifies four key pig postures: standing, sitting, lying prone, and lying on one side [21]. However, current methods for pig posture detection often result in blurred or missed detection of the object box boundary due to occultation and adhesion of pigs, and their detection accuracy still needs to be further improved [18]. To address the above-mentioned issues, this study introduced an enhanced YOLOv5 DA model derived from YOLOv5s, which generally has three improvements: Mosaic9 data augmentation [22], deformable convolution [23], and adaptive spatial feature fusion [24]. Our primary contribution is the development of a model that can efficiently discern three distinct pig postures--standing, prone lying, and side lying--even in crowded and obstructed environments, using 2D camera video. Compared to other mainstream algorithms, our model achieves higher accuracy and faster detection speeds.