高级检索+

基于轻量化YOLOv8n-PGM的荔枝劣果检测方法

Detection method of defective litchi fruit based on lightweight YOLOv8n-PGM

  • 摘要: 为提高采后分拣场景下荔枝劣果检测精度与低算力设备部署速度,提出一种轻量化荔枝劣果检测模型YOLOv8n-PGM。该模型采用广义混合卷积(generalized shuffle convolution, GSConv)替换颈部普通卷积,并以部分卷积(partial convolution, PConv)重构C2f模块,降低参数量与计算量;在检测头前引入混合局部通道注意力(mixed local channel attention, MLCA),增强遮挡条件下的特征表达;将边界框回归损失替换为Inner-WIoU,改善回归性能。试验结果表明,YOLOv8n-PGM的mAP@50和mAP@50~95分别为97.7%和80.0%,参数量由YOLOv8n的3.0 M降至2.0 M,降幅为33.3%,两项平均精度指标分别提高0.5和1.5个百分点。在Raspberry Pi 5上采用PyTorch(PT)推理框架时,模型平均帧率为3.1帧/s,较同框架下YOLOv8n提高1.4帧/s。在本研究数据集和部署条件下,该模型同时实现了检测精度提高、参数量下降和推理帧率提升,可为荔枝劣果分拣检测设备的轻量化部署提供参考。

     

    Abstract: Objective: This study aimed to develop a lightweight model that balances accuracy, complexity, and inference speed for detecting defective litchi fruit on postharvest conveyor belts, especially on devices with limited computing resources. Methods: Cracking, decay, and pericarp browning were treated as one defective-fruit category in accordance with the rejection task in sorting. Images of four litchi varieties were acquired under laboratory conveyor conditions covering five camera heights, two light color temperatures, two conveyor-belt types, multiple viewpoints, and different degrees of occlusion. After quality screening, 780 original images were retained, comprising 226 Feizixiao, 226 Guiwei, 226 Nuomici, and 102 Xianjinfeng images and approximating a variety ratio of 11:11:11:5. Before augmentation, the images were stratified by variety and divided into training, test, and validation sets at a ratio of 8:1:1, containing 624, 78, and 78 images, respectively. Offline augmentation was applied only to the training set, expanding it to 1,953 images. No augmented sample was included in the validation or test set, thereby avoiding augmentation-derived leakage across subsets. A model named YOLOv8n-PGM was constructed from You Only Look Once version 8 nano (YOLOv8n). Generalized shuffle convolution replaced standard convolution in the neck, while partial convolution reconstructed the C2f feature-fusion module to reduce redundant computation and memory access. Mixed local channel attention was inserted before the detection head to strengthen feature representation under occlusion. The original bounding-box regression loss was replaced with Inner-WIoU, combining an auxiliary bounding-box strategy with the dynamic focusing mechanism of Wise intersection over union. Performance was evaluated using precision, recall, F1-score, mean average precision, parameter count, model size, and frames per second. The experiments included ablation, loss-function and ratio-factor comparisons, variety-specific evaluation, comparisons with nine mainstream detectors, and embedded deployment tests. Results: YOLOv8n-PGM achieved a precision of 94.3%, a recall of 93.5%, an F1-score of 93.9%, mAP@50 of 97.7%, and mAP@50–95 of 80.0%. Compared with YOLOv8n, the two mean average precision measures increased by 0.5 and 1.5 percentage points, respectively. Parameter count decreased from 3.0 million to 2.0 million, a reduction of 33.3%, and model size decreased from 6.0 to 4.1 MB. On the workstation test video, average inference speed increased from 113.6 to 118.8 frames per second. In the ratio-factor experiment, Inner-WIoU with a factor of 0.8 produced the best combined result among factors from 0.5 to 1.0. In the variety-specific evaluation, mAP@50 ranged from 96.7% to 98.1%, and mAP@50–95 ranged from 77.1% to 81.0%. Under the same dataset and workstation conditions, YOLOv8n-PGM used fewer parameters and produced higher mAP@50 and mAP@50–95 than the nine comparison detectors. The models were also deployed on a Raspberry Pi 5 with PyTorch. Under the same device and input conditions, YOLOv8n-PGM reached 3.1 frames per second, compared with 1.7 frames per second for YOLOv8n. Its mAP@50 and mAP@50–95 were 97.7% and 80.0%, respectively, representing increases of 0.5 and 1.5 percentage points over YOLOv8n. These results indicated that the proposed modules jointly improved the balance between accuracy, compactness, and inference efficiency. Conclusion: Under the dataset and hardware conditions used in this study, the proposed method reduced model complexity while maintaining high detection accuracy and improving inference speed, providing a feasible basis for low-cost litchi sorting equipment; however, independent data and continuous tests on actual sorting lines are still required to establish robustness across seasons, devices, and long-term operation.

     

/

返回文章
返回