1. Introduction
Abundant agricultural resources are a crucial foundation for the survival and development of human society [
1,
2]. Against the backdrop of accelerating urbanization, maintaining agricultural resources to meet the growing demands of society is facing significant challenges [
3,
4]. In this context, achieving crop type identification has become a crucial task in agricultural remote sensing [
5]. Remote sensing crop mapping aims to utilize remote sensing data to characterize the spatial distribution of different crop types, providing critical support for agricultural applications such as crop growth monitoring, yield estimation, and disaster loss assessment [
6]. Therefore, how to achieve high-precision crop classification using remote sensing imagery has been one of the core research issues in the field of agricultural remote sensing.
Hyperspectral image (HSI), with its coverage of hundreds to thousands of continuous narrow bands and high spatial resolution, can more comprehensively reflect the spectral characteristics of objects, demonstrating significant advantages over traditional multispectral or optical remote sensing imagery [
7,
8]. Crop classification using HSI is essentially a hyperspectral image classification task, aiming to assign a semantic label to each pixel in the image [
9]. However, in real agricultural scenes, different crop types often exhibit pronounced spatial heterogeneity and complex structural distributions, making robust discrimination difficult when relying solely on pixel-wise spectral information. This limitation has gradually driven research toward the joint modeling of spectral and spatial information. In practice, spatially adjacent pixels tend to share similar spectral characteristics and are more likely to belong to the same semantic category. Appropriately incorporating spatial constraints can therefore reduce classification uncertainty and effectively suppress salt-and-pepper noise. As a result, the joint exploitation of spectral and spatial information in hyperspectral imagery is widely regarded as a prerequisite for improving classification performance [
10,
11].
Early research on hyperspectral image (HSI) classification was primarily based on traditional machine learning methods, such as k-nearest neighbors (kNNs) [
12], Bayesian estimation [
13], multinomial logistic regression [
14,
15], and support vector machines (SVMs) [
16,
17,
18,
19]. These approaches achieved reasonable performance in spectral feature discrimination and were further extended to incorporate spatial information in order to improve classification accuracy. For example, Zhao [
20] developed a robust spectral–spatial crop mapping method based on conditional random fields (SCRFs), in which spectrally weighted kernels were employed to learn crop-sensitive spectral information, while spatial interactions among neighboring pixels were exploited to enhance classification performance. Yang [
21] proposed a kernel tensor sparse coding model for fine-grained crop classification, which leverages kernel tensor representations to improve linear separability while preserving spectral–spatial structural information. These studies clearly demonstrate the long-standing value of spectral–spatial joint modeling in hyperspectral crop classification. However, such methods typically rely on manually designed spatial constraints or shallow feature fusion mechanisms [
22]. When applied to large-format, high-dimensional HSI data, they often suffer from low computational efficiency, heavy dependence on handcrafted features, and limited generalization capability [
23]. Moreover, the joint modeling of spectral and spatial information in these approaches is relatively complex and lacks adaptability, making it difficult to meet the practical requirements of complex agricultural application scenarios.
In recent years, with the remarkable advances of deep learning in the field of computer vision, its application to hyperspectral image (HSI) classification has also increased substantially [
24]. As one of the earliest deep learning paradigms introduced for HSI classification, patch-based classification models incorporate neighborhood information by exploiting local pixel contexts. Representative approaches include 3D convolutional neural networks (3D-CNNs) and two-stream networks. The former is widely regarded as the most natural architecture for modeling spectral–spatial information, as it employs three-dimensional convolutional kernels that slide directly over the hyperspectral data cube, simultaneously capturing correlations along the spectral dimension and structural information in the spatial domain, without the need for handcrafted feature design as required by traditional methods.In contrast, two-stream networks are designed with two independent branches to separately extract spectral features (e.g., using 1D-CNNs or recurrent neural networks) and spatial features (e.g., using 2D-CNNs), which are subsequently fused at the fully connected layer [
25]. These methods demonstrate strong capability in modeling local spectral–spatial features. For instance, approaches such as SSRN [
26] and S3AM [
27] effectively extract hierarchical representations through 2D or 3D convolutional operations.
However, although the aforementioned deep models enhance spectral–spatial feature modeling to a certain extent, in crop hyperspectral classification scenarios, these CNN-based strategies implicitly treat all spatial locations and spectral channels equally. For hyperspectral imagery, there is no explicit mechanism to emphasize more informative spectral bands or spatial positions. Consequently, their feature extraction capability largely depends on network depth and convolutional kernel size, making it difficult to adaptively learn which spectral bands or pixel locations are more discriminative [
28].
The attention mechanism (AM) was originally proposed [
29] to emulate the human visual perception process, enabling models to focus on critical components within the feature space while suppressing irrelevant information. With the rapid development of attention mechanisms, an increasing number of hyperspectral image (HSI) classification models have incorporated AM-based designs. For example, SSFTT [
30], SSTN [
31], and the spatial–spectral feature extraction network with a patch attention module (PASSNet) [
32] have demonstrated the effectiveness of attention mechanisms, which is closely related to their strong capability in feature representation learning. They adaptively recalibrate feature responses across spectral channels or spatial locations, thereby emphasizing information-rich features while suppressing less informative ones. This substantially enhances the exploitation of spectral–spatial information, leading to improved classification accuracy.
However, most of the aforementioned methods are built upon the patch-based input methods discussed earlier, which is inherently analogous to image classification approaches in computer vision. Patch-based input methods are fundamentally similar to image classification methods in computer vision. These methods draw inspiration from the fundamental principles of image classification in computer vision. Their core idea is: during training and inference, a hyperspectral image of size H × W is divided into several fixed-size subregions of size S × S. Each subregion is treated as an independent sample, fed into the classification network to extract features and perform category discrimination. Compared to traditional pixel-wise classification methods, this strategy leverages spatial structural information within each pixel neighborhood to enhance classification accuracy. However, in patch-based classification methods, there is an inherent trade-off between the model’s implicit receptive field and the effectiveness of model performance evaluation. Specifically, the method’s ability to capture long-range spatial dependencies is directly constrained by the input patch size S. To alleviate this problem, researchers tend to adopt larger S values. However, while this strategy increases the model’s perceptual range, it also systematically increases the correlation between training and test samples. This, in turn, leads to information leakage and violates the basic assumptions of supervised learning [
33,
34], making it difficult to objectively evaluate model performance and generalization ability [
35].
With the widespread application of advanced airborne platforms and drones equipped with high-resolution hyperspectral sensors, large-format hyperspectral image data has become increasingly prevalent in recent years [
36]. However, traditional patch-based methods face significant bottlenecks when addressing large-format classification tasks. Therefore, some researchers have enhanced traditional semantic segmentation models (such as U-Net and fully convolutional networks (FCNs)) to address the challenges of large-format hyperspectral image classification. These improvements aim to enhance computational efficiency and achieve higher accuracy [
37]. Leveraging the end-to-end pixel-level prediction capabilities of semantic segmentation models, each pixel in the input image can be efficiently classified and annotated. For instance, the FPGA framework extracts global spatial context information from the entire image using an encoder based on spectral attention and a lightweight decoder structure, it obtains different gradients from hierarchical samples to ensure convergence [
38]. HSI-TransUnet employs a CNN network with spectral attention and a residual connection Transformer to extract global contextual features, yielding outstanding performance in HSI crop classification [
39].
However, most current works still heavily rely on convolutional neural networks (CNNs) in their overall architecture or key blocks. For example, some methods still employ a fully CNN-based structure for encoding and decoding, which results in significant dimensional redundancy in their rich spectral features. Relying solely on local convolutions makes it difficult to exploit their potential discriminative features fully. While some fusion models incorporate Transformer blocks into the encoder to enhance global context modeling capabilities, their decoders remain entirely CNN-based, primarily achieving spatial restoration and classification through layer-wise convolutions and upsampling, thereby inevitably increasing the model’s parameter count and computational burden. Additionally, many image categories are rich, and spatial information is complex. When restoring resolution, semantic segmentation models often need to reconstruct both complete ground target boundaries and fine-grained targets, which requires balancing the reconstruction of local and global features. Furthermore, regarding data sampling strategies, existing methods use the entire HSI as input for both training and testing. Even when employing label masking strategies, they face inherent data leakage challenges between training and evaluation datasets, which compromises the reliability of accuracy assessments [
40]. Additionally, using the entire HSI as input leads to high memory consumption and batch size limitations, significantly reducing training speed.
Although spectral–spatial joint modeling has been extensively studied, how to further improve the exploitation of spectral–spatial information in crop hyperspectral classification remains an open and challenging problem. Specifically, it is not sufficient to merely introduce spatial information into the model; more importantly, a well-designed modeling mechanism is required to dynamically adjust the relative importance of spectral and spatial information across multiple levels of feature representation. However, most existing works based on semantic segmentation paradigms still heavily rely on convolutional neural networks (CNNs) in either the overall architecture or key modules. For example, some methods adopt fully CNN-based encoder–decoder structures, which often result in significant dimensional redundancy in spectral–spatial features, making it difficult for local convolutions alone to fully exploit their latent discriminative characteristics. Other hybrid approaches incorporate Transformer modules into the encoder to enhance global context modeling, while retaining CNN-based decoders that rely primarily on successive convolutions and upsampling operations for spatial recovery and classification. This design inevitably leads to suboptimal feature reconstruction performance. In practice, hyperspectral images often contain diverse land-cover categories and complex spatial structures. During resolution recovery, semantic segmentation models are required to reconstruct complete object boundaries and fine-grained details, which necessitates a careful balance between local feature refinement and global contextual reconstruction. Furthermore, regarding data sampling strategies, existing patch-based approaches that treat the entire HSI as input for training and testing still suffer from inherent data leakage between training and evaluation sets, thereby compromising the reliability of accuracy assessment [
40]. In addition, using full HSI data as model input incurs high memory consumption and imposes strict limitations on batch size, significantly reducing training efficiency.
Overall, current research primarily focuses on addressing the following challenges:
HSI simultaneously contains rich spectral information about objects and complex spatial structural information. Designing a feature extraction paradigm that can effectively fuse the two and deeply explore their intrinsic correlations to learn more discriminative spectral–spatial joint features is a prerequisite for achieving precise object classification.
Accurate classification requires models to capture pixel-level local textures and boundary details (local features) while also understanding the layout of large-format scenes and long-range dependencies between objects (global features) to ensure semantic consistency. Balancing different model architectures (such as CNNs’ local inductive biases and Transformers’ global modeling capabilities) to achieve efficient, synergistic modeling of multi-scale features is a critical architectural design challenge.
The high dimensionality of HSI poses notable computational and memory challenges. In addition, patch-based training may suffer from information leakage caused by overlapping patches, leading to biased performance evaluation.
To address the above issues, we propose a fusion network based on a fully attention mechanism that combines CNN and Transformer, named A2Former (All-Attention Transformer) for HSI classification. A2Former effectively extracts and enhances deep spatial–spectral features using an efficient and lightweight spectral–spatial attention weights block (SSWB) and a convolutional vision transformer block (C-VIT). It also employs a Transformer-based decoder with a gated-style weighted fusion and interaction attention block (WIAB) and a fused head (FH) that fuses spectral–spatial attention to efficiently model local and global features, achieving precise segmentation. Additionally, we propose a checkerboard-style sampling strategy that prevents information leakage, ensuring the objective evaluation of the proposed model’s performance. The main contributions of this study are as follows:
We propose the A2Former framework to address the synergistic utilization of spectral and spatial features as well as the efficient modeling of local and global information. The proposed model adopts a hybrid architecture that integrates CNNs and Transformers, enabling efficient exploitation of spectral–spatial characteristics while simultaneously capturing fine-grained local textures and modeling global contextual layouts, thereby producing more robust joint feature representations.
To address the long-standing challenges of computational overhead and information leakage in model evaluation, we design a novel checkerboard-style sampling strategy. By partitioning the hyperspectral data into several strictly non-overlapping groups and balancing the classes as much as possible, we mitigate the inherent information leakage risks associated with traditional patch-based input methods, thereby making model performance evaluation more objective and reliable.
The primary objective of this study is to develop a novel semantic segmentation-based framework for the accurate and efficient classification of large-format airborne hyperspectral imagery of croplands, while ensuring the reliability of classification accuracy through a carefully designed sampling strategy.
The rest of this paper is organized as follows.
Section 2 provides an in-depth examination of the proposed A
2Former framework.
Section 3 presents experimental results on two datasets and further analyzes the proposed blocks. Finally,
Section 4 and
Section 5 provide a summary of the paper and present further discussions.
3. Experiments
In this section, we systematically evaluate the effectiveness of the proposed A2Former framework through a series of comprehensive experiments. First, we present the experimental setup, detailing the two benchmark datasets used, the proposed checkerboard sampling strategy, and the specific dataset partitioning scheme. To validate the necessity and contribution of each key component within A2Former, we conducted a series of detailed ablation experiments. Finally, to comprehensively evaluate the overall performance of A2Former, we conducted both quantitative and qualitative comparisons with a range of existing methods.
3.1. Datasets
As shown in
Figure 3, the two datasets are described in detail as follows:
- (1)
Xiongan dataset: The Xiongan hyperspectral image (HSI) dataset serves as another benchmark for evaluating fine-grained vegetation classification performance. The dataset was acquired in 2017 in the Xiongan New Area of China using the AMMIS VNIR block and has 256 spectral bands. The original image contains 3750 × 1580 pixels, with a spatial resolution of 0.5 m. A 1492 × 1580 pixel area in the central region was selected as the study area, containing 16 categories, including negative samples. This area was chosen due to its diverse crop types and pronounced intra-class variability, mainly caused by differences in vegetation growth stages and shadows cast by street trees, which present challenges for accurate HSI classification [
49].
- (2)
HSI-CROP dataset: The study area is located in Shenzhou City, Hebei Province, China, and consists of two sub-regions: the Majiakou Village site (MJK) and the Xijingmeng Village site (XJM). Hyperspectral data were acquired using a UAV on 18 September 2019. The UAV was equipped with a Pika L hyperspectral imager (Resonon Inc.), covering a spectral range of 385–1024 nm with 200 spectral bands. The flight altitude was 100 m, and the spatial resolution was 0.1 m. A total of 30 categories, including negative samples, were identified. The hyperspectral data were preprocessed using Spectronon and ENVI software, including radiometric calibration, geometric correction, image stitching, and atmospheric correction. Additionally, the image size of Study Area A is 2332 × 959 pixels, while Study Area B measures 864 pixels in width and 1618 pixels in height [
39]. This dataset was due to its greater diversity compared to the Xiongan dataset, as it contains 30 classes, including negative samples. Furthermore, the images are characterized by a high prevalence of fine-grained targets and mixed-pixel challenges.
3.2. Experimental Setup
- (1)
Evaluation metrics: The performance of the proposed A2Former model was evaluated using four standard metrics: classification accuracy (CA), overall accuracy (OA), mean intersection over union (mIoU), and the Kappa coefficient. CA is defined as the proportion of correctly classified samples within each category. OA denotes the proportion of correctly classified samples out of the total number of samples. The mIoU metric, crucial for semantic segmentation tasks, quantifies the average overlap between the predicted regions and the ground truth annotations. Consequently, it provides a holistic assessment of the model’s segmentation performance across all classes. The Kappa coefficient is a robust accuracy metric derived from the confusion matrix. It provides a more reliable evaluation than OA, particularly in scenarios with class imbalance, because it accounts for the possibility of correct classification occurring by chance.
- (2)
Sampling Strategy: To address the information leakage problem discussed in the Introduction. Based on the four fundamental principles of effective sampling strategy design proposed in [
40], we designed a checkerboard-style leak-free balanced sampling strategy, as shown in
Figure 4. The process unfolds in several stages. Initially, the hyperspectral image (HSI) and its corresponding ground truth map are partitioned into a grid of non-overlapping S × S blocks. To systematically eliminate information leakage from spatial adjacency, a periodic grouping mechanism is then introduced. Specifically, all blocks are assigned to one of five spatially disjoint groups based on their row index in a repeating five-row cycle, creating an interleaved, checkerboard-like distribution. Subsequently, these groups are randomly partitioned into training and test sets. This group-level allocation ensures complete spatial decoupling. Finally, a fine-tuning step addresses class imbalance: a minimal number of blocks are strategically transferred between subsets to correct distributional biases. This systematic approach not only prevents information leakage but also guarantees a balanced class distribution as much as possible, thereby laying a solid foundation for reliable model training and fair performance evaluation.
To mitigate overfitting, we employed a data augmentation strategy encompassing both spatial transformations and spectral perturbations. Specifically, the spatial augmentations included random rotations, as well as horizontal and vertical flips. For spectral and photometric augmentations, we introduced Gaussian noise and applied random adjustments to both brightness and contrast. Collectively, these operations simulate real-world variations in remote sensing imagery—such as those arising from differing sensor characteristics, illumination, and atmospheric conditions—thereby enhancing the model’s generalization and robustness.
In this experiment, the comparison section of the patch-based image classification method employed the sampling method mentioned in [
31] and referenced the settings in [
36] to extract 1000 samples from each feature category in the HSI-CROP and Xiongan datasets. The remaining labeled pixels were used as the validation set. Furthermore, for each sample, a 9 × 9 pixel patch was extracted, centered on the corresponding labeled pixel, to serve as the model input. This ensured that the comparison models could perform optimally and maintained the fairness of the comparison.
It should be noted that the adopted sampling strategy still has certain limitations. Specifically, due to the relatively large and fixed input sizes of the two datasets (e.g., 48 × 48 for HSI-CROP and 24 × 24 for Xiongan), and the fact that pixels of some rare classes are highly concentrated within individual input samples, severe imbalances between the training and testing splits may persist even after applying the checkerboard sampling strategy. As a result, certain rare classes, such as Classes 7 and 29 in the HSI-CROP dataset, contain no samples in the test set. This inevitably leads to zero classification accuracy for these classes in subsequent experimental evaluations.
- (3)
Implementation Details: In the experiment, the dataset was constructed based on the sampling strategy described in (2), with a training-to-test set ratio of 4:1, the results are shown in
Table 1 and
Table 2. To ensure that the experimental results do not depend on specific initialization or data partitioning, we reported the average performance and standard deviation of all experiments to verify the robustness and stability of the model. All experiments were conducted on a computer equipped with an Intel(R) Xeon(R) Gold 5218 2.30 GHz CPU, 256 GB of memory, and two NVIDIA GeForce A100 GPUs, and implemented using the PyTorch 1.7.1 deep-learning framework.
- (4)
Parameter settings: To achieve rapid convergence, we deployed the AdamW optimizer to train all models in the experiment. The learning rate is adjusted using a cosine learning strategy. Additionally, we set the relevant optimal parameters based on the experiment: the number of training epochs is set to 500, the learning rate for the Xiongan dataset is set to 0.0001, while the HSI-CROP dataset is set to 0.001, and the batch size is uniformly set to 64.
3.3. Ablation Study
In this section, the symbol “✔” indicates the use of the component in the experiment, whereas “-” indicates its absence. In addition, results in bold indicate the best performance.
- (1)
Ablation experiment of the encoder: By comparing the impact of the three encoder structures: ResNet-50 [
50], ConvNextV2 [
51], and the aforementioned encoder on classification performance, the effectiveness of our encoder was further validated, with the remaining network structures remaining consistent. ResNet-50 was selected as it constitutes the backbone of our baseline model. ConvNeXtV2 was included as a representative state-of-the-art (SOTA) architecture, which is recognized for its high performance, albeit with greater model complexity. As detailed in
Table 3, Experiment A serves as the baseline using ResNet-50 as the encoder. Experiment B adopts the proposed SSWB encoder, while Experiment C replaces it with ConvNeXtV2-Base. Compared with the proposed encoder, ConvNeXtV2-Base yields an OA improvement of 0.61% on HSI-CROP and 0.83% on Xiongan. This gain, however, was accompanied by a substantial increase in model complexity and the number of parameters. Additionally, compared to ResNet-50, our encoder achieves higher mIoU performance, particularly on the HSI-CROP and Xiongan datasets, where mIoU improves by 0.99% and 0.76%, respectively. These findings suggest that for large-format HSI semantic segmentation, a lightweight yet powerful encoder, such as the one proposed, offers a compelling trade-off between computational efficiency and performance.
- (2)
Ablation experiments on the C-VIT block: Similar to the ablation analysis of the encoder block, this paper compares the impact of the three VITs on classification performance to validate the performance and efficiency of the final C-VIT block. VIT-B was selected as it represents the baseline configuration, whereas RTB was included as a contemporary, lightweight hybrid architecture that integrates convolutional principles. The OA results for each of the three configurations are presented in
Table 4. Experiment A represents the baseline, which employs the original ViT-B as the low-level feature enhancement module. Experiment B replaces ViT-B with the RTB proposed in the literature, while Experiment C further substitutes RTB with the proposed C-ViT module.
Specifically, compared to the VIT-B and RTB blocks, the proposed C-VIT block performs better, demonstrating stronger spatial structure modeling capabilities. Moreover, the channel shuffling and reshuffling mechanisms effectively capture and represent the intrinsic, high-dimensional spectral features, addressing the limitations of depthwise separable convolutions in modeling inter-channel correlations. These design choices enable C-VIT to efficiently capture complex spectral–spatial joint features, leading to improved classification performance. In terms of computational efficiency, the C-VIT block replaces certain linear operations with convolutions, removes positional encoding, and significantly reduces parameter count, resulting in a simpler and more robust structure. Overall, C-VIT strikes a balance between lightweight design and expressive capacity, substantially reducing computational overhead while enhancing accuracy, making it an efficient solution for hyperspectral image semantic segmentation.
- (3)
Other ablation experiments: By combining different components across two datasets and conducting ablation experiments, we conducted a comprehensive analysis of the contributions of the four key blocks in the A
2Former model.
Table 5 shows the changes in model performance (evaluated by OA) across the five possible combinations of these four blocks. Specifically, Experiment A represents the baseline model without any enhanced blocks, exhibiting the lowest classification performance among all experiments. Results from Experiment B indicate that the proposed encoder effectively extracts discriminative features, thereby improving classification accuracy. In Experiment C, classification accuracy decreases slightly due to the lack of a suitable decoder to effectively utilize semantically rich high-dimensional features, leading to noticeable feature redundancy. Nevertheless, it remains higher than the baseline. Experiment D demonstrates that introducing the proposed decoder significantly enhances model performance, indicating its superior ability to utilize multi-scale features compared to the baseline, thereby contributing positively to hyperspectral image classification. The accuracy improvement is even more pronounced in Experiment E, where the auxiliary segmentation head effectively guides the reconstruction of deep high-dimensional features, enabling better feature utilization and achieving optimal performance.
In summary, the experimental results fully validate the effectiveness of each block and demonstrate that their combination brings significant improvements in overall classification performance.
3.4. Comparison with Other Methods
To validate the effectiveness of the proposed A
2Former model, this paper selected five representative algorithms as comparison methods, covering CNN–Transformer-based models (TransUnet [
52], HSI-TransUnet [
39]), hyperspectral classification-based models (SSTN [
31], PASSNet [
32]) and Transformer-based models (VIT [
53]).
Among the CNN–Transformer hybrid models, TransUnet combines the global modeling capabilities of Transformers with the fine-grained localization advantages of U-Net, achieving a balance between global perception and local detail in medical image segmentation. We introduce it into the hyperspectral image classification task for comparison. HSI-TransUnet designs a spectral feature attention block to aggregate spectral features in the encoder and employs a series of Transformer layers with residual connections to learn global contextual features, enabling precise segmentation of hyperspectral images. These two models, which belong to the same category of semantic segmentation-based methods as A2Former, are selected to evaluate the superior performance of our model. As a pure Transformer model, VIT represents a pioneering effort in applying Transformers to image recognition tasks. In patch-based models, SSTN is a novel spectral–spatial Transformer network composed of a spatial attention block and a spectral correlation block to overcome the limitations of convolutional kernels and achieve stronger spectral–spatial feature modeling. PASSNet similarly combines the local modeling capabilities of CNNs with the global modeling advantages of Transformers, proposing the PAM block and lightweight PConv block to effectively enhance high-spectral image classification performance. These two models, which fuse CNN and Transformer architectures and are based on different principles, are selected to evaluate the computational efficiency and classification accuracy of this model under conditions of no information leakage.
To ensure the fairness of the comparative experiments, all models strictly followed the network architecture described in their respective original papers to optimize their performance. The specific quantitative and qualitative results are as follows.
- (1)
Results for the Xiongan dataset: For the Xiongan hyperspectral dataset, the quantitative evaluation results of the A
2Former framework and other comparative algorithms are shown in
Table 6, with the highest accuracy in bold and the second-highest underlined. The experimental results show that the proposed A
2Former framework delivers superior performance, achieving an OA of 90.65%, a Kappa coefficient of 0.954, and an mIoU of 0.739. Specifically, compared to the top-performing patch-based method, PASSNet, A
2Former improves OA by 2.44%, mIoU by 3.45%, and Kappa by 3.06%. Compared to other patch-free models, the A
2Former framework also exhibits substantial performance gains. Compared to HSI-TransUnet, A
2Former improves OA by 3.74%, mIoU by 10.97%, and Kappa by 5.07%. Overall, the proposed A
2Former framework excels in fine-grained object classification tasks, particularly showing a distinct advantage in crop classification.
Figure 5 shows the overall and local classification results generated by different methods in several typical areas of the Xiongan dataset, facilitating an intuitive comparison of the model’s performance on different types of land features. As shown in
Figure 5, the A
2Former framework demonstrates significantly superior visual performance compared to other methods. Unlike image classification-based models such as PASSNet and SSTN, A
2Former effectively reduces salt-and-pepper noise, better preserves the integrity of feature internal structures, and is less susceptible to interference from negative samples. It accurately delineates boundaries and maintains an accuracy rate above 85% across all 12 categories, particularly excelling in the rose and white wax categories.
From the local magnification results (
Figure 6), in the first row, A
2Former can accurately identify more complex local areas, with the most precise recognition of Maize, Pear trees, Sophora japonica, and grasslands; in the second and third rows, all models accurately identify positive samples but some models (such as SSTN and PASSNet) fail to reduce salt-and-pepper noise, resulting in poor visualization effects, while A
2Former produces the least noise; in the fourth row, among all models exhibiting severe boundary fusion phenomena, A
2Former performs the most precise boundary delineation, with strong spatial consistency in classification results.
- (2)
Results for the HSI-CROP dataset: Although A2Former demonstrated excellent performance on the Xiongan dataset, given that the Xiongan dataset features relatively regular landforms and a limited number of categories, we selected the HSI-CROP dataset to validate the model’s generalization ability further. thereby, This dataset includes 30 categories (including negative samples) and features more complex spatial distributions of landforms, with numerous small objects, further increasing the classification difficulty.
Figure 7 and
Figure 8 shows the visualization classification maps of each model on the HSI-CROP dataset. As observed in the figure, patch-based methods exhibit noticeable salt-and-pepper noise in the classification maps, particularly on this high-resolution dataset, due to their pixel-wise prediction approach. In contrast, semantic segmentation-based methods (especially the proposed A
2Former) generate smoother classification maps with more consistent and aesthetically pleasing visual effects.
Similarly, from the local magnification results (
Figure 9), in the first and second rows, A
2Former demonstrates superior classification accuracy in regions with highly similar spectra and textures, accurately identifying dominant crops such as Millet, Chinese cabbage, cotton, corn, and beans. In the third row, for strip-shaped small target crop categories such as carrot and sesame, A
2Former still achieves the highest accuracy with sound visualization effects. In the fourth, fifth, and sixth rows, A
2Former produces almost no noise and performs precise boundary delineation, with strong spatial consistency in classification results.
Table 7 shows the classification results of each comparison method on the HSI-CROP hyperspectral image (HSI) dataset. Overall, the proposed A
2Former framework performs the best, significantly outperforming other methods. Quantitative evaluation results show that A
2Former achieves an OA of 87.63%, a Kappa coefficient of 85.28, and an average intersection-over-union (mIoU) of 42.36 on this dataset. Among them, PASSNet, as a typical patch-based method, also achieves a high classification accuracy, ranking second.
Additionally, due to the complex distribution of the HSI-CROP dataset, TransUnet, whose encoder structure relies solely on spatial contextual information, fails to fully utilize the rich spectral information in the data, resulting in poor classification accuracy. HSI-TransUnet utilizes a spectral information utilization block, similar to channel attention, which significantly improves classification accuracy for dominant categories. However, due to the designed loss function and data sampling strategy, it fails to effectively address the long-tail phenomenon, resulting in overall metrics that are slightly below those of TransUnet. Additionally, in patch-based methods, PASSNet and SSTN exhibit noticeable noise phenomena, attributed to their pixel-wise prediction approach.In the classification of categories such as Green bean and Spinach, the classification accuracy of most patch-free methods is generally far lower than that of patch-based methods. This difference is primarily attributed to the extreme scarcity of samples in these categories, which are represented by only a single training image. Additionally, the model tends to learn dominant category features during training, significantly limiting the performance of the A2Former semantic segmentation model in these categories.
In summary, the A2Former framework achieves optimal performance in both visualization quality and OA by effectively utilizing spectral space features while efficiently leveraging local–global context interactions to reconstruct features. This method effectively mitigates common issues such as salt-and-pepper noise and checkerboard effects, significantly improving the accuracy and visual consistency of classification results.
4. Discussion
4.1. Complexity and Inference Efficiency Analysis
Table 8 provides a comparative analysis of computational efficiency across various methods, evaluated through three key metrics: model parameter count, computational complexity (FLOPs), and inference time. Hyperspectral image classification methods for semantic segmentation tasks generally exhibit higher parameter counts and FLOPs compared to patch-based methods. This difference arises from their distinct approaches. Semantic segmentation methods capture both global context and local details of a large image in a single forward pass, producing precise pixel-level classifications while restoring the original resolution. In contrast, patch-based methods process smaller image patches and predict only the central pixel’s category.
Specifically, semantic segmentation methods capture both global contextual information and fine-grained local details from a larger input image in a single forward pass, producing accurate pixel-level classifications while restoring the original spatial resolution. In contrast, patch-based methods operate on smaller image patches and predict only the category of the central pixel. For example, patch-free models are able to process an entire image (e.g., 48 × 48 or larger) in a single inference step, whereas patch-based methods typically use much smaller patches (e.g., 9 × 9), generating predictions solely for the central pixel. As discussed in the introduction, this strategy inevitably leads to repeated computations for non-central pixels across overlapping patches, which substantially increases inference time. Consequently, despite optimizations for GPU parallel processing, although semantic segmentation methods incur significantly higher per-pass FLOPs due to their larger input size, the elimination of redundant computations enables a considerable reduction in overall inference time. For instance, on the HSI-CROP dataset, the proposed A2Former framework completes inference, including data loading, in just 16.3 s, whereas the fastest patch-based method, SSTN, requires 183.11 s.
In summary, while delivering classification accuracy comparable to or exceeding that of patch-based methods, the proposed patch-free model significantly enhances computational efficiency.
4.2. Quantitative Assessment via Confusion Matrix
Based on the analysis results of the confusion matrix for the Xiongan dataset in
Figure 10a, it can be seen that the classification accuracy of soybean and sparse forest is significantly lower. Specifically, soybean is frequently misclassified as a negative sample, and pear tree, while sparse forest also exhibits significant confusion, primarily being misclassified as pear tree. The primary cause of these issues lies in the fact that these categories have extremely scarce samples across the entire dataset, and in real-world non-ideal conditions, the spatial distribution of various sample categories is often not entirely random, making it difficult for existing sampling strategies to achieve complete balance between categories. For example, soybeans account for only 1% of the samples in the test set, which greatly increases the risk of misclassification.
For sparse forests, due to the high similarity of their spectral curves with pear trees, coupled with the fact that they account for only 11% of the samples in the test set, which is below the predefined 20% threshold, the model ultimately exhibits severe misclassification, thereby lowering the classification accuracy for this category.
Further analysis of the confusion matrix for the HSI-CROP dataset (
Figure 10b) reveals that the classification accuracy for Green bean, Spinach, Bok choy, Sorghum, Mulched field, and Okra is zero. Based on the category distribution and classification accuracy statistics, Except for Spinach and Mulched field, the remaining categories also suffered from severe data imbalance, which was the primary factor contributing to their poor classification performance. As for the excluded two categories, their misclassification can be attributed to other causes. Taking Spinach as an example, it was frequently misclassified as the dominant category Bare soil & Weed. This is largely due to the fact that the number of pixels for Bare soil & Weed in the training set was nearly 600 times that of Spinach, which significantly biased the model’s prediction tendency toward the dominant class.
Furthermore, categories such as Daikon, Eggplant, Sichuan peppercorn, Cauliflower, and Pumpkin also exhibited low classification accuracy, primarily due to a severe imbalance in the number of training samples. This further highlights the critical role of sampling strategies in enhancing classification performance. The issue is particularly pronounced in large-format models that adopt a patch-free input scheme for entire images. In such cases, achieving a relatively balanced class distribution while preventing information leakage has become an urgent research focus in the field.
4.3. Uncertainties and Limitations
Although the proposed method achieves state-of-the-art performance in terms of both classification accuracy and computational efficiency, several limitations remain. First, from the perspective of data sources, this study relies solely on single-temporal hyperspectral imagery. However, multi-temporal observations can provide valuable phenological information of different crops, which is beneficial for enhancing inter-class separability. Therefore, as hyperspectral imagery becomes increasingly available, future work could incorporate multi-temporal hyperspectral data to further improve crop mapping accuracy.
Second, from a methodological perspective, the proposed model adopts a patch-free semantic segmentation paradigm. While this design improves computational efficiency compared with patch-based approaches, it inevitably introduces a more complex encoder–decoder architecture. Despite efforts to employ lightweight module designs, this complexity leads to an increase in model parameters and per-inference FLOPs, particularly in the Transformer-based decoder. Future research may explore more lightweight encoder designs to further reduce model complexity.
Finally, from the training perspective, the proposed chessboard sampling strategy effectively prevents information leakage and improves the balance between training and test sets. Nevertheless, due to the relatively fixed input size, severe imbalance between training and test samples still exists for certain rare classes. Moreover, the fixed loss function assigns uniform importance to all classes during training, which may limit the model’s ability to adequately learn rare categories. Future work will investigate the trade-off between variable input sizes and sampling strategies to better balance class distributions, as well as the adoption of loss functions or data augmentation techniques specifically designed for rare classes.