Developments in object detection algorithms are critical for urban planning, environmental monitoring, surveillance, and many other applications. The primary objective of the article was to improve detection precision and model efficiency. The paper compared the performance of six different metaheuristic optimization algorithms including Gray Wolf Optimizer (GWO), Particle Swarm Optimization (PSO), Genetic Algorithm (GA), Remora Optimization Algorithm (ROA), Aquila Optimizer (AO), and Hybrid PSO–GWO (HPSGWO) combined with YOLOv7 and YOLOv8. The study included two distinct remote sensing datasets, RSOD and VHR-10. Many performance measures as precision, recall, and mean average precision (mAP) were used during the training, validation, and testing processes, as well as the fit score. The results show significant improvements in both YOLO variants following optimization using these strategies. The GWO-optimized YOLOv7 with 0.96 mAP 50, and 0.69 mAP 50:95, and the HPSGWO-optimized YOLOv8 with 0.97 mAP 50, and 0.72 mAP 50:95 had the best performance in the RSOD dataset. Similarly, the GWO-optimized versions of YOLOv7 and YOLOv8 had the best performance on the VHR-10 dataset with 0.87 mAP 50, and 0.58 mAP 50:95 for YOLOv7 and with 0.99 mAP 50, and 0.69 mAP 50:95 for YOLOv8, indicating greater performance. The findings supported the usefulness of metaheuristic optimization in increasing the precision and recall rates of YOLO algorithms and demonstrated major significance in improving object recognition tasks in remote sensing imaging, opening up a viable route for applications in a variety of disciplines.