Pest attacks are one of the main causes of declining rice production in Indonesia. To address this issue, this study examines the use of artificial intelligence-based object detection algorithms, namely YOLOv5 and YOLOv7, in a rice pest monitoring system using drones. The main focus of this study is to assess the effect of image capture speed on pest detection results, as well as to compare the performance of the two algorithms in various aspects, such as detection accuracy, speed, and effectiveness in identifying two main types of pests, namely rice stem borers and planthoppers. The applied methodology includes collecting visual datasets from the field, object annotation using Roboflow, training and testing models using the Anaconda Prompt platform, and analyzing the detected images in binary and grayscale forms using MATLAB. Performance evaluation is carried out using Intersection over Union (IoU), mean IoU (mIoU), and visual analysis of pixel heatmaps. The results show that detection speed is affected by variations in image capture height. YOLOv7 has faster processing performance than YOLOv5, with a capture time of 0.82 s–1.41 s, while YOLOv5 is in the range of 1.15 s–1.47 s. Accuracy evaluation through IoU and mIoU calculations produces consistent values in each frame. The YOLOv5 model obtained an IoU = 0.8711 and mIoU = 0.8711, while YOLOv7 also achieved an IoU = 0.8711 and mIoU = 0.8711. Both models showed a high balance of prediction areas, but YOLOv7 was superior in terms of time efficiency and performance stability at various heights. This research provides an important contribution to the development of AI-based precision agriculture systems, especially in detecting pests automatically and in real-time to improve pest control efficiency and agricultural productivity in Indonesia.