U-Net EfficientNet-B4 (dist3) — VHR building instance segmentation
Building footprint instance segmentation for HOT's fAIr. Trained on a pool of
18,557 chips filtered from hotosm/vhr-building-segmentation by a label-quality
classifier, after manual review established that 27.2% of that dataset's labels
(n = 6,459 reviewed) are unusable.
Selected as the fold with the highest validation PQ of five. Selecting on the benchmark instead would have given fold 4 (48.14) — that would be selection on the test set and is not what is published here.

Dense chips, 11 or more buildings. Each colour in the right-hand column is one predicted instance.

Medium density, 4 to 10 buildings.
Experimental branch:
v2-e60-f3holds a single fold trained on the larger v2 pool. It cuts false positives on empty chips from 37.4% to 23.8% at the same PQ, but it is one fold and is not what the results below describe.
Results
Mean ± sd over five cross-validation folds. Threshold selected on each fold's own validation split, never on a test set.
nilsho01/vhr-buildings-benchmark-v1 (400 chips, reviewed labels)
| model | PQ | SQ | RQ | pixel F1 | pixel IoU |
|---|---|---|---|---|---|
| this model (5 folds) | 47.79 ± 0.23 | 75.44 ± 0.17 | 63.35 ± 0.27 | 84.43 ± 0.11 | 73.05 ± 0.16 |
shipped dinov3s_upernet_hot | 33.92 | 72.08 | 47.06 | 83.03 | 70.98 |
This benchmark is disadvantageous to this model: all 400 chips lie in
vhr-buildings' train split, so the shipped baseline trained on every chip it is
scored on, and this model never saw one.
hotosm/vhr-building-segmentation test (7,236 chips, raw OSM labels)
Neither model trained on this split.
| metric | this model (5 folds) | shipped DINOv3 |
|---|---|---|
| PQ | 30.02 ± 0.26 | 27.81 |
| SQ | 78.45 ± 0.29 | 76.82 |
| RQ | 38.28 ± 0.30 | 36.20 |
| pixel F1 | 60.46 ± 0.48 | 61.50 |
| pixel IoU | 43.33 ± 0.49 | 44.41 |
Ahead on the instance metrics, behind on the pixel metrics by ~1 point. The shipped model predicts 75% of the true object count against this model's ~116%: a model that under-predicts is rewarded by an area-weighted metric and penalised by an object-weighted one.
Why panoptic quality
![]()
The second and third panels are indistinguishable to a pixel metric and 86 points apart on an object metric. One merged the terrace into a single blob; the other separated all four and traced them a pixel fat. Pixel metrics weight by area, panoptic quality by object, and with a median building around 256 px most objects carry very little area.
Known limitation
37.4% ± 2.3 of chips containing no buildings receive at least one spurious
detection on the test split, against 8.3% for the shipped model (15.8–19.8% on
the reviewed benchmark). The rate rose as training data was added. It costs about
0.7 pixel IoU but is visible to a user. Likely a domain-coverage effect: the
training pool is ~61% Myanmar, and vhr-buildings' validation and test splits
contain no Myanmar at all.
Usage
Three output channels: mask, per-instance normalised distance transform, instance boundary. Instances come from marker-controlled watershed seeded by channel 1 — connected components on channel 0 alone merges roughly 2.3 buildings per blob.
import json, torch, numpy as np, segmentation_models_pytorch as smp
from huggingface_hub import hf_hub_download
repo = "nilsho01/unet-effb4-dist3-buildings"
cfg = json.load(open(hf_hub_download(repo, "config.json")))["args"]
thr = json.load(open(hf_hub_download(repo, "best_threshold.json")))["threshold"] # 0.50
net = smp.Unet(encoder_name="efficientnet-b4", encoder_weights=None,
in_channels=3, classes=3)
net.load_state_dict(torch.load(hf_hub_download(repo, "best.pth"),
map_location="cpu")["model"])
net.eval()
# normalise with ImageNet statistics, 256x256 input
# prob = torch.sigmoid(net(x))[0].numpy()
# mask, edt, boundary = prob[0] > thr, prob[1], prob[2]
# seeds = scipy.ndimage.label((edt > 0.5) & mask)[0]
# instances = skimage.segmentation.watershed(
# -scipy.ndimage.distance_transform_edt(mask), markers=seeds, mask=mask)
best_threshold.json matters — folds selected 0.40–0.50, and the operating point
is not interchangeable between them.
Evaluate it
Panoptic quality rather than pixel F1, because pixel metrics cannot tell a correctly separated building from several merged into one: a single blob over a terrace of four scores pixel IoU 86 and PQ 0, while the same four separated but traced one pixel too wide score pixel IoU 86 and PQ 86.
Training
smp.Unet, EfficientNet-B4 (ImageNet), decoder 256/128/64/32/16, dist3 head,
40 epochs, batch 32, Adam at 2e-3 (decoder) / 2e-4 (encoder), 256×256, seed 42.
Folds split by 4×4 spatial tile block — adjacent OAM tiles share buildings, so a
per-chip split leaks.
Licence and attribution
Imagery and base labels: hotosm/vhr-building-segmentation (OpenAerialMap +
OpenStreetMap, ODbL). The training pool was filtered using a classifier whose
label-debt evidence draws on Google Open Buildings (CC-BY 4.0 / ODbL) and
Microsoft Building Footprints (ODbL). Attribution review for those sources is
outstanding, which is why this repository is private.