Wheat is one of the most crucial food crops globally, with its yield directly impacting global food security. The accurate detection and counting of wheat spikes is essential for monitoring wheat growth, predicting yield, and managing fields. However, the current methods face challenges, such as spike size variation, shading, weed interference, and dense distribution. Conventional machine learning approaches have partially addressed these challenges, yet they are hampered by limited detection accuracy, complexities in feature extraction, and poor robustness under complex field conditions. In this paper, we propose an improved YOLOv10 algorithm that significantly enhances the model’s feature extraction and detection capabilities. This is achieved by introducing a bidirectional feature pyramid network (BiFPN), a separated and enhancement attention module (SEAM), and a global context network (GCNet). BiFPN leverages both top-down and bottom-up bidirectional paths to achieve multi-scale feature fusion, improving performance in detecting targets of various scales. SEAM enhances feature representation quality and model performance in complex environments by separately augmenting the attention mechanism for channel and spatial features. GCNet captures long-range dependencies in the image through the global context block, enabling the model to process complex information more accurately. The experimental results demonstrate that our method achieved a precision of 93.69%, a recall of 91.70%, and a mean average precision (mAP) of 95.10% in wheat spike detection, outperforming the benchmark YOLOv10 model by 2.02% in precision, 2.92% in recall, and 1.56% in mAP. Additionally, the coefficient of determination (R2) between the detected and manually counted wheat spikes was 0.96, with a mean absolute error (MAE) of 3.57 and a root-mean-square error (RMSE) of 4.09, indicating strong correlation and high accuracy. The improved YOLOv10 algorithm effectively solves the difficult problem of wheat spike detection under complex field conditions, providing strong support for agricultural production and research.