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, 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='???', 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)

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: Optional[str] = None

Model configuration file. Should be specified without a location.

custom_config_file: Optional[str] = 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: Optional[str] = None

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

engine_create_func_name: Optional[str] = None

Name of the custom TensorRT CudaEngine creation function.

engine_file: Optional[str] = None

Serialized model engine file.

format: NvInferModelFormat = '???'

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, 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: Optional[str] = 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: Optional[str] = None

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

local_path: Optional[str] = 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: Optional[str] = None

Pathname of mean data file in PPM format.

model_file: Optional[str] = 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: Optional[str] = None

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

remote: Optional[RemoteFile] = None

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

tlt_model_key: Optional[str] = None

Key for the TAO toolkit encoded model.

workspace_size: int = 6144

Workspace size to be used by the engine, in MB

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

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