Spectral Loader
Get a hyperspectral cube into ComfyUI at all
- preview
- spectral
ComfyUI has no idea what a hyperspectral image is, and why would it? A normal photo is three bands - red, green, blue. A hyperspectral cube is hundreds of bands, where every pixel carries a full light spectrum instead of a color. That's the data from airborne and satellite sensors (AVIRIS, EnMAP, Hyperion) used in mineral exploration, agriculture monitoring, and defense. If you work with that kind of data and you also live in ComfyUI, you've been out of luck - until now.
Spectral Loader is the front door of a tiny, obscure pack (chenlongming/ComfyUI_Spectral) that wraps the classic spectral Python library from spectralpython and hands hyperspectral imagery to the graph. It's not a generation node. There are no checkpoints, no LoRAs, no models to download. Your "models" are your own spectral data files. The whole pack is remote-sensing tooling that happens to live in ComfyUI, and this node is where every workflow in it starts.
What it does
Give it a file path and it opens the image with spectral.open_image() - that handles the standard ENVI data formats (.lan, .bil, .bsq, .bip), which is what most hyperspectral data actually ships as. The repo's example workflow loads the classic Indian Pines AVIRIS cube (92AV3C.lan), the same dataset the spectral library's own tutorials use, so you can test with that if you have it lying around.
The node then does two things with the opened object:
- Renders a preview - it calls
sp.save_rgb()to write a JPEG totemp/spectral_preview.jpg, picks a sensible default RGB band combination for display, converts it to a tensor with torchvision, and hands it out as a normal ComfyUIIMAGE. - Passes the opened spectral object out as the pack's custom
SPEtype.
The one input that matters
image_file - a plain string. This is worth stressing because it trips people up: there's no file-browser widget here. You type or paste the absolute path yourself. The example workflow shows a Windows path (D:\Downloads\92AV3C.lan); on Linux you'd paste /data/92AV3C.lan. It reads the path as given, relative to wherever ComfyUI runs if it isn't absolute, so use full paths.
Outputs and where they go
preview(IMAGE) - wire this to aPreviewImagenode so you can actually see the cube as an image.spectral(SPE) - this is the object every other node in the pack wants. It feedsCalculate,Plot, and theKMeansnode. Note thatSPEonly exists inside this pack, so its only valid destinations are those three nodes.
Installing it
Easiest is ComfyUI Manager: open Custom Nodes Manager, search ComfyUI_Spectral, install, restart. Manual install works the same way as any pack:
cd ComfyUI/custom_nodes
git clone https://github.com/chenlongming/ComfyUI_Spectral
cd ComfyUI_Spectral
pip install -r requirements.txt
then restart ComfyUI. (The README tells you to run pip install -r reqirements.txt - yes, misspelled. The actual file is requirements.txt, which is the one you want.) The requirements are numpy, pillow, spectral, torch, torchvision, matplotlib, tqdm. You almost certainly already have everything except spectral; that's the one genuinely new dependency, and it's small.
The gotchas
The README is upfront that this is early-stage, incomplete, and subject to change - the codebase is a handful of nodes and a single commit, and there's basically zero community footprint behind it (the nodes show no search impressions anywhere). Treat it as a hobby project for the niche audience of people who own both hyperspectral data and a ComfyUI install.
Two practical quirks worth knowing. First, the preview is a JPEG written into a temp/ folder in your working directory - fine for eyeballing, not a scientific artifact. Second, because the path is a raw string, a typo fails silently as an opaque open error, not a friendly picker. If you're here, you're already an outlier; embrace typing paths.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image_file | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| preview | IMAGE | — |
| spectral | SPE | — |