nv_ingest_api.internal.primitives.nim package#

Subpackages#

Submodules#

nv_ingest_api.internal.primitives.nim.default_values module#

nv_ingest_api.internal.primitives.nim.nim_client module#

class nv_ingest_api.internal.primitives.nim.nim_client.NimClient(
model_interface,
protocol: str,
endpoints: Tuple[str, str],
auth_token: str | None = None,
timeout: float = 120.0,
max_retries: int = 5,
)[source]#

Bases: object

A client for interfacing with a model inference server using gRPC or HTTP protocols.

close()[source]#
infer(data: dict, model_name: str, **kwargs) Any[source]#

Perform inference using the specified model and input data.

Parameters:
  • data (dict) – The input data for inference.

  • model_name (str) – The model name.

  • kwargs (dict) – Additional parameters for inference.

Returns:

The processed inference results, coalesced in the same order as the input images.

Return type:

Any

try_set_max_batch_size(model_name, model_version: str = '')[source]#

Attempt to set the max batch size for the model if it is not already set, ensuring thread safety.

nv_ingest_api.internal.primitives.nim.nim_model_interface module#

class nv_ingest_api.internal.primitives.nim.nim_model_interface.ModelInterface[source]#

Bases: object

Base class for defining a model interface that supports preparing input data, formatting it for inference, parsing output, and processing inference results.

format_input(
data: dict,
protocol: str,
max_batch_size: int,
)[source]#

Format the input data for the specified protocol.

Parameters:
  • data (dict) – The input data to format.

  • protocol (str) – The protocol to format the data for.

name() str[source]#

Get the name of the model interface.

Returns:

The name of the model interface.

Return type:

str

parse_output(
response,
protocol: str,
data: dict | None = None,
**kwargs,
)[source]#

Parse the output data from the model’s inference response.

Parameters:
  • response (Any) – The response from the model inference.

  • protocol (str) – The protocol used (“grpc” or “http”).

  • data (dict, optional) – Additional input data passed to the function.

prepare_data_for_inference(data: dict)[source]#

Prepare input data for inference by processing or transforming it as required.

Parameters:

data (dict) – The input data to prepare.

process_inference_results(
output_array,
protocol: str,
**kwargs,
)[source]#

Process the inference results from the model.

Parameters:
  • output_array (Any) – The raw output from the model.

  • kwargs (dict) – Additional parameters for processing.

Module contents#

class nv_ingest_api.internal.primitives.nim.ModelInterface[source]#

Bases: object

Base class for defining a model interface that supports preparing input data, formatting it for inference, parsing output, and processing inference results.

format_input(
data: dict,
protocol: str,
max_batch_size: int,
)[source]#

Format the input data for the specified protocol.

Parameters:
  • data (dict) – The input data to format.

  • protocol (str) – The protocol to format the data for.

name() str[source]#

Get the name of the model interface.

Returns:

The name of the model interface.

Return type:

str

parse_output(
response,
protocol: str,
data: dict | None = None,
**kwargs,
)[source]#

Parse the output data from the model’s inference response.

Parameters:
  • response (Any) – The response from the model inference.

  • protocol (str) – The protocol used (“grpc” or “http”).

  • data (dict, optional) – Additional input data passed to the function.

prepare_data_for_inference(data: dict)[source]#

Prepare input data for inference by processing or transforming it as required.

Parameters:

data (dict) – The input data to prepare.

process_inference_results(
output_array,
protocol: str,
**kwargs,
)[source]#

Process the inference results from the model.

Parameters:
  • output_array (Any) – The raw output from the model.

  • kwargs (dict) – Additional parameters for processing.

class nv_ingest_api.internal.primitives.nim.NimClient(
model_interface,
protocol: str,
endpoints: Tuple[str, str],
auth_token: str | None = None,
timeout: float = 120.0,
max_retries: int = 5,
)[source]#

Bases: object

A client for interfacing with a model inference server using gRPC or HTTP protocols.

close()[source]#
infer(data: dict, model_name: str, **kwargs) Any[source]#

Perform inference using the specified model and input data.

Parameters:
  • data (dict) – The input data for inference.

  • model_name (str) – The model name.

  • kwargs (dict) – Additional parameters for inference.

Returns:

The processed inference results, coalesced in the same order as the input images.

Return type:

Any

try_set_max_batch_size(model_name, model_version: str = '')[source]#

Attempt to set the max batch size for the model if it is not already set, ensuring thread safety.