Getting started
Install TlseHypDataSet (compatible with Python>=3.8,<3.1) with pip:
$ pip install TlseHypDataSetOption 1: working with 3D patches
Download the hyperspectral images at www.toulouse-hyperspectral-data-set.com in an images folder:
/path/to/dataset/
├── images
├── TLS_1b_2021-06-15_10-41-20_reflectance_rect.bsq
├── TLS_1b_2021-06-15_10-41-20_reflectance_rect.hdr
├── ...
Then, specify the 'patch' mode and the desired patch size:
from TlseHypDataSet.tlse_hyp_data_set import TlseHypDataSet
dataset = TlseHypDataSet('/path/to/dataset/', pred_mode='patch', patch_size=64)
Option 2: working with 1D reflectance spectra
Download the 1D hyperspectral data at huggingface.co/datasets/Romain3Ch216/TlseHypDataSet in an inputs folder:
/path/to/dataset/
├── inputs
├── areas.npy
├── data_pixel_1_images_0_1_2_3_4_5_6_7_8__.hdf5
├── ...
Then, specify the 'pixel' mode:
from TlseHypDataSet.tlse_hyp_data_set import TlseHypDataSet
dataset = TlseHypDataSet('/path/to/dataset/', pred_mode='pixel', patch_size=1)
Loading the ground truth
The TlseHypDataSet class has a standard_splits attribute that contains 8 standard splits of the ground truth in a 'train' set, a 'labeled_pool', an 'unlabeled_pool', a 'validation' set and a 'test' set, as explained here. The following example shows how to load the training set of the first standard train / test split in a Pytorch data loader with the DisjointDataSplit class (see the Dataset and the Spatially disjoint ground truth splits sections for more details):
import torch
from TlseHypDataSet.tlse_hyp_data_set import TlseHypDataSet
from TlseHypDataSet.utils.dataset import DisjointDataSplit
dataset = TlseHypDataSet('/path/to/dataset/', pred_mode='pixel', patch_size=1)
# Load the first standard ground truth split
ground_truth_split = DisjointDataSplit(dataset, split=dataset.standard_splits[0])
train_loader = torch.utils.data.DataLoader(
ground_truth_split.sets_['train'],
shuffle=True,
batch_size=1024
)
for epoch in range(100):
for samples, labels in train_loader:
...
NB: at first use, the images and the ground truth will be processed and additional data will be saved in a rasters folder.