INTRODUCTION: An improved Yolo v7 model.OBJECTIVES: To solve the weed detection and identification in complex field background.METHODS: The dataset was enhanced by online data enhancement, in which the feature extraction, feature fusion and feature point judgment of weed image were carried out by Yolov7 to predict the weed situation corresponding to the prior box. In the enhanced feature extraction part of Yolov7, CBAM, an attention mechanism combining channel and space, is introduced to improve the attention of the algorithm to weeds and strengthen the characteristics of weeds.RESULTS: The mean average precision (mAP ) of the improved algorithm reached 91.15%, which was 2.06% higher than that of the original Yolov7 algorithm. Compared with the current mainstream target detection algorithms Yolox, Yolov5l, Fster RCNN, Yolov4-tiny and Yolov3, the mAP value of the improved algorithm increased by 4.35, 4.51, 5.41, 19.77 and 20.65 percentage points. Weed species can be accurately identified when multiple weeds are adjacent.CONCLUSION: This paper provides a detection model based on Yolov7 for weed detection in the field, which has a good detection effect on weed detection, and lays a research foundation for intelligent weeding robot and spraying robot.