Skip to content

Twahaaa/DSFormer-modified

Repository files navigation

DSFormer

Dual Selective Fusion Transformer Network for Hyperspectral Image Classification

Yichu Xu1, Di Wang1, Lefei Zhang1 *, Liangpei Zhang1,2

NN paper arXiv paper

1 Wuhan University, 2 Henan Academy of Sciences, * Corresponding author

📖Overview

  • DSFormer is a novel Dual Selective Fusion Transformer Network for HSI classification. It adaptively selects and fuses features from diverse receptive fields to achieve joint spatial-spectral context modeling, while reducing unnecessary information interference by focusing on the most relevant spatial-spectral tokens.


🚀Let's Get Started!

A. Installation

Step 1: Clone the repository:

Clone this repository and navigate to the project directory:

git clone https://github.com/YichuXu/DSFormer.git
cd DSFormer

Step 2: Environment Setup:

It is recommended to set up a conda environment and installing dependencies via pip. Use the following commands to set up your environment:

Create and activate a new conda environment

conda create -n DSFormer
conda activate DSFormer

Install dependencies

Our method uses python 3.8, pytorch 1.13, other environments are in requirements.txt

pip install -r requirements.txt

B. Data Preparation

Download HSI classification dataset from Google Drive or Baidu Drive (百度网盘) and put it under the [dataset] folder. It will have the following structure:

${DATASET_ROOT}   # Dataset root directory
├── datasets
│   │
│   ├── pu        # Pavia University data
│   │   ├──PaviaU.mat
│   │   ├──PaviaU_gt.mat
│   │
│   ├── houston13  # Houston 2013 data
│   │   ├──GRSS2013.mat
│   │   ├──GRSS2013_gt.mat 
│   │
│   ├── ip         # Indian Pines data	
│   │   ├──Indian_pines_corrected.mat
│   │   ├──Indian_pines_gt.mat 
│   │     
│   ├── whuhh     # Whu-HongHu data
│   │   ├──WHU_Hi_HongHu.mat
│   │   ├──WHU_Hi_HongHu_gt.mat 
│   │
│   ├── other HSI Datasets   
│   │   ├ ... 
│   │    

C. Performance Evaluation

  • The following commands show how to train and evaluate DSFormer for HSI classification:
python main.py --model DSFormer --dataset_name pu --num_run 10 --epoch 500 --device 0 --dataID 1 --patch_size 10 --k 2/5 --train_num 30 --group_num 4 --ps 2
python main.py --model DSFormer --dataset_name ip --num_run 10 --epoch 500 --device 1 --dataID 4 --patch_size 10 --k 4/5 --train_num 50 --group_num 4 --ps 2
python main.py --model DSFormer --dataset_name houston13 --num_run 10 --epoch 500 --device 2 --dataID 3 --patch_size 10 --k 3/5 --train_num 50 --group_num 4 --ps 2
python main.py --model DSFormer --dataset_name whuhh --num_run 10 --epoch 500 --device 3 --dataID 7 --patch_size 10 --k 3/5 --train_num 50 --group_num 4 --ps 2

📜Reference

if you find it useful for your research, please consider giving this repo a ⭐ and citing our paper! We appreciate your support!😊

@ARTICLE{Xu2025DSFormer,
  author={Xu, Yichu and Wang, Di and Zhang, Lefei and Zhang, Liangpei},
  title={Dual Selective Fusion Transformer Network for Hyperspectral Image Classification}, 
  journal={Neural Networks},
  volume = {187},
  pages = {107311},
  year = {2025}
}

🙋Q & A

For any questions, please contact us.

💖 Thanks

This project is based on GSC-ViT, TTST, LSKNet, ObjFormer. Thanks for their great work!

About

WATPFormer extends DSFormer by incorporating wavelength-aware embeddings and a hierarchical token pyramid to better capture physical spectral semantics and multi-scale spectral features for hyperspectral image classification.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages