Abstract
To improve citrus detection accuracy under complex conditions, including branch and leaf occlusion, fruit overlap, and variable illumination in natural hilly and mountainous orchards, this study proposes an improved YOLOv8-based method for citrus detection in complex environments. To address the limitations of the original YOLOv8 in complex scenarios, including insufficient multi-scale feature fusion capability, limited target feature representation, and low bounding box localization accuracy, the feature fusion structure, feature representation strategy, and bounding box regression mechanism were jointly optimized. First, a BiFPN-based bidirectional feature fusion structure was introduced to enhance information interaction among multi-scale features, thereby improving the detection performance of small and occluded targets. Second, a Coordinate Attention (CA) mechanism was incorporated to strengthen the modeling of spatial positional information and improve target feature representation under complex backgrounds. Finally, the Inner-PIoU loss function was adopted to optimize the bounding box regression process, improving localization accuracy and training stability. Experimental results demonstrated that, with only 8.8% and 13.6% increases in the number of parameters and floating-point operations, respectively, the improved model achieved increases of 3.6, 4.4, and 3.7 percentage points in precision, recall, and mAP@0.5 compared with the original YOLOv8. Meanwhile, the inference time was only 3.9 ms, achieving a favorable balance between detection accuracy and real-time performance. Hyperparameter optimization further increased the model’s mAP@0.5 to 94.1%, the highest value observed among the configurations evaluated. Compared with mainstream object detection models, including Faster R-CNN, YOLOv5, YOLOv9, YOLOv10, and RT-DETR, the proposed method exhibited superior overall detection performance in complex orchard environments, meaning that the proposed model can provide a reliable fruit detection component for citrus orchard monitoring systems in hilly and mountainous regions. Future implementations could integrate a tracking and counting module to estimate the number of fruits.
1. Introduction
China ranks first worldwide in terms of both citrus cultivation area and production, making citrus an important component of the agricultural economy. With the advancement of agricultural modernization [1], the realization of intelligent orchard management [2], accurate yield estimation [3], and automated harvesting [4] has become an emerging trend in the agricultural industry. The foundation of these applications lies in the rapid and accurate detection of citrus fruits under complex orchard environments [5]. However, as shown in Figure 1, hilly and mountainous orchards generally exhibit characteristics such as severe illumination variations, dense fruit distribution with significant mutual occlusion, and a high proportion of small-scale targets. These challenges make existing detection algorithms insufficient in terms of localization accuracy, detection robustness, and real-time performance, limiting their practical applications. Therefore, developing a citrus detection model that simultaneously achieves high detection accuracy, fast inference speed, and lightweight deployment capability has become one of the critical challenges for intelligent orchard production.
Figure 1.
Example images of citrus fruits.
Early citrus detection methods mainly relied on traditional image processing techniques, including color space segmentation [6], texture feature extraction [7], and geometric shape matching [8]. HE et al. [9] proposed a deep bounding box regression forest method, which recognized fruits by describing the shape, texture, and color characteristics of green citrus at different scales, achieving a detection accuracy of only 87.6%. Although these approaches are simple to implement and require relatively low computational resources, they heavily depend on manually designed features and are highly sensitive to illumination changes, fruit occlusion, and complex backgrounds. Consequently, they often fail to extract discriminative target features effectively, resulting in limited model generalization capability and difficulty in meeting the requirements of citrus detection under complex natural orchard environments.
With the rapid development of deep learning technologies, object detection algorithms based on convolutional neural networks (CNNs) have gradually become a research hotspot [10,11]. Among them, two-stage object detection algorithms represented by Faster R-CNN [12] can achieve high detection accuracy. Apolo-Apolo et al. [13] used an unmanned aerial vehicle (UAV) to acquire images of a commercial citrus orchard and trained a Faster R-CNN model to detect fruit. They then used the detection results to estimate fruit size and yield. Their study demonstrated the practical application of two-stage object detection in citrus orchards. Their UAV-based image acquisition differs from the close-range handheld imaging used in the present study, so detection performance should be assessed in light of the imaging conditions and application requirements. Liu and Ampatzidis et al. [14] proposed GeoSphere-DETR, an RT-DETR-based model integrating geometric-aware gated fusion and spherical consistency rescoring for robust citrus orchard fruit detection. The proposed method improved mAP50 from 0.786 to 0.863 and reduced false positives per image (FPPI) from 7.240 to 3.286 on cross-field and cross-day test sets. Nevertheless, two-stage detection methods require both region proposal generation and classification/regression stages, resulting in complex network structures, large parameter sizes, and slow inference speeds, which are difficult to satisfy the requirements of real-time orchard detection and edge-device deployment.
Compared with two-stage detection algorithms, single-stage object detection algorithms represented by YOLO achieve a favorable balance between detection accuracy and real-time performance, and have become a research focus in agricultural object detection. Liao et al. [15] proposed a lightweight citrus detection model YOLO-MECD by introducing the EMA attention mechanism, CSPPC module, and MPDIoU loss function. The model achieved an mAP of 81.6%, while reducing the number of parameters by 75.6% compared with YOLOv11s, achieving a balance between detection accuracy and lightweight design. However, its detection performance in scenarios with severe occlusion and densely distributed fruits still requires further improvement. Zheng et al. [16] proposed the YOLO-BP multi-scale feature fusion network, which achieved an average detection accuracy of 91.55% and a detection speed of 18 frames/s. Nevertheless, false detections still occurred in partially occluded and overlapping fruit scenarios. Z. Wang et al. [17] proposed the ACDNet citrus detection network by designing the CAFE feature extraction module, DMS dynamic multi-scale sampling module, and FSA-IoU loss function. The model achieved an mAP@0.5 of 97.5% under complex orchard environments, improving by 1.7 percentage points compared with YOLOv8n, while reducing the number of parameters by 11%. However, the study mainly focused on citrus detection, and the generalization capability of the model to other fruit tree scenarios requires further validation. In the context of citrus orchard disease monitoring, Zhou et al. [18] reviewed the application of deep learning-based object detection methods to citrus greening (huanglongbing, HLB) and citrus canker, and discussed a YOLO-based mobile system for in-field HLB detection. MA Shafique et al. [19] developed a real-time citrus leaf disease detection model based on YOLOv11, achieving an mAP@0.5 of 81.2% on a self-built dataset, with an image processing time of only 10.5 ms. This study demonstrated the potential of deep learning for intelligent citrus disease recognition; however, the adaptability of the model for fruit detection under complex natural environments requires further investigation. To further improve model deployment capability, many researchers have conducted studies on lightweight YOLO-based models [20]. Zhou et al. [21] deployed MobileNetV3 on an Android platform for kiwifruit yield estimation, achieving a detection accuracy of 90.3% and an image processing time of 103 ms on mobile devices. Duan et al. [22] developed FEM-YOLOv8 based on YOLOv8s to detect protective equipment during UAV-assisted live-line operations. Relative to the original YOLOv8s, FEM-YOLOv8 reduced the parameter count and computational cost by 12.6% and 14.4%, respectively, and achieved a detection speed of 83 frames per second on the Atlas 200I DK A2 platform. This study illustrates how model complexity and detection speed can be evaluated together on a specific hardware platform. Santos et al. [23] evaluated and compared the performance of YOLOv7, YOLOv8, YOLOv9, YOLOv11, and YOLOv12 for detecting Diaphorina citri in citrus orchards. The results indicated that YOLOv9 outperformed other versions in all evaluation metrics and enabled accurate early-stage pest identification before transmission capability developed, providing technical references for UAV-based monitoring and intelligent pest management. Lin et al. [24] proposed AG-YOLO for detecting citrus fruits affected by occlusion from branches and foliage and by overlap between fruits. The model uses a NextViT backbone and a global context fusion module to strengthen interactions between local features and global contextual information. Their findings suggest that integrating contextual information can improve citrus fruit detection under occlusion and inform the present study’s approach to feature fusion and target feature enhancement in complex orchard environments. Quanyu Zhang et al. [25] proposed the BRA-YOLOv10 UAV object detection model. By introducing Bi-Level Routing Attention, adding a small-object detection layer, and improving the feature fusion module, the model achieved an mAP@0.5 of 96.5%, which was 1.7 percentage points higher than YOLOv10, effectively improving small-object detection performance in complex backgrounds. C. Tao et al. [26] proposed the YOLOv11-STDD object detection model by designing the C3k2_SP feature extraction module, adding a small-object detection head, and introducing the Shape IoU loss function. The proposed model improved mAP@0.5 by 4.49 percentage points compared with YOLOv11n; however, its overall performance remained relatively limited.
Although previous studies have advanced citrus fruit detection through improved feature extraction, multiscale fusion, and bounding box regression, occlusion by branches and foliage, fruit overlap, variations in apparent fruit size, and complex backgrounds remain challenging in orchard imagery. To address these challenges in citrus orchards in hilly and mountainous regions, this study integrates and adapts existing feature fusion, attention, and regression loss methods within the YOLOv8 framework. Specifically, a bidirectional feature pyramid network (BiFPN) [27] is used to adapt the original PAN-FPN feature fusion structure. Its bidirectional cross-scale connections and learnable weights combine features from different levels to account for changes in apparent fruit size caused by variations in imaging distance and viewpoint. Coordinate attention (CA) [28] is incorporated into the neck to recalibrate features using positional information and support fruit feature representation against backgrounds containing branches and foliage and under partial occlusion. In addition, the Inner-PIoU loss combines the regression mechanism of Powerful-IoU [29] with the auxiliary bounding box mechanism of Inner-IoU [30] to refine fruit bounding box regression.BiFPN and CA are established methods, and the combination of Inner-IoU and Powerful-IoU was previously reported by Yang et al. in their study of SGI-YOLOv9 [31]. The contribution of the present study lies in adapting the model to the specific task of citrus fruit detection and evaluating the resulting design experimentally. The components were selected to address scale variation, background interference, and localization requirements in orchard images. Their effects were examined through ablation experiments and comparisons with other models. The resulting detector is intended to support the future development of a server-based citrus orchard monitoring system.
The main contributions of this study are summarized as follows:
- A citrus fruit detection dataset was constructed from 1507 original RGB images collected in hilly and mountainous orchards in Beibei District, Chongqing, China. The images capture fruits at different stages of maturity and a range of lighting conditions, occlusion by branches and foliage, fruit overlap, and variations in apparent fruit size. The dataset supports the training and evaluation of citrus fruit detectors under complex orchard conditions.
- A YOLOv8n-based citrus fruit detector was developed by integrating BiFPN, coordinate attention (CA), and Inner-PIoU. These established components were adapted to address fruit occlusion and small-fruit detection through multiscale feature fusion, position-aware feature enhancement, and bounding box regression. Ablation experiments quantified the effects of individual components and their combinations on detection performance.
- Using a fixed dataset split and consistent experimental conditions, the proposed model was compared with several widely used detectors in terms of detection accuracy, parameter count, computational cost, and inference latency. The results provide an empirical basis for selecting a detection module for a future server-based citrus orchard monitoring system.
2. Citrus Detection Model and Improvement Method for Hilly and Mountainous Orchards
2.1. Improvement Strategy of the YOLOv8 Model
The YOLOv8 (You Only Look Once v8) series algorithm is a typical one-stage object detection method, which simultaneously performs object localization regression and category prediction through a single forward inference process. It has advantages including high detection speed, end-to-end training, and convenient engineering deployment. However, natural orchards in hilly and mountainous regions are characterized by severe illumination variations, significant branch and leaf occlusion, dense and overlapping fruits, and a high proportion of small-scale targets. These environmental factors impose higher requirements on the multi-scale feature representation capability, spatial information modeling ability, and bounding box regression accuracy of object detection models. Although YOLOv8 achieves excellent performance in general object detection tasks, its original network structure remains insufficient for citrus detection in complex hilly and mountainous orchard environments, leading to problems such as missed detection of small targets, inaccurate localization of occluded fruits, and false detection of densely distributed targets, which limit its practical application performance in real orchard scenarios.
From the perspective of network architecture, the Neck component of YOLOv8n still adopts the PAN-FPN feature fusion structure, where multi-scale features are mainly fused through fixed operations, lacking adaptive modeling of the importance of different hierarchical features. When distant small-scale citrus fruits, branch and leaf occlusion, and dense fruit distribution occur in hilly and mountainous orchards, insufficient interaction between shallow detail features and deep semantic features may result in the loss of small-target information and missed detection of occluded fruits. Furthermore, YOLOv8 has limited capability in modeling spatial positional information of targets. Under complex backgrounds and varying illumination conditions, the model is easily affected by branches, leaves, sky regions, and other background interference, making it difficult to accurately focus on fruit regions and consequently reducing detection accuracy. YOLOv8 employs the CIoU loss function for bounding box regression by default. However, when targets exhibit dense overlap or significant scale variations, the regression gradient may weaken, resulting in limited optimization capability for the localization of overlapping fruits and small-scale targets, which cannot fully satisfy the requirements of high-precision detection in complex orchard environments.
To address the above issues, this study conducts targeted improvements to YOLOv8 based on the practical requirements of citrus detection in complex hilly and mountainous orchard environments. The improvements are mainly designed from three aspects: multi-scale feature fusion, spatial feature enhancement, and bounding box regression optimization. First, to alleviate the loss of feature information from small-scale and occluded citrus fruits, a lightweight Bi-directional Feature Pyramid Network (BiFPN) is introduced to replace the original PAN-FPN structure. Through bidirectional weighted feature fusion, the information interaction among different-scale features is enhanced, improving the feature representation capability of small and occluded fruits while maintaining model lightweightness. Second, to address insufficient feature responses in target regions caused by branch and leaf occlusion, complex backgrounds, and illumination variations, a Coordinate Attention (CA) mechanism is embedded into the Neck feature fusion stage. By incorporating direction-aware positional information, the fused multi-scale features are spatially refined, enhancing the model’s attention to critical fruit regions with low computational overhead and effectively suppressing interference from complex background noise. Finally, considering the characteristics of dense fruit distribution, mutual occlusion, and large-scale variations in citrus fruits, an Inner-PIoU loss function integrating the advantages of Inner-IoU and PIoU is introduced. By optimizing the bounding box regression process through internal target region constraints and gradient modulation mechanisms, the localization accuracy of overlapping fruits and small-scale targets is improved, while enhancing model convergence stability and detection robustness.
The improved YOLOv8 model proposed in this study addresses key challenges in citrus detection under complex hilly and mountainous orchard environments, including the loss of small-target features, severe background interference, and difficult localization of overlapping fruits. By collaboratively optimizing multi-scale feature fusion, spatial feature enhancement, and bounding box regression, the proposed model achieves an effective balance between detection accuracy and real-time performance while preserving the lightweight advantage of YOLOv8. The improved network architecture is illustrated in Figure 2. The BiFPN feature fusion structure, CA attention mechanism, and Inner-PIoU loss function are introduced in detail in the following sections.
Figure 2.
Improved YOLOv8 network architecture.
2.2. Multi-Scale Feature Fusion Optimization Based on BiFPN
The traditional Feature Pyramid Network (FPN) used in early YOLO models is limited by its unidirectional information flow, resulting in relatively low utilization of image features. To improve feature utilization efficiency, the original YOLOv8 network adopts the PANet structure in the Neck component for feature fusion. As shown in Figure 3a, PANet introduces an additional bottom-up path aggregation network based on the traditional FPN, enabling bidirectional information propagation from top to bottom and bottom to top to a certain extent. However, its feature fusion strategy mainly relies on simple concatenation or addition operations, lacking an adaptive weighting mechanism for features at different scales. Consequently, the feature representation capability for small targets and occluded targets remains limited in complex scenarios. To enhance the model’s multi-scale object detection capability, this study introduces the Bi-directional Feature Pyramid Network (BiFPN) structure into the Neck component of YOLOv8 to optimize the original feature fusion strategy. The BiFPN architecture is shown in Figure 3b.
Figure 3.
Comparison between the original PANet structure of YOLOv8 and the BiFPN structure.
BiFPN constructs bidirectional feature fusion pathways through top-down and bottom-up information flows, enabling sufficient interaction between high-level semantic information and low-level spatial details across multiple scales. Therefore, it enhances spatial detail representation while maintaining strong semantic feature extraction capability. Furthermore, BiFPN introduces a learnable weighted fusion mechanism, which assigns adaptive weights to different input features during multi-scale feature fusion. This allows the network to automatically adjust the importance of features at different scales according to data distributions, providing stronger adaptability compared with traditional fixed-weight fusion methods. The feature fusion process can be formulated as the weighted summation and normalization of multi-scale features, preventing any single-scale feature from excessively dominating the output representation. When fusing features with different resolutions, conventional methods typically resize the feature maps to the same resolution and then perform element-wise addition. However, previous approaches treat all input features equally, despite the fact that features with different resolutions generally contribute differently to the final output. Therefore, BiFPN introduces an additional learnable weight for each input feature, enabling the network to automatically learn the importance of each feature. The fusion process is expressed as follows:
In the formula, O represents the fused output feature map, Ii denotes the i-th input feature map, represents the learnable fusion weight obtained through network training, and indicates the sum of all input weights, which is used to normalize the contribution of each input feature. is a small constant introduced to prevent division by zero and improve numerical stability. In the actual implementation, the weights are first constrained to non-negative values using the ReLU activation function and then normalized. This enables the network to adaptively learn the importance of multi-scale features, achieving efficient and stable feature fusion.
Based on bidirectional cross-scale connections and fast normalized fusion, the final weighted bidirectional feature pyramid network (BiFPN) is constructed. The feature fusion process of BiFPN can be formulated as follows:
where represents the intermediate feature of level 6 in the top-down pathway, and denotes the output feature of level 6 in the bottom-up pathway. Here, Conv represents the depthwise separable convolution, and each convolution operation is followed by Batch Normalization (BN) and an activation function. In complex orchard environments, small targets often rely more heavily on high-resolution features, while densely distributed or occluded regions require the assistance of high-level semantic information. The adaptive weighting mechanism of BiFPN can dynamically balance the contributions of features at different scales, thereby improving the model’s adaptability to diverse target appearances and spatial distributions. This study adopts the original BiFPN architecture in full. The YOLOv8n backbone produces feature maps at levels P3, P4, and P5 with 64, 128, and 256 channels, respectively. The P6 and P7 levels are generated by successive downsampling from P5. Feature maps from all five levels (P3–P7) are fed into the BiFPN module, which replaces the original PAN structure and performs one iteration of bidirectional feature fusion. Nearest-neighbor interpolation is used for upsampling, and stride-2 convolutions are used for downsampling. The coordinate attention (CA) module is placed after the C2f module and before the BiFPN fusion branch. It recalibrates the C2f output along the spatial and channel dimensions before the features enter the BiFPN for weighted multiscale fusion. Through repeated bidirectional fusion of multi-scale features and convolutional integration, the enhanced feature representations are finally transmitted to the detection head for prediction.
2.3. Spatial Feature Enhancement Method Based on the CA Attention Mechanism
Although the introduction of the BiFPN structure enhances multi-scale feature fusion capability, the fused feature maps still contain considerable redundant background information, making it difficult for the model to accurately highlight critical target regions. To further improve the feature representation capability of the model under occluded and densely distributed scenarios, a Coordinate Attention (CA) mechanism is introduced into the Neck component of the YOLO network to perform spatial directional modeling and channel-wise feature recalibration on the fused features.
As illustrated in Figure 4, the input feature map is subjected to global average pooling along the width and height directions, respectively, generating feature representations in the horizontal and vertical directions. Assuming that the input feature map has a shape of , after average pooling along the width direction, the global information in the height direction (Y-axis), such as vertical gradients and shape structures, is captured, resulting in a feature representation with a shape of . At this stage, the feature information is encoded along the height dimension. Similarly, after average pooling along the height direction, global information in the width direction (X-axis), such as horizontal edges and texture patterns, is captured, producing a feature representation with a shape of , thereby encoding feature information along the width dimension. The two parallel branches are then merged by transforming the width and height dimensions into the same representation space, followed by feature concatenation to combine the horizontal and vertical directional information. The resulting feature representation can be expressed as . Subsequently, convolution, normalization, and activation operations are applied to extract the encoded feature representation. After that, the feature map is split into two parallel branches again, and the width and height components are separated into and , respectively. After dimension transformation, two directional feature maps and are obtained. Then, 1 × 1 convolution is employed to adjust the channel dimensions, followed by the sigmoid activation function to generate attention weights along the height and width directions. Finally, the obtained directional attention weights are multiplied with the original input feature map to complete the Coordinate Attention (CA) operation. In citrus detection tasks, citrus fruits generally exhibit approximately circular distributions and strong structural continuity in images. Through direction-aware feature encoding, the CA mechanism enhances the feature response of fruit regions while suppressing interference from background leaves and branches. This enables the network to focus more effectively on fruit-related regions during subsequent feature extraction, thereby improving the detection capability for partially occluded targets and small-scale objects.
Figure 4.
Coordinate Attention (CA) mechanism.
2.4. Introduction of the Inner-PIoU Loss Function
Bounding box regression is a crucial component of object detection tasks, and its regression accuracy directly affects the precision of target localization. To enhance multi-scale detection capability and improve convergence efficiency, this study introduces the Inner-PIoU loss function to replace the original CIoU loss function used in YOLOv8 for bounding box regression. The replacement position is illustrated in Figure 5.
Figure 5.
Replacement of the bounding box loss function.
The proposed loss function integrates the advantages of both Inner-IoU and PIoU (Powerful IoU). Specifically, Inner-IoU utilizes a scaled “inner box” to accelerate the cross-scale bounding box regression process, while PIoU introduces a penalty factor that adaptively adjusts according to target size to improve convergence speed. By combining the strengths of these two approaches, Inner-PIoU significantly enhances the model’s generalization capability for multi-scale targets. The related data used for calculation are shown in Figure 6.
Figure 6.
Schematic diagram of the Inner-PIoU mechanism.
First, the coordinates of the ground-truth bounding box and the predicted bounding box are derived based on their center coordinates, width, height, and scaling factor:
where and represent the center coordinates of the ground-truth bounding box and the predicted bounding box, respectively; and denote the width and height of the ground-truth box and predicted box, respectively; ratio is the scaling factor; and and represent the left, right, top, and bottom boundary coordinates of the scaled ground-truth box and predicted box, respectively. Subsequently, the intersection and union areas are calculated to obtain the Inner-IoU value.
where inter and union denote the intersection and union areas of the two auxiliary boxes, respectively, and is a numerical constant introduced to prevent division by zero.
The penalty factor is computed from the absolute distances between corresponding boundaries of the predicted and ground-truth boxes before scaling. Let denote the left, right, top, and bottom boundaries of the original predicted box, and let denote the corresponding boundaries of the original ground-truth box. The horizontal and vertical distances are normalized by the width and height of the original ground-truth box, respectively, as given below:
where and denote the absolute horizontal boundary deviations, and denote the absolute vertical boundary deviations, and . The calculation of uses only the boundary coordinates of the scaled auxiliary boxes, while the penalty factor uses only those of the original boxes.
The base regression loss is the sum of the IoU loss computed from the auxiliary boxes and a nonnegative penalty term, as given below:
A nonmonotonic modulation mechanism based on boundary deviations is applied to the base regression loss. The quantity associated with localization quality is first defined by the following expression:
The modulation function is defined by the following expression:
The final per-sample bounding box regression loss is given below:
where is the hyperparameter that controls the modulation function. The mechanism multiplies the base regression loss by a prediction-dependent weight, yielding nonmonotonic loss weighting across samples with different localization quality.
In the implementation, the penalty factor P, the quality-related quantity q, and the modulation weight retain their gradient dependence on the predicted box. The gradient of the final loss therefore accounts for how both the base loss and the modulation weight change with the predicted box. Accordingly, the constant term in Equation (10) must be retained. For numerical stability, the horizontal and vertical overlap lengths used to compute the intersection area are clamped separately to a minimum of zero. The constant is added to the auxiliary-box union area and to the ground-truth box width and height used as denominators in the penalty factor. Half-precision inputs are cast to float32 within the loss function to preserve the effectiveness of these numerical safeguards. The function returns per-sample loss values, which are passed directly to the weighted normalization step.
The proposed citrus fruit detector uses this loss for bounding box regression. The loss characterizes localization error using both the overlap between the auxiliary boxes and the boundary deviations between the original boxes. The nonmonotonic modulation function adjusts each sample’s contribution to the loss. Its effect on detection performance is evaluated through ablation experiments on the citrus dataset.
3. Experimental Results and Analysis
3.1. Experimental Dataset
3.1.1. Data Acquisition
Data were collected in a citrus orchard in Xiema Town, Beibei District, Chongqing, a representative hilly orchard area in southwestern China. Slopes within the orchard ranged from approximately 15° to 35°. RGB images were acquired at a resolution of 4096 × 3072 pixels using a handheld HONOR 200 smartphone (Honor Device Co., Ltd., Shenzhen, China) and saved in JPEG format. The smartphone was selected for its portability, which allowed field personnel to adjust the camera position, distance, and viewing angle on uneven terrain. Images were captured from multiple angles at distances of 0.5–2 m under a range of lighting conditions, including early-morning backlighting, strong midday illumination, and low evening light. In total, 1507 images were collected for model training and performance evaluation. These images include representative cases of occlusion by branches and foliage, fruit overlap, and variation in apparent fruit size.
The smartphone was used solely for image acquisition. Model training and testing were conducted on a computer. The proposed detector is intended to serve as the perception module of a future server-based citrus orchard monitoring system. It will accept images or video streams and output fruit class labels and bounding boxes. The input device for that system can be selected independently of the smartphone used to collect the dataset. The present study evaluates the detector on close-range images from the study orchard. Its applicability to other imaging devices, acquisition distances, and viewing angles requires further validation. Monitoring system development, model integration, and testing on the target server are planned for future work.
All images were collected in a single orchard using one device during a single season. The distributions of occlusion, lighting, and slope therefore reflect conditions at this site, limiting the conclusions that can be drawn about the model’s generalizability. Future work will construct a multi-orchard dataset and quantitatively evaluate detection performance by occlusion level, lighting condition, and terrain slope.
3.1.2. Data Processing
Considering the complexity of orchard environments and the influence of varying illumination conditions, the 1507 collected citrus images were randomly divided into training, validation, and test sets at a ratio of 7:2:1, corresponding to 1055, 301, and 151 images, respectively. As shown in Figure 7, to improve the generalization ability and robustness of the proposed model, data augmentation techniques, including image flipping, noise injection, and brightness reduction, were applied. As a result, the dataset size was expanded from 1507 to 6028 images, as summarized in Table 1. Augmented images were generated separately within each subset and kept in the same subset as their source images. The data collection records lacked unique tree identifiers and did not support grouped splitting by tree or acquisition session. Consequently, images of the same tree captured from different viewpoints may appear in both the training and test sets. This is a limitation of the dataset. Future work will collect data from independent orchards to further assess model generalizability. All primary detection metrics reported in Table 2, Table 3, Table 4 and Table 5 were calculated using the 151 original, unaugmented test images. The 453 augmented images derived from the test set were used exclusively for robustness testing.
Figure 7.
Examples of data augmentation.
Table 1.
Distribution of dataset samples.
Images were collected on 15 January 2026, under early-morning backlighting, strong midday illumination, and low evening light. A total of 30,958 citrus fruit instances were identified across all annotation files. Fruit instances were grouped by relative bounding box area. Medium-sized instances (2–8%) were the most common, accounting for 17,223 annotations (55.6%). Small instances (<2%) accounted for 12,379 annotations (40.0%), and large instances (>8%) accounted for 1356 annotations (4.4%). Finally, all images were manually annotated using the LabelImg annotation tool. During the annotation process, “citrus” was defined as the target class, and the location information of each annotated object, including the bounding box coordinates and corresponding class label, was recorded to ensure the accuracy and consistency of the annotations.
The dataset was collected in a working citrus orchard in hilly and mountainous terrain, where variations in slope and elevation can lead to changes in camera viewpoint, fruit occlusion, and lighting conditions. The dataset is limited to fruit images from mountainous orchards, and the detector was designed without slope-specific optimization. This study focuses on citrus fruit detection. Future work will integrate the detector into a server-based orchard monitoring system and use DeepSORT to track and count fruits. System integration, tracking, and counting remain to be implemented and quantitatively evaluated.
3.2. Experimental Environment and Evaluation Metrics
The experiments were conducted based on the YOLOv8 deep learning object detection framework. The experimental environment was configured as follows: the operating system was Windows 10 (64-bit), the deep learning framework was PyTorch (v2.4.1), and the programming language was Python 3.8. The hardware platform consisted of an Intel(R) Core(TM) i5-12600KF CPU with a base frequency of 1.60 GHz and an NVIDIA GeForce RTX 4060 GPU, with CUDA version 12.0. During model training, the input image size was set to 640 × 640 pixels, the number of training epochs was 200, and the batch size was 16. The model was trained using stochastic gradient descent (SGD) with an initial learning rate of 0.01, a momentum coefficient of 0.937, and a weight decay coefficient of 0.0005. The learning rate followed a cosine annealing schedule with a warm-up period of three epochs. To accelerate convergence, the backbone was initialized with the official YOLOv8n weights pretrained on the COCO dataset. Training used the default YOLOv8 data augmentation strategy, including Mosaic augmentation, random horizontal flipping, and HSV color perturbations. The detection head retained the original Distribution Focal Loss (DFL). The overall training objective combined classification loss, DFL, and the Inner-PIoU loss for bounding box regression. The model was evaluated on the validation set after each epoch, and the checkpoint with the highest validation mAP@0.5 was selected for final testing. Evaluation used intersection-over-union (IoU) thresholds consistent with the COCO protocol. The reported metrics were precision, recall, mAP@0.5, AP@0.75, and mAP@0.5:0.95. To comprehensively evaluate the performance of the proposed citrus detection model, several widely used object detection metrics were employed for quantitative analysis, including Precision (P), Recall (R), mean Average Precision at an IoU threshold of 0.5 (mAP@0.5), the number of parameters (Parameters), floating-point operations (FLOPs), and the average inference time per image (Inference Time). The formulations of Precision, Recall, and mAP are given as follows:
In the above equations, P denotes Precision, which represents the proportion of correctly predicted positive samples among all predicted positive samples. R denotes Recall, which represents the proportion of correctly detected positive samples among all actual positive samples. TP, FP, and FN represent the numbers of true positives, false positives, and false negatives, respectively. mAP@0.5 denotes the mean Average Precision (mAP) calculated at an Intersection over Union (IoU) threshold of 0.5. Inference latency was measured on an NVIDIA GeForce RTX 4060 desktop GPU using a batch size of 1 and FP32 precision. After GPU warm-up, latency was averaged over 100 inference runs. The mean network forward-pass latency was 3.9 ms, excluding image preprocessing and non-maximum suppression (NMS) post-processing. Latency ranged from 3.7 to 4.1 ms across repeated tests. These measurements characterize performance on the RTX 4060 desktop GPU. Performance on embedded edge devices requires separate evaluation.
3.3. Selection of the YOLOv8 Baseline Model
In recent years, object detection models have continued to evolve, and the YOLO series has successively released newer versions, such as YOLOv9 and YOLOv10. However, YOLOv9 introduces novel architectures, including Programmable Gradient Information (PGI) and Generalized Efficient Layer Aggregation Network (GELAN), resulting in increased model complexity and higher requirements for training strategies and computational resources. YOLOv10 adopts an end-to-end detection framework and achieves NMS-free inference through the Consistent Dual Assignments strategy. Although it offers high detection efficiency, its network architecture and training strategy differ substantially from those of YOLOv8, making it unsuitable as a baseline for objectively evaluating the performance gains introduced by the proposed improvement modules. In contrast, YOLOv8 is currently one of the most widely adopted and technically mature one-stage object detection models. It provides an excellent balance between detection accuracy, inference speed, lightweight deployment, and community support and has been extensively applied to agricultural object detection tasks. Therefore, to ensure the specificity of the proposed architectural improvements and the comparability of the experimental results, YOLOv8 was selected as the baseline detection framework in this study. Furthermore, different variants of the YOLOv8 series were comparatively evaluated. To determine the most suitable baseline model for the citrus detection task, comparative experiments were conducted on five YOLOv8 variants with different model scales (YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l, and YOLOv8x) under identical training parameters and dataset settings. The experimental results are presented in Table 2.
Table 2.
Experimental results of YOLOv8 models with different scales.
As shown in Table 2, as the model scale increases from lightweight to large variants, the detection accuracy generally improves, accompanied by substantial increases in the number of parameters, computational complexity, and inference latency. Among the five models, YOLOv8l and YOLOv8x achieved the highest mAP@0.5 of 90.9%, with precision values of 89.7% and 87.6%, respectively. However, these two models contain 43.6 M and 68.2 M parameters, require 165.4 GFLOPs and 258.1 GFLOPs, and exhibit inference times of 17.5 ms and 48.5 ms, respectively, resulting in prohibitively high computational costs and deployment overhead. In comparison, YOLOv8s achieved the highest recall (88.3%), whereas YOLOv8m attained the highest precision (89.2%), with inference times of 6.9 ms and 8.6 ms, respectively, demonstrating a favorable balance between detection performance and computational efficiency. As the most lightweight variant, YOLOv8n achieved a precision of 88.8%, a recall of 85.8%, and an mAP@0.5 of 89.9%, which were only slightly lower than those of the larger models. Nevertheless, it contains only 3.0 M parameters, requires 8.1 GFLOPs, and achieves an inference time of only 3.7 ms, demonstrating excellent computational efficiency and real-time inference capability while maintaining competitive detection performance. Considering the trade-offs among detection accuracy, computational cost, and practical deployment feasibility, YOLOv8n was selected as the baseline model in this study to maximize model lightweightness and real-time performance while ensuring satisfactory citrus detection accuracy.
3.4. Ablation Experiments
3.4.1. Module Ablation Study
To evaluate the contribution of each proposed improvement to the overall model performance, ablation experiments were conducted using YOLOv8n as the baseline model. The effects of the BiFPN, Coordinate Attention (CA) mechanism, and Inner-PIoU loss function were evaluated individually and in combination. The experimental results are presented in Table 3.
As shown in Table 3, the modules had varying effects on model performance, and only some improved mAP@0.5 when applied individually. When only BiFPN was introduced, the recall increased by 4.3 percentage points, whereas the precision decreased by 2.1 percentage points. This improvement can be attributed to the bidirectional weighted feature fusion mechanism of BiFPN, which strengthens the interaction between shallow detailed features and deep semantic features, thereby enhancing the detection capability for small-scale and occluded citrus fruits in hilly and mountainous orchards. Consequently, the number of missed detections is effectively reduced, leading to a higher recall. However, the increased sensitivity to potential targets also results in a small number of background regions being incorrectly identified as fruits, causing a slight decrease in precision. This pattern is consistent with the precision–recall trade-off in object detection. The mAP@0.5 metric summarizes precision–recall curves across detection confidence thresholds at an IoU threshold of 0.5. When BiFPN was used alone, the decrease in precision appeared to offset the gain in recall, resulting in a slight decline in mAP@0.5. Notably, BiFPN introduces only 0.016 M additional parameters while keeping the FLOPs almost unchanged, demonstrating its lightweight characteristic while effectively enhancing multi-scale feature representation. When the CA attention mechanism was incorporated independently, the model precision increased by 3.0 percentage points, whereas the recall remained nearly unchanged. This indicates that the primary contribution of CA lies in encoding positional and channel information to guide the model toward critical fruit regions while effectively suppressing interference from branches, leaves, the sky, and other complex background elements. As a result, false detections are reduced, leading to higher detection precision. Owing to its lightweight architecture, the CA module introduces only a small increase in model parameters and computational complexity, with a negligible impact on real-time inference performance. Replacing the original CIoU loss with the Inner-PIoU loss function improved the mAP@0.5 by 3.6 percentage points, while only marginal changes were observed in precision and recall. The mAP@0.5:0.95 increased by 4.4 percentage points. Adding Inner-PIoU yielded larger gains than adding either of the other two modules, both when evaluated individually and when added to configurations with other modules. These results suggest that Inner-PIoU improves localization by bringing predicted bounding boxes into closer alignment with the ground-truth boxes. This demonstrates that Inner-PIoU primarily enhances localization accuracy by introducing internal target region constraints together with the PIoU gradient modulation mechanism, thereby improving the bounding box regression capability for densely overlapping fruits and targets with significant scale variations. Consequently, the predicted bounding boxes fit the ground-truth objects more accurately, leading to a substantial improvement in localization performance. Inner-PIoU is a parameter-free geometric loss applied during training. Constructing auxiliary boxes and computing boundary distances introduce additional floating-point operations during training. The slight discrepancy in the parameter counts reported in the table was a profiling artifact. When tracing the training computation graph, the profiling tool incorrectly counted temporary, non-trainable tensors generated by the loss computation as model parameters. When profiling was restricted to the inference forward pass, the Inner-PIoU-only configuration had exactly the same parameter count and number of floating-point operations as the YOLOv8n baseline. Further analysis of the dual-module combinations reveals that integrating BiFPN with CA increased the precision and recall by 3.4 and 4.2 percentage points, respectively, indicating that the two modules complement each other effectively in terms of multi-scale feature fusion and spatial feature enhancement. Similarly, the combinations of BiFPN + Inner-PIoU and CA + Inner-PIoU both achieved relatively high mAP@0.5 values, the ablation results suggest that the main gain in mAP@0.5 was attributable to the use of Inner-PIoU for bounding box regression. Adding both BiFPN and CA to the Inner-PIoU configuration increased mAP@0.5 by only 0.1 percentage points, while improving the precision–recall operating point. Precision rose from 89.1% to 92.4%, and recall rose from 85.9% to 90.2%. The simultaneous improvement in precision and recall is relevant to the planned citrus fruit counting task, where both false positives and missed detections can affect counting accuracy.
In addition to detection accuracy, the influence of each improvement module on model complexity was also analyzed. After introducing BiFPN, the number of parameters increased from 3.006 M to 3.022 M, corresponding to an increase of approximately 0.55%. This increase is mainly attributed to the additional bidirectional cross-scale feature fusion paths and a small number of convolution operations introduced by BiFPN. However, unlike conventional FPN or PAN structures, BiFPN employs depthwise separable convolutions instead of standard convolutions and adopts fast normalized weighted feature fusion for multi-scale information aggregation. Consequently, the model complexity is effectively controlled while enhancing feature representation capability, resulting in almost no increase in FLOPs. After further incorporating the CA attention mechanism, the number of model parameters increased to 3.108 M. The additional parameters mainly originate from the 1 × 1 convolutions used for coordinate encoding and channel recalibration. Since CA establishes only lightweight attention mappings across feature channels without introducing computationally intensive convolution operations, it increases the computational complexity by only about 0.1 GFLOPs, while significantly enhancing the model’s ability to capture spatial positional information and channel-wise feature representations of citrus fruits. In contrast, the Inner-PIoU loss function only affects the bounding box regression loss during the training stage. It does not modify the network architecture or participate in the inference process; therefore, it introduces virtually no additional model parameters or inference computational cost, requiring only a negligible amount of extra computation during training. When all three improvement modules were integrated, the number of model parameters increased from 3.006 M to 3.271 M, while the computational complexity increased from 8.1 GFLOPs to 9.2 GFLOPs, corresponding to increases of approximately 8.8% and 13.6%, respectively. Meanwhile, the mAP@0.5 improved by 3.7 percentage points. The full configuration also achieved the highest mAP@0.5:0.95 among all configurations tested, suggesting that the combined modifications improved both overall detection accuracy and bounding box localization. These results demonstrate that the proposed method significantly enhances detection performance with only a modest increase in model complexity, achieving an effective balance between detection accuracy and computational efficiency. Furthermore, they verify the practical effectiveness and engineering applicability of the proposed improvement modules.
All ablation experiments used a confidence threshold of 0.25 and an intersection-over-union (IoU) threshold of 0.7 for non-maximum suppression (NMS), consistent with the default YOLOv8 settings. The dataset split, data augmentation settings, training hyperparameters, and random seed were held fixed across all configurations to support reproducibility. Combining the three modifications increased precision, recall, and mAP@0.5 by 3.6, 4.4, and 3.7 percentage points, respectively, relative to the baseline. The parameter count, floating-point operation count, and inference latency increased by 8.6%, 13.5%, and 5.4%, respectively. The combined model thus improved detection performance while retaining a lightweight architecture and real-time inference capability.
Table 3.
Ablation experiment of the Improved Model.
To visually demonstrate the contribution of each proposed module to the overall detection performance, an image containing multiple challenging conditions—including low illumination, severe occlusion, overlapping fruits, and distant small-scale targets—was selected for qualitative comparison in the ablation study. The detection results are presented in Figure 8. Dim lighting and occlusion by branches and foliage made small citrus fruits farther from the camera difficult to detect, leading to several missed detections by the original YOLOv8 model. The red circles highlight fruits that the final model detected and the original YOLOv8 model missed. After incorporating the BiFPN module, the model’s capability for multi-scale feature fusion is significantly enhanced, enabling it to detect several previously missed small and occluded fruits. Building upon this improvement, the introduction of the Coordinate Attention (CA) mechanism allows the model to more effectively suppress background noise and focus on discriminative fruit regions, thereby improving the separation of overlapping fruits and further increasing the number of correctly detected citrus fruits. Finally, after replacing the original loss function with Inner-PIoU, the localization accuracy of the predicted bounding boxes is further improved. The enhanced model successfully detects extremely small distant fruits that were missed by all previous configurations, while the predicted bounding boxes exhibit a closer alignment with the true fruit boundaries. Throughout the entire ablation process, the number of detected citrus fruits increases progressively as each proposed module is introduced, accompanied by a substantial reduction in missed detections. These qualitative results demonstrate that the proposed improvements exhibit strong complementarity and robustness in complex hilly orchard environments, significantly enhancing the detection stability of the model under challenging visual conditions.
Figure 8.
Comparison of detection results in YOLOv8 ablation experiments.
Figure 9 plots validation-set mAP@0.5 across training epochs to compare the convergence behavior of the baseline and improved YOLOv8 models. The improved model converged faster, exhibited smaller fluctuations in validation mAP@0.5 during later epochs, and achieved a higher mAP@0.5 than the baseline.
Figure 9.
Comparison of mAP@0.5 between the YOLOv8 baseline and the proposed model.
3.4.2. Hyperparameter Sensitivity Analysis
To further investigate the influence of key hyperparameters associated with the proposed modules on the detection performance, a hyperparameter sensitivity analysis was conducted following the module ablation study. Specifically, the smoothing factor in BiFPN, the reduction ratio of the Coordinate Attention (CA) module, the inner-box scaling ratio (ratio) in Inner-PIoU, and the penalty modulation coefficient were evaluated. Their default values were set to 0.0001, 32, 0.8, and 1.3, respectively. A controlled variable approach was adopted throughout the experiments, in which only one hyperparameter was varied at a time while all other hyperparameters remained at their default values to ensure the comparability of the experimental results. All experiments were conducted using the same dataset partition, training strategy, and evaluation metric (mAP@0.5). Moreover, the network architecture remained unchanged, with only the corresponding hyperparameter being adjusted. The experimental results are summarized in Table 4.
Table 4.
Effect of module hyperparameter sensitivity experiments on mean average precision.
- (1)
- Analysis of the BiFPN Smoothing Factor ()
BiFPN employs a fast normalized weighted fusion strategy to aggregate multi-scale features. To prevent numerical instability caused by excessively small denominators during weight normalization, a smoothing factor, , is introduced. To investigate the influence of different values on detection performance, was set to 0.00005, 0.0001, 0.0005, 0.001, and 0.05, respectively. As shown in Table 4, the overall detection performance exhibits a trend of first improving and then deteriorating as increases. When is relatively small, the smoothing effect during normalization is insufficient, making the fusion weights of different BiFPN branches more susceptible to minor numerical fluctuations, which leads to unstable feature fusion and consequently lower detection accuracy. As gradually increases, the normalization process becomes more stable, enabling a more appropriate allocation of fusion weights across different feature scales and thereby improving detection performance. The highest mAP@0.5 of 93.7% is achieved when = 0.001. However, when is further increased to 0.05, the excessively large smoothing term weakens the weight differences among features at different scales, reducing the adaptive fusion capability of BiFPN and resulting in a decline in detection performance. Therefore, = 0.001 was selected as the optimal smoothing factor for the BiFPN module.
- (2)
- Analysis of the Reduction Ratio of the Coordinate Attention Module (reduction)
The Coordinate Attention (CA) module jointly encodes spatial positional information and channel information through channel compression, where the reduction ratio determines the compression degree of the intermediate feature representation and directly affects both the attention representation capability and model complexity. In the experiments, the reduction ratio was set to 8, 16, 24, 32, and 64, respectively. As shown in Table 4, when the reduction ratio increased from 8 to 16, the detection performance improved significantly, with mAP@0.5 increasing from 93.3% to 94.0%. However, further increasing the reduction ratio led to a gradual decline in detection accuracy. When the reduction ratio is small, the intermediate hidden representation retains a relatively high dimensionality, preserving richer feature information but also introducing more redundant information, which reduces the efficiency of attention learning. Conversely, when the reduction ratio is excessively large, the intermediate feature dimension becomes too low, causing the loss of spatial positional and channel information during compression and consequently weakening the attention module’s ability to represent critical target regions. Therefore, reduction = 16 achieves an effective balance between feature representation capability and model complexity, providing the best detection performance while maintaining low computational overhead. Accordingly, reduction = 16 was adopted as the optimal parameter for the CA module.
- (3)
- Analysis of the Inner-PIoU Scaling Ratio (ratio)
Inner-PIoU constructs a scaled inner box within the original bounding box and calculates the IoU based on this inner region, thereby enhancing the model’s sensitivity to localization errors in the central area of the target. The scaling ratio ratio determines the size of the inner box and directly affects the supervision range for localization optimization. In this experiment, ratio was set to 0.6, 0.7, 0.8, 0.9, and 1.0, respectively. As shown in Table 4, the detection performance first increases and then decreases as the ratio varies. When the ratio is relatively small, the inner box covers only a limited central region of the target. Although this strengthens the supervision of the target center, considerable boundary information is lost, resulting in degraded overall localization capability. As the ratio gradually increases, the coverage of the inner box becomes more appropriate, enabling the model to emphasize the target center while simultaneously retaining boundary information. Consequently, the detection accuracy continues to improve. When ratio = 0.8, the model achieves the highest mAP@0.5 of 93.6%. However, when the ratio is further increased to 0.9 and 1.0, the inner box gradually approaches the original bounding box, causing Inner-PIoU to become increasingly similar to conventional IoU calculation. As a result, the advantage of enhanced central-region supervision is weakened, leading to a decline in detection performance. Considering both localization accuracy and training stability, ratio = 0.8 was selected as the optimal scaling ratio for Inner-PIoU.
- (4)
- Analysis of the Inner-PIoU Penalty Modulation Coefficient ()
The parameter is used to adjust the strength of the PIoU penalty term, and its value directly influences the magnitude of gradient updates for localization errors. In this experiment, was set to 1.1, 1.2, 1.3, 1.4, and 1.5, respectively. As shown in Table 4, the detection performance exhibits relatively small fluctuations under different values, while maintaining a trend of gradual improvement followed by a slight decline. When is relatively small, the penalty term of PIoU has a weak influence, resulting in insufficient constraints on localization errors and limiting the optimization of bounding box positions. As increases, the penalty imposed on localization errors becomes more appropriate, allowing the model to learn target boundary information more effectively and gradually improving detection performance. When = 1.4, the model achieves the highest mAP@0.5 of 93.9%. However, further increasing to 1.5 introduces an excessively strong penalty effect, which enlarges the gradient update magnitude and slightly reduces training stability, resulting in a minor decrease in detection performance. Therefore, = 1.4 was selected as the optimal penalty modulation coefficient for Inner-PIoU.
Based on the above experimental results, different hyperparameters have varying degrees of influence on model detection performance. Among them, the reduction ratio of the CA module has the most significant impact, indicating that an appropriate feature compression ratio is crucial for improving attention representation capability. The BiFPN smoothing factor mainly affects numerical stability during multi-scale feature fusion, and excessively large or small values may reduce detection performance. The ratio parameter in Inner-PIoU directly determines the supervision range of the inner box and has a significant influence on localization accuracy. The coefficient mainly regulates the strength of localization error penalties and has a relatively smaller impact on overall performance; however, an appropriate setting can still further improve detection accuracy. Hyperparameter optimization identified = 0.001, reduction = 16, ratio = 0.8, and = 1.4 as the best combination among the configurations evaluated. This configuration achieved a validation mAP@0.5 of 94.1%, demonstrating the potential for performance gains through tuning. The optimized model had 3,294,153 parameters, required 9.3 GFLOPs per forward pass, and achieved a single-image inference latency of 3.9 ms. For a consistent comparison with widely used detectors, each baseline was evaluated using its recommended default hyperparameters. The proposed model was evaluated in the same comparison using its initial hyperparameter settings ( = 0.0001, reduction = 32, ratio = 0.8, and = 1.3), yielding a test-set mAP@0.5 of 93.6%.
3.5. Comparison Experiments with Mainstream Methods
To further assess the performance of the proposed model, we compared it with six widely used object detectors: Faster R-CNN with a ResNet-50 backbone, YOLOv5n, YOLOv8n, YOLOv9t, YOLOv10n, and RT-DETR-R18. To ensure a fair comparison, all models were trained on the same citrus dataset split using identical hardware, data augmentation settings, and numbers of training epochs. The results are reported in Table 5.
As shown in Table 5, compared with Faster R-CNN, YOLOv5, YOLOv8, YOLOv9, YOLOv10, and RT-DETR, the proposed model improves the mAP@0.5 by 1.4, 0.8, 3.7, 2.8, 2.1, and 3.1 percentage points, respectively. In terms of computational complexity, the proposed model requires only 9.2 GFLOPs. Although this is 15.0% and 13.5% higher than that of YOLOv5 and the original YOLOv8, respectively, it is reduced by 56.2%, 15.6%, 19.7%, and 84.7% compared with the other four mainstream models. Regarding inference efficiency, the average inference time of the proposed model is 3.9 ms per image, which is only 0.2 ms higher than the original YOLOv8, while reducing the inference time by 3.8, 1.0, 1.8, 1.6, and 4.0 ms compared with Faster R-CNN, YOLOv5, YOLOv9, YOLOv10, and RT-DETR, respectively. Furthermore, the experimental results demonstrate that the proposed model achieves significantly higher precision and recall than the other six detection models. Compared with the baseline YOLOv8 model, the precision and recall are improved by 3.6 and 4.4 percentage points, respectively. Meanwhile, the number of parameters increases by only 8.8% compared with the baseline model, remaining lower than that of the other compared models. Overall, the proposed model exhibits superior comprehensive performance and effectively meets the requirements of citrus fruit detection in hilly orchard environments.
Further analysis of model complexity and inference efficiency indicates that although the proposed model introduces a small increase in parameters and computational cost compared with the original YOLOv8, the inference time increases by only 0.2 ms, maintaining strong real-time detection capability. This is mainly attributed to the following aspects: First, BiFPN constructs bidirectional feature fusion pathways using depthwise separable convolutions, enhancing multi-scale feature representation while effectively controlling computational complexity. Second, the CA attention module introduces only lightweight 1 × 1 convolution operations and coordinate encoding processes, resulting in limited additional computational overhead and minimal impact on inference speed. Third, Inner-PIoU is only involved in bounding box regression loss calculation during the training stage and does not introduce additional inference computation, thereby avoiding extra deployment costs. Compared with advanced models such as YOLOv9, YOLOv10, and RT-DETR, although some models contain fewer parameters than the proposed method, their deeper network structures and more complex feature interaction mechanisms lead to longer computational paths during inference, preventing them from achieving superior inference efficiency. Overall, by combining network architecture optimization with loss function improvement, the proposed method achieves a coordinated enhancement of detection accuracy and inference efficiency with only a slight increase in model complexity. It provides a better balance between real-time performance and detection capability, making it more suitable for deployment on intelligent citrus harvesting robots and edge computing devices in hilly and mountainous orchard environments.
It should be noted that model inference efficiency is influenced not only by the number of parameters and FLOPs but also by factors such as network architecture design, feature fusion strategies, and GPU computational parallelism. Therefore, a smaller parameter size does not necessarily guarantee faster inference speed. The proposed model achieves a favorable balance between detection accuracy and real-time performance through lightweight feature fusion optimization and training-stage loss function improvement, demonstrating strong overall performance and practical deployment potential.
Table 5.
Comparison experiments with mainstream detection models.
Taking citrus fruit images from the test set as examples, a comparative evaluation between the original YOLOv8 and the proposed improved model was conducted under various complex orchard environments to intuitively verify the practical application performance of the proposed method. The evaluation scenarios included typical challenging conditions such as low illumination, severe branch and leaf occlusion, fruit overlap, and distant small-scale targets. As shown in Figure 10, under low-light and uneven illumination conditions, the original YOLOv8 model is easily affected by background noise, resulting in missed detections. In contrast, the improved model effectively extracts weak visual features through the CA attention mechanism, which enables more accurate spatial information modeling and maintains high detection sensitivity under challenging lighting conditions. When facing severe branch and leaf occlusion or highly overlapping fruits, the original model often suffers from feature loss, resulting in inaccurate localization or missed detections. However, the improved model achieves deeper fusion of high-level semantic information and low-level detailed features through BiFPN, significantly enhancing the robustness to incomplete target appearances and enabling more accurate identification of partially occluded fruit contours. Furthermore, for densely distributed small-scale targets in distant views, the improved model utilizes the Inner-PIoU loss function to optimize localization around critical target regions, effectively improving the detection capability for extremely small objects and substantially reducing the missed detection rate. Overall, the experimental results demonstrate that the improved model not only achieves higher detection accuracy but also exhibits significant advantages in environmental adaptability. It can robustly handle various visual disturbances in natural hilly and mountainous orchard environments, providing an effective algorithmic foundation for intelligent and precise citrus harvesting.
Figure 10.
Comparison of detection results before and after model improvement. Note. Red circles indicate citrus fruits detected by the improved model and missed by the original YOLOv8 model.
4. Conclusions
To address the degradation of citrus detection accuracy caused by branch and leaf occlusion, fruit overlap, and complex illumination conditions in natural hilly orchard environments, this study focuses on several key limitations of the YOLOv8 detection model, including insufficient feature extraction capability under complex scenarios, limited multi-scale feature fusion ability, and low bounding box localization accuracy. A series of targeted improvements were proposed to enhance citrus detection performance in challenging environments. To overcome the insufficient interaction among features of different scales, a BiFPN-based bidirectional feature pyramid structure was introduced to optimize the multi-scale feature fusion strategy and strengthen the information transmission between shallow detailed features and deep semantic features. A CA attention mechanism was incorporated into the feature fusion stage to enhance the representation capability of spatial positional information and important feature regions, thereby improving the recognition ability of occluded and densely distributed targets. To address the large localization errors during bounding box regression, an improved Inner-PIoU loss function combining the advantages of Inner-IoU and PIoU was adopted. By introducing an inner auxiliary box and the PIoU penalty mechanism, the stability and accuracy of bounding box regression were improved, enabling the model to focus more effectively on target core regions and enhancing localization performance and training stability. Ultimately, the collaborative optimization of network architecture and loss function achieved an overall improvement in citrus detection performance under complex orchard conditions.
Experimental results demonstrate that the proposed model outperforms the original YOLOv8 and several mainstream object detection models on the citrus dataset. Compared with the original YOLOv8, the improved model increases the number of parameters, floating-point operations, and inference time by only 8.8%, 13.6%, and 5.4%, respectively, while improving precision, recall, and mAP@0.5 by 3.6, 4.4, and 3.7 percentage points, respectively. The ablation experiments verified that the three proposed modules, namely BiFPN, CA, and Inner-PIoU, can effectively improve model performance, and their combination further enhances citrus detection accuracy in complex orchard environments. The hyperparameter sensitivity analysis identified a configuration that increased the model’s validation mAP@0.5 to 94.1%, the highest value among the configurations evaluated. The analysis also indicated that detection performance was generally stable across the tested settings. To ensure a fair comparison with other widely used detectors, the proposed model was evaluated using its initial default hyperparameters in the comparative experiments. Comparative experiments with mainstream detection models demonstrated that the proposed method achieves superior detection performance with lower computational complexity. It provides competitive advantages in terms of detection accuracy, inference speed, and overall performance. It is a promising candidate for server-side fruit detection in orchard monitoring systems and could support future research on intelligent orchard management.
The experimental results show that the proposed model improved citrus fruit detection in images from hilly orchards, providing a basis for the detection module of a future orchard monitoring system. Future work will deploy the model in a server-based monitoring system to process video streams captured from multiple viewpoints around individual trees and use DeepSORT to track and count fruits. Capturing multiple viewpoints can increase the likelihood of detecting visible fruits, and associating detections across frames can reduce repeated counting of the same fruit. Fruits that remain fully occluded by branches and foliage cannot be directly observed in two-dimensional images. Prolonged occlusion, fruits entering or leaving the field of view, and overlap between the initial and final viewpoints when filming around a tree can still lead to fragmented tracks and duplicate counts. Future work will investigate multiview fusion, object association, and count correction strategies and evaluate counting accuracy against manually annotated ground truth. The conclusions of the present study are limited to citrus fruit detection in two-dimensional images. Video-based tracking, fruit counting, and integration of the full monitoring system remain to be evaluated.
Author Contributions
Z.L. (Zuojin Li) provided project supervision, overall research framework design and revised the manuscript. L.X. (Second Author, main contributor) completed the overall algorithm design, YOLO model improvement, experimental construction, data analysis, result verification, and drafted the full manuscript. L.D. (Corresponding Author) proposed research ideas, guided the experimental scheme, reviewed and revised the manuscript. Q.X., Z.L. (Zili Li), Z.J., R.Z. and X.Z. participated in data collection, experimental testing, result sorting and manuscript proofreading. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by China Tower Corporation Limited (Project No. CTC-CQCQ-2025-000216), under the project entitled Research on the “Liangqing” Intelligent Video Analysis System for Precision Operation in Standardized Citrus Orchards. The funder had no role in the design of the study; the collection, analysis, or interpretation of data; the writing of the manuscript; or the decision to publish the results.
Institutional Review Board Statement
Not applicable. The study did not involve human or animal subjects, and no personal sensitive data was collected.
Informed Consent Statement
Not applicable, because this article does not contain any studies involving human participants.
Data Availability Statement
The data that support the findings of this study are available from the corresponding author upon reasonable request.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Rahmawati, N. Agricultural Modernization and Rural Income Diversification in the Global South. Sch. Int. J. Manag. Dev. 2026, 13. [Google Scholar] [CrossRef] [Scilit]
- Wei, W.; Iqbal, M.A. Sustaining citrus production under climate stress: Estimating the technical efficiency of citrus farms in China. Appl. Fruit Sci. 2026, 68, 126. [Google Scholar] [CrossRef] [Scilit]
- Weng, H.; Lu, D.U.; Zhang, B.; Su, L.; Xu, J.; Xiao, G.; Sun, D.; Ye, D. Citrus tracking and counting using UAV remote sensing video imagery with improved YOLO11. Trans. Chin. Soc. Agric. Eng. 2026, 42, 182–192. [Google Scholar] [CrossRef]
- Mirhaji, H.; Soleymani, M.; Asakereh, A.; Mehdizadeh, S.A. Fruit detection and load estimation of an orange orchard using the YOLO models through simple approaches in different imaging and illumination conditions. Comput. Electron. Agric. 2021, 191, 106533. [Google Scholar] [CrossRef] [Scilit]
- Zhao, R.; Guan, Y.; Lu, Y.; Ji, Z.; Yin, X.; Jia, W. FCOS-LSC: A novel model for green fruit detection in a complex orchard environment. Plant Phenomics 2023, 5, 0069. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Yan, J.; Liang, K.; Liu, C.; Gao, M. Citrus recognition in orchard scene based on modified HSV-morphology method. Appl. Comput. Eng. 2024, 88, 64–71. [Google Scholar] [CrossRef] [Scilit]
- Lu, J.; Lee, W.S.; Gan, H.; Hu, X. Immature citrus fruit detection based on local binary pattern feature and hierarchical contour analysis. Biosyst. Eng. 2018, 171, 78–90. [Google Scholar] [CrossRef] [Scilit]
- Lin, G.; Tang, Y.; Zou, X.; Cheng, J.; Xiong, J. Fruit detection in natural environment using partial shape matching and probabilistic Hough transform. Precis. Agric. 2020, 21, 160–177. [Google Scholar] [CrossRef] [Scilit]
- He, Z.; Xiong, J.; Chen, S.; Li, Z.; Chen, S.; Zhong, Z.; Yang, Z. A method of green citrus detection based on a deep bounding box regression forest. Biosyst. Eng. 2020, 193, 206–215. [Google Scholar] [CrossRef] [Scilit]
- Kumari, Y.S.; Kumari, R.R.; Swapna, M.; Khyathi, P. Comparing Deep Learning (CNN) Features with Hybrid Models (HOG_CNN, LBP_CNN) for Classification of Leafs. In Proceedings of the 2025 International Conference on Computational, Communication and Information Technology (ICCCIT), Indore, India, 7–8 February 2025; pp. 25–30. [Google Scholar]
- Kumar, B.V.P.; Rahul, P.; Avinash, S.; Shyamsundar, K.; Sandhya, B.; Sandhya, B. Object Detection using Convolutional Neural Network. Int. J. Adv. Res. Sci. Commun. Technol. 2024, 4, 511–518. [Google Scholar] [CrossRef] [Scilit]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks. IEEE Trans. Pattern Anal. Mach. Intell. 2017, 39, 1137–1149. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Apolo-Apolo, O.E.; Martínez-Guanter, J.; Egea, G.; Raja, P.; Pérez-Ruiz, M. Deep learning techniques for estimation of the yield and size of citrus fruits using a UAV. Eur. J. Agron. 2020, 115, 126030. [Google Scholar] [CrossRef] [Scilit]
- Liu, S.; Ampatzidis, Y. GeoSphere-DETR: Geometry-Aware RT-DETR with Sphere-Consistency Re-scoring for Robust Citrus Orchard Fruit Detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Denver, CO, USA, 3–7 June 2026; pp. 9759–9767. [Google Scholar]
- Liao, Y.; Li, L.; Xiao, H.; Xu, F.; Shan, B.; Yin, H. YOLO-MECD: Citrus Detection Algorithm Based on YOLOv11. Agronomy 2025, 15, 687. [Google Scholar] [CrossRef] [Scilit]
- Zheng, Z.; Xiong, J.; Lin, H.; Han, Y.; Sun, B.; Xie, Z.; Yang, Z.; Wang, C. A method of green citrus detection in natural environments using a deep convolutional neural network. Front. Plant Sci. 2021, 12, 705737. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Wang, Z.; Xia, W.; Li, M. ACDNet: Adaptive Citrus Detection Network Based on Improved YOLOv8 for Robotic Harvesting. Agriculture 2026, 16, 148. [Google Scholar] [CrossRef] [Scilit]
- Zhou, Z.; Zhang, Y.; Gu, Z.; Yang, S.X. Deep learning approaches for object recognition in plant diseases: A review. Intell. Robot. 2023, 3, 514–537. [Google Scholar] [CrossRef] [Scilit]
- Shafique, M.A.; Rehman, S.U.; Rashid, J.; Liaquat, M.; El-Ganainy, S.M.; Almaghasla, M.I.S.; Al Hashedi, S.A.; Sattar, M.N. Real-Time Multiclass Detection of Citrus Leaf Diseases Using an Enhanced YOLOv11 Architecture. IEEE Access 2026, 14, 22998–23017. [Google Scholar] [CrossRef] [Scilit]
- Zhao, J.; Du, C.; Li, Y.; Mudhsh, M.; Guo, D.; Fan, Y.; Wu, X.; Wang, X.; Almodfer, R. YOLO-Granada: A lightweight attentioned Yolo for pomegranates fruit detection. Sci. Rep. 2024, 14, 16848. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Zhou, Z.; Song, Z.; Fu, L.; Gao, F.; Li, R.; Cui, Y. Real-time kiwifruit detection in orchard using deep learning on Android™ smartphones for yield estimation. Comput. Electron. Agric. 2020, 179, 105856. [Google Scholar] [CrossRef] [Scilit]
- Duan, H.; Shi, F.; Gao, B.; Zhou, Y.; Cui, Q. A novel real-time intelligent detector for monitoring UAVs in live-line operation on 10 kV distribution networks. Intell. Robot. 2025, 5, 70–87. [Google Scholar] [CrossRef] [Scilit]
- Santos, A.D.; Mafra, S.; Figueiredo, F.A.P.D. On the performance analysis of Yolo algorithms to identify the vector of Greening in orange farms. In 2025 International Conference on Artificial Intelligence, Computer, Data Sciences and Applications (ACDSA); IEEE: Piscataway, NJ, USA, 2025. [Google Scholar] [CrossRef] [Scilit]
- Lin, Y.; Huang, Z.; Liang, Y.; Liu, Y.; Jiang, W. AG-YOLO: A Rapid Citrus Fruit Detection Algorithm with Global Context Fusion. Agriculture 2024, 14, 114. [Google Scholar] [CrossRef] [Scilit]
- Zhang, Q.; Wang, X.; Shi, H.; Wang, K.; Tian, Y.; Xu, Z.; Zhang, Y.; Jia, G. BRA-YOLOv10: UAV Small Target Detection Based on YOLOv10. Drones 2025, 9, 159. [Google Scholar] [CrossRef] [Scilit]
- Tao, C.; Huang, Z.; Huang, Z.; Chen, M.; Liu, K.; Zhou, M. YOLOv11-STDD: Improved YOLOv11 Small Target Detection for Drones. In Proceedings of the 2025 7th International Conference on Internet of Things, Automation and Artificial Intelligence (IoTAAI), Guangzhou, China, 12–14 September 2025. [Google Scholar] [CrossRef] [Scilit]
- Tan, M.; Pang, R.; Le, Q.V. Efficientdet: Scalable and efficient object detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020; pp. 10781–10790. [Google Scholar]
- Hou, Q.; Zhou, D.; Feng, J. Coordinate attention for efficient mobile network design. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Nashville, TN, USA, 20–25 June 2021; pp. 13713–13722. [Google Scholar]
- Liu, C.; Wang, K.; Li, Q.; Zhao, F.; Zhao, K.; Ma, H. Powerful-IoU: More straightforward and faster bounding box regression loss with a nonmonotonic focusing mechanism. Neural Netw. 2024, 170, 276–284. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Zhang, H.; Xu, C.; Zhang, S. Inner-IoU: More Effective Intersection over Union Loss with Auxiliary Bounding Box. arXiv 2023, arXiv:2311.02877. [Google Scholar] [CrossRef] [Scilit]
- Yang, M.; Chen, B.; Lin, C.; Yao, W.; Li, Y. SGI-YOLOv9: An effective method for crucial components detection in the power distribution network. Front. Phys. 2025, 12, 1517177. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.









