Enhanced apple counting in orchards via wavelet-guided pyramid vision transformer
Abstract
Accurate apple counting is important for orchard yield estimation and management. However, in the orchard images acquired in this study, factors such as variable lighting, scale variation, and fruit occlusion pose challenges to density-map-based counting. Current mainstream models often face difficulties in effectively balancing global contextual information with local fine-grained features, leading to inaccurate counting in dense fruit regions and a limited ability to distinguish apples from cluttered backgrounds. To address these issues, we propose the wavelet-guided pyramid vision transformer, dubbed WGPFormer. Specifically, a wavelet-enhanced multi-scale consistent attention module is designed, which consists of two submodules: wavelet gate fusion (WGF) and adaptive spatial channel refinement (ASCR). The WGF module utilizes wavelet transformation to decompose features into multi-scale frequency components, adaptively fusing low-frequency contour information with high-frequency details to handle the scale and illumination variations represented in the constructed dataset and to enhance texture discrimination. Building on this, the ASCR module further suppresses background interference by coupling channel and spatial attention mechanisms. Furthermore, we develop a hierarchical cross-scale feature fusion module to mitigate fruit occlusion by effectively integrating high-level semantic information with low-level spatial details. Experimental results on the self-collected single-orchard apple dataset show that WGPFormer achieves a mean absolute error of 3.29 and a root mean square error of 4.50 on the held-out test set, yielding numerically lower errors than the compared methods under the same data split and experimental protocol. These results demonstrate the effectiveness of WGPFormer for apple counting under the illumination, scale, and occlusion variations represented in the constructed orchard dataset.