Skip to content

API reference

The web app calls this through the /hf-space proxy. It can also be called with gradio_client, which needs a token with read access because the Space is private.

from gradio_client import Client, handle_file
client = Client("akashch1512/SingleViewHeigthEstimation", hf_token="hf_…")
result = client.predict(
image_path=handle_file("scene.tif"),
gsd=0.5, # m/px; 0 = read from file or assume
tta=False, # 8-view test-time augmentation
api_name="/predict",
)
Name Type Default Description
image_path filepath required PNG, JPG or (Geo)TIFF
gsd float 0.5 Resolution in m/px. The web app sends 0 for “auto”
tta bool false Higher quality (slower). Reserves 120 s of GPU instead of 45 s
# Type Content
0 gallery height colormap and hillshade previews
1 filepath 16-bit height PNG
2 str (HTML) embedded viewer
3 list[filepath] downloads: *_result.zip, ndsm_m.npy, meta.json, terrain.glb, previews
4 str (Markdown) status / stats (also carries error text)
5 str (Markdown) warnings (e.g. little flat ground, assumed GSD)
Terminal window
BASE=http://localhost:8080/hf-space # proxy adds the token
# 1. upload
curl -s -F files=@scene.tif $BASE/gradio_api/upload
# → ["/tmp/gradio/…/scene.tif"]
# 2. start
curl -s -H 'Content-Type: application/json' \
-d '{"data":[{"path":"/tmp/gradio/…/scene.tif","meta":{"_type":"gradio.FileData"}},0,false]}' \
$BASE/gradio_api/call/predict
# → {"event_id":"a1b2c3…"}
# 3. stream (SSE): heartbeat / generating … then complete or error
curl -N $BASE/gradio_api/call/predict/a1b2c3…