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): download and extract the inference raster package beneath folder_path.

The current API exports the canonical inference raster on its native spatial grid. The SDK computes MEDIAN_FILTER locally using the legacy 5-by-5 spatial median, independently for each band, with zero borders and preserved nodata. Filtering preserves raster values' dtype, CRS, transform, and band order. Downloads always retain the canonical native grid and use {inference_id}_{method}.tif inside {inference_id}_{method}/. There is no view or projection option. Incompatible caches are refreshed automatically.

Filtering is optional and disabled by default. Select it with InferencePostProcessingMethodEnum.MEDIAN_FILTER from fusion_sdk.implementations_v2.common.enums, or read median_filtered_data. The 5-by-5 window and zero border are fixed, not configurable. Invalid neighbors are excluded when computing the median, and marked nodata centers remain nodata. For classification labels, numeric median filtering is not a majority vote.

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

When both thresholds are omitted, get_data also returns those model types' data without thresholding. Supply at least one endpoint to apply the selected threshold mode; an omitted start defaults to 0 and an omitted end to 1.

  • 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,
)