NvInferComplexModel

Inheritance diagram of NvInferComplexModel

NvInferComplexModel inheritance diagram

class savant.deepstream.nvinfer.model.NvInferComplexModel(local_path=None, remote=None, model_file=None, batch_size=1, precision=ModelPrecision.FP16, input=NvInferModelInput(object='auto.frame', layer_name=None, shape=None, maintain_aspect_ratio=False, symmetric_padding=False, scale_factor=1.0, offsets=(0.0, 0.0, 0.0), color_format=<ModelColorFormat.RGB: 0>, preprocess_object_meta=None, preprocess_object_image=None, object_min_width=None, object_min_height=None, object_max_width=None, object_max_height=None), output=NvInferComplexModelOutput(layer_names=[], converter='???', attributes='???', objects='???', num_detected_classes=None), format=None, config_file=None, int8_calib_file=None, engine_file=None, proto_file=None, custom_config_file=None, mean_file=None, label_file=None, tlt_model_key=None, gpu_id=0, interval=0, workspace_size=6144, custom_lib_path=None, engine_create_func_name=None, layer_device_precision=<factory>, enable_dla=None, use_dla_core=None, scaling_compute_hw=None, scaling_filter=None)

NvInferComplexModel configuration template.

Complex model combines object and attribute models.

For example face detector that produces bounding boxes and landmarks:

- element: nvinfer@complex_model
  name: face_detector
  model:
    format: onnx
    config_file: config.txt
    output:
      layer_names: ['bboxes', 'scores', 'landmarks']
      converter:
        module: module.face_detector_coverter
        class_name: FaceDetectorConverter
      objects:
        - class_id: 0
          label: face
          selector:
            module: savant.selector
            class_name: BBoxSelector
            kwargs:
              confidence_threshold: 0.5
              nms_iou_threshold: 0.5
      attributes:
        - name: landmarks
batch_size: int = 1

Number of frames or objects to be inferred together in a batch.

Note

In case the model is an NvInferModel and it is configured to use the TRT engine file directly, the default value for batch_size will be taken from the engine file name, by parsing it according to the scheme {model_name}_b{batch_size}_gpu{gpu_id}_{precision}.engine

config_file: str | None = None

Model configuration file. Should be specified without a location.

custom_config_file: str | None = None

Configuration file for custom model, eg for YOLO. By default, the model file name (model_file) will be used with the extension .cfg.

custom_lib_path: str | None = None

Absolute pathname of a library containing custom method implementations for custom models.

enable_dla: bool | None = None

Specifies that DLA engines to be used for inference.

engine_create_func_name: str | None = None

Name of the custom TensorRT CudaEngine creation function.

engine_file: str | None = None

Serialized model engine file.

format: NvInferModelFormat | None = None

Model file format.

Example

format: onnx
# format: caffe
# etc.
# look in enum for full list of format options
gpu_id: int = 0

Device ID of GPU to use for pre-processing/inference (dGPU only).

Note

In case the model is configured to use the TRT engine file directly, the default value for gpu_id will be taken from the engine_file, by parsing it according to the scheme {model_name}_b{batch_size}_gpu{gpu_id}_{precision}.engine

input: NvInferModelInput = NvInferModelInput(object='auto.frame', layer_name=None, shape=None, maintain_aspect_ratio=False, symmetric_padding=False, scale_factor=1.0, offsets=(0.0, 0.0, 0.0), color_format=<ModelColorFormat.RGB: 0>, preprocess_object_meta=None, preprocess_object_image=None, object_min_width=None, object_min_height=None, object_max_width=None, object_max_height=None)

Optional configuration of input data and custom preprocessing methods for a model. If not set, then input will default to entire frame.

int8_calib_file: str | None = None

INT8 calibration file for dynamic range adjustment with an FP32 model. Required only for models in INT8.

interval: int = 0

Specifies the number of consecutive batches to be skipped for inference.

label_file: str | None = None

Pathname of a text file containing the labels for the model.

local_path: str | None = None

Path where all the necessary model files are placed. By default, the value of module parameter “model_path” and element name will be used (“model_path / element_name”).

mean_file: str | None = None

Pathname of mean data file in PPM format.

model_file: str | None = None

The model file, eg yolov4.onnx.

Note

The model file is specified without a location. The absolute path to the model file will be defined as “local_path/model_file”.

precision: ModelPrecision = 2

Data format to be used by inference.

Example

precision: fp16
# precision: int8
# precision: fp32

Note

In case the model is an NvInferModel and it is configured to use the TRT engine file directly, the default value for precision will be taken from the engine file name, by parsing it according to the scheme {model_name}_b{batch_size}_gpu{gpu_id}_{precision}.engine

proto_file: str | None = None

Caffe model prototxt file. By default, the model file name (model_file) will be used with the extension .prototxt.

remote: RemoteFile | None = None

Configuration of model files remote location. Supported schemes: s3, http, https, ftp.

scaling_compute_hw: NvInferScalingComputeHW | None = None

Specifies the hardware to be used for scaling compute.

scaling_filter: NvInferScalingFilter | None = None

Specifies the algorithm to be used for scaling.

tlt_model_key: str | None = None

Key for the TAO toolkit encoded model.

use_dla_core: int | None = None

Specifies the DLA core to be used for inference.

workspace_size: int = 6144

Workspace size to be used by the engine, in MB

layer_device_precision: List[str]

Specifies the device type and precision for any layer in the network. List of items of format <layer1-name>:<precision>:<device-type>.

output: NvInferComplexModelOutput = NvInferComplexModelOutput(layer_names=[], converter='???', attributes='???', objects='???', num_detected_classes=None)

Configuration for post-processing of a complex model’s results.