Abstract:
Target detection has been widely applied to many scenarios in daily life, including people flow management, items counting, and object searching. Deep learning has also effectively improved the accuracy of target detection in recent years. Therefore, target detection can be expected to improve the efficiency of intelligent management in the livestock industry, such as pig farms. Daily population counting has been one of the most important steps in modern pig farms, such as target tracking and behavior recognition. However, the small targets or occluded pigs are difficult to accurately detect during counting. In this study, an accurate and rapid detection of the pig population was proposed to treat the small targets and occlusion in the dataset using a multi-scale fusion attention mechanism. YOLOpig network was constructed to detect the individual pig target using YOLOv7. Then, the scale network structure was proposed to enhance the detection of small targets. The residual thought of network structure was used to improve the convolution module for the high accuracy of the experiments. A parameter-free attention mechanism was also added to reduce the network weights while accelerating the detection speed. GradCAM was used for the feature visualization to verify the effectiveness of the experimental feature extraction. Finally, target tracking (StrongSORT) was adopted to accurately track the individual IDs of the pigs that were detected by the improved model, providing the identity information required for pig detection tasks. Experiments were conducted to verify the accuracy and real-time performance of the improved model on Large White pigs in the fattening stage. A series of experiments were conducted, including model ablation, model comparison, pig feature information extraction, and tracking. The effectiveness and feasibility of the models were verified to detect the pig groups. The great potential was obtained to solve the difficulties and challenges in pig population counting, providing important support in the agricultural breeding field. The experimental results show that the accuracy, recall, and average accuracy of the counting were 90.4%, 85.5%, and 92.4%, respectively. Furthermore, the average accuracy and the detection speed were improved by 5.1 percentage points and 7.14%, respectively, compared with the basic YOLOv7 model. The average accuracies of the YOLOv5, YOLOv7tiny, and YOLOv8n models were also improved by 12.1, 16.8, and 5.7 percentage points, respectively. Specifically, the pig population counting with a multi-scale fusion attention mechanism can be expected to rapidly and accurately complete the counting task, and then effectively deal with small targets and occlusion. The widespread application of the improved model can greatly contribute to the operational efficiency of pig farms for labor cost-saving, in order to promote the development of intelligent technology in the field of agricultural breeding. The more accurate and efficient counting of pigs can provide strong technical support for the field of agricultural breeding and intelligent farming.