Abstract:To improve the efficiency and intelligence of automatic cotton-picking machines and avoid false and missed picking, we propose an improved YOLOv4 target detection algorithm to detect single cotton in complex backgrounds. The K-means algorithm is used to screen the size of the clustering anchor frame and obtain the refined size suitable for the cotton data set. The attention mechanism is also introduced to the YOLOv4 algorithm, and the Squeeze-and-Excitation Networks (SENet) module is located in the network structure. During model training, the weights of pre-training are obtained by training on an open data set, and fine-tuning parameters of the cotton data set are applied to the pre-training model. Furthermore, the original data set is expanded through data enhancement and the pre-training model has been trained again. Experimental results show that the improved YOLOv4 algorithm proposed in this study can effectively realize cotton detection in the field environment.