Skip to main content

GHOST: Generalizable Hyperspectral Observation & Segmentation Toolkit

Project description

GHOST

Generalizable Hyperspectral Observation & Segmentation Toolkit

An attempt to generalize Hyperspectral Imaging.

GHOST is a general-purpose hyperspectral segmentation tool — point it at a hyperspectral image and get a segmentation map without writing dataset-specific code. Band count, class count, and spatial dimensions are read at runtime with no hardcoding. Loosely inspired by nnU-Net, though much simpler and narrower in scope.

Supports Python 3.9 - 3.12

pip install ghost-hsi
ghost demo

Design Goals

Goal Status
Data Agnosticism — band count, class count, spatial dims read at runtime Achieved
Band Count Agnosticism — works on 3 to 400+ bands with identical pipeline Achieved
Sensor Agnosticism — remote sensing, medical pathology, planetary science Achieved
Spectral-Only Context — scene-to-scene transfer without spatial dependency In progress (v0.2.x)

Numbers so far

Dataset Config OA mIoU Kappa Hardware Time
LUSC 32 / 8 99.42% 0.9263 0.9876 RTX 3050 (laptop) 1h 8m
Salinas Valley 32 / 8 98.69% 0.9577 0.9855 Kaggle T4 10h 51m
Indian Pines 64 / 16 98.16% 0.9071 0.9790 RTX 3050 (laptop) 2h 20m
Pavia University 32 / 8 97.47% 0.9531 0.9667 Kaggle T4 7h 29m
Indian Pines 32 / 8 97.20% 0.8030 0.9681 RTX 3050 (laptop) 1h 17m
Mars CRISM 32 / 8 71.70% 0.5228 0.6829 Kaggle T4 6h 44m

Config = base_filters / num_filters. All runs use ce+dice loss and ensemble routing. Roughly +/-1% variance between runs due to random splits and seed sensitivity.

Caveats: Evaluation is pixel-level train/test split on a single scene, standard for these benchmarks but limited for real-world generalization. LUSC is a single 512x512 crop. Mars CRISM ground truth is extremely sparse and noisy.


How it works (v0.1.x)

Hyperspectral Image (H, W, Bands)
    |
    v
Continuum Removal ---- physics-based normalisation, no PCA
    |
    v
Spectral 3D Conv ----- learns cross-band features, kernel (7,3,3)
    |
    v
SE Attention ---------- per-channel importance weighting
    |
    v
2D U-Net -------------- multi-scale spatial context
    |
    v
SPT ------------------- Spectral Partition Tree
    |                   each node: independent model ensemble
    v
Prediction Map (H, W)

The SPT (Spectral Partition Tree) recursively splits classes into groups based on spectral similarity (using SAM distance), and trains separate model ensembles for each group. This helps significantly with class imbalance.

See architecture.md for full details.


Quick start

# Install
pip install ghost-hsi

# See bundled dataset paths and example command
ghost demo

# Train with Spectral Partition Tree
ghost train_spt \
  --data data.mat --gt labels.mat \
  --loss dice \
  --base_filters 32 --num_filters 8 \
  --ensembles 5 --leaf_ensembles 3 \
  --epochs 400 --patience 50 --min_epochs 40 \
  --out-dir runs/my_experiment

# Predict
ghost predict \
  --data data.mat --gt labels.mat \
  --model runs/my_experiment/spt_models.pkl \
  --routing forest --out-dir runs/my_experiment

# Visualize
ghost visualize \
  --data data.mat --gt labels.mat \
  --model runs/my_experiment/spt_models.pkl \
  --out-dir runs/my_experiment

A flat baseline (no SPT) is available via ghost train.


Data format

GHOST accepts .mat files (MATLAB/HDF5 format):

  • Data file: 3D array (H, W, Bands) — the hyperspectral cube
  • Ground truth file: 2D array (H, W) — integer class labels, 0 = background

Keys inside the .mat file are auto-detected by array dimensionality.

Converting other formats (v0.1.7+)

GHOST can convert ENVI, TIFF, GeoTIFF, and HDF5 files to .mat:

pip install ghost-hsi[convert]

ghost convert_to_mat \
  --img image.hdr \
  --gt  labels.tif \
  --out-dir converted/

All metadata is preserved in a metadata.json sidecar file. Optional spatial cropping via --crop Y X H W. See API Reference for full details.

Standard datasets (Indian Pines, Pavia University, Salinas Valley) are available from the GIC group at UPV/EHU.


Known limitations (v0.1.x)

  • Spatial dependence: U-Net processes neighbouring pixels; models don't reliably transfer across scenes
  • No transfer learning: Each dataset requires full retraining
  • Single-scene constraint: Training and inference on same/identical-condition scenes only
  • SSSR router non-functional: Use --routing forest (default and recommended)

Docs

Document What's in it
Architecture How the pipeline works
API Reference CLI commands and flags
Commands Usage examples for each dataset

Website: anakinskywalker0.github.io/GhostWEB


License

Proprietary. All rights reserved. See LICENSE.


Citation

@software{ghost2026,
  title  = {GHOST: Generalizable Hyperspectral Observation \& Segmentation Toolkit},
  author = {IshuIsAwake},
  year   = {2026},
  url    = {https://pypi.org/project/ghost-hsi/}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ghost_hsi-0.1.7.tar.gz (8.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ghost_hsi-0.1.7-cp312-cp312-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.12Windows x86-64

ghost_hsi-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ghost_hsi-0.1.7-cp312-cp312-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ghost_hsi-0.1.7-cp311-cp311-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.11Windows x86-64

ghost_hsi-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ghost_hsi-0.1.7-cp311-cp311-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

ghost_hsi-0.1.7-cp310-cp310-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.10Windows x86-64

ghost_hsi-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

ghost_hsi-0.1.7-cp310-cp310-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

ghost_hsi-0.1.7-cp39-cp39-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9Windows x86-64

ghost_hsi-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

ghost_hsi-0.1.7-cp39-cp39-macosx_11_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file ghost_hsi-0.1.7.tar.gz.

File metadata

  • Download URL: ghost_hsi-0.1.7.tar.gz
  • Upload date:
  • Size: 8.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ghost_hsi-0.1.7.tar.gz
Algorithm Hash digest
SHA256 a6da7532d6a91129d5957889a1388affe8aebe3d41e0642a539a890821b6dbf2
MD5 a98de828d9e8a5c5775b3541d20afd0d
BLAKE2b-256 4fea8d792fabcdc6669f9f4eea802bd748cd113365e364626fa26a2479826904

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7.tar.gz:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: ghost_hsi-0.1.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 6.9 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ghost_hsi-0.1.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 90a3d592e794013b4b4ae2d33dafb2deb0c7a86b868713ff029b739e37a3fdee
MD5 f6f8605b4d3f6f5d4756ffb230257dfc
BLAKE2b-256 57646e26dbcfe9e2626e7f1c89cee6e0ae417f9e287a3ebc86e3bdba43dade7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7a1c070a953b78ab652b12f0f0d5660404520934f8bde206df376db7fb2ff974
MD5 6311e960d86e24c77fdfd30ee5253d51
BLAKE2b-256 6b8bffef23180c152690a12bf8b8eda01177208fe5f324788ca19c7ddd269d06

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7aebcad7928dca7444f400e0b3b0cf4f6a9b1c145631250a1ec2c1ef23b03daa
MD5 25a6a20d243333ed9069a9f1ffe1578b
BLAKE2b-256 2b9c2c61480bee05d0f69a2abd8e6d4f71e8ac901e2ff0bc10d439b7795b6a53

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: ghost_hsi-0.1.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 6.9 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ghost_hsi-0.1.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1ae4193d2c688225261aa22180c43c7b8161717428a0498199f4184ca556f4d5
MD5 c76a806411c008571f785b38a086a776
BLAKE2b-256 1f480768aecc3b40eb0779915ea4c7f8f6c92ccaf585b113f55ab7014e9f51e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac0405ba771638a63e97b9da6ee21f46588d0ba56549befef24c3d38fd8d794d
MD5 663f48a4e81b6f3a656887375f2ad41e
BLAKE2b-256 71fae2567ffbd24bffdece7e58543fc4ad94a5616200a654256c44b0047e691d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6eaaf6841136376e98a0d32dddde9eab330bc031ad25473d03da40ee8186517
MD5 facbf8dd5f7d4dcfd83c249847f1ee51
BLAKE2b-256 f322c06634f230c41ac530603550ca00e00b2eadf3e1868f3ad4701cee7a9ca2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: ghost_hsi-0.1.7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 6.9 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ghost_hsi-0.1.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 10b218ee73b0a635b346f10a91764b5746838f8b09ef1fdb787c1782a4ad913f
MD5 88fb6462304c28795debcbc297cea37a
BLAKE2b-256 331c4482ccfc675b03aa16b2bb9b9c09e6a1d8a720127b0fbc2188493ed8a1e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp310-cp310-win_amd64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a9acac73fb2cff0639bf27b01739e5528106b79415847e9c045a96331ba2c965
MD5 ba8fd3be94d8026c8d57daa10924d0e3
BLAKE2b-256 db774d7ef69a1f09c8dc2a4e42186361efc1912b301ffdba22759deeccf70ada

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c40792112d2f5634d4d5536690d6bfe8e51fe37e9d64f23066743e06c18190d
MD5 fbe21e047263069017c6137adec29075
BLAKE2b-256 ee63f9ef8df5e58c0fcad56e8a1bd6a8488927bdba3a043ccdf1ad014365a3cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: ghost_hsi-0.1.7-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 6.9 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ghost_hsi-0.1.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3e7f1d50c6bb530e9fd4115fdd1bb436a00c45f2a7c7bd2b16bf7e31bdcd0391
MD5 dd3e2d823c0a15e5b7b2c2f8778d6bdc
BLAKE2b-256 4e56544dbfe113aa92ef2c5dc66871e694f8427a24ad7d9098e91f5a21a17e06

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp39-cp39-win_amd64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bff4557ade070ecf5e9b65da720af8a8321d7af8c46693a6c4b6683ba7353ee8
MD5 74c3ab3f46fdf01009d15ecd530f0d85
BLAKE2b-256 b3f17b1cba3b75893a813af4185a73cf4a282461af07f536f7f1cdefcd86a0db

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ghost_hsi-0.1.7-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ghost_hsi-0.1.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27f38046593ed585214879d9497e62c8ca9c4ce3dde741df58027dece50cf733
MD5 fd84f94a322c8a7fe3a8fc23526e8a70
BLAKE2b-256 e8b6715c550ac12dd15e7643a91b16ab4b56bffdaf9776c3b70fcb073db2ddaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for ghost_hsi-0.1.7-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: publish.yml on IshuIsAwake/GHOST

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page