Skip to Content
AgronomyAgronomy
  • Article
  • Open Access

15 May 2026

A Green Jujube Grading Model Using BiFPN and COT Attention Mechanism

,
,
,
and
Subtropical Agriculture Research Institute, Fujian Academy of Agricultural Sciences, Zhangzhou 363005, China
*
Author to whom correspondence should be addressed.
These authors contributed equally to this work.
This article belongs to the Special Issue Agricultural Imagery and Machine Vision

Abstract

The grading of green jujube is a key factor in improving production efficiency and market competitiveness. However, traditional grading methods are inefficient, imprecise, and struggle to detect minor damages. This study proposes an improved BCW-YOLO deep learning model specifically designed for automated grading of green jujube. The model integrates a Bidirectional Feature Pyramid Network (BiFPN) and a Contextual Transformer Attention (COT) mechanism to enhance feature fusion accuracy and capture fine-grained details. In addition, the WIoU v3 loss function is introduced to optimize object localization performance. By constructing a multi-angle green jujube dataset and applying data augmentation techniques, the model’s generalization capability was significantly improved. The results of the experiement indicate that the improved BCW-YOLO achieves precision, recall, mAP, and F1 score of 90.87%, 92.12%, 95.66%, and 91.49%, respectively, representing increases of 1.93%, 2.77%, 1.58%, and 2.34% compared to the original YOLO model. Through comprehensive validation using confusion matrices, PR curves, heatmap analyses, and ablation studies, the model’s performance was thoroughly verified. Compared with other YOLO series models, BCW-YOLO performs exceptionally well in detecting minor damages, demonstrating its potential in practical agricultural grading. The findings provide a new technical approach for precise grading and automated sorting of green jujube, showing promising application prospects.

1. Introduction

Green jujube (Ziziphus mauritiana Lam.) is a plant in the Rhamnaceae family and Ziziphus genus, also known as Indian jujube, Yunnan thorn jujube, and large green jujube. It is native to India, Myanmar, and China, primarily distributed in tropical and subtropical regions, and is classified as a deciduous tree or shrub. The fruit of green jujube is rich in carbohydrates, proteins, fatty acids, minerals, carotenoids, vitamin C (2–3 times the content found in common fruits), and various bioactive compounds [1]. According to statistics, the global annual production of green jujube exceeds 900,000 tons [2]. In China, the cultivated area reaches 21,000 hectares with an annual production of over 200,000 tons [3]; in India, it covers 90,000 hectares with an annual yield of approximately 700,000 tons; in Pakistan, there are about 5425 hectares, with a production of around 28,000 tons [4].
The quality of green jujube is a key factor determining its market competitiveness [5]. Sensory quality is the primary driver for consumer purchasing decisions, continuously influencing their willingness to buy. Consumers tend to favor jujubes with a proper shape, smooth surface, and no defects. Therefore, it is essential to detect and grade green jujubes before entering the market, which significantly boosts the income of farmers. Green jujube has a thin skin, which is prone to damage and deterioration during harvesting and transportation, and damaged fruits are susceptible to infection by other fruits. Given the concentrated production areas of green jujube and its short shelf life, it is crucial to grade, store, and sell them in a timely manner based on factors such as fruit size and surface defects.
Currently, the grading of green jujube mainly relies on simple screening or manual sorting based on experience, which is labor-intensive, inefficient, and subject to subjective judgment standards. This makes the rapid grading of green jujubes under the same criteria a significant technical challenge. Most existing fruit sorting equipment relies on simple color and size-based grading, a method widely applied to fruit recognition such as citrus [6], strawberries [7], and plums [8]. However, such sorting equipment is relatively basic and cannot accurately detect fruits with surface defects. Therefore, developing an efficient and precise jujube detection and grading system is crucial for improving production efficiency, reducing costs, and enhancing the market competitiveness of green jujube.
In recent years, deep learning has become one of the most effective target detection methods in agriculture, widely used in key processes such as fruit recognition, pest and disease diagnosis, yield estimation, and quality grading [9]. As shown in Table 1, Wang et al. (2024) [10] proposed a lemon surface disease YOLO model (LSD-YOLO), which integrates switchable atrous convolution (SAConv) and convolutional block attention module (CBAM), and adds a small target detection layer based on the C2f-SAC structure to enhance the extraction of key features and the fusion of features at different scales. The proposed LSD-YOLO model achieved an accuracy of 90.62%. Liang et al. (2022) [11] proposed an apple injury prevention conveyance system based on independent fruit stalks, integrating BiSeNet V2 semantic segmentation and pruning YOLO V4 detection technology to accurately identify defect areas and map their size, achieving an accuracy rate of 92.42%, with significant application potential in commercial sorting equipment. Li and Mao (2023) [12] proposed an improved YOLOv7, embedding the parameter-free attention module SimAM into the original YOLOv7 backbone, replacing the standard convolution with GSconv at the neck, using shallow networks for lateral connections instead of deep networks, and adopting the Mish activation function. The improved YOLOv7 achieved an accuracy rate of 91.56% and an mAP of 93.42%. Almutairi et al. (2024) [13] used deep learning techniques and the YOLO algorithm to detect and classify 9 types of date palms, achieving high accuracy. Chiou et al. (2025) [14] proposed using YOLOv4 for appearance defect detection of guava fruits, achieving a precision of 92.44%. Jrondi et al. (2025) [15] introduced a citrus fruit quality classification pipeline based on the ViT-Base model vit_base_patch16_224 and Microsoft Phi-3-mini LLM, reaching an accuracy of 98.29%. Gu et al. (2024) [16] developed an improved YOLOv8 model and successfully deployed it on the edge device NVIDIA Jetson Orin Nano for mango fruit detection.
Table 1. Performance of Different Deep Learning Models in Fruit Detection Tasks.
In the field of jujube quality detection and grading, the application of deep learning methods has been increasing. Sun et al. (2019) [17] proposed a deep network with a multi-visual attention mechanism, achieving high classification accuracy in large-scale red jujube image grading. Gao et al. (2024) [18] developed a red jujube quality assessment method based on an object detection network, enabling multi-task capability for simultaneous localization and grading, providing a foundational framework for automated jujube inspection. To address data imbalance, Cang et al. (2023) [19] introduced a generative adversarial network (Jujube-GAN) to augment defective red jujube images, significantly improving the F1 score in imbalanced grading tasks. Ban et al. (2023) [20] combined physical indicators with deep visual models to achieve high-accuracy classification of winter jujube maturity levels, revealing intrinsic quality differences across maturity stages. Ju et al. (2022) [21] implemented automatic defect detection in jujubes based on convolutional networks and transfer learning, offering a practical solution for production-line defect inspection.
However, current research on jujube quality detection primarily focuses on red and winter jujubes, with very few studies on green jujubes. Moreover, these studies still have limitations in fine-grained defect recognition and multi-scale feature fusion. For example, existing methods largely rely on traditional CNN architectures or specific augmentation techniques, limiting accuracy in distinguishing multiple texture damages and minor flaws. Additionally, a unified end-to-end metric optimization mechanism is often lacking.
Against this background, this study proposes an improved BCW-YOLO model for green jujube quality detection. The BCW-YOLO model demonstrates significant performance improvements over the original baseline models. The main contributions of this study are:
  • An improved BCW-YOLO model for green jujube grading detection is proposed. The architecture integrates the bidirectional feature pyramid network (BiFPN) and the context transformation (COT) attention mechanism, which fuses both static and dynamic contextual information, to improve detection accuracy and robustness.
  • Green jujube images are classified and annotated, and a multi-angle image dataset is constructed and augmented using data enhancement techniques for model training, validation, and testing.
  • The model’s performance and generalization capability are comprehensively evaluated using various validation methods, including confusion matrix analysis, PR curve analysis, heatmap analysis, ablation experiments, and multi-model comparisons.
The organization of this paper is as follows: Section 2 introduces the dataset and preprocessing methods in detail, and provides a thorough description of the BCW-YOLO model architecture and its components. Section 3 presents the experimental results, emphasizing various validation methods to demonstrate model performance. Finally, the study summarizes the main contributions and outlines directions for future research.

2. Materials and Methods

Figure 1 illustrates the overall workflow of this study. Images of green jujubes were first collected and preprocessed, followed by annotation to obtain the bounding boxes and class information for each instance. Data augmentation techniques, including mirror flipping, Gaussian blur, contrast adjustment, random translation, and image stitching, were then applied to increase data diversity. The processed data were used to train the improved BCW-YOLO model for automatic grading and recognition of green jujubes. Finally, the training results were evaluated using loss curves, confusion matrices, PR curves, and multi-model performance comparisons.
Figure 1. Overall workflow for green jujube grading study.

2.1. Dataset Construction

The samples used in this study were sourced from the National Fujian-Taiwan Specialty Crop Germplasm Resource Nursery, subtropical agriculture research institute of the Fujian Academy of Agricultural Sciences (117° E, 24° N, 50 m above sea level). The green jujube varieties included in the study were: Apple jujube, Gaolang No. 1, Jinshi honey jujube, Peach honey, Tainong 11, Honey jujube, and Persimmon jujube. All images were captured using an Apple iPhone 12 (Apple Inc., Cupertino, CA, USA), with a resolution of 2532 × 1170 pixels. To facilitate subsequent fruit automation sorting applications, the jujubes were photographed from multiple angles (Figure 2), resulting in a total of 785 original images.
Figure 2. Green jujube photographed from different angles. (a) Side view of the fruit; (b) Base of the fruit; (c) Top of the fruit.
For classification purposes, green jujube fruits were graded based on the agricultural industry standard NYT484-2018 [22] into four categories: Grade A, Grade B, Grade C, and Cull (Figure 3). Grade A fruits have a proper shape and a defect-free surface, and are labeled as Grade A. Grade B fruits also have a proper shape but may exhibit minor defects such as light blemishes or bruises, with a total area not exceeding 0.5 cm2, and no defects caused by pesticide damage; these are labeled as Grade B. Grade C fruits have shape imperfections, allowing for slight defects but no deformities; light insect damage, bruising, or surface injuries that do not severely affect the fruit’s appearance are permitted, with a total area not exceeding 1.0 cm2; these are labeled as Grade C. Cull fruits have an improper shape with obvious deformities or significant damage, such as bruising, puncture wounds, insect damage, blemishes, or rot; these are labeled as Cull. To ensure data accuracy, each image was annotated using the LabelImg (v1.8.1) tool, strictly following the “single object, single box” principle to mark the areas of surface damage on the jujubes [23].
Figure 3. Examples of fruits from different grades. (a) Grade A fruit. (b) Grade B fruit. (c) Grade C fruit. (d) Cull fruit.
Training a model requires a large dataset, as a small dataset can lead to neural network overfitting [24]. To enhance the effectiveness of network training and improve model generalization, data augmentation techniques were applied to the collected data [25]. To avoid data leakage, the original data was first divided into training, validation, and testing sets using a stratified random split method at a 75%:15%:15% ratio. Then, various data augmentation techniques, including image flipping, Gaussian blur, contrast adjustment, random translation, and image stitching, were randomly combined [26] to expand the image data. This resulted in a training set of 3293 images, a validation set of 715 images, and a test set of 702 images. The number of samples in each subset is shown in Figure 4.
Figure 4. Sample distribution across different categories in each dataset.

2.2. BCW-YOLO Network Architecture

YOLOv8, released by Ultralytics in 2023, features a robust deep learning framework and powerful training techniques, allowing it to handle more complex image recognition tasks [27]. The YOLOv8 network model consists of three parts: the backbone, the neck, and the head. The backbone is responsible for feature extraction, and the head handles the final target detection task, adopting a decoupled head structure and transitioning from anchor-based to anchor-free methods [28].
To further improve the accuracy, recall rate, and other performance metrics of the green jujube quality detection model, this study proposes an improved BCW-YOLO network structure based on the YOLOv8 model. First, the Concat module in the neck network is replaced with the BiFPN module, which introduces bidirectional feature fusion, allowing low-level and high-level features to complement each other and achieve more precise multi-scale feature fusion. Second, a Contextual Transformer Attention (COT) module is cascaded before the Pyramid Pooling (SPPF) layer. By combining local context mining with dynamic attention learning, the ability to represent visual features is enhanced. Finally, the WIoUv3 loss function replaces the original CIoU loss function, effectively reducing the negative impact of low-quality samples on the bounding box regression (BBR) training by dynamically allocating gradient gains, thus improving the model’s generalization ability and localization accuracy. The improved network architecture is shown in Figure 5.
Figure 5. BCW-YOLO Network Architecture.

2.2.1. Bidirectional Feature Pyramid Network (BiFPN)

To improve the efficiency and accuracy of feature fusion, we replaced the original feature fusion module in the network with the BiFPN (Bidirectional Feature Pyramid Network) module. BiFPN, proposed by Mingxing Tan et al. [29], is an optimization method aimed at addressing the challenge of multi-scale feature fusion. This method significantly improves feature fusion by introducing bidirectional feature fusion (top-down and bottom-up), resulting in a more effective fusion process. As shown in Figure 6, traditional Feature Pyramid Networks (FPN) only use a top-down feature fusion path, gradually merging high-level features into low-level features. This single-direction fusion method may lead to the loss of important information in low-resolution features during the fusion process. In contrast, BiFPN allows bidirectional information flow, enabling low-level and high-level features to complement each other, achieving more accurate multi-scale feature fusion. This bidirectional connection allows the network to capture both high-level abstract features and low-level detailed features, effectively improving the model’s performance on complex tasks. Additionally, BiFPN introduces a learnable weighting mechanism, which assigns weights to each input feature. This mechanism enables the network to adaptively adjust fusion weights based on the contribution of different scale features, ensuring that more important features receive greater attention during fusion, thereby improving the accuracy of feature fusion and the overall performance of the model.
Figure 6. Comparison of Traditional FPN and BiFPN.

2.2.2. COT Attention Mechanism

To enhance the network’s ability to learn detailed features of surface damage on green jujubes, we introduced the COT (Contextual Transformer) attention mechanism into the backbone network. This attention mechanism, proposed by Yehao Li et al. [30], aims to improve performance in visual recognition tasks by enhancing the contextual information in the traditional self-attention mechanism. Unlike conventional self-attention methods that model relationships using only local query–key pairs, the COT attention mechanism first captures static contextual information between keys through a 3 × 3 convolution. Then, dynamic attention matrices are computed based on this contextual information combined with the queries. As shown in Figure 7, in the COT module, the keys in the input feature map undergo a 3 × 3 convolution to obtain a static context representation. The static context is then combined with the queries, and dynamic multi-head attention matrices are calculated through consecutive 1 × 1 convolutions. This attention matrix is subsequently multiplied with the input values to generate dynamic context representations. Finally, static and dynamic context information is fused together to form the final output features. This method effectively enhances the self-attention mechanism, allowing it to capture long-range dependencies in the spatial feature map while avoiding the neglect of local relationships that is common in traditional methods. With this context-enhanced self-attention mechanism, our model is able to more accurately fuse features, thus improving the accuracy and robustness of green jujube damage detection.
Figure 7. Structure of the COT Attention Mechanism.

2.2.3. WIoU v3 Loss Function

To improve the model’s localization performance and generalization ability, this study introduced the WIoU (Wise-IoU v3) loss function proposed by Zanjia Tong et al. [31], replacing the original CIoU loss function. This modification aims to solve the issue of slow localization of predicted bounding boxes during training, thereby enhancing the model’s convergence speed and localization accuracy. WIoU v3 is an improved bounding box regression loss function that introduces a dynamic non-monotonic focus mechanism (FM). This mechanism dynamically adjusts gradient gains based on the quality of the bounding boxes, minimizing the negative impact of low-quality samples on the regression process while maintaining focus on ordinary quality samples. Specifically, WIoU v3 evaluates the outlier degree between anchor boxes and ground truth boxes to dynamically allocate gradient gains. For high-quality anchor boxes, i.e., those with a high overlap with the target boxes, WIoU v3 assigns smaller gradient gains to avoid over-optimizing high-quality samples. Conversely, for low-quality anchor boxes, larger gradient gains are allocated to minimize their negative impact on the regression process. This method effectively reduces the negative influence of low-quality samples on bounding box regression (BBR) and enhances the model’s attention to ordinary quality samples, thereby improving localization performance and generalization ability. The relationship between anchor boxes B → = {x, y, w, h} and ground truth boxes Bgt → = {xgt, ygt, wgt, hgt} is illustrated in Figure 8, where the values represent the center coordinates and sizes of each bounding box. By employing this approach, WIoU v3 enhances the network’s adaptability in handling different quality samples, thus improving training outcomes and localization accuracy [32].
Figure 8. Illustration of anchor box and target box.

2.3. Evaluation Metrics

Selecting appropriate evaluation metrics is crucial for measuring model performance [33]. In this study, the following metrics were used to assess the model’s performance: Precision, Recall, F1 score, and mAP (mean of Average Precision). Precision is defined as the ratio of correctly predicted positive samples to the total number of samples predicted as positive [34], as shown in the formula:
P r e c i s i o n = T P T P + F P × 100 %
where TP represents the number of true positive samples, and FP represents the number of false positive samples.
Recall represents the ratio of correctly predicted positive samples to the total number of actual positive samples [35], as shown in the formula:
R e c a l l = T P T P + F N × 100 %
where FN represents the number of false negative samples.
The F1 score is the harmonic mean of Precision and Recall, used to evaluate the balanced performance of the model [36], as shown in the formula:
F 1 = 2 × P × R P + R × 100 %
mAP (mean Average Precision) measures the overall performance of the model [37], and is calculated as follows:
A P i = 0 1 P r d r × 100 %
m A P = 1 N i = 1 N A P i × 100 %
where mAP@0.5mAP@0.5mAP@0.5 (commonly referred to as “mAP”) is the mAP calculated when the Intersection over Union (IoU) threshold is 0.5, meaning a predicted box is considered correct if the overlap with the ground truth box is ≥50%. mAP@0.5:0.95mAP@0.5:0.95mAP@0.5:0.95 is the average mAP calculated across IoU thresholds from 0.5 to 0.95 (with a step size of 0.05).

3. Results and Analysis

3.1. Experimental Environment

To ensure fairness in the experiments, all tests were conducted on a server with identical performance specifications. The server used an Intel (R) Xeon (R) Platinum 8481C processor (16 vCPUs), an RTX 4090D GPU (24GB VRAM), and 80 GB of memory, with the operating system being Ubuntu 20.04. The experiments were implemented using the Pytorch 1.10 framework, CUDA version 11.3, and Python 3.8 as the programming language. The input image size was set to 640 × 640 pixels, and the batch size was 16 images. The learning rate was set to 0.01, weight decay to 0.0005, and momentum to 0.937. During training, the stochastic gradient descent (SGD) optimizer was used, with the number of training epochs set to 300, an early stopping patience of 50, and the random seed fixed at 0. The best model weights obtained during training were used to evaluate the test set.

3.2. Model Training Results

3.2.1. Performance Comparison Before and After Improvement

The improved BCW-YOLO model outperforms the original baseline model in several metrics. The accuracy, recall, mAP50, and F1 score of the improved model were 90.87%, 92.12%, 95.66%, and 91.49%, respectively, showing improvements of 1.93%, 2.77%, 1.58%, and 2.34% compared to the original YOLOv8n model (Figure 9).
Figure 9. Model performance before and after improvement.
In addition to the improvement in performance metrics, the model’s training and validation losses also showed noticeable changes. As shown in Figure 10, during training, the improved model exhibited a rapid and stable decline in bounding box loss for both training and validation, with smooth curves and no significant oscillations, indicating good convergence of the bounding box regression task. Regarding classification loss, the trends for both training and validation were highly consistent, with no obvious signs of overfitting.
Figure 10. Loss curves during the training process of the improved model.

3.2.2. Confusion Matrix Analysis

To evaluate the performance improvements across the four categories, a detailed analysis of the confusion matrices before and after the model improvement was conducted. The confusion matrix is an essential tool for evaluating classification model performance, particularly in multi-class problems, as it provides detailed insights into prediction accuracy and misclassification rates [38]. As shown in Figure 11, the performance of the improved model has increased across all categories, especially for Grade A and Cull categories. The reduction in misclassification rates further indicates that the model’s ability to differentiate between categories has been enhanced, improving overall classification stability and accuracy. This result suggests that the improved model has better generalization ability and robustness, making it more suited for the classification of green jujubes.
Figure 11. Confusion matrices for model inference before and after improvement. (a) Baseline model’s confusion matrix. (b) Improved model’s confusion matrix. Note: The “background” class is automatically added for statistical purposes to indicate detection errors and does not represent an actual training label.

3.2.3. PR Curve Analysis

PR curves show the trade-off between Precision and Recall, effectively reflecting model performance on imbalanced datasets, especially in terms of the changes in classification precision and recall across different categories [39]. As shown in Figure 12a, the performance of the model before improvement exhibited significant variations across categories. Notably, for Grade B and Cull categories, the PR curves were relatively steep, showing a poor balance between precision and recall and indicating lower overall performance. This suggests that the pre-improvement model had some errors, particularly when achieving high recall, where precision dropped rapidly. After improvement, the model’s PR curves (Figure 12b) significantly outperformed the baseline model’s curves. Notably, the PR curves for Grade A and Cull categories improved significantly, with a more optimized balance between precision and recall. Comparing the PR curves, it is clear that the improved model has demonstrated greater stability and accuracy when handling different categories, with a significant improvement observed for the Cull category. This result indicates that the improvements to the model effectively enhanced its recognition capabilities across categories, especially in balancing precision and recall, showcasing its better generalization ability.
Figure 12. Precision–Recall curves before and after model improvement. (a) Baseline model PR curve. (b) BCW-YOLO model PR curve.

3.2.4. Heatmap Analysis

Feature extraction is key in object detection [40]. Due to the lack of transparency in the computational process of neural networks, Grad-CAM (Gradient-weighted Class Activation Mapping) technology was used in this study to generate heatmaps [41]. Grad-CAM generates class activation maps for detection models, clearly showing where the network focuses during the detection task. In the heatmaps, red areas indicate higher attention and contribution from the network at those locations [42].
For the original YOLOv8 model, as shown in Figure 13b, the heatmap still shows many hot spots outside the target region. This indicates that the original network focused on features unrelated to the target detection, and these irrelevant features might negatively impact the model’s detection ability. However, after modification, the heatmap of the improved BCW-YOLO model (Figure 13c) shows significant changes, with the hot spots outside the target region greatly reduced or even eliminated. The focus of the heatmap is more concentrated on the target region, indicating that the improved model’s attention during feature extraction is more focused, effectively reducing the attention on irrelevant information and improving the accuracy of target detection.
Figure 13. Heatmaps before and after network improvement. (a) Original image. (b) Pre-improvement. (c) Post-improvement.

3.3. Ablation Experiment

To further verify the impact of each improvement in the BCW-YOLO model on its performance, we conducted an ablation experiment. The improvements included three components: (A) replacing the original Concat module in the neck network with BiFPN; (B) introducing the COT attention mechanism into the backbone network; and (C) replacing the original CIoU loss function with the WIoUv3 loss function. The experiments evaluated the effects of these combinations on object detection precision, recall, mAP50, F1 score, GFLOPs, FPS, and model size (Table 2).
Table 2. Ablation Experiment Results.
As shown in Table 2, the results of the ablation experiment demonstrate that each improvement significantly contributes to the enhancement of the model’s performance. The baseline model (without any improvements) exhibited moderate performance in terms of precision, recall, mAP50, and F1 score. Introducing BiFPN alone (Improvement A) significantly increased the model’s recall and mAP50, indicating that BiFPN helps enhance feature fusion and improves the utilization of multi-scale information. However, the inclusion of BiFPN increased GFLOPs to 23.8, reduced FPS to 215.68, and expanded the model size from 5.4 M to 19.1 M, showing that the performance gains inevitably come with higher computational costs. With the addition of the COT attention mechanism (Improvement B), precision improved noticeably, while recall changed only slightly. This indicates that the COT attention mechanism enhances the model’s discriminative capability for target objects. In terms of computational cost, its impact on GFLOPs and model size was minimal, showing only a slight increase. Using the WIoUv3 loss function (Improvement C) led to significant improvements in both precision and recall without introducing extra computational overhead. This demonstrates that WIoUv3 can better optimize the model’s object localization ability without increasing computational demands, improving overall performance. The combination of Improvements A and B produced substantial performance gains, especially in recall. The combination of Improvements A and C focused more on balancing recall and precision. The final model, integrating all three improvements, achieved the best results across all performance metrics, with precision of 90.87%, recall of 92.12%, mAP50 of 95.66%, and an F1 score of 91.49%. Although this three-fold improvement increased GFLOPs to 25.6, model size to 23.5 M, and reduced FPS to 195.1, it still far exceeds the real-time detection requirement of 30 FPS, indicating a reasonable trade-off between computational cost and performance gain.
In summary, the results of the ablation experiment show that each of the improvements in the BCW-YOLO model plays a significant role in enhancing its performance. Each modification contributes to increasing precision, recall, mAP50, and F1 score. The combination of BiFPN, COT attention mechanism, and WIoUv3 loss function results in a more stable and precise model for target detection tasks. Ultimately, the combined application of all three improvements significantly enhanced the overall performance of the model, confirming that these modifications effectively optimize the object detection capabilities of the BCW-YOLO model. Although the increases in GFLOPs and model size indicate a reduction in processing speed, the BCW-YOLO model still meets the requirements for real-time detection.

3.4. Comparison Experiment

To further demonstrate the superiority of the improved model, we conducted comparison experiments with several YOLO series algorithms. To ensure fairness, we used a consistent experimental environment and the same parameter settings. As shown in Table 3, BCW-YOLO achieved a precision of 90.87%, recall of 92.12%, mAP50 of 95.66%, and an F1 score of 91.49%. These values not only outperform other YOLO models but also highlight the overall advantages of this model in the green jujube detection task. In comparison, while YOLOv3 achieved a higher mAP50 (96.01%), its recall (91.71%) and F1 score (91.05%) were both lower than BCW-YOLO, suggesting that although it excels in localization accuracy, it lags in target capture and overall performance. YOLOv5 and YOLOv6 series performed relatively weaker, with YOLOv5, in particular, achieving a precision of 87.31% and recall of 87.87%. Its mAP50 (92.91%) and F1 score (87.59%) also showed inferior performance, indicating that these models had poorer accuracy and target recognition ability in the green jujube detection task. It is also worth noting that while YOLOv10s showed good performance in precision (90.87%) and mAP50 (95.24%), its recall and F1 score were relatively lower, meaning it might sacrifice some detection precision to improve target capture capability. Overall, BCW-YOLO outperforms other YOLO series models in terms of precision, recall, mAP50, and F1 score, proving its efficiency and stability in the green jujube detection task, with stronger practical application potential.
Table 3. Comparison Experiment Results.
In this study, we conducted a detailed analysis of the inference results from multiple algorithms. Figure 14 shows part of the detection results, which indicate that BCW-YOLO performs better than other YOLO models in the green jujube detection task. Specifically, BCW-YOLO excels in both detection accuracy and classification performance, especially in detecting minor damages, accurately identifying and classifying the jujubes. In contrast, YOLOv5 exhibited the highest false detection rate, with a significant number of incorrect detections. YOLOv10 followed closely, misclassifying several Grade C jujubes as Cull. In summary, BCW-YOLO demonstrates a clear advantage in handling the details and precision of green jujube detection, particularly when dealing with minor damages, showing a higher level of accuracy.
Figure 14. Detection Results of Different Models. (a) Original image. (b) BCW-YOLO detection result. (c) YOLOv5 detection result. (d) YOLOv10 detection result. (e) YOLOv11 detection result.

4. Discussions

With the rapid development of agricultural intelligence, fruit quality grading has become an essential aspect of improving production efficiency and market competitiveness [43]. With the rapid advancement of smart agriculture, fruit quality grading has become a key factor in improving production efficiency and market competitiveness [36]. In recent years, deep learning has achieved significant progress in the detection and grading of agricultural products. Deep convolutional neural networks (CNNs), due to their excellent ability to learn visual features, have been widely applied in external quality inspection, defect recognition, and grading tasks, effectively replacing traditional manual grading methods and improving both efficiency and consistency. In specific fruit grading studies, various solutions have been proposed to address surface defect detection and grade classification. For example, Liu et al. [44] proposed the ATC-YOLOv5 algorithm, which improved the feature pyramid and introduced an attention mechanism, achieving an mAP50 of 95.36% for passion fruit quality classification. Wu et al. [45] developed an improved apple quality detection model, achieving an mAP of 93.7%, but the model had high computational demands and could only reach a processing speed of 45.1 FPS on an RTX 4090 GPU.
Compared with existing studies, the BCW-YOLO model demonstrates stronger balance in the quality grading of green jujube.The improved model outperforms traditional YOLO models in precision, recall, mAP50, and F1 score, particularly excelling at detecting minor surface damages and defects. By incorporating a Bidirectional Feature Pyramid Network (BiFPN), the COT attention mechanism, and the WIoU v3 loss function, BCW-YOLO significantly enhances detection performance in multi-scale feature fusion, fine-detail learning, and localization accuracy. The BiFPN module strengthens the network’s ability to integrate multi-scale features, the COT attention mechanism improves the capture of fine-grained details, and the WIoU v3 loss function effectively optimizes object localization, reducing false positives and missed detections. Compared with models such as YOLOv5 and YOLOv6, BCW-YOLO achieves a better balance between precision and recall, showing particularly high accuracy in classifying Grade A and Cull categories. Although the performance improvements increase computational demands and reduce FPS compared with the baseline, the model still operates at 195.1 FPS, far exceeding the requirement for real-time detection. Overall, the analysis confirms that BCW-YOLO has strong application potential for green jujube grading.
Despite the excellent performance of the BCW-YOLO model in green jujube grading, there are still some limitations. First, the model’s training relies heavily on large amounts of labeled data, particularly the labeling of surface damage and defects in green jujubes. While we expanded the training dataset through data augmentation, the diversity and coverage of the data remain limited, particularly for jujube images from different production areas and environmental conditions [46]. In addition, all images were captured using an iPhone 12, which differs significantly from the fixed industrial cameras typically used in practical sorting or grading systems. This discrepancy may affect the model’s performance in real-world applications. Therefore, future work could involve data collection using multiple imaging devices (e.g., fixed industrial cameras and high-quality mobile devices) and gathering more diverse datasets across various regions and environmental conditions. Expanding the dataset and including more types of fruit damage samples would further enhance the model’s generalization capability [47]. Second, although the improved model has achieved gains in precision and recall, its performance in handling extremely small damages and severely deformed fruits still requires further enhancement. To address this, exploring more advanced damage feature extraction methods and integrating other image processing technologies may help further improve the model’s precision [48].
Future research can expand on several directions. First, more visual information, such as infrared or multispectral images, can be incorporated to enhance the model’s stability and accuracy under different lighting conditions [49]. Additionally, the real-time performance and processing speed of the model are crucial areas for future research, especially when BCW-YOLO is applied to actual agricultural sorting systems. Further optimization of inference speed will be necessary to ensure practical use. To improve sorting efficiency, combining the model with hardware devices such as automated sorting robots could enable efficient real-time detection and classification [50]. Finally, future work may explore the application of the BCW-YOLO model in grading other agricultural products, validating its applicability and generalization ability across different crops and fruit varieties.

5. Conclusions

The BCW-YOLO model proposed in this study significantly improved the accuracy and robustness of green jujube quality grading, particularly excelling in detecting minor damages. By introducing the BiFPN module, the COT attention mechanism, and the WIoU v3 loss function, the model achieved improvements in several key performance indicators, particularly in precision, recall, and mAP50. Compared to existing YOLO models, BCW-YOLO demonstrated superior overall performance in green jujube grading tasks, accurately identifying and classifying different grades of jujubes. The findings of this study provide a new technological pathway for automated grading of green jujube. Future research can further explore the model’s application in detecting a broader range of surface defects and other fruit varieties. Additionally, optimizing the dataset and enhancing model diversity could improve its generalization ability and applicability in more complex environments. In practical applications, the BCW-YOLO model shows considerable potential, providing technical support for the precise grading of green jujubes and enhancing market competitiveness. With the continued development of agricultural intelligence, deep learning-based automated sorting technology will become a key force in enhancing the quality of agricultural products.

Author Contributions

Conceptualization, methodology, investigation, formal analysis, data curation, validation, writing—original draft, and writing—review and editing, P.C.; conceptualization, methodology, investigation, formal analysis, data curation, validation, writing—original draft, and data curation, X.Z.; methodology, writing—original draft, visualization, investigation, validation, and writing—review and editing, H.W.; methodology, investigation, writing—review and editing, and validation, S.W.; conceptualization, resources, supervision, and writing—review and editing, F.J. All authors have read and agreed to the published version of the manuscript.

Funding

This research was financially supported by the Basic Scientific Research Project of Fujian Public Welfare Scientific Research Institute (2025R1028003, 2025R1028002, and 2025R11010015-3), the Natural Science Foundation Project of Zhangzhou City (ZZ2025JH09), the National Tropical Plants Germplasm Resource Center (NTPGRC2025-032), and the National Germplasm Repository for Fujian-Taiwan Characteristic Crops (Zhangzhou).

Data Availability Statement

The original contributions presented in the study are included in the article. Further inquiries can be directed to the corresponding author.

Conflicts of Interest

The authors declare no conflicts of interest. The funders had no role in the design of the study, in the collection, analyses, or interpretation of data, in the writing of the manuscript, or in the decision to publish the results.

References

  1. Krishna, H.; Kumar, L.; Haldhar, S.M.; Singh, D.; Saroj, P.L. Phenological growth stages of Indian jujube (Ziziphus mauritiana Lamk.) according to the BBCH scale. Ann. Appl. Biol. 2018, 174, 106–112. [Google Scholar] [CrossRef] [Scilit]
  2. Anjum, M.A.; Haram, A.; Ahmad, R.; Bashir, M.A. Physico-chemical attributes of fresh and dried Indian jujube (Zizyphus mauritiana) fruits. Pak. J. Agric. Sci. 2020, 57, 165–176. [Google Scholar]
  3. Zhou, C. Investigation on the Fresh Jujube Industry in China. Master’s Thesis, Northwest A&F University, Xianyang, China, 2023; pp. 25–34. [Google Scholar]
  4. Ahmad, I.; Nafees, M.; Ashraf, I.; Ahmad, B.; Qureshi, R. Fruit morphological attributes to assess genetic diversity in jujube (Ziziphus mauritiana L.) germplasm of Bahawalpur. Pure Appl. Biol. (PAB) 2016, 5, 921–926. [Google Scholar] [CrossRef] [Scilit]
  5. Zhang, C.; Hao, Y.J. Advances in genomic, transcriptomic, and metabolomic analyses of fruit quality in fruit crops. Hortic. Plant J. 2020, 6, 361–371. [Google Scholar] [CrossRef] [Scilit]
  6. Gan, H.; Lee, W.S.; Alchanatis, V.; Ehsani, R.; Schueller, J.K. Immature green citrus fruit detection using color and thermal images. Comput. Electron. Agric. 2018, 152, 117–125. [Google Scholar] [CrossRef] [Scilit]
  7. Yamamoto, S.; Hayashi, S.; Yoshida, H.; Kobayashi, K. Development of a stationary robotic strawberry harvester with a picking mechanism that approaches the target fruit from below. Jpn. Agric. Res. Q. JARQ 2014, 48, 261–269. [Google Scholar]
  8. Kaur, H.; Sawhney, B.K.; Jawandha, S.K. Evaluation of plum fruit maturity by image processing techniques. J. Food Sci. Technol. 2018, 55, 3008–3015. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  9. Lu, Z.; Zhao, M.; Luo, J.; Wang, G.; Wang, D. Design of a winter-jujube grading robot based on machine vision. Comput. Electron. Agric. 2021, 186, 106170. [Google Scholar] [CrossRef] [Scilit]
  10. Wang, S.; Li, Q.; Yang, T.; Li, Z.; Bai, D.; Tang, C.; Pu, H. LSD-YOLO: Enhanced YOLOv8n Algorithm for Efficient Detection of Lemon Surface Diseases. Plants 2024, 13, 2069. [Google Scholar] [CrossRef] [Scilit]
  11. Liang, X.; Jia, X.; Huang, W.; He, X.; Li, L.; Fan, S.; Li, J.; Zhao, C.; Zhang, C. Real-Time Grading of Defect Apples Using Semantic Segmentation Combination with a Pruned YOLO V4 Network. Foods 2022, 11, 3150. [Google Scholar] [CrossRef] [Scilit]
  12. Li, Y.; Mao, L. An improved YOLOv7 method to identify epidermal defects in mature litchi. J. Intell. Fuzzy Syst. 2023, 45, 12027–12036. [Google Scholar] [CrossRef] [Scilit]
  13. Almutairi, A.; Alharbi, J.; Alharbi, S.; Alhasson, H.F.; Alharbi, S.S.; Habib, S. Date Fruit Detection and Classification Based on Its Variety Using Deep Learning Technology. IEEE Access 2024, 12, 190666–190677. [Google Scholar] [CrossRef] [Scilit]
  14. Chiou, K.-D.; Chen, Y.-X.; Chen, P.-S.; Jou, Y.-T.; Tsai, S.-H.; Chang, C.-Y. Application of deep learning for fruit defect recognition in Psidium guajava L. Sci. Rep. 2025, 15, 6145. [Google Scholar] [CrossRef] [Scilit]
  15. Jrondi, Z.; Moussaid, A.; Hadi, M.Y. Interpretable Citrus Fruit Quality Assessment Using Vision Transformers and Lightweight Large Language Models. AgriEngineering 2025, 7, 286. [Google Scholar] [CrossRef] [Scilit]
  16. Gu, Z.; He, D.; Huang, J.; Chen, J.; Wu, X.; Huang, B.; Dong, T.; Yang, Q.; Li, H. Simultaneous detection of fruits and fruiting stems in mango using improved YOLOv8 model deployed by edge device. Comput. Electron. Agric. 2024, 227, 109512. [Google Scholar] [CrossRef] [Scilit]
  17. Sun, X.; Ma, L.; Li, G. Multi-vision attention networks for on-line red jujube grading. Chin. J. Electron. 2019, 28, 1108–1117. [Google Scholar] [CrossRef] [Scilit]
  18. Gao, Y.; Yuan, B.; Zhu, Q.; Zhao, J.; Ma, X.; Chen, J.; Wang, F.; Chu, P.; Wang, C. Deep Learning Based Jujube Quality Assessment: An Automated Surface Defect Detection Approach. In Proceedings of the 2024 7th International Conference on Signal Processing and Machine Learning, Qingdao, China, 12–14 July 2024; pp. 75–81. [Google Scholar]
  19. Cang, H.; Yan, T.; Duan, L.; Yan, J.; Zhang, Y.; Tan, F.; Lv, X.; Gao, P. Jujube quality grading using a generative adversarial network with an imbalanced data set. Biosyst. Eng. 2023, 236, 224–237. [Google Scholar] [CrossRef] [Scilit]
  20. Ban, Z.; Fang, C.; Liu, L.; Wu, Z.; Chen, C.; Zhu, Y. Detection of fundamental quality traits of winter jujube based on computer vision and deep learning. Agronomy 2023, 13, 2095. [Google Scholar] [CrossRef] [Scilit]
  21. Ju, J.; Zheng, H.; Xu, X.; Guo, Z.; Zheng, Z.; Lin, M. Classification of jujube defects in small data sets based on transfer learning. Neural Comput. Appl. 2022, 34, 3385–3398. [Google Scholar]
  22. NY/T 484-2018; India jujube. China Agriculture Press: Beijing, China, 2018.
  23. Kaur, J.; Singh, W. Tools, techniques, datasets and application areas for object detection in an image: A review. Multimed. Tools Appl. 2022, 81, 38297–38351. [Google Scholar] [PubMed]
  24. Alomar, K.; Aysel, H.I.; Cai, X. Data augmentation in classification and segmentation: A survey and new strategies. J. Imaging 2023, 9, 46. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  25. Cheung, T.H.; Yeung, D.Y. A survey of automated data augmentation for image classification: Learning to compose, mix, and generate. IEEE Trans. Neural Netw. Learn. Syst. 2023, 35, 13185–13205. [Google Scholar]
  26. Tatar, A.; Haghighi, M.; Zeinijahromi, A. Experiments on image data augmentation techniques for geological rock type classification with convolutional neural networks. J. Rock Mech. Geotech. Eng. 2025, 17, 106–125. [Google Scholar]
  27. Sapkota, R.; Flores-Calero, M.; Qureshi, R.; Badgujar, C.; Nepal, U.; Poulose, A.; Zeno, P.; Vaddevolu, U.B.P.; Khan, S.; Shoman, M.; et al. YOLO advances to its genesis: A decadal and comprehensive review of the You Only Look Once (YOLO) series. Artif. Intell. Rev. 2025, 58, 274. [Google Scholar] [CrossRef] [Scilit]
  28. Yu, C.; Shi, X.; Luo, W.; Feng, J.; Zheng, Z.; Yorozu, A.; Hu, Y.; Guo, J. MLG-YOLO: A Model for Real-Time Accurate Detection and Localization of Winter Jujube in Complex Structured Orchard Environments. Plant Phenomics 2024, 6, 0258. [Google Scholar] [CrossRef] [Scilit]
  29. 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, 14–19 June 2020; pp. 10781–10790. [Google Scholar]
  30. Li, Y.; Yao, T.; Pan, Y.; Mei, T. Contextual transformer networks for visual recognition. IEEE Trans. Pattern Anal. Mach. Intell. 2022, 45, 1489–1500. [Google Scholar] [CrossRef] [Scilit]
  31. Tong, Z.; Chen, Y.; Xu, Z.; Yu, R. Wise-IoU: Bounding box regression loss with dynamic focusing mechanism. arXiv 2023, arXiv:2301.10051. [Google Scholar]
  32. Rao, Y.; An, T.; Xuan, Y.; Wang, R.; Zhou, Q.; Guan, H.; Li, M. Feature enhancement and attention mechanism fusion method for Cantonese embroidery image detection based on YOLOv8. npj Herit. Sci. 2025, 13, 521. [Google Scholar]
  33. Lu, J.; Chen, W.; Lan, Y.; Qiu, X.; Huang, J.; Luo, H. Design of citrus peel defect and fruit morphology detection method based on machine vision. Comput. Electron. Agric. 2024, 219, 108721. [Google Scholar] [CrossRef] [Scilit]
  34. Padilla, R.; Passos, W.L.; Dias, T.L.B.; Netto, S.L.; da Silva, E.A.B. A comparative analysis of object detection metrics with a companion open-source toolkit. Electronics 2021, 10, 279. [Google Scholar] [CrossRef] [Scilit]
  35. Rainio, O.; Teuho, J.; Klén, R. Evaluation metrics and statistical tests for machine learning. Sci. Rep. 2024, 14, 6086. [Google Scholar]
  36. Aloufi, N.; Alnori, A.; Thayananthan, V.; Basuhail, A. Object detection performance evaluation for autonomous vehicles in sandy weather environments. Appl. Sci. 2023, 13, 10249. [Google Scholar] [CrossRef] [Scilit]
  37. Otani, M.; Togashi, R.; Nakashima, Y.; Rahtu, E.; Heikkilä, J.; Satoh, S.I. Optimal correction cost for object detection evaluation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, New Orleans, LA, USA, 18–24 June 2022; pp. 21107–21115. [Google Scholar]
  38. Riehl, K.; Neunteufel, M.; Hemberg, M. Hierarchical confusion matrix for classification performance evaluation. J. R. Stat. Soc. Ser. C Appl. Stat. 2023, 72, 1394–1412. [Google Scholar]
  39. He, L.; Zhou, Y.; Liu, L.; Cao, W.; Ma, J.-H. Research on object detection and recognition in remote sensing images based on YOLOv11. Sci. Rep. 2025, 15, 14032. [Google Scholar] [CrossRef] [Scilit]
  40. Zhao, X.; Wang, L.; Zhang, Y.; Han, X.; Deveci, M.; Parmar, M. A review of convolutional neural networks in computer vision. Artif. Intell. Rev. 2024, 57, 99. [Google Scholar] [CrossRef] [Scilit]
  41. Selvaraju, R.R.; Cogswell, M.; Das, A.; Vedantam, R.; Parikh, D.; Batra, D. Grad-cam: Visual explanations from deep networks via gradient-based localization. In Proceedings of the IEEE International Conference on Computer Vision, Venice, Italy, 22–29 October 2017; pp. 618–626. [Google Scholar]
  42. Liu, Y.; Tang, L.; Liao, C.; Zhang, C.; Guo, Y.; Xia, Y.; Zhang, Y.; Yao, S. Optimized Dropkey-based grad-CAM: Toward accurate image feature localization. Sensors 2023, 23, 8351. [Google Scholar] [PubMed]
  43. Chuquimarca, L.E.; Vintimilla, B.X.; Velastin, S.A. A review of external quality inspection for fruit grading using CNN models. Artif. Intell. Agric. 2024, 14, 1–20. [Google Scholar] [CrossRef] [Scilit]
  44. Liu, C.; Lin, W.; Feng, Y.; Guo, Z.; Xie, Z. ATC-YOLOv5: Fruit Appearance Quality Classification Algorithm Based on the Improved YOLOv5 Model for Passion Fruits. Mathematics 2023, 11, 3615. [Google Scholar] [CrossRef] [Scilit]
  45. Wu, Y.; Tang, J.; Zeng, W. Research on the Intelligent Detection Algorithm of Apple Quality Based on Deep Learning. Artif. Intell. Robot. Res. 2025, 14, 1034. [Google Scholar] [CrossRef]
  46. Espinoza, S.; Aguilera, C.; Rojas, L.; Campos, P.G. Analysis of fruit images with deep learning: A systematic literature review and future directions. IEEE Access 2023, 12, 3837–3859. [Google Scholar] [CrossRef] [Scilit]
  47. Fu, Y.; Nguyen, M.; Yan, W.Q. Grading methods for fruit freshness based on deep learning. SN Comput. Sci. 2022, 3, 264. [Google Scholar] [CrossRef] [Scilit]
  48. Unay, D. Deep learning based automatic grading of bi-colored apples using multispectral images. Multimed. Tools Appl. 2022, 81, 38237–38252. [Google Scholar] [CrossRef] [Scilit]
  49. Lv, M.; Xu, Y.X.; Miao, Y.H.; Su, W.H. A Comprehensive Review of Deep Learning in Computer Vision for Monitoring Apple Tree Growth and Fruit Production. Sensors 2025, 2, 2433. [Google Scholar] [CrossRef] [Scilit]
  50. Colaco, L.; Kamat, P. Artificial intelligence advances for cashew fruit maturity and quality detection: A systematic review on models, sensors, and farming applications. J. Big Data 2025, 12, 250. [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.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.