Abstract:Hen counting is a very important task in hen farm asset valuation. The current manual counting methods used in hen farms suffer from low efficiency and unstable counting accuracy. To resolve this problem, a method for identifying and counting individual laying hens was proposed based on improved YOLO v5s. The method introduced the SimAM attention mechanism in the Neck part of the YOLO v5s model in order to eliminate the interference brought by facilities such as laying boxes and feeding troughs on the identification of individual laying hens in the real complex environment; in order to expand the sensory field of the model and solve the problem of small individual laying hens and difficulties in identification, the spatial pyramid pooling module (SPPF) of the YOLO v5s model was replaced by the SPPCSPC module; in order to extract as many effective features of laying hens as possible, the detection accuracy of the model was further improved by adding the adaptive feature fusion module ASFF to the Neck structure of YOLO v5s, which fused the imaging feature information of laying hens at different scales. On this basis, the counting of individual laying hens and the calculation of the housing density were realized by calling the model detection interface and adding counting functions and counting target numbers inside the interface. The improved model was packaged by PyQt toolkit, and the system of individual laying hens identification and automatic counting was developed. The test results showed that the precision, recall and mAP of the improved YOLO v5s model were 89.91%, 79.24% and 87.53%, respectively, which were 2.37, 2.55 and 2.20 percentage points higher than those of the YOLO v5s model. The average accuracy of this model in counting 120~247 laying hen houses was 94.77%, which was 2.49 percentage points better than that of the YOLO v5s model. The laying hens counting system developed was applied in a farm base in Hebei, providing a reliable and effective method for counting the number of laying hens on a farm.