GithubHelp home page GithubHelp logo

zy-lii / ieee_tgrs_spformer Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 8.37 MB

A slim implementation of Self-Pooling Transformer for hyperspectral image classification.

Python 100.00%
few-shot-classifcation hyperspectral-image-classification pooling transformer token-mixer

ieee_tgrs_spformer's Introduction

SPFormer: Self-Pooling Transformer for Few-Shot Hyperspectral Image Classification

Ziyu Li, Zhaohui Xue, Qi Xu, Ling Zhang, Tianzhi Zhu, Mengxue Zhang


This is a slim implementation of the "SPFormer: Self-Pooling Transformer for Few-Shot Hyperspectral Image Classification", and the official release please sees "here".

alt text Figure 1: The overview of Self-Pooling Transformer, including three stages: HSI dimensionality reduction, SPF block encoding, classification.

alt text Figure 2: Spectral token mixer module in SPFormer.

alt text Figure 3: Spatial token mixer module in SPFormer.

Citation

Reproductions of our model and experiments are very welcome, and citations to our paper will be greatly appreciated

Z. Li, Z. Xue, Q. Xu, L. Zhang, T. Zhu and M. Zhang, "SPFormer: Self-Pooling Transformer for Few-Shot Hyperspectral Image Classification," in IEEE Transactions on Geoscience and Remote Sensing, vol. 62, pp. 1-19, 2024, Art no. 5502019, doi: 10.1109/TGRS.2023.3345923.

@ARTICLE{10371361,
    author={Li, Ziyu and Xue, Zhaohui and Xu, Qi and Zhang, Ling and Zhu, Tianzhi and Zhang, Mengxue},
    journal={IEEE Transactions on Geoscience and Remote Sensing}, 
    title={SPFormer: Self-Pooling Transformer for Few-Shot Hyperspectral Image Classification}, 
    year={2024},
    volume={62},
    number={},
    pages={1-19},
    keywords={Transformers;Feature extraction;Training;Convolutional neural networks;Prototypes;Mixers;Data models;Autoencoder;channel shuffle (CS);few-shot learning (FSL);hyperspectral image (HSI) classification;self-pooling;Transformer},
    doi={10.1109/TGRS.2023.3345923}
}

Requirements

Running environment and required packages:

python==3.8
numpy==1.19.5
matplotlib==3.3.4
scipy==1.5.2
scikit-learn==0.23.2
opencv-python==4.5.1.48
torch==1.10.2+cu111

Instructions for usage

AutoEncoder.py ...... Train an autoencoder for hyperspectral image dimensionality reduction and save the .pt file.
SelfPoolingTransformer.py ...... A script for the implementation of SPFormer.
main.py ...... A main script for hyperspectral image classification.
data.py ...... A data processing script for hyperspectral image.
loop_train_test.py ...... Perform iterative training and testing loops, saving the model weights in the 'save\models' directory, and storing the confusion matrix of the test results in the 'save\results' directory.
loss_function.py ...... A script for calculating training loss.
visualization.py ...... A script for drawing and visualization.
  1. Begin by executing AutoEncoder.py to initiate the training of the autoencoder for the specific dataset. It is advised to set the training iterations to a minimum of 50. Automatically save the model with the lowest loss, and take note of the file path for the corresponding .pt file.
  2. Proceed to run main.py for model training and testing on the specified dataset. Ensure that you accurately input the autoencoder's file path into the designated dictionary variable before initiating the process.

ieee_tgrs_spformer's People

Contributors

zy-lii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kenny-08

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.