Skip to main content

Model versions

Use sdk.model_version to retrieve model versions, inspect their inference results, and download model artifacts.

Module methods

  • get(model_version_id: int): return one model version.
  • get_by_date_range(model_trained_after: datetime, model_trained_before: datetime, exclude_draft: bool = False): return model versions trained within a window.

Use timezone-aware datetime values so the requested window is unambiguous.

A returned ModelVersionResource includes fields such as id, model_name, date_updated, model_type, is_draft, model_architecture, model_size, dataset_version, and inference_results. Use download(folder_path) to download its model artifacts.

Inference results

Each InferenceResultResource includes its inference, model-version, image, and image-layer IDs, model type, and output-class mapping. It provides:

  • raw_data: load the unfiltered inference raster as a NumPy array.
  • median_filtered_data: load the median-filtered raster as a NumPy array.
  • get_data(post_processing_method=NONE, threshold_start=None, threshold_end=None, threshold_mode=CLASSIFY): load data with optional post-processing and thresholding.
  • download(folder_path, post_processing_method=NONE, view_type=BASE_MAP): download and extract the inference raster package beneath folder_path.

Thresholds apply to unmixing and target-detection results. Other model types return their raster data without thresholding.

  • CLASSIFY returns 1 for values inclusively between the effective start and end thresholds and 0 elsewhere.
  • STRETCH clamps values to the threshold interval and rescales them to [0, 1]. Equal threshold endpoints return zeros.

Example

from datetime import datetime, timezone

from fusion_sdk.models.thresholding_mode_enum import ThresholdingModeEnum

# Fetch and download one model version.
model = sdk.model_version.get(model_version_id=38)
model.download(folder_path="/local/downloads/models")

# Read thresholded inference arrays.
for inference_result in model.inference_results:
classified = inference_result.get_data(
threshold_start=0.2,
threshold_end=0.8,
threshold_mode=ThresholdingModeEnum.CLASSIFY,
)
print(inference_result.image_id, classified.shape)

# Use an explicit timezone for a date-range query.
recent = sdk.model_version.get_by_date_range(
model_trained_after=datetime(2025, 1, 1, tzinfo=timezone.utc),
model_trained_before=datetime(2026, 1, 1, tzinfo=timezone.utc),
exclude_draft=True,
)