Inference engine
predict_scene in Model_Traning/v5/infer/engine.py is the only inference path. The CLI, the FastAPI service, the hosted Space and the sliding-window evaluation all call it, so the reported metrics describe what users actually get.
Pipeline
Section titled “Pipeline”flowchart TB
subgraph Prepare["Prepare"]
direction LR
A[Scene RGB, any size] --> B[2–98 % stretch] --> C[Fill no-data] --> D[Resample to 0.5 m] --> E[512 px windows, 25 % overlap]
end
subgraph Predict["Predict"]
direction LR
F{TTA?} -- no --> G[Batched forward]
F -- yes --> H[8 D4 views × scales] --> G
end
subgraph Assemble["Assemble"]
direction LR
I[Hann-weighted blend] --> J[Resample to input grid] --> K[height · seg · σ]
end
Prepare --> Predict --> Assemble
Tiling and blending
Section titled “Tiling and blending”| Parameter | Value |
|---|---|
| Canonical GSD | 0.5 m |
| Window | 512 × 512 px |
| Overlap | 0.25 (stride 384 px) |
| Blend | 2-D Hann window, normalised |
| Border handling | reflect padding |
| Precision | bf16 autocast on CUDA, fp32 on CPU |
| Batch | 4 tiles by default (batch_tiles) |
Test-time augmentation
Section titled “Test-time augmentation”With TTA on, each tile runs through the 8 elements of the dihedral group D4 (4 rotations × optional flip). Each prediction is inverse-transformed and averaged, optionally at several scales (tta_scales = (1.0, 1.25)). The model checkpoint (best.pt) is chosen without TTA; TTA is applied only at evaluation and inference time.
Large scenes
Section titled “Large scenes”Scenes above 40 megapixels go through predict_scene_windowed (run_windowed in the service). It processes horizontal bands of 2048 rows plus a one-tile margin and streams the GeoTIFF outputs straight to disk. A 20k × 20k px scene peaked at 5.9 GB RAM.
Outputs
Section titled “Outputs”| Array | Units | Notes |
|---|---|---|
height |
metres above ground | the nDSM, on the input grid |
seg |
class id 0–6 | argmax of Head C |
std |
metres | Head B spread; median about 0.25 m on a Cartosat-2E test scene |
See Output formats for the files written to disk.
Command line
Section titled “Command line”python -m infer.predict scene.tif --ckpt outputs/v5/best.pt --tta # nDSM (+ GeoTIFF if georeferenced)python -m infer.predict scene.tif --ckpt outputs/v5/best.pt --absolute # + DTM/DSM from Copernicus GLO-30python -m infer.predict scene.tif --ckpt outputs/v5/best.pt --dem cartodem.tifpython -m infer.predict scene.png --ckpt outputs/v5/best.pt --gsd 0.5 # plain image, declared GSDpython -m infer.predict scene.tif --ckpt outputs/v5/best.pt --gcps gcps.csv # absolute via ground control pointspython -m infer.predict scene.tif --ckpt outputs/v5/best.pt --report # self-contained HTML report