pystac.extensions.mlm#

Implements the Machine Learning Model (MLM) Extension.

This documentation does not provide a full-detail description of the meaning of each parameter and how to use them. For an in-depth description of this extension, and the use of each property, please refer to the official documentation

class pystac.extensions.mlm.AcceleratorType(value)[source]#

An enumeration of accelerators supported by the extension

AMD64 = 'amd64'#
AMD_ROCM = 'amd-rocm'#
CUDA = 'cuda'#
INTEL_IPEX_CPU = 'intel-ipex-cpu'#
INTEL_IPEX_GPU = 'intel-ipex-gpu'#
MACOS_ARM = 'macos-arm'#
XLA = 'xla'#
class pystac.extensions.mlm.AssetDetailedMLMExtension(asset: Asset)[source]#

A class that can be used to extend the properties of an pystac.Asset object with properties from the Machine Learning Model Extension.

Use this class, if model metadata is provided by the asset. If model metadata is provided by the asset’s parent object (i.e. pystac.Item or pystac.Item, use AssetGeneralMLMExtension.

For extending pystac.Item, pystac.Collection or pystac.ItemAssetDefinition objects, use MLMExtension instead.

property accelerator: AcceleratorType | None#

Get or set the accelerator property

property accelerator_constrained: bool | None#

Get or set the accelerator_constrained property

property accelerator_count: int | None#

Get or set the accelerator_count property

property accelerator_summary: str | None#

Get or set the accelerator_summary property

additional_read_properties: Iterable[dict[str, Any]] | None = None#

Additional read-only properties accessible from the extended object.

These are used when extending an Asset to give access to the properties of the owning Item. If a property exists in both additional_read_properties and properties, the value in additional_read_properties will take precedence.

apply(name: str, architecture: str, tasks: list[TaskType], input: list[ModelInput], output: list[ModelOutput], framework: str | None = None, framework_version: str | None = None, memory_size: int | None = None, total_parameters: int | None = None, pretrained: bool | None = None, pretrained_source: str | None = None, batch_size_suggestion: int | None = None, accelerator: AcceleratorType | None = None, accelerator_constrained: bool | None = None, accelerator_summary: str | None = None, accelerator_count: int | None = None, hyperparameters: Hyperparameters | None = None, artifact_type: str | None = None, compile_method: str | None = None, entrypoint: str | None = None) None[source]#

Sets the properties of a new AssetDetailedMLMExtensions

Parameters:
  • name – name for the model

  • architecture – A generic and well established architecture name of the model

  • tasks – Specifies the Machine Learning tasks for which the model can be used for

  • input – Describes the transformation between the EO data and the model input

  • output – Describes each model output and how to interpret it.

  • framework – Framework used to train the model

  • framework_version – The framework library version

  • memory_size – The in-memory size of the model on the accelerator during inference (bytes)

  • total_parameters – Total number of model parameters, including trainable and non-trainable parameters.

  • pretrained – Indicates if the model was pretrained. If the model was pretrained, consider providing pretrained_source if it is known

  • pretrained_source – The source of the pretraining.

  • batch_size_suggestion – A suggested batch size for the accelerator and summarized hardware.

  • accelerator – The intended computational hardware that runs inference

  • accelerator_constrained – Indicates if the intended accelerator is the only accelerator that can run inference

  • accelerator_summary – A high level description of the accelerator

  • accelerator_count – A minimum amount of accelerator instances required to run the model

  • hyperparameters – Additional hyperparameters relevant for the model

  • artifact_type – Specifies the kind of model artifact, any string is allowed. Typically related to a particular ML framework. This property is required when mlm:model is listed as a role of this asset

  • compile_method – Describes the method used to compile the ML model either when the model is saved or at model runtime prior to inference

  • entrypoint – Specific entrypoint reference in the code to use for running model inference.

property architecture: str#

Get or set the required architecture property

property artifact_type: str | None#

Get or set the artifact_type property. This is required if mlm:model as one of the asset’s roles

asset: Asset#
asset_href: str#
property batch_size_suggestion: int | None#

Get or set the batch_size_suggestion property

property compile_method: str | None#

Get or set this asset’s compile_method property

property entrypoint: str | None#

Get or set this asset’s entrypoint property

classmethod ext(obj: Asset, add_if_missing: bool = False) AssetDetailedMLMExtension[source]#

Extend a pystac.Asset (obj) with the AssetDetailedMLMExtension

Parameters:
  • obj – The Asset to be extended.

  • add_if_missing – Defines whether this extension’s URI should be added to this asset’s parent’s list of extensions if it is not already listed there. Use False if the asset does not specify a parent

Returns:

The extended object

Return type:

AssetDetailedMLMExtension[pystac.Asset]

property framework: str | None#

Get or set the framework property

property framework_version: str | None#

Get or set the framework_version property

classmethod get_schema_uri() str#

Retrieve this extension’s schema URI

Returns:

Schema URI

Return type:

str

property hyperparameters: Hyperparameters | None#

Get or set the hyperparameters property

property input: list[ModelInput]#

Get or set the required input property

property memory_size: int | None#

Get or set the memory_size property

property mlm_name: str#

Get or set the required (mlm) name property. It is named mlm_name in this context to not break convention and overwrite the extension name class property.

name: Literal['mlm'] = 'mlm'#
property output: list[ModelOutput]#

Get or set the required output property

property pretrained: bool | None#

Get or set the pretrained property

property pretrained_source: str | None#

Get or set the pretrained_source property

properties: dict[str, Any]#

The properties that this extension wraps.

The extension which implements PropertiesExtension can use _get_property and _set_property to get and set values on this instance. Note that _set_properties mutates the properties directly.

property tasks: list[TaskType]#

Get or set the required tasks property

to_dict() dict[str, Any]#

Serializes the extended asset’s properties into a dict

Returns:

dict[str, Any]

property total_parameters: int | None#

Get or set the total_parameters property

class pystac.extensions.mlm.AssetGeneralMLMExtension(asset: Asset)[source]#

A class that can be used to extend the properties of an pystac.Asset object with properties from the Machine Learning Model Extension.

Use this class, if model metadata is provided by by the asset’s parent object (i.e. pystac.Item or pystac.Item. If Model metadata is provided by the asset object itself, use AssetDetailedMLMExtension.

For extending pystac.Item, pystac.Collection or pystac.ItemAssetDefinition objects, use MLMExtension instead.

additional_read_properties: Iterable[dict[str, Any]] | None = None#

Additional read-only properties accessible from the extended object.

These are used when extending an Asset to give access to the properties of the owning Item. If a property exists in both additional_read_properties and properties, the value in additional_read_properties will take precedence.

apply(artifact_type: str | None = None, compile_method: str | None = None, entrypoint: str | None = None) None[source]#

Sets the properties of a new AssetGeneralMLMExtension

Parameters:
  • artifact_type – Specifies the kind of model artifact, any string is allowed. Typically related to a particular ML framework. This property is required when mlm:model is listed as a role of this asset

  • compile_method – Describes the method used to compile the ML model either when the model is saved or at model runtime prior to inference

  • entrypoint – Specific entrypoint reference in the code to use for running model inference.

property artifact_type: str | None#

Get or set the artifact_type property. This is required if mlm:model as one of the asset’s roles

asset: Asset#
asset_href: str#
property compile_method: str | None#

Get or set this asset’s compile_method property

property entrypoint: str | None#

Get or set this asset’s entrypoint property

classmethod ext(obj: Asset, add_if_missing: bool = False) AssetGeneralMLMExtension[Asset][source]#

Extend a pystac.Asset (obj) with the AssetGeneralMLMExtension

Parameters:
  • obj – The Asset to be extended.

  • add_if_missing – Defines whether this extension’s URI should be added to this asset’s parent’s list of extensions if it is not already listed there. Use False if the asset does not specify a parent

Returns:

The extended object

Return type:

AssetGeneralMLMExtension[pystac.Asset]

classmethod get_schema_uri() str#

Retrieve this extension’s schema URI

Returns:

Schema URI

Return type:

str

name: Literal['mlm'] = 'mlm'#
properties: dict[str, Any]#

The properties that this extension wraps.

The extension which implements PropertiesExtension can use _get_property and _set_property to get and set values on this instance. Note that _set_properties mutates the properties directly.

to_dict() dict[str, Any]#

Serializes the extended asset’s properties into a dict

Returns:

dict[str, Any]

class pystac.extensions.mlm.CollectionMLMExtension(collection: Collection)[source]#
property accelerator: AcceleratorType | None#

Get or set the accelerator property

property accelerator_constrained: bool | None#

Get or set the accelerator_constrained property

property accelerator_count: int | None#

Get or set the accelerator_count property

property accelerator_summary: str | None#

Get or set the accelerator_summary property

apply(name: str, architecture: str, tasks: list[TaskType], input: list[ModelInput], output: list[ModelOutput], framework: str | None = None, framework_version: str | None = None, memory_size: int | None = None, total_parameters: int | None = None, pretrained: bool | None = None, pretrained_source: str | None = None, batch_size_suggestion: int | None = None, accelerator: AcceleratorType | None = None, accelerator_constrained: bool | None = None, accelerator_summary: str | None = None, accelerator_count: int | None = None, hyperparameters: Hyperparameters | None = None, *args: Any, **kwargs: Any) None#

Sets the properties of a new MLMExtension

Parameters:
  • name – name for the model

  • architecture – A generic and well established architecture name of the model

  • tasks – Specifies the Machine Learning tasks for which the model can be used for

  • input – Describes the transformation between the EO data and the model input

  • output – Describes each model output and how to interpret it.

  • framework – Framework used to train the model

  • framework_version – The framework library version

  • memory_size – The in-memory size of the model on the accelerator during inference (bytes)

  • total_parameters – Total number of model parameters, including trainable and non-trainable parameters.

  • pretrained – Indicates if the model was pretrained. If the model was pretrained, consider providing pretrained_source if it is known

  • pretrained_source – The source of the pretraining.

  • batch_size_suggestion – A suggested batch size for the accelerator and summarized hardware.

  • accelerator – The intended computational hardware that runs inference

  • accelerator_constrained – Indicates if the intended accelerator is the only accelerator that can run inference

  • accelerator_summary – A high level description of the accelerator

  • accelerator_count – A minimum amount of accelerator instances required to run the model

  • hyperparameters – Additional hyperparameters relevant for the model

  • *args – Unused (no effect, only here for signature compliance with apply method in derived classes

  • **kwargs – Unused (no effect, only here for signature compliance with apply method in derived classes

property architecture: str#

Get or set the required architecture property

property batch_size_suggestion: int | None#

Get or set the batch_size_suggestion property

collection: Collection#
classmethod ext(obj: T, add_if_missing: bool = False) MLMExtension[T]#

Extend a STAC object (obj) with the MLMExtension

Parameters:
  • obj – The STAC object to be extended.

  • add_if_missing – Defines whether this extension’s URI should be added to this object’s (or its parent’s) list of extensions if it is not already listed there.

Returns:

The extended object

Return type:

MLMExtension[T]

Raises:
  • TypeError – When a pystac.Asset object is passed as the obj parameter

  • pystac.ExtensionTypeError – When any unsupported object is passed as the obj parameter. If you see this extension in this context, please raise an issue on github.

property framework: str | None#

Get or set the framework property

property framework_version: str | None#

Get or set the framework_version property

classmethod get_schema_uri() str#

Retrieves this extension’s schema URI

Returns:

the schema URI

Return type:

str

property hyperparameters: Hyperparameters | None#

Get or set the hyperparameters property

property input: list[ModelInput]#

Get or set the required input property

property memory_size: int | None#

Get or set the memory_size property

property mlm_name: str#

Get or set the required (mlm) name property. It is named mlm_name in this context to not break convention and overwrite the extension name class property.

name: Literal['mlm'] = 'mlm'#
property output: list[ModelOutput]#

Get or set the required output property

property pretrained: bool | None#

Get or set the pretrained property

property pretrained_source: str | None#

Get or set the pretrained_source property

properties: dict[str, Any]#

The properties that this extension wraps.

The extension which implements PropertiesExtension can use _get_property and _set_property to get and set values on this instance. Note that _set_properties mutates the properties directly.

property tasks: list[TaskType]#

Get or set the required tasks property

to_dict() dict[str, Any]#

Serializes this MLMExtension object into a dict

Returns:

dict[str, Any]

property total_parameters: int | None#

Get or set the total_parameters property

class pystac.extensions.mlm.Hyperparameters(properties: dict[str, Any])[source]#
apply(**kwargs: Any) None[source]#

Sets the properties for a new Hyperparameters object. The stac:mlm specification defines neither their names nor their values, so any key-value pair is allowed. :param **kwargs: any model hyperparameter name and its value, as key-value paris

classmethod create(**kwargs: Any) Hyperparameters[source]#
properties: dict[str, Any]#
to_dict() dict[str, Any][source]#

Serializes this Hyperparameters object into a dictionary :returns: dict[str, Any]

class pystac.extensions.mlm.InputStructure(properties: dict[str, Any])[source]#
apply(shape: list[int], dim_order: list[str], data_type: DataType) None[source]#

Set the properties for a new InputStructure.

Parameters:
  • shape – Shape of the input n-dimensional array (e.g.: B×C×H×W), including the batch size dimension. Each dimension must either be greater than 0 or -1 to indicate a variable dimension size.

  • dim_order – Order of the shape dimensions by name.

  • data_type – The data type of values in the n-dimensional array. For model inputs, this should be the data type of the processed input supplied to the model inference function, not the data type of the source bands.

classmethod create(shape: list[int], dim_order: list[str], data_type: DataType) InputStructure[source]#

Create a new InputStructure.

Parameters:
  • shape – Shape of the input n-dimensional array (e.g.: B×C×H×W), including the batch size dimension. Each dimension must either be greater than 0 or -1 to indicate a variable dimension size.

  • dim_order – Order of the shape dimensions by name.

  • dim_order – Order of the shape dimensions by name.

  • data_type – The data type of values in the n-dimensional array. For model inputs, this should be the data type of the processed input supplied to the model inference function, not the data type of the source bands.

Returns:

InputStructure

property data_type: DataType#

Get or set the required data_type property of this InputStructure object

property dim_order: list[str]#

Get or set the required dim_order property of this InputStructure object

properties: dict[str, Any]#
property shape: list[int]#

Get or set the required shape property of this InputStructure object

to_dict() dict[str, Any][source]#

Serializes a dict representation of this InputStucture object

Returns:

dict[str, Any]

class pystac.extensions.mlm.ItemAssetMLMExtension(item_asset: ItemAssetDefinition)[source]#
property accelerator: AcceleratorType | None#

Get or set the accelerator property

property accelerator_constrained: bool | None#

Get or set the accelerator_constrained property

property accelerator_count: int | None#

Get or set the accelerator_count property

property accelerator_summary: str | None#

Get or set the accelerator_summary property

apply(name: str, architecture: str, tasks: list[TaskType], input: list[ModelInput], output: list[ModelOutput], framework: str | None = None, framework_version: str | None = None, memory_size: int | None = None, total_parameters: int | None = None, pretrained: bool | None = None, pretrained_source: str | None = None, batch_size_suggestion: int | None = None, accelerator: AcceleratorType | None = None, accelerator_constrained: bool | None = None, accelerator_summary: str | None = None, accelerator_count: int | None = None, hyperparameters: Hyperparameters | None = None, *args: Any, **kwargs: Any) None#

Sets the properties of a new MLMExtension

Parameters:
  • name – name for the model

  • architecture – A generic and well established architecture name of the model

  • tasks – Specifies the Machine Learning tasks for which the model can be used for

  • input – Describes the transformation between the EO data and the model input

  • output – Describes each model output and how to interpret it.

  • framework – Framework used to train the model

  • framework_version – The framework library version

  • memory_size – The in-memory size of the model on the accelerator during inference (bytes)

  • total_parameters – Total number of model parameters, including trainable and non-trainable parameters.

  • pretrained – Indicates if the model was pretrained. If the model was pretrained, consider providing pretrained_source if it is known

  • pretrained_source – The source of the pretraining.

  • batch_size_suggestion – A suggested batch size for the accelerator and summarized hardware.

  • accelerator – The intended computational hardware that runs inference

  • accelerator_constrained – Indicates if the intended accelerator is the only accelerator that can run inference

  • accelerator_summary – A high level description of the accelerator

  • accelerator_count – A minimum amount of accelerator instances required to run the model

  • hyperparameters – Additional hyperparameters relevant for the model

  • *args – Unused (no effect, only here for signature compliance with apply method in derived classes

  • **kwargs – Unused (no effect, only here for signature compliance with apply method in derived classes

property architecture: str#

Get or set the required architecture property

asset_defn: ItemAssetDefinition#
property batch_size_suggestion: int | None#

Get or set the batch_size_suggestion property

classmethod ext(obj: T, add_if_missing: bool = False) MLMExtension[T]#

Extend a STAC object (obj) with the MLMExtension

Parameters:
  • obj – The STAC object to be extended.

  • add_if_missing – Defines whether this extension’s URI should be added to this object’s (or its parent’s) list of extensions if it is not already listed there.

Returns:

The extended object

Return type:

MLMExtension[T]

Raises:
  • TypeError – When a pystac.Asset object is passed as the obj parameter

  • pystac.ExtensionTypeError – When any unsupported object is passed as the obj parameter. If you see this extension in this context, please raise an issue on github.

property framework: str | None#

Get or set the framework property

property framework_version: str | None#

Get or set the framework_version property

classmethod get_schema_uri() str#

Retrieves this extension’s schema URI

Returns:

the schema URI

Return type:

str

property hyperparameters: Hyperparameters | None#

Get or set the hyperparameters property

property input: list[ModelInput]#

Get or set the required input property

property memory_size: int | None#

Get or set the memory_size property

property mlm_name: str#

Get or set the required (mlm) name property. It is named mlm_name in this context to not break convention and overwrite the extension name class property.

name: Literal['mlm'] = 'mlm'#
property output: list[ModelOutput]#

Get or set the required output property

property pretrained: bool | None#

Get or set the pretrained property

property pretrained_source: str | None#

Get or set the pretrained_source property

properties: dict[str, Any]#

The properties that this extension wraps.

The extension which implements PropertiesExtension can use _get_property and _set_property to get and set values on this instance. Note that _set_properties mutates the properties directly.

property tasks: list[TaskType]#

Get or set the required tasks property

to_dict() dict[str, Any]#

Serializes this MLMExtension object into a dict

Returns:

dict[str, Any]

property total_parameters: int | None#

Get or set the total_parameters property

class pystac.extensions.mlm.ItemMLMExtension(item: Item)[source]#
property accelerator: AcceleratorType | None#

Get or set the accelerator property

property accelerator_constrained: bool | None#

Get or set the accelerator_constrained property

property accelerator_count: int | None#

Get or set the accelerator_count property

property accelerator_summary: str | None#

Get or set the accelerator_summary property

apply(name: str, architecture: str, tasks: list[TaskType], input: list[ModelInput], output: list[ModelOutput], framework: str | None = None, framework_version: str | None = None, memory_size: int | None = None, total_parameters: int | None = None, pretrained: bool | None = None, pretrained_source: str | None = None, batch_size_suggestion: int | None = None, accelerator: AcceleratorType | None = None, accelerator_constrained: bool | None = None, accelerator_summary: str | None = None, accelerator_count: int | None = None, hyperparameters: Hyperparameters | None = None, *args: Any, **kwargs: Any) None#

Sets the properties of a new MLMExtension

Parameters:
  • name – name for the model

  • architecture – A generic and well established architecture name of the model

  • tasks – Specifies the Machine Learning tasks for which the model can be used for

  • input – Describes the transformation between the EO data and the model input

  • output – Describes each model output and how to interpret it.

  • framework – Framework used to train the model

  • framework_version – The framework library version

  • memory_size – The in-memory size of the model on the accelerator during inference (bytes)

  • total_parameters – Total number of model parameters, including trainable and non-trainable parameters.

  • pretrained – Indicates if the model was pretrained. If the model was pretrained, consider providing pretrained_source if it is known

  • pretrained_source – The source of the pretraining.

  • batch_size_suggestion – A suggested batch size for the accelerator and summarized hardware.

  • accelerator – The intended computational hardware that runs inference

  • accelerator_constrained – Indicates if the intended accelerator is the only accelerator that can run inference

  • accelerator_summary – A high level description of the accelerator

  • accelerator_count – A minimum amount of accelerator instances required to run the model

  • hyperparameters – Additional hyperparameters relevant for the model

  • *args – Unused (no effect, only here for signature compliance with apply method in derived classes

  • **kwargs – Unused (no effect, only here for signature compliance with apply method in derived classes

property architecture: str#

Get or set the required architecture property

property batch_size_suggestion: int | None#

Get or set the batch_size_suggestion property

classmethod ext(obj: T, add_if_missing: bool = False) MLMExtension[T]#

Extend a STAC object (obj) with the MLMExtension

Parameters:
  • obj – The STAC object to be extended.

  • add_if_missing – Defines whether this extension’s URI should be added to this object’s (or its parent’s) list of extensions if it is not already listed there.

Returns:

The extended object

Return type:

MLMExtension[T]

Raises:
  • TypeError – When a pystac.Asset object is passed as the obj parameter

  • pystac.ExtensionTypeError – When any unsupported object is passed as the obj parameter. If you see this extension in this context, please raise an issue on github.

property framework: str | None#

Get or set the framework property

property framework_version: str | None#

Get or set the framework_version property

classmethod get_schema_uri() str#

Retrieves this extension’s schema URI

Returns:

the schema URI

Return type:

str

property hyperparameters: Hyperparameters | None#

Get or set the hyperparameters property

property input: list[ModelInput]#

Get or set the required input property

item: Item#
property memory_size: int | None#

Get or set the memory_size property

property mlm_name: str#

Get or set the required (mlm) name property. It is named mlm_name in this context to not break convention and overwrite the extension name class property.

name: Literal['mlm'] = 'mlm'#
property output: list[ModelOutput]#

Get or set the required output property

property pretrained: bool | None#

Get or set the pretrained property

property pretrained_source: str | None#

Get or set the pretrained_source property

properties: dict[str, Any]#

The properties that this extension wraps.

The extension which implements PropertiesExtension can use _get_property and _set_property to get and set values on this instance. Note that _set_properties mutates the properties directly.

property tasks: list[TaskType]#

Get or set the required tasks property

to_dict() dict[str, Any]#

Serializes this MLMExtension object into a dict

Returns:

dict[str, Any]

property total_parameters: int | None#

Get or set the total_parameters property

class pystac.extensions.mlm.MLMExtension[source]#

An abstract class that can be used to extend to properties of an pystac.Item or pystac.Collection with properties from the Machine Learning Model Extension.

This class can be used to extend pystac.Item, pystac.Collection and pystac.ItemAssetDefinition. For extending pystac.Asset, use either AssetGeneralMLMExtension: or AssetDetailedMLMExtension.

property accelerator: AcceleratorType | None#

Get or set the accelerator property

property accelerator_constrained: bool | None#

Get or set the accelerator_constrained property

property accelerator_count: int | None#

Get or set the accelerator_count property

property accelerator_summary: str | None#

Get or set the accelerator_summary property

apply(name: str, architecture: str, tasks: list[TaskType], input: list[ModelInput], output: list[ModelOutput], framework: str | None = None, framework_version: str | None = None, memory_size: int | None = None, total_parameters: int | None = None, pretrained: bool | None = None, pretrained_source: str | None = None, batch_size_suggestion: int | None = None, accelerator: AcceleratorType | None = None, accelerator_constrained: bool | None = None, accelerator_summary: str | None = None, accelerator_count: int | None = None, hyperparameters: Hyperparameters | None = None, *args: Any, **kwargs: Any) None[source]#

Sets the properties of a new MLMExtension

Parameters:
  • name – name for the model

  • architecture – A generic and well established architecture name of the model

  • tasks – Specifies the Machine Learning tasks for which the model can be used for

  • input – Describes the transformation between the EO data and the model input

  • output – Describes each model output and how to interpret it.

  • framework – Framework used to train the model

  • framework_version – The framework library version

  • memory_size – The in-memory size of the model on the accelerator during inference (bytes)

  • total_parameters – Total number of model parameters, including trainable and non-trainable parameters.

  • pretrained – Indicates if the model was pretrained. If the model was pretrained, consider providing pretrained_source if it is known

  • pretrained_source – The source of the pretraining.

  • batch_size_suggestion – A suggested batch size for the accelerator and summarized hardware.

  • accelerator – The intended computational hardware that runs inference

  • accelerator_constrained – Indicates if the intended accelerator is the only accelerator that can run inference

  • accelerator_summary – A high level description of the accelerator

  • accelerator_count – A minimum amount of accelerator instances required to run the model

  • hyperparameters – Additional hyperparameters relevant for the model

  • *args – Unused (no effect, only here for signature compliance with apply method in derived classes

  • **kwargs – Unused (no effect, only here for signature compliance with apply method in derived classes

property architecture: str#

Get or set the required architecture property

property batch_size_suggestion: int | None#

Get or set the batch_size_suggestion property

classmethod ext(obj: T, add_if_missing: bool = False) MLMExtension[T][source]#

Extend a STAC object (obj) with the MLMExtension

Parameters:
  • obj – The STAC object to be extended.

  • add_if_missing – Defines whether this extension’s URI should be added to this object’s (or its parent’s) list of extensions if it is not already listed there.

Returns:

The extended object

Return type:

MLMExtension[T]

Raises:
  • TypeError – When a pystac.Asset object is passed as the obj parameter

  • pystac.ExtensionTypeError – When any unsupported object is passed as the obj parameter. If you see this extension in this context, please raise an issue on github.

property framework: str | None#

Get or set the framework property

property framework_version: str | None#

Get or set the framework_version property

classmethod get_schema_uri() str[source]#

Retrieves this extension’s schema URI

Returns:

the schema URI

Return type:

str

property hyperparameters: Hyperparameters | None#

Get or set the hyperparameters property

property input: list[ModelInput]#

Get or set the required input property

property memory_size: int | None#

Get or set the memory_size property

property mlm_name: str#

Get or set the required (mlm) name property. It is named mlm_name in this context to not break convention and overwrite the extension name class property.

name: Literal['mlm'] = 'mlm'#
property output: list[ModelOutput]#

Get or set the required output property

property pretrained: bool | None#

Get or set the pretrained property

property pretrained_source: str | None#

Get or set the pretrained_source property

properties: dict[str, Any]#

The properties that this extension wraps.

The extension which implements PropertiesExtension can use _get_property and _set_property to get and set values on this instance. Note that _set_properties mutates the properties directly.

property tasks: list[TaskType]#

Get or set the required tasks property

to_dict() dict[str, Any][source]#

Serializes this MLMExtension object into a dict

Returns:

dict[str, Any]

property total_parameters: int | None#

Get or set the total_parameters property

class pystac.extensions.mlm.MLMExtensionHooks[source]#
has_extension(obj: dict[str, Any]) bool#
migrate(obj: dict[str, Any], version: STACVersionID, info: STACJSONDescription) None[source]#

Migrate a STAC Object in dict format from a previous version. The base implementation will update the stac_extensions to the latest schema ID. This method will only be called for STAC objects that have been identified as a previous version of STAC. Implementations should directly manipulate the obj dict. Remember to call super() in order to change out the old ‘stac_extension’ entry with the latest schema URI.

prev_extension_ids = {'https://stac-extensions.github.io/mlm/v1.0.0/schema.json', 'https://stac-extensions.github.io/mlm/v1.1.0/schema.json', 'https://stac-extensions.github.io/mlm/v1.2.0/schema.json', 'https://stac-extensions.github.io/mlm/v1.3.0/schema.json'}#
schema_uri: str = 'https://stac-extensions.github.io/mlm/v1.4.0/schema.json'#
stac_object_types = {'Collection', 'Feature'}#
class pystac.extensions.mlm.ModelBand(properties: dict[str, Any])[source]#
apply(name: str, format: str | None = None, expression: Any | None = None) None[source]#

Set the properties for a new ModelBand.

Parameters:
  • name – Name of the band referring to an extended band definition

  • format – The type of expression that is specified in the expression property

  • expression – An expression compliant with the format specified. The cxpression can be applied to any data type and depends on the format given

classmethod create(name: str, format: str | None = None, expression: Any | None = None) ModelBand[source]#

Create a new ModelBand.

Parameters:
  • name – Name of the band referring to an extended band definition

  • format – The type of expression that is specified in the expression property

  • expression – An expression compliant with the format specified. The expression can be applied to any data type and depends on the format given

property expression: Any#

Get or set the optional expression property of a ModelBand object

property format: str | None#

Get or set the optional format property of a ModelBand object

property name: str#

Get or set the required name property of a ModelBand object

properties: dict[str, Any]#
to_dict() dict[str, Any][source]#

Returns the dictionary encoding of this ModelBand object

Returns:

dict[str, Any

class pystac.extensions.mlm.ModelInput(properties: dict[str, Any])[source]#
apply(name: str, bands: list[ModelBand] | list[str], input: InputStructure, description: str | None = None, value_scaling: ValueScaling | None = None, resize_type: ResizeType | None = None, pre_processing_function: ProcessingExpression | None = None) None[source]#

Sets the Properties for a new Input

Parameters:
  • name – Name of the input variable defined by the model. If no explicit name is defined by the model, an informative name (e.g.: “RGB Time Series”) can be used instead.

  • bands – The raster band references used to train, fine-tune or perform inference with the model, which may be all or a subset of bands available in a STAC Item’s Band Object. If no band applies for one input, use an empty array.

  • input – The N-dimensional array definition that describes the shape, dimension ordering, and data type.

  • description – Additional details about the input such as describing its purpose or expected source that cannot be represented by other properties.

  • value_scaling – Method to scale, normalize, or standardize the data inputs values, across dimensions, per corresponding dimension index, or null if none applies. These values often correspond to dataset or sensor statistics employed for training the model, but can come from another source as needed by the model definition. Consider using pre_processing_function for custom implementations or more complex combinations.

  • resize_type – High-level descriptor of the resize method to modify the input dimensions shape. Select an appropriate option or null when none applies. Consider using pre_processing_function for custom implementations or more complex combinations.

  • pre_processing_function – Custom preprocessing function where rescaling and resize, and any other significant data preparation operations takes place. The pre_processing_function should be applied over all available bands.

property bands: list[ModelBand] | list[str]#

Gets or sets the required bands property of this ModelInput object

classmethod create(name: str, bands: list[ModelBand] | list[str], input: InputStructure, description: str | None = None, value_scaling: ValueScaling | None = None, resize_type: ResizeType | None = None, pre_processing_function: ProcessingExpression | None = None) ModelInput[source]#

Creates a new Input

Parameters:
  • name – Name of the input variable defined by the model. If no explicit name is defined by the model, an informative name (e.g.: “RGB Time Series”) can be used instead.

  • bands – The raster band references used to train, fine-tune or perform inference with the model, which may be all or a subset of bands available in a STAC Item’s Band Object. If no band applies for one input, use an empty array.

  • input – The N-dimensional array definition that describes the shape, dimension ordering, and data type.

  • description – Additional details about the input such as describing its purpose or expected source that cannot be represented by other properties.

  • value_scaling – Method to scale, normalize, or standardize the data inputs values, across dimensions, per corresponding dimension index, or null if none applies. These values often correspond to dataset or sensor statistics employed for training the model, but can come from another source as needed by the model definition. Consider using pre_processing_function for custom implementations or more complex combinations.

  • resize_type – High-level descriptor of the resize method to modify the input dimensions shape. Select an appropriate option or null when none applies. Consider using pre_processing_function for custom implementations or more complex combinations.

  • pre_processing_function – Custom preprocessing function where rescaling and resize, and any other significant data preparation operations takes place. The pre_processing_function should be applied over all available bands.

property description: str | None#

Gets or sets the description property of this ModelInput object

property input: InputStructure#

Gets or sets the required input property of this ModelInput object

property name: str#

Gets or sets the required name property of this ModelInput object

property pre_processing_function: ProcessingExpression | None#

Gets or sets the pre_processing_function property of this ModelInput object

properties: dict[str, Any]#
property resize_type: ResizeType | None#

Gets or sets the resize_type property of this ModelInput object

to_dict() dict[str, Any][source]#

Serializes this ModelInput object into its dict representation

Returns:

dict[str, Any]

property value_scaling: ValueScaling | None#

Gets or sets the value_scaling property of this ModelInput object

class pystac.extensions.mlm.ModelOutput(properties: dict[str, Any])[source]#
apply(name: str, tasks: list[TaskType], result: ResultStructure, description: str | None = None, classes: list[Classification] | None = None, post_processing_function: ProcessingExpression | None = None) None[source]#

Sets the properties for a new Output

Parameters:
  • name – Name of the output variable defined by the model. If no explicit name is defined by the model, an informative name (e.g.: “CLASSIFICATION”) can be used instead.

  • tasks – Specifies the Machine Learning tasks for which the output can be used for. This can be a subset of mlm:tasks defined under the Item properties as applicable.

  • result – The structure that describes the resulting output arrays/tensors from one model head.

  • description – Additional details about the output such as describing its purpose or expected result that cannot be represented by other properties.

  • classes – A list of class objects adhering to the Classification Extension.

  • post_processing_function – Custom postprocessing function where normalization, rescaling, or any other significant operations takes place.

property classes: list[Classification] | None#

Gets or sets the classes property of this ModelOutput object

classmethod create(name: str, tasks: list[TaskType], result: ResultStructure, description: str | None = None, classes: list[Classification] | None = None, post_processing_function: ProcessingExpression | None = None) ModelOutput[source]#

Creates a new Output

Parameters:
  • name – Name of the output variable defined by the model. If no explicit name is defined by the model, an informative name (e.g.: “CLASSIFICATION”) can be used instead.

  • tasks – Specifies the Machine Learning tasks for which the output can be used for. This can be a subset of mlm:tasks defined under the Item properties as applicable.

  • result – The structure that describes the resulting output arrays/tensors from one model head. description: Additional details about the output such as describing its purpose or expected result that cannot be represented by other properties.

  • classes – A list of class objects adhering to the Classification Extension.

  • post_processing_function – Custom postprocessing function where normalization, rescaling, or any other significant operations takes place.

Returns:

ModelOutput

property description: str | None#

Gets or sets the description property of this ModelOutput object

property name: str#

Gets or sets the required name property of this ModelOutput object

property post_processing_function: ProcessingExpression | None#

Gets or sets the post_processing_function property of this ModelOutput object

properties: dict[str, Any]#
property result: ResultStructure#

Gets or sets the required results property of this ModelOutput object

property tasks: list[TaskType]#

Gets or sets the required tasks property of this ModelOutput object

to_dict() dict[str, Any][source]#

Serializes this ModelOutput object into a dict :returns: dict[str, Any]

class pystac.extensions.mlm.ProcessingExpression(properties: dict[str, Any])[source]#
apply(format: str, expression: Any) None[source]#

Set the properties for a new ProcessingExpression

Parameters:
  • format – The type of the expression that is specified in the expression property.

  • expression – An expression compliant with the format specified. The expression can be any data type and depends on the format given, e.g. string or object.

classmethod create(format: str, expression: Any) ProcessingExpression[source]#

Creates a new ProcessingExpression

Parameters:
  • format – The type of the expression that is specified in the expression property.

  • expression – An expression compliant with the format specified. The expression can be any data type and depends on the format given, e.g. string or object.

Returns:

ProcessingExpression

property expression: Any#

Get or set the required expression property of this ProcessingExpression

property format: str#

Get or set the required format property of this ProcessingExpression

properties: dict[str, Any]#
to_dict() dict[str, Any][source]#

Returns the dictionary encoding of this ProcessingExpression :returns: dict[str, Any]

class pystac.extensions.mlm.ResizeType(value)[source]#

An enumeration of Resize operations supported by the extension

CROP = 'crop'#
INTERPOLATION_AREA = 'interpolation-area'#
INTERPOLATION_CUBIC = 'interpolation-cubic'#
INTERPOLATION_LANCZOS4 = 'interpolation-lanczos4'#
INTERPOLATION_LINEAR = 'interpolate-linear'#
INTERPOLATION_MAX = 'interpolation-max'#
INTERPOLATION_NEAREST = 'interpolate-nearest'#
PAD = 'pad'#
WRAP_FILL_OUTLIERS = 'wrap-fill-outliers'#
WRAP_INVERSE_MAP = 'wrap-inverse-map'#
class pystac.extensions.mlm.ResultStructure(properties: dict[str, Any])[source]#
apply(shape: list[int], dim_order: list[str], data_type: DataType) None[source]#

Set the properties for a new ResultStructure.

Parameters:
  • shape – Shape of the n-dimensional result array (e.g.: B×H×W or B×C), possibly including a batch size dimension. The dimensions must either be greater than 0 or -1 to indicate a variable size.

  • dim_order – Order of the shape dimensions by name for the result array.

  • data_type – The data type of values in the n-dimensional array. For model outputs, this should be the data type of the result of the model inference without extra post processing.

classmethod create(shape: list[int], dim_order: list[str], data_type: DataType) ResultStructure[source]#

Creates a new ResultStructure.

Parameters:
  • shape – Shape of the n-dimensional result array (e.g.: B×H×W or B×C), possibly including a batch size dimension. The dimensions must either be greater than 0 or -1 to indicate a variable size.

  • dim_order – Order of the shape dimensions by name for the result array.

  • data_type – The data type of values in the n-dimensional array. For model outputs, this should be the data type of the result of the model inference without extra post processing.

Returns:

ResultStructure

property data_type: DataType#

Gets or sets the required data_type property of the ResultStructure object

property dim_order: list[str]#

Gets or sets the required dim_order property of the ResultStructure object

properties: dict[str, Any]#
property shape: list[int]#

Gets or sets the required shape property of the ResultStructure object

to_dict() dict[str, Any][source]#

Serilaizes this ResultStructure object to a dict :returns: dict[str, Any]

class pystac.extensions.mlm.T#

Generalized version of pystac.Item, pystac.ItemAssetDefinition, pystac.Collection, or pystac.Asset

alias of TypeVar(‘T’, ~pystac.item.Item, ~pystac.item_assets.ItemAssetDefinition, ~pystac.collection.Collection, ~pystac.asset.Asset)

class pystac.extensions.mlm.TaskType(value)[source]#

An enumeration of Tasks supported by the extension

CLASSIFICATION = 'classification'#
DETECTION = 'detection'#
GENERATIVE = 'generative'#
IAMGE_CAPTIONING = 'image-captioning'#
INSTANCE_SEGMENTATION = 'instance-segmentation'#
OBJECT_DETECTION = 'object-detection'#
PANOPTIC_SEGMENTATION = 'panoptic-segmentation'#
REGRESSION = 'regression'#
SCENE_CLASSIFICATION = 'scene-classification'#
SEGMENTATION = 'segmentation'#
SEMANTIC_SEGMENTATION = 'semantic-segmentation'#
SUPER_RESOLUTION = 'super-resolution'#
class pystac.extensions.mlm.ValueScaling(properties: dict[str, Any])[source]#
apply(type: ValueScalingType, minimum: int | float | None = None, maximum: int | float | None = None, mean: int | float | None = None, stddev: int | float | None = None, value: int | float | None = None, format: str | None = None, expression: str | None = None) None[source]#

Creates new ValueScaling object. Depending on the type parameter, different parameters are required. Consult STAC:MLM documentation or use get_required_props() for details on what parameters are required for which ValueScaling type.

Parameters:
  • type – The type of ValueScaling object.

  • minimum – A minimum value

  • maximum – A maximum value

  • mean – A mean value

  • stddev – A standard deviation value

  • value – A scalar value

  • format – The format of the expression

  • expression – The expression itself

classmethod create(type: ValueScalingType, minimum: int | float | None = None, maximum: int | float | None = None, mean: int | float | None = None, stddev: int | float | None = None, value: int | float | None = None, format: str | None = None, expression: str | None = None) ValueScaling[source]#

Creates new ValueScaling object. Depending on the type parameter, different parameters are required. Consult STAC:MLM documentation or use get_required_props() for details on what parameters are required for which ValueScaling type.

Parameters:
  • type – The type of ValueScaling object.

  • minimum – A minimum value

  • maximum – A maximum value

  • mean – A mean value

  • stddev – A standard deviation value

  • value – A scalar value

  • format – The format of the expression

  • expression – The expression itself

Returns:

ValueScaling

property expression: str | None#

Get or set the expression property of this ValueScaling object

property format: str | None#

Get or set the format property of this ValueScaling object

classmethod get_required_props(type: ValueScalingType) list[str][source]#

Determines the parameters required for a certain ValueScaling operation.

Parameters:

type – The type of ValueScaling operation for which required properties are to be retrieved

Returns:

names of properties required for the given type

Return type:

list[str]

property maximum: int | float | None#

Get or set the maximum property of this ValueScaling object

property mean: int | float | None#

Get or set the mean property of this ValueScaling object

property minimum: int | float | None#

Get or set the minimum property of this ValueScaling object

properties: dict[str, Any]#
property stddev: int | float | None#

Get or set the stddev (standard deviation) property of this ValueScaling object

to_dict() dict[str, Any][source]#

Serialize a dict representation of this ValueScaling object

Returns:

dict[str, Any]

property type: str#

Get or set the required type property of this ValueScaling object

classmethod validate_property_dict(type: ValueScalingType, props: dict[str, Any]) None[source]#
Validate whether given properties satisfy the requirements set by the

ValueScaling type parameter

Parameters:
  • type – The type of ValueScaling operation

  • props – The properties to validate. Keys in this dict are the property names, values are the property values

Raises:

STACError – if the given properties do not satisfy the requirements of the ValueScaling type

property value: int | float | None#

Get or set the value property of this ValueScaling object

class pystac.extensions.mlm.ValueScalingType(value)[source]#

An enumeratino of Value Scaling operations supported by the extension

CLIP = 'clip'#
CLIP_MAX = 'clip-max'#
CLIP_MIN = 'clip-min'#
MIN_MAX = 'min-max'#
OFFSET = 'offset'#
PROCESSING = 'processing'#
SCALE = 'scale'#
Z_SCORE = 'z-score'#