segrails.client

Segrails pipeline orchestrator.

Classes

SegrailsClient

Orchestrate the full Segrails inference pipeline.

Module Contents

class segrails.client.SegrailsClient(config: altametris.segrails.config.SegrailsConfig | None = None, credentials: altametris.azure_sdk.authentication.credentials.Credentials | None = None, device: str = 'cpu')

Orchestrate the full Segrails inference pipeline.

Steps:
  1. WeightStep — resolve model weights from Azure Blob or local cache.

  2. RasterStep — generate a PNG raster from the input point cloud.

  3. InferenceStep — run UNet inference to produce a binary mask.

  4. PostprocessStep — detect rail tracks and crossings from the mask.

The model is loaded on the first call to predict() and cached for subsequent calls.

Parameters:
  • config – SegrailsConfig instance. When None, built from SegrailsConfig().

  • credentials – Pre-built Credentials instance from altametris.azure_sdk. When None, created with auth_mode="default" (az login / SP env vars).

  • device – PyTorch device string. Defaults to "cpu".

Example

>>> client = SegrailsClient(config=config, credentials=creds)
>>> result = client.predict(Path("cloud.las"), center=(790490.0, 6878297.0))
>>> result = client.predict(
...     {"path": "https://altametris.xyz/dev/u3d/data/proj/ept.json",
...      "headers": {"Bearer": "mytoken"}},
...     center=(790490.0, 6878297.0),
... )
>>> print(result.predictions.n_tracks)
config
_device = 'cpu'
_weight_step
_raster_step
_postprocess_step
_inference_step: altametris.segrails.pipeline.inference.InferenceStep | None = None
_model_dir: pathlib.Path | None = None
_tracker
predict(point_cloud: altametris.segrails.pipeline.raster.PointCloudSource, center: tuple[float, float], pipeline_name: str | None = None, env: str | None = None) altametris.segrails.result.SegrailsResult

Run the full pipeline on a single point cloud tile.

Parameters:
  • point_cloud

    Point cloud source. Either:

    • str | Path — local LAS/LAZ file path.

    • dict — remote EPT filespec with keys:

      • "path" (required): EPT endpoint URL.

      • "headers" (optional): dict of HTTP headers. The "Bearer" key is forwarded as the EPT token.

  • center – Geographic centre of the raster tile as (X, Y) in the same coordinate reference system as the point cloud.

  • pipeline_name – Optional identifier of the calling pipeline.

  • env – Optional environment override for this call.

Returns:

SegrailsResult with status="success" and populated predictions, or status="failure" with a SegrailsError describing which step failed and why.