A unified RepVGG model factory with plug-in SE attention and GeM pooling for fine-grained agricultural classification
摘要
Accurate and efficient weed identification is essential for precision agriculture, yet existing deep learning approaches struggle to balance classification accuracy with computational efficiency required for real-time field deployment. Fine-grained weed classification presents unique challenges due to subtle inter-species morphological differences and significant intra-class variations caused by diverse growth stages and environmental conditions. In this paper, we propose a unified RepVGG model factory with plug-in Squeeze-and-Excitation (SE) attention and Generalized Mean (GeM) pooling for fine-grained agricultural classification. Our approach leverages the structural re-parameterization technique of RepVGG to achieve efficient inference while enhancing discriminative feature learning through channel-wise attention recalibration and adaptive feature aggregation. The SE attention module explicitly models inter-channel dependencies to emphasize informative features, while the learnable GeM pooling enables adaptive interpolation between average and max pooling behaviors for optimal feature aggregation. We further develop a unified model construction interface that supports systematic benchmarking across multiple deep learning backends with consistent experimental protocols. Comprehensive experiments on the CottonWeedID15 dataset demonstrate that our proposed RepVGG-B1 + SE + GeM model achieves state-of-the-art performance with a testing F1-score of 99.5%, outperforming 27 baseline architectures including ResNet101 (99.1%), DenseNet161 (98.9%), and EfficientNet variants. Notably, our model maintains superior inference efficiency at 188.7 ms, which is 8.8% faster than ResNet101 while achieving 0.4% higher accuracy. Ablation studies confirm that SE attention consistently improves accuracy by 0.3% across different RepVGG backbones with minimal parameter overhead (2–3%), while GeM pooling provides complementary gains of 0.1–0.2%. The proposed unified framework offers a flexible and modular solution for deploying high-performance weed identification systems in resource-constrained agricultural environments.