Skip to main content

ModelMetadata dataclass

Loads and parses Machine Learning Model Metadata JSON.

Parameters

model_meta_path
string
default:true
required
Path or S3 URI to the model metadata JSON file.

Raises

ValueError
ValueError
Shape mismatch error if the length of the class_map differs from the shape of the result.
ValueError
ValueError
Only MLM metadata that define statistics per band and norm_by_channels are supported.

read_model_metadata()

read_model_metadata(model_meta_uri) Reads and parses a model metadata JSON file from S3.

Parameters

model_meta_uri
string
required
The S3 URI for the model metadata JSON file.

Returns

STACObject
STACObject
pystac.STACObject: The parsed model metadata conforming to the MLM Extension.

create_object_detection_udfs()

create_object_detection_udfs(batch_size, sedona) Create and register UDFs for object detection tasks. Registers SQL functions for RS_DETECT_BBOXES and RS_FILTER_BOX_CONFIDENCE and returns corresponding functions.

Parameters

batch_size
int
required
The number of samples to include in each batch.
sedona
SedonaContext
required
The current Sedona context.

Returns

tuple[Callable, Callable]
tuple[Callable, Callable]
Tuple[Callable, Callable]: A tuple of functions configured for object detection.

create_semantic_segmentation_udfs()

create_semantic_segmentation_udfs(batch_size, sedona) Create and register SQL functions for semantic segmentation tasks. Registers SQL function as RS_SEGMENT and returns a corresponding function.

Parameters

batch_size
int
required
The number of samples to include in each batch.
sedona
SedonaContext
required
The current Sedona context.

Returns

Callable
Callable
A function configured for semantic segmentation.

create_single_label_classification_udfs()

create_single_label_classification_udfs(batch_size, sedona) Create and register SQL Functions for single-label classification tasks. Registers SQL function as RS_CLASSIFY RS_MAX_CONFIDENCE and returns corresponding functions.

Parameters

batch_size
int
required
The number of samples to include in each batch.
sedona
SedonaContext
required
The current Sedona context.

Returns

tuple[Callable, Callable]
tuple[Callable, Callable]
Tuple[Callable, Callable]: A tuple of pandas UDFs configured for single-label classification tasks, [RS_CLASSIFY, RS_MAX_CONFIDENCE].

show_detections()

show_detections(df, geometry_column=None, geometry_crs='EPSG:4326', confidence_threshold=0.05, plot_geoms=True, side_by_side=True) Plot raster images with detected object geometries overlaid. This function handles both Pandas and Wherobots DataFrames containing geometries, automatically detecting the raster column. It is compatible with dataframes returned from a SQL inference function. Exploded dataframes are not supported.

Parameters

df
DataFrame
required
Pandas or Wherobots DataFrame containing raster data and detection results
geometry_column
string
required
Column name containing WKT geometries
geometry_crs
string
default:"EPSG:4326"
required
Coordinate reference system of the geometries
confidence_threshold
float
default:"0.05"
required
Minimum confidence score for displaying detections
plot_geoms
bool
default:"True"
required
Whether to overlay geometries on the images
side_by_side
bool
default:"True"
required
Whether to show original and detection images side by side

Raises

ValueError
ValueError
If the DataFrame is empty or required columns cannot be found