Chao Zhao, Jiaheng Zhang, Duangsamorn Suthisut, Chunqi Bai, Lei Yan, Dianxuan Wang, Jianhua Lü, Peng Li
To address the issues of poor model generalization caused by sample scarcity and class imbalance in hyperspectral detection of storage Astragalus pests, this study proposes a detection method that integrates near-infrared hyperspectral imaging with Wasserstein Generative Adversarial Network with Gradient Penalty (WGAN-GP) data augmentation. By constructing a dataset containing 1023 samples, the study systematically compared four generative models: Variational Autoencoder (VAE), Generative Adversarial Network (GAN), WGAN, and WGAN-GP. The results showed that WGAN-GP performed best in terms of Root Mean Square Error (RMSE), Maximum Mean Discrepancy (MMD), and Sliced Wasserstein Distance (SWD) evaluation metrics, and the generated data highly overlapped with the real data in Principal Component Analysis (PCA) and t-distributed Stochastic Neighbor Embedding (t-SNE) visualizations. Through systematic optimization, the optimal data augmentation ratio was determined to be 0.75 times, under which the performance of five classifiers—Convolutional Neural Network (CNN), Support Vector Machine (SVM), Random Forest (RF), Transformer, and Partial Least Squares-Discriminant Analysis (PLS-DA)—was significantly improved. This study confirms that WGAN-GP data augmentation can effectively address the challenges of small sample sizes and class imbalance, providing a reliable technical solution for intelligent and non-destructive pest grading of Astragalus and other traditional Chinese medicinal materials.