Skip to main content

GHOST: Generalizable Hyperspectral Observation & Segmentation Toolkit

Project description

GHOST

Generalizable Hyperspectral Observation & Segmentation Toolkit

97.5% OA | 0.86 mIoU on Indian Pines — trained on a laptop GPU in 77 minutes.

pip install ghost-hsi

What is GHOST?

GHOST is a hyperspectral image segmentation framework. Point it at any .mat hyperspectral dataset and get a segmentation map — no code, no pipeline configuration, no PCA.

It runs on consumer hardware (RTX 3050, 6 GB VRAM) and handles any band count, class count, or spatial resolution automatically.

ghost train_rssp \
  --data data.mat --gt labels.mat \
  --routing forest --loss dice \
  --out-dir runs/my_experiment

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

Why GHOST?

No PCA Required

Every major hyperspectral deep learning method requires PCA as a preprocessing step — choosing how many components to retain, accepting discarded spectral information. For non-standard domains (planetary science, medical imaging, novel sensors), this is a barrier and a source of information loss.

GHOST uses Continuum Removal: a physics-informed normalisation that strips brightness variation and isolates absorption feature shape. All spectral bands preserved. No dimensionality choices.

Fully Data-Agnostic

Band count, class count, spatial dimensions — all read from the file at runtime. Nothing is hardcoded. The same binary that segments Indian Pines (200 bands, 16 classes) also handles lung cancer pathology slides (61 bands, 3 classes) and Mars CRISM data — with zero code changes.

Runs on Consumer Hardware

Full training on a 6 GB laptop GPU. No A100s, no cloud compute, no multi-GPU setups. Designed for researchers who don't have institutional compute access.


Results

All results: --train_ratio 0.2 --val_ratio 0.1 --seed 42, forest routing, NVIDIA RTX 3050 (6 GB).

Indian Pines

Config OA mIoU Dice Kappa Time
64 base / 32 num filters 97.52% 0.8593 0.9038 0.9717 6h 2m
32 base / 8 num filters 97.55% 0.8027 0.8391 0.9721 77m
Per-class IoU (64/32 config)
Class IoU Class IoU
1 0.9143 9 0.1905
2 0.9351 10 0.9547
3 0.9425 11 0.9689
4 0.8811 12 0.9607
5 0.9415 13 0.9592
6 0.9961 14 0.9694
7 0.4286 15 0.9890
8 0.9256 16 0.7910

Classes 7 and 9 have <30 training samples. Low IoU on these is expected and consistent with published literature.

Salinas Valley

Results pending re-run with latest pipeline. Space reserved.

Config OA mIoU Dice Kappa Time

Pavia University

Results pending re-run with latest pipeline. Space reserved.

Config OA mIoU Dice Kappa Time

LUSC (Lung Squamous Cell Carcinoma)

Single image only (1 of 62). Not comparable to published benchmarks. Trained on a 512x512 crop with same-region pixel split. Published methods use patient-level cross-validation across 10 patients. These numbers demonstrate data-agnostic capability, not SOTA claims.

Metric Value
OA 99.43%
mIoU 88.96%
Dice 93.49%
Kappa 0.9878

See LUSC_ghost_report.md for full details on why these results are not directly comparable.

Mars CRISM / Asteroid Ryugu

Tested on planetary remote sensing data. Results in early exploration phase — not benchmarked against published methods.


Quick Start

Install

pip install ghost-hsi

Train

ghost train_rssp \
  --data data/indian_pines/Indian_pines_corrected.mat \
  --gt   data/indian_pines/Indian_pines_gt.mat \
  --loss dice --routing forest \
  --base_filters 32 --num_filters 8 \
  --forests 5 --leaf_forests 3 \
  --epochs 400 --patience 50 --min_epochs 40 \
  --out-dir runs/indian_pines

Predict

ghost predict \
  --data  data/indian_pines/Indian_pines_corrected.mat \
  --gt    data/indian_pines/Indian_pines_gt.mat \
  --model runs/indian_pines/rssp_models.pkl \
  --routing forest --out-dir runs/indian_pines

Visualize

ghost visualize \
  --data    data/indian_pines/Indian_pines_corrected.mat \
  --gt      data/indian_pines/Indian_pines_gt.mat \
  --model   runs/indian_pines/rssp_models.pkl \
  --dataset indian_pines --routing forest \
  --out-dir runs/indian_pines

Hardware Requirements

Setting VRAM Flags Indian Pines Time
Lightweight 4 GB --base_filters 16 --num_filters 4 --d_model 32 ~30m
Standard 6 GB --base_filters 32 --num_filters 8 ~77m
Full 8 GB+ --base_filters 64 --num_filters 32 ~6h

No multi-GPU support. Single consumer GPU is all you need.


Data Format

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

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

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

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


Architecture Overview

.mat file (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
RSSP Tree ------------- recursive binary class splitting
    |                   each node: independent forest ensemble
    v
Prediction Map (H, W)

See architecture.md for technical details.


Documentation

Document Description
Architecture Pipeline components, RSSP tree, training details
API Reference All CLI commands and flags
TODO Roadmap, known limitations, planned features

License

Proprietary. All rights reserved. See LICENSE.

For source code access, research collaborations, or licensing inquiries, contact the author directly.


Citation

If you use GHOST in your research, please cite:

@software{ghost2026,
  title  = {GHOST: Generalizable Hyperspectral Observation \& Segmentation Toolkit},
  author = {Ishu},
  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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

ghost_hsi-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

ghost_hsi-0.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

ghost_hsi-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

File hashes

Hashes for ghost_hsi-0.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 664f8e52e4f85464c92cc2b965a0fb009d2da19bfb6f113010be92ef8f0be01f
MD5 fe871570bb0369cb954ea9ef5b55f9af
BLAKE2b-256 df3cf58cfd47c920d8d05264e9748ac4d1c6b50c542d534ee014ba62205c3e69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ghost_hsi-0.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 929bc6e9a04fec966d1f8d0d0494167e5d22b071212d44b4d2e9cb309e17f748
MD5 ff47390d9f1d1385daa2d2d96c26f9df
BLAKE2b-256 5064fce0d4f435c1fd1637f0777cde656628955e1ec5f9a53f4ec0bb9dafdfb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ghost_hsi-0.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 59803540044ab79052c81dd632d2f859467b83e3f421d9d291ff0a9de344e9a6
MD5 368e8ded061b883b25ccc8928d43ed10
BLAKE2b-256 1f9b8a5503464d26745ba12e8d875dfb61cc0d41e06127e1a20d881dabbc0e0e

See more details on using hashes here.

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