Abstract:The disadvantage of the existing weed recognition models for a variety of small target weeds is that they are low recognition rate, large volume, many parameters and slow detection speed in complex farmland environment. In order to solve this problem, a lightweight weed recognition method was proposed based on YOLO v5 model. Firstly, the multi-scale retinex with color restoration (MSRCR) algorithm was used to preprocess part of the image data to improve the image definition with blurred edge details and reduce the shadow interference in the image. On this basis, the feature extraction network in the recognition model was reset by using the lightweight network PP-LCNet to reduce the amount of model parameters. Secondly, the Ghost convolution model lightweight feature fusion network was used to further reduce the amount of calculation. In order to make up for the loss of model performance caused by lightweight, a normalization-based attention module (NAM) was added at the end of the feature fusion network to enhance the feature extraction ability of the model for weeds and corn seedlings. Finally, the activation function of the attention mechanism of the backbone network was optimized to improve the nonlinear fitting ability of the model. Experiments were carried out on the self-built dataset. The experimental results showed that compared with the current mainstream target detection algorithm YOLO v5s and the mature lightweight target detection algorithms MobileNetv3-YOLO v5s and ShuffleNet v2-YOLO v5s, the volume of the lightweight weed recognition model was 6.23MB, which was reduced by 54.5%, 12% and 18%, respectively. The mean average precision (mAP) was 97.8%, which was increased by 1.3 percentage points, 5.1 percentage points, and 4.4 percentage points, respectively. The detection time of single image was 118.1ms, which achieved the requirement of lightweight. It could significantly reduce the complexity of the model while maintaining high model recognition accuracy. The proposed method could identify corn seedling and weed accurately and rapidly, which provided technical support for the use of mobile devices with limited resources for farmland weed recognition.