Skip to content
Deep learning toolbox based on PyTorch for hyperspectral data classification.
Python Dockerfile Shell
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.dockerignore Smaller docker image May 30, 2018
.gitignore Add .mat files to .gitignore Aug 30, 2017
Dockerfile Smaller docker image May 30, 2018
License Add dual license May 7, 2019 Add say thanks badge + update logos Mar 26, 2019 Example of a custom dataset (DFC2018) May 29, 2018 Create a separate inference script Sep 25, 2018 Create a separate inference script Sep 25, 2018 [Models] Use correct initialization for all deep nets Sep 25, 2018
requirements.txt Add torchsummary to requirements.txt Sep 25, 2018 Update Dockerfile May 25, 2018 Introduce get_device function to automatically find the Tensor storage Sep 25, 2018


A Python tool to perform deep learning experiments on various hyperspectral datasets.


This tool is compatible with Python 2.7 and Python 3.5+.

It is based on the PyTorch deep learning and GPU computing framework and use the Visdom visualization server.


The easiest way to install this code is to create a Python virtual environment and to install dependencies using: pip install -r requirements.txt


Alternatively, it is possible to run the Docker image.

Grab the image using:

docker pull

And then run the image using:

docker run -p 9999:8097 -ti --rm -v `pwd`:/workspace/DeepHyperX/

This command:

  • starts a Docker container using the image
  • starts an interactive shell session -ti
  • mounts the current folder in the /workspace/DeepHyperX/ path of the container
  • binds the local port 9999 to the container port 8097 (for Visdom)
  • removes the container --rm when the user has finished.

All data and products are stored in the current folder.

Users can build the Docker image locally using the Dockerfile using the command docker build ..

Hyperspectral datasets

Several public hyperspectral datasets are available on the UPV/EHU wiki. Users can download those beforehand or let the tool download them. The default dataset folder is ./Datasets/, although this can be modified at runtime using the --folder arg.

At this time, the tool automatically downloads the following public datasets:

  • Pavia University
  • Pavia Center
  • Kennedy Space Center
  • Indian Pines
  • Botswana

The Data Fusion Contest 2018 hyperspectral dataset is also preconfigured, although users need to download it on the DASE website and store it in the dataset folder under DFC2018_HSI.

An example dataset folder has the following structure:

├── Botswana
│   ├── Botswana_gt.mat
│   └── Botswana.mat
├── DFC2018_HSI
│   ├── 2018_IEEE_GRSS_DFC_GT_TR.tif
│   ├── 2018_IEEE_GRSS_DFC_HSI_TR
│   ├── 2018_IEEE_GRSS_DFC_HSI_TR.aux.xml
├── IndianPines
│   ├── Indian_pines_corrected.mat
│   ├── Indian_pines_gt.mat
├── KSC
│   ├── KSC_gt.mat
│   └── KSC.mat
├── PaviaC
│   ├── Pavia_gt.mat
│   └── Pavia.mat
└── PaviaU
    ├── PaviaU_gt.mat
    └── PaviaU.mat

Adding a new dataset

Adding a custom dataset can be done by modifying the file. Developers should add a new entry to the CUSTOM_DATASETS_CONFIG variable and define a specific data loader for their use case.


Currently, this tool implements several SVM variants from the scikit-learn library and many state-of-the-art deep networks implemented in PyTorch.

Adding a new model

Adding a custom deep network can be done by modifying the file. This implies creating a new class for the custom deep network and altering the get_model function.


Start a Visdom server: python -m visdom.server and go to http://localhost:8097 to see the visualizations (or http://localhost:9999 if you use Docker).

Then, run the script

The most useful arguments are:

  • --model to specify the model (e.g. 'svm', 'nn', 'hamida', 'lee', 'chen', 'li'),
  • --dataset to specify which dataset to use (e.g. 'PaviaC', 'PaviaU', 'IndianPines', 'KSC', 'Botswana'),
  • the --cuda switch to run the neural nets on GPU. The tool fallbacks on CPU if this switch is not specified.

There are more parameters that can be used to control more finely the behaviour of the tool. See python -h for more information.


  • python --model SVM --dataset IndianPines --training_sample 0.3 This runs a grid search on SVM on the Indian Pines dataset, using 30% of the samples for training and the rest for testing. Results are displayed in the visdom panel.
  • python --model nn --dataset PaviaU --training_sample 0.1 --cuda This runs on GPU a basic 4-layers fully connected neural network on the Pavia University dataset, using 10% of the samples for training.
  • python --model hamida --dataset PaviaU --training_sample 0.5 --patch_size 7 --epoch 50 --cuda This runs on GPU the 3D CNN from Hamida et al. on the Pavia University dataset with a patch size of 7, using 50% of the samples for training and optimizing for 50 epochs.

Say Thanks!

You can’t perform that action at this time.