monai.deploy.operators.InferenceOperator

class monai.deploy.operators.InferenceOperator(fragment, *args, **kwargs)[source]

Bases: holoscan.core.Operator

The base operator for operators that perform AI inference.

This operator preforms pre-transforms on a input image, inference with a given model, post-transforms, and final results generation.

Constructor of the operator.

Methods

__init__(fragment, *args, **kwargs)

Constructor of the operator.

add_arg(*args, **kwargs)

Overloaded function.

compute(op_input, op_output, context)

An abstract method that needs to be implemented by the user.

initialize(self)

Operator initialization method.

post_process(data, *args, **kwargs)

Transform the prediction results from the model(s).

pre_process(data, *args, **kwargs)

Transforms input before being used for predicting on a model.

predict(data, *args, **kwargs)

Predicts results using the models(s) with input tensors.

setup(spec)

Default implementation of setup method.

start(self)

Operator start method.

stop(self)

Operator stop method.

Attributes

args

The list of arguments associated with the component.

conditions

Conditions associated with the operator.

description

YAML formatted string describing the operator.

fragment

The fragment that the operator belongs to.

id

The identifier of the component.

name

The name of the operator.

operator_type

The operator type.

resources

Resources associated with the operator.

spec

class OperatorType(self: holoscan.core._core.Operator.OperatorType, value: int) None

Bases: pybind11_builtins.pybind11_object

Members:

NATIVE

GXF

property name
__init__(fragment, *args, **kwargs)[source]

Constructor of the operator.

add_arg(*args, **kwargs)

Overloaded function.

  1. add_arg(self: holoscan.core._core.Component, arg: holoscan.core._core.Arg) -> None

Add an argument to the component.

  1. add_arg(self: holoscan.core._core.Component, arg: holoscan.core._core.ArgList) -> None

Add a list of arguments to the component.

property args

The list of arguments associated with the component.

arglist : holoscan.core.ArgList

compute(op_input, op_output, context)[source]

An abstract method that needs to be implemented by the user.

Parameters
  • op_input (InputContext) – An input context for the operator.

  • op_output (OutputContext) – An output context for the operator.

  • context (ExecutionContext) – An execution context for the operator.

property conditions

Conditions associated with the operator.

property description

YAML formatted string describing the operator.

property fragment

The fragment that the operator belongs to.

name : holoscan.core.Fragment

property id

The identifier of the component.

The identifier is initially set to -1, and will become a valid value when the component is initialized.

With the default executor (holoscan.gxf.GXFExecutor), the identifier is set to the GXF component ID.

id : int

initialize(self: holoscan.core._core.Operator) None

Operator initialization method.

property name

The name of the operator.

name : str

property operator_type

The operator type.

holoscan.core.Operator.OperatorType enum representing the type of the operator. The two types currently implemented are native and GXF.

post_process(data, *args, **kwargs)[source]

Transform the prediction results from the model(s).

This method must be overridden by a derived class.

Raises

NotImplementedError – When the subclass does not override this method.

Return type

Union[Image, Any, Tuple[Any, …], Dict[Any, Any]]

pre_process(data, *args, **kwargs)[source]

Transforms input before being used for predicting on a model.

This method must be overridden by a derived class.

Raises

NotImplementedError – When the subclass does not override this method.

Return type

Union[Image, Any, Tuple[Any, …], Dict[Any, Any]]

predict(data, *args, **kwargs)[source]

Predicts results using the models(s) with input tensors.

This method must be overridden by a derived class.

Raises

NotImplementedError – When the subclass does not override this method.

Return type

Union[Image, Any, Tuple[Any, …], Dict[Any, Any]]

property resources

Resources associated with the operator.

setup(spec)

Default implementation of setup method.

start(self: holoscan.core._core.Operator) None

Operator start method.

stop(self: holoscan.core._core.Operator) None

Operator stop method.