AssetAnalysisWorkflow#
- class rapidtools.gui.AssetAnalysisWorkflow(progress_callback: Callable[[str], None] | None = None)[source]#
Bases:
objectOrchestrates 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 passprintor leave itNone.
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
Crop the raster around every asset and run VLM inference on the crops.
Run one prompt-assistant action with a rapidtools model backend.
Request cancellation.
Detect one or more asset types in the raster with SAM 3.
Discover objects along a Mapillary street survey.
Stitch a Bing or Google satellite basemap over a region into a GeoTIFF.
Drop the cached assistant model and free GPU memory if it was local.
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_imageryisFalsea 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_tilesbefore 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:
ValueError – If the region covers more than
max_tilestiles.FileNotFoundError – If
geojson_pathdoes not exist.
- 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 (
Nonewhen nothing was found).- Raises:
FileNotFoundError – If
raster_pathis 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,textorindicators.- Raises:
ValueError – If the model reply cannot be used.