Multi-spectral trainer: N-channel loader, per-band stats, first-conv surgery (+ nidus-sync API design) #14
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-13-multispectral-trainer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Trainer work for issue #13, per Eli's go-ahead in comment #1693. Two parts:
1. Multi-spectral training support (real code, unblocks the 3-way ablation):
src/data/normalization.py—BandNormalizer: ImageNet (default, unchanged behavior) or per-band corpus stats.src/data/dataset.py— N-channel loader: 4-band (B,G,R,NIR) TIFFs via rasterio (raw reflectance preserved), 8-bit path unchanged; band order defaults to R,G,B,NIR[2,1,0,3].src/models/segmentation.py—widen_first_conv(): first-conv surgery so pretrained ImageNet encoders keep RGB weights when widened to 4ch (SMP reinitializes conv1 randomly otherwise, throwing away ImageNet features).src/inference/predict.py— reconstructs training normalization from checkpoint metadata.scripts/compute_band_stats.py— corpus-wide per-band mean/std →band_stats_fileJSON.tests/test_multispectral.py— 9 tests incl. full 4-band dataset + surgery weight preservation.Verified: 13 tests pass; 4-band end-to-end train smoke test passes (1 epoch, ResNet-34 UNet, per-band norm); ruff clean; mypy 18→8 errors (no new ones; 10 pre-existing in label_studio.py/losses.py remain).
2. nidus-sync training-data API design (
doc/nidus-sync-training-data-api.md) — how planet tiles + pool geometries get from nidus-sync onto GPU hardware:/train/corpus,/train/stats,/train/tile(multipart 16-bit per-band PNG or GeoTIFF),/train/mask(from feature_pool geometry, stadia vs confirmed source, dilation),/train/udm, andPOST /train/manifest(reproducible, split-aware corpus recipe). Reuses the vision-worker Bearer auth. Rollout order: tile+mask first (unblocks Stadia-on-SkySat geometry check), then manifest+stats (unblocks ablation), then corpus+udm.Open questions in the doc: auth scoping for a trainer role, manifest storage, frozen eval manifests for the ~1k confirmed set.
CI run 220 status: container-image ✅, lint-and-test ✅ (13/13 tests), type-check ❌ — same pre-existing mypy errors in
src/label_studio.pyandsrc/geojson.pythat also fail on main (runs 1693/1690/1673/1670). Verified locally against commita47ccdf: 8 errors, all in files untouched by this PR; no new errors introduced. Ready for review.