The screening and identifying flax germplasm resources are critical for achieving precise flax breeding and variety enhancement. This study integrates hyperspectral imaging (HSI) technology with deep learning to identify flaxseed varieties. Hyperspectral images were captured for 15 flaxseed varieties across two spectral ranges: Vis-NIR (380–1018 nm) and NIR (870–1709 nm). PCA and LDA were utilized to visually cluster these varieties. To automatically learn the spectral features and improve model performance, a one-dimensional convolutional neural network (CAM-TM-1DCNN) embedded with a channel attention module (CAM) and transformer module (TM) was developed for rapid recognition of flaxseed varieties. Experimental results validate the model's efficacy. Compared with ELM, BPNN, LSTM and 1DCNN classification models, the CAM-TM-1DCNN demonstrated superior classification performance in the NIR spectral range, achieving a test accuracy of 95.26 %. Moreover, all models performed better in the NIR spectral range compared to the Vis-NIR spectral range. The study also evaluated the impact of SPA and CARS feature selection algorithms on the classification models, confirming that the full-spectrum-based CAM-TM-1DCNN model outperformed others. These findings suggest that the CAM-TM-1DCNN model can effectively identify flaxseed varieties, providing a novel strategy and viable technical approach for future flaxseed variety recognition based on HSI technology.