To accurately detect various kinds of locusts in real-time and make locust detection more universal, A locust data set that contains all kinds of locusts was created through the Internet crawler and public dataset IP102, and a locust target detection algorithm YOLOv7-MobileNetV3-CA.was proposed in this paper, Firstly, to reduce the size of model parameters, the backbone of YOLOv7 was replaced by MobileNetV3, Secondly, a CA (Coordinate Attention) attention mechanism was added to further improve the detection accuracy of locusts. after feature enhancement. The experiment showed that the precision of locusts was 95.96%, the recall rate was 92%, the AP was 95.74%, and the F1 was 0.92. Compared with YOLOv7, the model size was reduced by 27%, and the AP was improved by 4.48%. Compared with YOLOv4, YOLOv4 MobileNetV3, YOLOv5, and SSD algorithms, AP has improved by 51.16%, 26.81%, 11.9%, and 11.75%, respectively. Experiments have shown that this algorithm performs well in detecting locusts of different scales, scenes, and types, and can provide reference for real-time locust detection.