Skip to content

HSI Reconstruction

Script: 1_deeplens_hsi.py

The script renders each CAVE spectral band through the fixed Pixel2D DOE, collapses the result with the configured RGB response curves, and trains NAFNet to reconstruct the original 31-band cube. AdamW receives only self.model.parameters(); the DOE is not updated.

Run

python 1_deeplens_hsi.py

The script always reads configs/1_deeplens_hsi.yml; it has no --config argument.

Source defaults

Setting Value
Spectral samples 31 bands, 400–700 nm
Network NAFNet, 3 input channels, 31 output channels, width 32
Blocks middle 1; encoder [1, 1, 1, 18]; decoder [1, 1, 1, 1]
Initialization Included ckpts/nafnet_hsi.pth checkpoint
Optimizer AdamW, learning rate 1e-4
Schedule Cosine annealing to 1e-7, stepped after each batch
Training 1000 epochs; 256×256 crops; batch 2; 3 workers
Validation Every 10 epochs; 512×512 center crops; batch 1; 3 workers
Logging Every 20 training batches
Objective and metrics L1 training loss; PSNR and SSIM validation

The committed split files list 24 training scenes and 8 validation scenes. CaveDataset attempts to download CAVE when the first listed scene is absent.

First-run dependency

The trainer constructs a pretrained VGG16-based PerceptualLoss, although that object is not used by the L1 objective. If its weights are not cached, startup can download them.

Outputs

Each run creates results/<timestamp>-HSI-Recon-<id>/, copies the resolved configuration and training script, saves sample images, writes checkpoints every 10 epochs, and retains the best validation-PSNR model.

Next steps