Pitaya, the flamboyant dragon fruit with magenta skin and speckled flesh, has become one of the most sought-after tropical specialties, prized for its water-soluble dietary fiber and plant proteins. Yet behind its growing market appeal lies a stubbornly old-fashioned bottleneck: in China’s pitaya industry, deciding whether a fruit is ready for harvest still depends overwhelmingly on human eyes. Manual grading is labor-intensive, slow, and notoriously inconsistent, because different workers apply different subjective standards. The result is uneven product specifications that erode brand image and competitiveness. A new study published in Smart Agricultural Technology offers a computational way out, presenting a lightweight deep learning model called YOLO11s-TSFL that can grade pitaya ripeness directly in the orchard, in real time, on modest hardware.
The research team, led by Zhi Qiu and colleagues, built their system around YOLO11, a single-stage object detection architecture released by Ultralytics in September 2024. Single-stage detectors such as the YOLO family and SSD perform end-to-end inference in a single pass, making them far faster than two-stage models like the R-CNN series, which achieve excellent accuracy but cannot keep up with real-time sorting lines or field robots. YOLO11 follows the classic four-module design of input, backbone, neck, and head, and introduces refinements such as the C3k2 residual convolution block for efficient gradient flow and the C2PSA spatial attention module, which helps the network focus on informative regions under occlusion, cluttered backgrounds, and small targets. Of the five available sizes, the authors selected the mid-small YOLO11s variant as their baseline, judging its balance of accuracy and speed best suited to orchard conditions.
Before any architecture work could begin, the team needed data that reflected the messy reality of a working plantation. They collected 2,092 images in natural orchard environments and supplemented them with 3,000 public images from the Roboflow platform, yielding 5,092 valid samples. The shooting conditions were deliberately harsh and varied: sunny and overcast skies, early morning and dusk light, midday overexposure, evening underexposure, handheld vibration, rain-blurred lenses, branch occlusion, fruit overlap, clustered and solitary fruits, and both close-range and distant views. Each fruit was labeled as raw, meaning predominantly light green or in a red-green color-turning stage, or ripe, meaning predominantly bright red and meeting harvest criteria. Ambiguous samples, fruits more than 90 percent hidden, color-similar interfering objects, and flower buds were excluded from annotation. After size unification, denoising, and contrast equalization, the dataset was split 7:2:1 into 3,565 training, 1,019 validation, and 508 test images.
With the baseline established, the researchers attacked the problem along four fronts. The first was the detection head. Standard YOLO11 uses a two-branch decoupled head in which classification and confidence prediction share a pathway while only bounding box regression runs independently. The team designed a TripleDetect head that splits all three subtasks, localization, classification, and confidence, into fully independent parallel branches, eliminating feature competition and gradient conflict between heterogeneous objectives. To keep the head light, the conventional 3-by-3 convolutions in the regression branch were replaced with depthwise separable convolutions, aligning all three branches with lightweight structures. The change adds only a small parameter overhead but measurably improves classification of ripeness, a task that competes directly with localization for features in the original design.
The second front was the loss function. The baseline CIoU loss applies uniform regression constraints regardless of target scale or aspect ratio, which is a poor fit for small, irregularly shaped pitayas half-hidden behind branches. The authors substituted Shape-IoU, a loss that computes width and height weights from the ground-truth box and assigns a larger penalty to the short side of the fruit. A shape-weighted center-point distance term preferentially corrects short-side offsets, speeding convergence for low-overlap occluded fruits, while a decoupled size constraint term optimizes width and height errors independently, avoiding the mutual interference that plagues irregular targets. Crucially, Shape-IoU adds no network computation, and its scale adaptation factor handles mixed large and small fruits without retuning hyperparameters, an important convenience for agricultural deployment.
The third and fourth fronts targeted size. In the neck, the standard Bottleneck inside the C3k2 module was replaced with a FasterNet Block built on partial convolution, which convolves only one quarter of the input channels while passing the remaining three quarters through unchanged identity mapping, cutting floating-point operations by roughly 75 percent in that component. Then came compression: the LAMP layer-adaptive magnitude-based pruning algorithm scores each channel by within-layer normalized squared weight magnitude, allowing fair cross-layer comparison and globally coordinated removal of redundant channels. Pruning inevitably discards some useful features, so the team applied Masked Generative Distillation, in which a larger teacher model’s feature maps supervise a student whose features are randomly masked and then reconstructed through a small generation module, forcing the compact network to learn the intrinsic distribution of the teacher’s representations rather than pixel-level copies.
The ablation experiments trace each module’s contribution. The baseline YOLO11s achieved an mAP50 of 0.978 with 9.41 million parameters, 21.3 GFLOPs, and an 18.3 MB footprint. Adding TripleDetect lifted mAP50 to 0.981; Shape-IoU pushed it to 0.982 and raised the F1-score to 0.965 at no extra cost; C3_FasterBlock trimmed parameters to 8.76 million with negligible accuracy loss. Aggressive LAMP pruning at a rate of 0.9 then slashed the model to 3.72 million parameters, 9.5 GFLOPs, and 7.31 MB, but dropped mAP50-95 from 0.779 to 0.750. MGD distillation recovered much of that loss, restoring mAP50 to 0.981 and mAP50-95 to 0.758 without changing the architecture. The final YOLO11s-TSFL model improves mAP50 by 0.3 percentage points over the baseline while reducing parameters by 60.5 percent, computation by 55.4 percent, and model size by 60.1 percent.
Comparisons against mainstream lightweight detectors underscore the achievement. YOLO11s-TSFL posts an mAP50 of 0.981, ahead of YOLOv5s, YOLO12s, YOLO26s, and the original YOLO11s, and essentially on par with YOLOv8s, while using roughly one third of the parameters and computation of YOLOv8s and only 37.6 percent of the storage of YOLO26s. Its inference time of 30.6 milliseconds was the fastest of all models tested. On the untouched test set, overall precision reached 0.967 and recall 0.965, with ripe fruit detection especially strong at 99.2 percent mAP50. Raw fruit proved slightly harder, with precision of 0.948, largely because the green peel of unripe pitaya resembles the surrounding foliage. Confusion matrix analysis showed 97 percent classification accuracy for raw and 99 percent for ripe fruits, with residual misses concentrated in severely occluded or overexposed scenes. Grad-CAM heatmaps confirmed that the improved model concentrates its attention on the fruit peel and bracts across shallow, middle, and deep layers, suppressing the scattered background responses that distract the baseline network.
To demonstrate practical readiness, the team packaged the trained weights into a Windows 11 application that accepts local images, local video, or live camera input and outputs visual grading results with one-click archiving. The authors caution that the attention visualizations remain a technical inference, and that the link between peel-focused activation and agronomic ripeness indicators needs confirmation in field trials. They also note that validation across multiple orchards and growing seasons is still needed. Even so, the study makes a compelling case that carefully targeted architectural surgery, smart loss design, and a pruning-plus-distillation pipeline can compress a state-of-the-art detector to the point where it runs comfortably on the low-power computers that harvesting robots actually carry, bringing fully automated pitaya grading a decisive step closer to the field.
Subject of Research: A lightweight deep learning model for automated pitaya ripeness grading in orchard environments
Article Title: YOLO11s-TSFL: a lightweight deep learning model for pitaya ripeness grading in orchard environments
Article References: Qiu, Z., Liu, N., Mo, D., Li, J., Ma, X., & Tian, X. (2026). YOLO11s-TSFL: a lightweight deep learning model for pitaya ripeness grading in orchard environments. Smart Agricultural Technology, 15, Article 102627. https://doi.org/10.1016/j.atech.2026.102627
Image Credits: AI Generated
DOI: 10.1016/j.atech.2026.102627
Keywords: pitaya, dragon fruit, deep learning, YOLO11, object detection, ripeness grading, machine vision, model pruning, knowledge distillation, precision agriculture, harvesting robots, edge deployment
News Source: Alan Morgan. (October 12, 2026). Lightweight AI Model Grades Pitaya Ripeness in the Orchard in Real Time. Scienmag.



