AssetAnalysisWorkflow#

class rapidtools.gui.AssetAnalysisWorkflow(progress_callback: Callable[[str], None] | None = None)[source]#

Bases: object

Orchestrates asset detection and VLM inference on an aerial raster.

Parameters:

progress_callback (Callable[[str], None] | None) – Optional function receiving short human-readable status strings (e.g. 'Scanning for tree...'). The GUI uses this to update its status bar; scripts may pass print or leave it None.

Example

>>> wf = AssetAnalysisWorkflow()
>>> detection = wf.detect(DetectionSettings(
...     raster_path='eaton_patch_20250214.tiff',
...     output_dir='output',
...     assets=['building', 'tree'],
... ))
>>> inference = wf.analyze(detection.collection, InferenceSettings(
...     raster_path='eaton_patch_20250214.tiff',
...     output_dir='output',
...     prompt='Describe the damage to the outlined asset.',
...     api_key='...',
... ))

Methods

analyze

Crop the raster around every asset and run VLM inference on the crops.

assist

Run one prompt-assistant action with a rapidtools model backend.

cancel

Request cancellation.

detect

Detect one or more asset types in the raster with SAM 3.

discover_street

Discover objects along a Mapillary street survey.

download_basemap

Stitch a Bing or Google satellite basemap over a region into a GeoTIFF.

release_assistant

Drop the cached assistant model and free GPU memory if it was local.

reset

Clear any pending cancellation request.

cancel() → None[source]#

Request cancellation. Honored at the next stage boundary.

reset() → None[source]#

Clear any pending cancellation request.

detect(settings: DetectionSettings) → DetectionResult[source]#

Detect one or more asset types in the raster with SAM 3.

Mirrors Part 1 of the generalized example notebook. When settings.detect_in_recon_imagery is False a Bing basemap is stitched over the raster extent and used for detection instead (useful when assets are destroyed in the post-disaster imagery).

Returns:

DetectionResult – The merged collection of every requested asset type plus the paths of the GeoJSON files written to disk.

analyze(collection: PhysicalAssetCollection, settings: InferenceSettings) → InferenceResult[source]#

Crop the raster around every asset and run VLM inference on the crops.

Mirrors Part 2 of the generalized example notebook.

Returns:

InferenceResult – The collection of assets that received at least one inferred attribute, and the GeoJSON path it was written to.

download_basemap(settings: RegionImagerySettings) → Path[source]#

Stitch a Bing or Google satellite basemap over a region into a GeoTIFF.

The region comes from the four WGS84 bounds or the extent of a GeoJSON file. The tile count is checked against settings.max_tiles before any download starts.

Parameters:

settings (RegionImagerySettings) – Provider, zoom and region.

Returns:

Path – The written GeoTIFF, named after the provider, zoom and bounds inside settings.output_dir.

Raises:
discover_street(settings: StreetDetectionSettings) → StreetDetectionResult[source]#

Discover objects along a Mapillary street survey.

Wraps MapillaryFeatureExtractor: the requested classes are located in every image of the region from Mapillary’s segmentation metadata, the survey vehicle is removed, and sightings are fused into one asset per object: a point for vehicles and other objects, a footprint polygon for buildings (placed from the survey’s point cloud). No pixels are downloaded; crops are made at inference time with the 'mapillary_objects' imagery source.

Parameters:

settings (StreetDetectionSettings) – Classes, token, region and localization options.

Returns:

StreetDetectionResult – The point assets and the GeoJSON they were written to (None when nothing was found).

Raises:
  • FileNotFoundError – If raster_path is given but missing.

  • WorkflowCanceled – If canceled.

assist(settings: AssistSettings) → dict[str, Any][source]#

Run one prompt-assistant action with a rapidtools model backend.

The model is loaded through rapidtools.models.load() and cached until a different backend or model is requested, or until detection or inference needs the GPU (local models are then released).

Parameters:

settings (AssistSettings) – The action and its inputs.

Returns:

dict[str, Any] – The run() result: spec, text or indicators.

Raises:

ValueError – If the model reply cannot be used.

release_assistant() → None[source]#

Drop the cached assistant model and free GPU memory if it was local.