BEV / MAP_MATCHING.md
SammySnake's picture
Connect real BEV features to semantic-map matching with bounded NPZ inputs
bf99854 verified
|
Raw History Blame Contribute Delete
3.78 kB

A newer version of the Gradio SDK is available: 6.32.0

Upgrade

Real BEV-to-semantic-map matching API

/match_bev(features_npz, maps_npz) returns (JSON receipt, diagnostics NPZ). This is OrienterNet-MGL pretrained map encoding + exhaustive BEV voting + the trained map unary prior. It is not an image-generation step or a satellite encoder, and does not apply a supplied GPS/heading prior.

Inputs

All archives must be NPZ, compressed size <=10 MiB, uncompressed size <=32 MiB. Only named NPY v1/v2 arrays, no objects/pickle/structured arrays/duplicate members. Metadata is one scalar UTF-8 JSON string <=128 KiB. All numeric values must be finite. Files are validated before the trained model is loaded.

features_npz

Pass the NPZ produced by /bev unchanged:

  • features: float [1,8,64,129] (absolute values <=1e6).
  • confidence: numeric [1,64,129] in [0,1].
  • valid: bool or integer 0/1 [1,64,129], at least one valid cell.
  • Optional camera: finite [1,6] pinhole tensor, positive dimensions/focals.
  • Optional metadata: scalar JSON, preserved in the output manifest.

maps_npz

  • raster: integer [N,3,256,256], N=1..12. Channel classes must use the exact upstream OrienterNet semantic encoding: areas 0..7, ways 0..10, nodes 0..33. An ordinary RGB map screenshot is not compatible.
  • metadata: scalar JSON with this schema (extra provenance keys are retained):
{
  "schema_version": 1,
  "pixels_per_meter": 2,
  "candidates": [{
    "id": "candidate-001",
    "center_wgs84_latlon": [31.5, 120.3],
    "projection": {
      "type": "caller-supplied local metric projection",
      "definition": "retain the exact map rasterizer projection parameters here"
    },
    "bbox_xy_m": {"min": [-64, -64], "max": [64, 64]}
  }]
}

id is unique, ASCII [A-Za-z0-9][A-Za-z0-9._:-]{0,95}. The local XY extent must be 128×128 meters. The service preserves this manifest and the input SHA256 hashes, does not interpret the projection, and does not invent WGS84 positions. Caller must convert returned (u,v) with its actual rasterizer's pixel-center and local projection conventions. Camera/centers/projection are caller data, not server-verified geographic facts.

Outputs

The JSON lists each candidate in input order with three separated (u,v,yaw) modes, raw combined score, visual correlation, map unary prior, raw peak/mean/std, top1/top2 separated-mode margin, class counts/nonzero fractions, and latency. Modes use u=column/right, v=row/down and upstream yaw conventions. Yaw step is 5.625 degrees (64 rotations); suppression radius is 8 pixels and 2 yaw bins.

The NPZ stores finite arrays combined_heatmaps, visual_heatmaps, unary_priors of shape [N,256,256], best_yaw_indices uint8 of that shape, and the JSON receipt as metadata. Heatmaps take max over yaw, not softmax; full rotation volumes are not retained to bound disk/memory.

target_presence="unassessed", coordinates_verified=false, calibrated_probability=false always. A wrong map can outscore the true map. No exact-location winner flag is returned. Map nonzero coverage measures label content, not map completeness. Pose modes must be checked against independent ground-level evidence before any precise geographic conclusion.

from gradio_client import Client, handle_file
client = Client("SammySnake/BEV")
receipt, diagnostics = client.predict(
    handle_file("orienternet-bev.npz"),
    handle_file("semantic-map-pack.npz"),
    api_name="/match_bev",
)

This endpoint uses a lazy CPU instance of the existing full hosted checkpoint. Existing /bev, /embed, /rank APIs and their numerical/device policies are unchanged. All inference endpoints share concurrency=1. No new model weights, map credentials, or photos are included in this patch.