xBD-S12 SUT Wrapper
Custom Inference Endpoints handler that serves the
prs-eth/xbd-s12 building-damage models
(3-seed localization + damage ensembles, Siamese/UNet on Sentinel-1 + Sentinel-2) behind an
HTTP API compatible with Resaro AIP's huggingface_image_classification SUT protocol.
The inference code under src/ is vendored from
github.com/prs-eth/xbd-s12 (MIT, Β© Olivier Dietrich) β
see LICENSE.upstream.
How it works
- At container boot, the handler downloads the six
prs-eth/xbd-s12_{loc,dmg}_seed{1,2,3}checkpoints and syncs a patch-store dataset repo (PATCH_DATASET_REPOenv var, defaultpeterachua/xbd-s12-eval-patches). - Per request, it reads
image_idfrom the JSON body (the posted image bytes are ignored), resolves the four co-registered GeoTIFFs from the patch store, runs the ensemble, and reduces the per-pixel damage raster to a patch-level[{label, score}]distribution. - Reduction rule: damaged-pixel fraction over all patch pixels, one-hot into four
ordinal buckets β
<10%βno_damage,10β30%βlight_damage,30β70%βmoderate_damage,β₯70%βheavy_damage. Patches with no detected buildings have fraction 0 and land inno_damage. Golden-dataset labels must use this same vocabulary.
Patch store layout
Native Zenodo xbd_s12 layout β build the dataset repo by uploading a subset (e.g. the
event_split == "test" uids from xbd_s12_metadata.geojson) of the extracted archive.
image_id in requests = the xBD-S12 xbd_uid.
s1/<xbd_uid>_pre_disaster_s1.tif # Sentinel-1, 2 bands (VV/VH), 4 m resampled
s1/<xbd_uid>_post_disaster_s1.tif
s2/<xbd_uid>_pre_disaster_s2.tif # Sentinel-2 L2A, 12 bands, 4 m resampled
s2/<xbd_uid>_post_disaster_s2.tif
Request / response
curl https://<endpoint>.endpoints.huggingface.cloud \
-H "Authorization: Bearer $HF_TOKEN" -H "Content-Type: application/json" \
-d '{"inputs": "", "image_id": "guatemala-volcano_00000000"}'
# β [{"label": "no_damage", "score": 0.0}, {"label": "light_damage", "score": 1.0},
# {"label": "moderate_damage", "score": 0.0}, {"label": "heavy_damage", "score": 0.0}]
Errors (missing image_id, incomplete patch quartet) raise, returning a non-2xx response β
intentionally loud so evaluation runs record a SUT error instead of a fabricated label.
Deployment notes
- CPU instance is sufficient (checkpoints total ~140 MB); enable scale-to-zero for demo-cadence use and warm the endpoint with one curl before an evaluation run (cold start β 1 min: checkpoint + patch-store download).
- Security: Protected. Register in AIP with
auth_type="bearer"and an HF token. - This SUT is dataset-coupled: it can only answer for
image_ids present in the patch store. A passing connection test proves reachability, not lookup completeness.