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
orpystac.Item
, useAssetGeneralMLMExtension
.For extending
pystac.Item
,pystac.Collection
orpystac.ItemAssetDefinition
objects, useMLMExtension
instead.- property accelerator: AcceleratorType | None#
Get or set the accelerator 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 owningItem
. If a property exists in bothadditional_read_properties
andproperties
, the value inadditional_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 versionmemory_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 knownpretrained_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 inferenceaccelerator_summary – A high level description of the
accelerator
accelerator_count – A minimum amount of
accelerator
instances required to run the modelhyperparameters – 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 assetcompile_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
- 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:
- classmethod get_schema_uri() str #
Retrieve this extension’s schema URI
- Returns:
Schema URI
- Return type:
- property hyperparameters: Hyperparameters | None#
Get or set the hyperparameters property
- property input: list[ModelInput]#
Get or set the required input 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.
- property output: list[ModelOutput]#
Get or set the required output 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.
- 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
orpystac.Item
. If Model metadata is provided by the asset object itself, useAssetDetailedMLMExtension
.For extending
pystac.Item
,pystac.Collection
orpystac.ItemAssetDefinition
objects, useMLMExtension
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 owningItem
. If a property exists in bothadditional_read_properties
andproperties
, the value inadditional_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 assetcompile_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
- 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:
- classmethod get_schema_uri() str #
Retrieve this extension’s schema URI
- Returns:
Schema URI
- Return type:
- class pystac.extensions.mlm.CollectionMLMExtension(collection: Collection)[source]#
- property accelerator: AcceleratorType | None#
Get or set the accelerator 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 versionmemory_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 knownpretrained_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 inferenceaccelerator_summary – A high level description of the
accelerator
accelerator_count – A minimum amount of
accelerator
instances required to run the modelhyperparameters – 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
- 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:
- Raises:
TypeError – When a
pystac.Asset
object is passed as the obj parameterpystac.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.
- classmethod get_schema_uri() str #
Retrieves this extension’s schema URI
- Returns:
the schema URI
- Return type:
- property hyperparameters: Hyperparameters | None#
Get or set the hyperparameters property
- property input: list[ModelInput]#
Get or set the required input 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.
- property output: list[ModelOutput]#
Get or set the required output 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]#
- 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
- class pystac.extensions.mlm.ItemAssetMLMExtension(item_asset: ItemAssetDefinition)[source]#
- property accelerator: AcceleratorType | None#
Get or set the accelerator 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 versionmemory_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 knownpretrained_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 inferenceaccelerator_summary – A high level description of the
accelerator
accelerator_count – A minimum amount of
accelerator
instances required to run the modelhyperparameters – 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
- asset_defn: ItemAssetDefinition#
- 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:
- Raises:
TypeError – When a
pystac.Asset
object is passed as the obj parameterpystac.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.
- classmethod get_schema_uri() str #
Retrieves this extension’s schema URI
- Returns:
the schema URI
- Return type:
- property hyperparameters: Hyperparameters | None#
Get or set the hyperparameters property
- property input: list[ModelInput]#
Get or set the required input 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.
- property output: list[ModelOutput]#
Get or set the required output property
- class pystac.extensions.mlm.ItemMLMExtension(item: Item)[source]#
- property accelerator: AcceleratorType | None#
Get or set the accelerator 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 versionmemory_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 knownpretrained_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 inferenceaccelerator_summary – A high level description of the
accelerator
accelerator_count – A minimum amount of
accelerator
instances required to run the modelhyperparameters – 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
- 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:
- Raises:
TypeError – When a
pystac.Asset
object is passed as the obj parameterpystac.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.
- classmethod get_schema_uri() str #
Retrieves this extension’s schema URI
- Returns:
the schema URI
- Return type:
- property hyperparameters: Hyperparameters | None#
Get or set the hyperparameters property
- property input: list[ModelInput]#
Get or set the required input 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.
- property output: list[ModelOutput]#
Get or set the required output property
- class pystac.extensions.mlm.MLMExtension[source]#
An abstract class that can be used to extend to properties of an
pystac.Item
orpystac.Collection
with properties from the Machine Learning Model Extension.This class can be used to extend
pystac.Item
,pystac.Collection
andpystac.ItemAssetDefinition
. For extendingpystac.Asset
, use eitherAssetGeneralMLMExtension
: orAssetDetailedMLMExtension
.- property accelerator: AcceleratorType | None#
Get or set the accelerator 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 versionmemory_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 knownpretrained_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 inferenceaccelerator_summary – A high level description of the
accelerator
accelerator_count – A minimum amount of
accelerator
instances required to run the modelhyperparameters – 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
- 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:
- Raises:
TypeError – When a
pystac.Asset
object is passed as the obj parameterpystac.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.
- classmethod get_schema_uri() str [source]#
Retrieves this extension’s schema URI
- Returns:
the schema URI
- Return type:
- property hyperparameters: Hyperparameters | None#
Get or set the hyperparameters property
- property input: list[ModelInput]#
Get or set the required input 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.
- property output: list[ModelOutput]#
Get or set the required output 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.
- class pystac.extensions.mlm.MLMExtensionHooks[source]#
- get_object_links(obj: STACObject) list[str | pystac.RelType] | None #
- 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'}#
- 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
- 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 input: InputStructure#
Gets or sets the required input property of this ModelInput object
- property pre_processing_function: ProcessingExpression | None#
Gets or sets the pre_processing_function property of this ModelInput object
- 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 post_processing_function: ProcessingExpression | None#
Gets or sets the post_processing_function property of this ModelOutput object
- property result: ResultStructure#
Gets or sets the required results property of this ModelOutput object
- 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
- 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
- class pystac.extensions.mlm.T#
Generalized version of
pystac.Item
,pystac.ItemAssetDefinition
,pystac.Collection
, orpystac.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'#
- SIMILARITY_SEARCH = 'similarity-search'#
- 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 ValueScalingtype
.- 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 ValueScalingtype
.- 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
- classmethod get_required_props(type: ValueScalingType) list[str] [source]#
Determines the parameters required for a certain ValueScaling operation.
- 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]
- 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