In order to achieve fast and accurate detection of Gannan navel orange fruits with different ripeness levels in a natural environment under all-weather scenarios and then to realise automated harvesting of Gannan navel oranges, this paper proposes a YOLOv5-NMM (YOLOv5 with Navel orange Measure Model) object detection model based on the improvement in the original YOLOv5 model. Based on the changes in the phenotypic characteristics of navel oranges and the Chinese national standard GB/T 21488-2008, the maturity of Gannan navel oranges is tested. And it addresses and improves the problems of occlusion, dense distribution, small target size, rainy days, and light changes in the detection of navel orange fruits. Firstly, a new detection head of 160 × 160 feature maps is constructed in the detection layer to improve the multi-scale target detection layer of YOLOv5 and to increase the detection accuracy of the different maturity levels of Gannan navel oranges of small sizes. Secondly, a convolutional block attention module is incorporated in its backbone layer to capture the correlations between features in different dimensions to improve the perceptual ability of the model. Then, the weighted bidirectional feature pyramid network structure is integrated into the Neck layer to improve the fusion efficiency of the network on the feature maps and reduce the amount of computation. Lastly, in order to reduce the loss of the target of the Gannan Navel Orange due to occlusion and overlapping, the detection frame is used to remove redundancy using the Soft-NMS algorithm to remove redundant candidate frames. The results show that the accuracy rate, recall rate, and average accuracy of the improved YOLOv5-NMM model are 93.2%, 89.6%, and 94.2%, respectively, and the number of parameters is only 7.2 M. Compared with the mainstream network models, such as Faster R-CNN, YOLOv3, the original model of YOLOv5, and YOLOv7-tiny, it is superior in terms of the accuracy rate, recall rate, and average accuracy mean, and also performs well in terms of the detection rate and memory occupation. This study shows that the YOLOv5-NMM model can effectively identify and detect the ripeness of Gannan navel oranges in natural environments, which provides an effective exploration of the automated harvesting of Gannan navel orange fruits.