This project focuses on hyperspectral image classification (HSI Classification), implementing a variety of mainstream and cutting-edge deep learning models (CNN, Transformer, Mamba, etc.) for remote sensing HSI analysis and classification. It supports multiple datasets and model comparison experiments, making it suitable for both research and engineering applications.
Key Features:
- Supports various mainstream and novel deep learning models
- Clean code structure, easy to extend
- Multi-dataset and batch experiment support
- Visualization and comparative analysis of results
Note: This project is a graduation design. Some implementations are for reference only. Feedback and suggestions are welcome.
-
Clone the repository and install dependencies:
git clone https://github.com/751K/HS_Image_Classification.git cd HS_Image_Classification pip install -r requirements.txt -
Run the main program:
python src/main.py
-
Train a specific model:
cd src python main.py -
Batch train all models:
cd src python run_all.py -
Visualize results:
cd src python vis.py
| Model Name | Type | Path |
|---|---|---|
| ResNet2D | CNN | src.CNNBase.ResNet2D |
| ResNet3D | CNN | src.CNNBase.ResNet3D |
| HybridSN | CNN | src.CNNBase.HybridSN |
| LeeEtAl3D | CNN | src.CNNBase.LeeEtAl3D |
| GCN2D | GCN | src.CNNBase.GCN2D |
| SSFTT | Transformer | src.TransformerBase.SSFTT |
| SwimTransformer | Transformer | src.TransformerBase.SwimTransformer |
| VisionTransformer | Transformer | src.TransformerBase.VisionTransformer |
| SFT | Transformer | src.TransformerBase.SFT |
| SSMamba | Mamba | src.MambaBase.SSMamba |
| MambaHSI | Mamba | src.MambaBase.MambaHSI |
| STMamba | Mamba | src.MambaBase.STMamba |
| AllinMamba | Mamba | src.MambaBase.AllinMamba |
Implementations are for reference only. Please adjust details and parameters according to papers and actual needs.
To add a new model:
- Add your model implementation under
src/CNNBase/,src/TransformerBase/, orsrc/MambaBase/. - Import the new model in the corresponding
__init__.py. - Configure the new model in
src/config.py.
project/
├── datasets/ # Datasets
│ ├── Indian/ # Indian Pines
│ ├── Pavia/ # Pavia University
│ └── Salinas/ # Salinas
├── results/ # Model results and outputs
├── src/ # Source code
│ ├── CNNBase/ # CNN models
│ ├── MambaBase/ # Mamba models
│ ├── TransformerBase/# Transformer models
│ ├── Dim/ # Dimensionality reduction
│ ├── Train_and_Eval/ # Training and evaluation
│ ├── datesets/ # Data processing
│ ├── draw/ # Visualization
│ ├── config.py # Config file
│ ├── main.py # Main entry
│ ├── model_init.py # Model initialization
│ └── run_all.py # Batch training script
├── LICENSE # License
└── requirements.txt # Dependencies
- Indian Pines
- Pavia University
- Salinas
- KSC
- Botswana
- WHU-Hi-Honghu
To add a new dataset:
- Add loading logic in
src/datesets/datasets_load.py. - Configure the new dataset in
src/config.py.
| Model Name | Dataset | Accuracy | AA | Kappa | Train Time(s) | Params | Inference Time(s) |
|---|---|---|---|---|---|---|---|
| LeeEtAl3D | Indian Pines | 0.8022 | 0.7257 | 0.7703 | 119.60 | 158,736 | 0.4582 |
| ResNet3D | Indian Pines | 0.9470 | 0.8830 | 0.9395 | 130.47 | 418,768 | 0.3068 |
| ResNet2D | Indian Pines | 0.9871 | 0.9898 | 0.9853 | 559.36 | 11,193,744 | 1.6913 |
| GCN2D | Indian Pines | 0.9026 | 0.6905 | 0.8887 | 22.85 | 23,441 | 0.0570 |
| HybridSN | Indian Pines | 0.9500 | 0.9231 | 0.9429 | 92.43 | 10,885,248 | 0.2625 |
| SwimTransformer | Indian Pines | 0.9461 | 0.8434 | 0.9385 | 81.72 | 53,264 | 0.2163 |
| VisionTransformer | Indian Pines | 0.9646 | 0.9223 | 0.9596 | 83.04 | 117,264 | 0.2238 |
| SSFTT | Indian Pines | 0.9376 | 0.8122 | 0.9289 | 20.24 | 165,536 | 0.0287 |
| SFT | Indian Pines | 0.8323 | 0.6128 | 0.8077 | 13.16 | 136,112 | 0.0197 |
| MambaHSI | Indian Pines | 0.9429 | 0.8431 | 0.9348 | 862.80 | 105,232 | 2.7553 |
| SSMamba | Indian Pines | 0.9648 | 0.9598 | 0.9599 | 289.79 | 240,050 | 0.7452 |
| STMamba | Indian Pines | 0.8473 | 0.6145 | 0.8237 | 602.23 | 69,456 | 1.0509 |
| AllinMamba | Indian Pines | 0.9879 | 0.9752 | 0.9862 | 417.85 | 2,232,084 | 1.3174 |
- Supports Linux, MacOS, Windows (WSL2 recommended)
- Python 3.12+
- PyTorch 2.1.0+
- Numpy
- scikit-learn
- See requirements.txt for details
- NVIDIA GPU (RTX 3060 or above recommended)
- At least 16GB RAM
- Apple Silicon is also supported, but NVIDIA GPU is recommended
Q: Error or missing dependencies?
A: Please make sure all dependencies in requirements.txt are installed.
Q: How to customize models or datasets?
A: See the "Model Extension" and "Dataset Extension" sections.
Q: Can I run on CPU?
A: Yes, but not recommended.
Issues, PRs, and suggestions are welcome! Please submit issues on GitHub for bugs or improvements.
- Author: 751K
- Email: k1012922528@gmail.com
This project is licensed under the MIT License. See LICENSE for details.
Thanks to myself and all future contributors. Thanks to ChatGPT and Claude for their assistance.