A lossless detection method for watermelon ripeness using gramian angular summation field image encoding and EfficientNetV2-ECA
摘要
The grading of watermelon ripeness directly influences its edible quality, nutritional value, and commercial value. To enable rapid, accurate, and non-destructive detection of watermelon ripeness, this study integrates visible and near-infrared (Vis/NIR) spectroscopy with deep learning. The collected near-infrared diffuse-transmission spectral data are transformed into two-dimensional images using Gramian Angular Summation Field (GASF) encoding. An enhanced EfficientNetV2-ECA network incorporating Efficient Channel Attention (ECA) is then developed to adaptively emphasise key spectral features, thereby improving ripeness classification. On the validation set, the model achieved an accuracy of 0.944, a precision of 0.956, and a recall of 0.958. Furthermore, a stacked autoencoder (SAE) is employed for feature extraction and dimensionality reduction, and the impact of different numbers of spectral points (500, 350, 150, and 50) on performance is systematically assessed. The optimal performance is obtained with 350 spectral points (Accuracy 0.972, Precision 0.978, Recall 0.978), indicating that moderate dimensionality reduction enhances the model’s discriminative capability and generalisation. In addition, Gradient-weighted Class Activation Mapping++ (Grad-CAM++) is used to generate heatmaps that visualise the basis of model decisions across samples at different ripeness levels, supporting interpretability and reliability. Overall, the proposed framework integrates Vis/NIR spectroscopy with GASF encoding and an EfficientNetV2-ECA model, enabling precise non-destructive assessment of watermelon ripeness and providing a methodological reference for non-destructive fruit quality inspection.