Abstract:Pig inventory is an important part of large-scale breeding and management of live pigs. Manual counting methods are more time-consuming and laborious, especially in pig inventory with large amounts of data. How to count high-density pig herd images with machine vision is still a difficult problem to be solved urgently. A multi-scale aware counting network was used to count pigs in high-density pig herd images. Based on the crowd counting network CSRNet, the pig counting network of pig counting net(PCN)was proposed. VGG16 was used as the front-end network to extract features, the spatial pyramid structure was used, and this structure can extract and fusion multi-scale information in the image, the back-end network used an improved dilated convolutional network. PCN added a multi-scale aware structure, expanded the back-end network receptive field, and can obtain a predicted density map by sensing multi-scale features, the predicted density map reflectedthe spatial distribution of pigs, then by integrating the density map, the number of pigs can be accurately calculated.The results showed that on the test set image with an average number of pigs of 40.71, the accuracy of PCN was better than that of the crowd counting net MCNN, CSRNet and the pig counting net that modified Counting CNN, the mean absolute error (MAE) and the root mean square error (RMSE) were 1.74 and 2.28, respectively,the lower error showed that PCN had better accuracy and robustness.The average recognition time of a single image of the final model was 0.108s, which met the real-time processing requirements of the algorithm.The method provided a research idea for the automatic inventory of high-density group raising pigs.