Views
No views yet
handler.py is a thin adapter around the versioned
ChangeStarHandler
integration. Hugging Face still discovers the model-local EndpointHandler,
while shared downloading, validation, tiling, inference, response, and bucket
logic is maintained in one package. It loads onnx/model_quantized.onnx when
available and falls back to onnx/model.onnx.inputs:1{
2 "inputs": {
3 "imagery": "https://huggingface.co/datasets/geobase/geoai-cogs/resolve/main/geoembeddings-demo/building-detection_sm.tif"
4 }
5}output_crs, threshold, and use_bucket
alongside imagery inside inputs. tile_size must remain 1024: the
exported ViT has fixed positional embeddings even though its ONNX input
metadata uses symbolic height and width. With no bucket configuration, the
endpoint returns the detected polygons inline. GeoJSON uses EPSG:4326 by
default.imagery also accepts typed GeoTIFF, ESRI ImageServer, and Mapbox raster
inputs documented in the
shared imagery guide.
Set MAPBOX_ACCESS_TOKEN for Mapbox requests and ESRI_TOKEN only for secured
ESRI services.1{
2 "inputs": {
3 "imagery": {
4 "type": "esri",
5 "url": "https://imagery.nationalmap.gov/arcgis/rest/services/USGSNAIPImagery/ImageServer",
6 "polygon": {
7 "type": "Polygon",
8 "coordinates": [[
9 [-117.59587065763711, 47.651865889977294],
10 [-117.58845496125399, 47.651865889977294],
11 [-117.58845496125399, 47.65414974834855],
12 [-117.59587065763711, 47.65414974834855],
13 [-117.59587065763711, 47.651865889977294]
14 ]]
15 },
16 "mapParams": {
17 "size": [1024, 1024],
18 "interpolation": "RSP_BilinearInterpolation",
19 "bandIds": [0, 1, 2]
20 }
21 }
22 }
23}ESRI_TOKEN. Configure that endpoint
secret only when using a secured ImageServer.MAPBOX_ACCESS_TOKEN as an Inference Endpoint secret, then send:1{
2 "inputs": {
3 "imagery": {
4 "type": "mapbox",
5 "polygon": {
6 "type": "Polygon",
7 "coordinates": [[
8 [-117.59587065763711, 47.651865889977294],
9 [-117.58845496125399, 47.651865889977294],
10 [-117.58845496125399, 47.65414974834855],
11 [-117.59587065763711, 47.65414974834855],
12 [-117.59587065763711, 47.651865889977294]
13 ]]
14 },
15 "mapParams": {
16 "tileset": "mapbox.satellite",
17 "zoom": 17,
18 "tileSize": 256,
19 "imageFormat": "png"
20 }
21 }
22 }
23}1{
2 "polygon_count": 12,
3 "building_pixels": 3456,
4 "building_coverage": 0.013,
5 "width": 1024,
6 "height": 1024,
7 "crs": "EPSG:4326",
8 "output_crs": "EPSG:4326",
9 "geojson": {
10 "type": "FeatureCollection",
11 "features": []
12 },
13 "duration_seconds": 2.4
14}buildings.geojson and buildings_mask.tif and returns their bucket keys
instead of embedding the GeoJSON in the HTTP response.| Environment variable | Required | Description |
|---|---|---|
HF_BUCKET | For uploads | Full bucket id, such as geobase/building-results |
HF_TOKEN or HUGGING_FACE_HUB_TOKEN | For uploads | Token with write access to the bucket namespace |
HF_OUTPUT_PREFIX | No | Object prefix; defaults to building-segmentation/ |
"use_bucket": false inside inputs to force an inline response. Set
"use_bucket": true to require an upload; the request fails clearly if the
endpoint is not configured with both variables. An optional output_prefix
can override the generated per-request key prefix.HF_BUCKET and HF_TOKEN as secrets/environment variables on the
Inference Endpoint, then send:1{
2 "inputs": {
3 "imagery": "https://example.com/image.tif",
4 "use_bucket": true
5 }
6}output_prefix is optional;
without it, the handler generates a unique dated path.1{
2 "polygon_count": 12,
3 "storage": {
4 "provider": "huggingface_hub",
5 "bucket": "geobase/building-results",
6 "keys": [
7 "building-segmentation/20260718/abc/buildings.geojson",
8 "building-segmentation/20260718/abc/buildings_mask.tif"
9 ]
10 }
11}