Skip to navigation

Gst-nvinferserver

View as Markdown

The Gst-nvinferserver plugin performs inferencing on input data using NVIDIA® Triton Inference Server (previously called TensorRT Inference Server).

The plugin supports the following Triton server versions:

The plugin accepts batched NV12/RGBA buffers from upstream. The NvDsBatchMeta structure must already be attached to the Gst Buffers.

The low-level library (libnvds_infer_server) operates on any of NV12 or RGBA buffers. The Gst-nvinferserver plugin passes the input batched buffers to the low-level library and waits for the results to be available. Meanwhile, it keeps queuing input buffers to the low-level library as they are received. Once the results are available from the low-level library, the plugin translates and attaches the results back in to Gst-buffer for downstream plugins.

The low-level library preprocesses the transformed frames (performs color conversion and scaling, normalization and mean subtraction) and produces final FP32/FP16/INT8/UINT8/INT16/UINT16/INT32/UINT32 RGB/BGR/GRAY planar/ packed data which is passed to the Triton for inferencing. The output type generated by the low-level library depends on the network type.

The pre-processing function is:

y = netscalefactor * (x - mean)

Where:

  • x is the input pixel value. It is an uint8 with range [0,255].

  • mean is the corresponding mean value, read either from the mean file or as offsets[c], where c is the channel to which the input pixel belongs, and offsets is the array specified in the configuration file. It is a float.

  • netscalefactor is the pixel scaling factor specified in the configuration file. It is a float.

  • y is the corresponding output pixel value. It can be of type float / half / int8 / uint8 / int16 / uint16 / int32 / uint32.

    Take specific example for uint8 to int8 conversion. set netscalefactor = 1.0 and mean = [128, 128, 128]. Then the function looks like:

    y = (1.0) * (x - 128)

Gst-nvinferserver currently works on the following type of networks:

  • Multi-class object detection
  • Multi-label classification
  • Segmentation

The Gst-nvinferserver plugin can work in three process modes:

  • Primary mode: Operates on full frames.

  • Secondary mode: Operates on objects added in the metadata by upstream components.

    When the plugin is operating as a secondary classifier in async mode along with the tracker, it tries to improve performance by avoiding re-inferencing on the same objects in every frame. It does this by caching the classification output in a map with the object’s unique ID as the key. The object is inferred upon only when it is first seen in a frame (based on its object ID) or when the size (bounding box area) of the object increases by 20% or more. This optimization is possible only when the tracker is added as an upstream element.

  • Preprocessed Tensor Input mode: Operates on tensors attached by upstream components.

    When operating in preprocessed tensor input mode, the pre-processing inside Gst-nvinferserver is completely skipped. The plugin looks for GstNvDsPreProcessBatchMeta attached to the input buffer and passes the tensor as is to the Triton Inference Server without any modifications. This mode currently supports processing on full-frame and ROI. The GstNvDsPreProcessBatchMeta is attached by the Gst-nvdspreprocess plugin. This mode is enabled by adding the input_tensor_from_meta configuration message in the InferenceConfig message.

Detailed documentation of the Triton Inference Server is available at: https://github.com/triton-inference-server/server/blob/r26.03/README.md (x86) and https://github.com/triton-inference-server/server/blob/r26.04/README.md (Jetson)

The plugin supports Triton features along with multiple deep-learning frameworks such as TensorRT, TensorFlow (GraphDef / SavedModel), ONNX and PyTorch on Tesla platforms. On Jetson, it also supports TensorRT and TensorFlow (GraphDef / SavedModel). TensorFlow and ONNX can be configured with TensorRT acceleration. For details, see Framework-Specific Optimization. The plugin requires a configurable model repository root directory path where all the models need to reside. All the plugin instances in a single process must share the same model root. For details, see Model Repository. Each model also needs a specific config.pbtxt file in its subdirectory. For details, see Model Configuration. The plugin supports Triton ensemble mode to enable users to perform preprocessing or postprocessing with Triton custom backend. The plugin also supports the interface for custom functions for parsing outputs of object detectors, classifiers, and initialization of non-image input layers in cases where there is more than one input layer. Refer to sources/includes/nvdsinfer_custom_impl.h for the custom method implementations for custom models.

Gst-nvinferserver

Downstream components receive a Gst Buffer with unmodified contents plus the metadata created from the inference output of the Gst-nvinferserver plugin. The plugin can be used for cascaded inferencing. That is, it can perform primary inferencing directly on input data, then perform secondary inferencing on the results of primary inferencing, and so on. This is similar with Gst-nvinfer, see more details in Gst-nvinfer.

Inputs and Outputs

This section summarizes the inputs, outputs, and communication facilities of the Gst-nvinferserver plugin.

  • Inputs

    • Gst Buffer
    • NvDsBatchMeta (attaching NvDsFrameMeta)
    • Model repository directory path (model_repo.root)
    • gRPC endpoint URL (grpc.url)
    • Runtime model file with config.pbtxt file in model repository
  • Control parameters

    • Gst-nvinferserver gets control parameters from a configuration file. You can specify this by setting the property config-file-path. For details, see Gst-nvinferserver Configuration File Specifications. Other control parameters that can be set through GObject properties are:

      • Batch size
      • Process mode
      • Unique id
      • Inference on GIE id and operate on class ids [secondary mode only]
      • Inference interval
      • Raw output generated callback function
    • The parameters set through the GObject properties override the parameters in the Gst-nvinferserver configuration file.

  • Outputs

    • Gst Buffer

    • Depending on network type and configured parameters, one or more of:

      • NvDsObjectMeta
      • NvDsClassifierMeta
      • NvDsInferSegmentationMeta
      • NvDsInferTensorMeta

Gst-nvinferserver Configuration File Specifications

The Gst-nvinferserver configuration file uses prototxt format described in https://developers.google.com/protocol-buffers.

The protobuf message structures of this configuration file are defined by nvdsinferserver_plugin.proto and nvdsinferserver_config.proto. All the basic data-type values are set to 0 or false from protobuf’s guide. Map, arrays and oneof are set to empty by default. See more details for each message definition.

  • The message PluginControl in nvdsinferserver_plugin.proto is the entry point for this config-file.
  • The message InferenceConfig configures the low-level settings for libnvds_infer_server.
  • The message PluginControl::InputControl configures the input buffers, objects filtering policy for model inference.
  • The message PluginControl::OutputControl configures inference output policy for detections and raw tensor metadata.
  • The message BackendParams configures backend input/output layers and Triton settings in InferenceConfig.
  • The message PreProcessParams configures network preprocessing information in InferenceConfig.
  • The message InputTensorFromMeta enables the preprocessed tensor input mode and configures the input tensor information in InferenceConfig.
  • The message PostProcessParams configures the output tensor parsing methods such as detection, classification, semantic segmentation and others in InferenceConfig.
  • There are also other messages (e.g. CustomLib, ExtraControl) and enum types (e.g. MediaFormat, TensorOrder, …) defined in the proto file for miscellaneous settings for InferenceConfig and PluginControl.

Features

The following table summarizes the features of the plugin.

Gst-nvinferserver plugin features

FeaturedGPUJetsonRelease
Gst-nvinferserver Running on HostNoYesDS 5.0
Running on Docker ImageYesYes(DS 6.0)DS 5.0
DS Preprocessing: Network input format: RGB/BGR/GrayYesYesDS 5.0
DS Preprocessing: Network input data types FP32/FP16/UINT8/INT8/UINT16/INT16/UINT32/INT32YesYesDS 5.0
DS Preprocessing: Network input tensor orders
NCHW / NHWC
YesYesDS 5.0
Mem: Cuda(GPU) buf-sharing for Input TensorsYesYesDS 5.0
Mem: Cuda Memory (GPU / CPU-pinned) for output tensorsYesYesDS 5.0
Backend: TensorRT runtime (plan engine file)YesYesDS 5.0
Backend: Tensorflow Runtime CPU/GPU (graphdef/savedmodel)YesYesDS 5.0
Backend: Tensorflow Runtime with TF-TRT accelerationYesYesDS 5.0
Backend: ONNX RuntimeYesYes(DS 6.0)DS 5.0
Backend: ONNX Runtime with ONNX-TRT accelerationYesYes(DS 6.0)DS 5.0
Backend: Pytorch RuntimeYesNoDS 5.0
Postprocessing: DS Detection / Classification/ SegmentationYesYesDS 5.0
Postprocessing: DS Detection cluster method: NMS / GroupRectangle / DBSCan / NoneYesYesDS 5.0
Postprocessing: custom parsing (NvDsInferParseCustomTfSSD)YesYesDS 5.0
Postprocessing: Triton native classificationYesYesDS 5.0
Triton Ensemble Mode (Triton preproc/postproc) with specified media-format (RGB/BGR/Gray) with Cuda GPU buffer as inputsYesYesDS 5.0
Postprocessing: Attach Triton raw tensor output in NvDsInferTensorMeta for downstream or application postprocessingYesYesDS 5.0
deepstream-app: pipeline works with PGIE / SGIE / nvtrackerYesYesDS 5.0
Sample App: deepstream-infer-tensor-meta-testYesYesDS 5.0
Basic LSTM features on single batch and single stream (beta version, config file might be changed in future version)YesYesDS 5.0
gRPC: Triton Server running as independent process and plugin communicates through gRPCYesYesDS 6.0
Custom process interface IInferCustomProcessor for extra multi-input tensors preprocess, multi-streams LSTM loop process, custom output data postprocess(parsing and metadata attaching). Basic single-stream LSTM could be replaced by custom loop processYesYesDS 6.0
gRPC: CUDA buffer sharing with local Triton server for input tensorsYesYesDS 6.2
Postprocessing: Clip object bounding boxes to fit within the ROIYesYesDS 6.3

Gst-nvinferserver plugin features message PluginControl definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
infer_configLow-level libnvds_infer_server inference configuration settingsInferenceConfiginfer_config { … }
see details in InferenceConfig
All
Both
input_controlControl plugin input buffers, objects filtering policy for inferencePluginControl ::InputControlinput_control{
process_mode: PROCESS_MODE_FULL_FRAME
}
see details in InputControl
All
Both
output_controlControl plugin output metadata filtering policy after inferencePluginControl ::OutputControloutput_control { … }
see details in OutputControl
All
Both
process_modeProcessing mode, selected from PluginControl::ProcessMode. In deepstream-app PGIE uses PROCESS_MODE_FULL_FRAME by default, SGIE use PROCESS_MODE_CLIP_OBJECTS by defaultenum PluginControl::ProcessModeprocess_mode: PROCESS_MODE_FULL_FRAMEAll
Both
operate_on_gie_idUnique ID of the GIE on whose metadata (bounding boxes) this GIE is to operate onint32, >=0, valid gie-id.
-1, disable gie-id check, inference on all GIE Ids
operate_on_gie_id: 1All
Secondary
operate_on_class_idsClass IDs of the parent GIE on which this GIE is to operate onComma delimited int32 arrayoperate_on_class_ids: [1, 2]
Operates on objects with class IDs 1, 2 generated by parent GIE
All
Secondary
intervalSpecifies the number of consecutive, batches to be skipped for inference. default is 0uint32interval: 1All
Primary
async_modeEnables inference on detected objects and asynchronous metadata attachments. Works only when tracker-ids are attached. Pushes buffer downstream without waiting for inference results. Attaches metadata after the inferenceboolasync_mode: falseClassifier
Secondary
object_controlinput object filter settingsPluginControl::InputObjectControlobject_control {
bbox_filter {
min_width: 64
min_height: 64
}
}
see details in
InputObjectControl
All
Secondary

Gst-nvinferserver plugin message PluginControl-InputControl definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
process_modeProcessing mode, selected from PluginControl::ProcessMode. In deepstream-app PGIE uses PROCESS_MODE_FULL_FRAME by default, SGIE use PROCESS_MODE_CLIP_OBJECTS by defaultenum PluginControl::ProcessModeprocess_mode: PROCESS_MODE_FULL_FRAMEAll
Both
operate_on_gie_idUnique ID of the GIE on whose metadata (bounding boxes) this GIE is to operate onint32, >=0, valid gie-id.
-1, disable gie-id check, inference on all GIE Ids
operate_on_gie_id: 1All
Secondary
operate_on_class_idsClass IDs of the parent GIE on which this GIE is to operate onComma delimited int32 arrayoperate_on_class_ids: [1, 2]
Operates on objects with class IDs 1, 2 generated by parent GIE
All
Secondary
intervalSpecifies the number of consecutive, batches to be skipped for inference. default is 0uint32interval: 1All
Primary
async_modeEnables inference on detected objects and asynchronous metadata attachments. Works only when tracker-ids are attached. Pushes buffer downstream without waiting for inference results. Attaches metadata after the inferenceboolasync_mode: falseClassifier
Secondary
object_controlinput object filter settingsPluginControl::InputObjectControlobject_control {
bbox_filter {
min_width: 64
min_height: 64
}
}
see details in
InputObjectControl
All
Secondary
secondary_reinfer_intervalRe-inference interval for objects, in framesuint32secondary_reinfer_interval: 90All
Secondary

Gst-nvinferserver plugin message PluginControl-OutputControl definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
output_tensor_metaEnable attaching Inference output tensor metadata, tensor buffer pointer for host onlybooloutput_tensor_meta: falseAll
Both
detect_controlSpecifies detection output filter policyPluginControl::OutputDetectionControldetect_control {
default_filter {
bbox_filter {
min_width: 32
min_height: 32
}
}
}
see details in OutputDetectionControl
Detector
Both
classifier_typeThe classifier type to be added in the NvDsClassifierMeta in case of classification networksstringclassifier_type: multi_class_classificationClassifier
Both

Gst-nvinferserver plugin message PluginControl-InputObjectControl definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
bbox_filterBounding box filterPluginControl::BBoxFilterbbox_filter {
min_width: 32
min_height: 32
}
see details in BBoxFilter
All
Secondary

Gst-nvinferserver plugin message PluginControl-BBoxFilter definition details for Input and Output controls

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
min_widthBounding box minimum widthuint32min_width: 64All
Both
min_heightBounding box minimum heightuint32min_height: 64All
Both
max_widthBounding box maximum width, default 0, max_width is ignoreduint32max_width: 640All
Both
max_heightBounding box maximum height,
default 0, max_height is ignored
uint32max_height: 640All
Both

Gst-nvinferserver plugin message PluginControl-OutputDetectionControl definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
default_filterdefault detection filter for output controlsPluginControl::DetectClassFilterdefault_filter {
bbox_filter {
min_width: 32
min_height: 32
}
}
see details in DetectClassFilter
All
Both
specific_class_filtersspecifies detection filters per class to replace default filtermap<uint32, DetectClassFilter>specific_class_filters: [
{ key: 1, value {…} },
{ key: 2,
value {…} }
]
All
Both
filter_out_class_idsFilter out detected objects belonging to specified class-idsAn array of comma-separated integers (class-ids)filter_out_class_ids: [1, 2]All
Both

Gst-nvinferserver plugin message PluginControl-DetectClassFilter definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
bbox_filterdetection bounding box filterPluginControl::BBoxFilterbbox_filter {
min_width: 64
min_height: 64
}
Detection
Both
roi_top_offsetOffset of the RoI from the top of the frame. Only objects within the RoI are output.uint32roi_top_offset: 128Detection
Both
roi_bottom_offsetOffset of the RoI from the bottom of the frame. Only objects within the RoI are output.uint32roi_bottom_offset:Detection
Both
border_colorspecify border color for detection bounding boxesPluginControl::Colorborder_color {
r: 1.0
g: 0.0
b: 0.0
a: 1.0
}
Detection
Both
bg_colorspecify background color for detection bounding boxesPluginControl::Colorborder_color {
r: 0.0
g: 1.0
b: 0.0
a: 0.5
}
Detection
Both

Gst-nvinferserver plugin message PluginControl-Color definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
rRed color valuefloat
Range[0.0, 1.0]
r: 0.5All
Both
gGreen color valuefloat. Range[0.0, 1.0]g: 0.5All
Both
bBlue color valuefloat. Range[0.0, 1.0]b: 0.3All
Both
aAlpha blending valuefloat. Range[0.0, 1.0]a: 1.0All
Both

Low Level libnvds_infer_server.so Configuration File Specifications

Low Level libnvds_infer_server.so Configuration File Specifications

The message InferenceConfig defines all the low-level structure fields in nvdsinferserver_config.proto. It has major settings for inference backend, network preprocessing and postprocessing.

NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
unique_idUnique ID identifying metadata generated by this GIEuint32, ≥0unique_id: 1All/Both
gpu_idsDevice IDs of GPU to use for pre-processing/inference (single GPU support only)int32 array, ≥0gpu_ids: [0]All/Both
max_batch_sizeMax number of frames/objects to be inferred together in a batchuint32, ≥0max_batch_size: 1All/Both
backendInference backend settingsBackendParamsbackend \{ trt_is \{ ... \} \} see details in BackendParamsAll/Both
preprocessingOne of preprocess or input_tensor_from_meta. Use preprocess if using frame or object processing mode and input_tensor_from_meta when using preprocessed tensor input modepreprocess or input_tensor_from_metaN/A. Refer preprocess and input_tensor_from_meta belowAll/Both
preprocessNetwork preprocessing settings for color conversion, scale and normalization applicable when using frame or object processing modePreProcessParamspreprocess \{ normalize \{ … \} \} see details in PreProcessParamsAll/Both
input_tensor_from_metaConfiguration for the input tensor applicable when using preprocessed tensor as inputInputTensorFromMetainput_tensor_from_meta \{ is_first_dim_batch : true \} see details in InputTensorFromMetaPreprocessed tensor input mode
postprocessInference output tensor parsing methods such as detection, classification, semantic segmentation and othersPostProcessParamspostprocess \{ detection \{...\} \} see details in PostProcessParamsAll/Both
custom_libSpecify custom lib path for custom parsing functions and preloads, optionalCustomLibcustom_lib \{ path : ./libcustom_parsing.so \}All/Both
extraextra controls for inference config.ExtraControlextra \{ output_buffer_pool_size: 2 \} see details in ExtraControlAll/Both
lstmLSTM control parameters, limited on batch-size 1 and single streamLstmParams [optional]lstm \{ loops \{ input: "init_lstm_c" output: "output/lstm_c" init_const \{ value: 0 \} \} \} See details in LstmParamsAll/Both
clip_object_outside_roiClip the object bounding boxes to fit within the specified ROI boundary.boolclip_object_outside_roi: falseDetector/Both
NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
inputsBackend input layer settings, optionalInputLayer arrayssee details in InputLayerAll/Both
outputsBackend output layer settings, optionalOutputLayer arrayssee details in OutputLayerAll/Both
tritonBackend of Triton Inference Server settingsTritonParamssee details in TritonParamsAll/Both
output_mem_typeTriton native output tensor memory typeMemoryType (select from [MEMORY_TYPE_DEFAULT, MEMORY_TYPE_CPU, MEMORY_TYPE_GPU])output_mem_type: MEMORY_TYPE_CPUAll/Both

Gst-nvinferserver message InputLayer definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
nameinput tensor namestringname: “input_0”All
Both
dimsinput tensor shape, optional. Only required if backend cannot figure out fixed input shapesint32 array,
> 0
dims: [299, 299, 3]All
Both
data_typeenum TensorDataType with types:
TENSOR_DT_NONE,
TENSOR_DT_FP32,
TENSOR_DT_FP16,
TENSOR_DT_INT8,
TENSOR_DT_INT16,
TENSOR_DT_INT32,
TENSOR_DT_UINT8,
TENSOR_DT_UINT16,
TENSOR_DT_UINT32
Default TENSOR_DT_NONE,
usually can be deduced from Triton model config.pbtxt
TensorDataTypedata_type:
TENSOR_DT_FP32
All
Both

Gst-nvinferserver message OutputLayer definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
nameoutput tensor namestringname: “detection_boxes”All
Both
max_buffer_bytesoutput tensor reserved buffer bytesuint64max_buffer_bytes: 2048All
Both

Gst-nvinferserver message TritonParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
model_nameTriton inference model namestringmodel_name: “ssd_inception_graphdef”All
Both
versionTriton model version number.
-1, latest version number.
>0, reserved for specific version number in future version
int64version: -1All
Both
model_repoTriton model repository settings.
Note, all model_repo settings must be same in single process
TritonParams::TritonModelRepomodel_repo {
root: “../triton_model_repo”
log_level: 2
}
Refer the details in TritonModelRepo
All
Both
grpcTriton gRPC server settings.TritonParams::TritonGrpcParamsgrpc {
url: “localhost:8001”
enable_cuda_buffer_sharing: false
}
Refer the details in TritonGrpcParams
All
Both
NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
rootTriton inference model repository directory pathstringroot: ”../triton_model_repo”All/Both
log_levelTriton log output levelsuint32; 0, ERROR; 1, WARNING; 2, INFO; >=3, VERBOSE Levellog_level: 1All/Both
strict_model_configEnable Triton strict model configuration, see details in Triton Generated Model Configuration. Suggest setting value trueboolstrict_model_config: trueAll/Both
tf_gpu_memory_fractionTensorFlow GPU memory fraction per process. Valid for Tensorflow models only. Default 0 means no GPU memory limitation. Suggest tuning to a proper value (e.g. in range of [0.2, 0.6]) in case Tensorflow uses up whole GPU memoryfloat, Range (0, 1.0]tf_gpu_memory_fraction: 0.6All/Both
tf_disable_soft_placementDisable TensorFlow soft placement of operators. It’s enabled by default.booltf_disable_soft_placement: falseAll/Both
min_compute_capacitySpecify minimal GPU compute capacity. The default value is 6.0 on x86 and 5.0 on Jetson.floatmin_compute_capacity: 6.0All/Both
backend_dirSpecify Triton backend directory which store Tensorflow/Onnx/Pytorch and custom backends. The Default value is /opt/tritonserver/backends on X86 and opt/nvidia/deepstream/deepstream-x.x/lib/triton_backends on Jetson.stringbackend_dir: /opt/tritonserver/backends/All/Both
cuda_device_memorySpecify a list of CudaDeviceMem blocks with pre-allocated memory pool. Use Triton’s default value if list is empty.message listcuda_device_memory [ { device: 0 memory_pool_byte_size: 2000000000 } ]All/Both
CudaDeviceMem::deviceSpecify device IDuint32; >= 0device: 0All/Both
CudaDeviceMem::memory_pool_byte_sizeIndicate pre-allocated memory pool byte size on according device for Triton runtimeuint64; >= 0memory_pool_byte_size: 8000000000All/Both
pinned_memory_pool_byte_sizeIndicate pre-allocated Pinned memory on host for Triton runtime. Use Triton’s default value (around 256MB) if not set.uint64; >= 0pinned_memory_pool_byte_size: 128000000All/Both
backend_configsA list of BackendConfig blocks for Tritonserver backend config settingsmessage listbackend_configs [ { backend: tensorflow setting: “allow-soft-placement” value: “true” } ]All/Both
BackendConfig::backendSpecify backend namestringbackend: tensorflowAll/Both
BackendConfig::settingSpecify backend setting namestringsetting: “allow-soft-placement”All/Both
BackendConfig::valueSpecify backend setting valuesstringvalue: “true”All/Both
NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
urlTriton server name and portstringurl: “localhost:8001”All/Both
enable_cuda_buffer_sharingEnable sharing of CUDA buffers with local Triton server for input tensors. If enabled, the input CUDA buffers are shared with the Triton server to improve performance. This feature should be enabled only when the Triton server is on the same machine. Applicable for x86 dGPU platform, not supported on Jetson devices. By default disabled i.e. CUDA buffers are copied to system memory while creating the inference request.Boolenable_cuda_buffer_sharing: trueAll/Both
NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
network_formatenum MediaFormat with formats: MEDIA_FORMAT_NONE, IMAGE_FORMAT_RGB, IMAGE_FORMAT_BGR, IMAGE_FORMAT_GRAY. use IMAGE_FORMAT_RGB by default.MediaFormatnetwork_format: IMAGE_FORMAT_RGBAll/Both
tensor_orderenum TensorOrder with order types: TENSOR_ORDER_NONE, TENSOR_ORDER_LINEAR(this includes NCHW, CHW, DCHW, … orders), TENSOR_ORDER_NHWC. It can deduce the value from backend layers info if set to TENSOR_ORDER_NONETensorOrdertensor_order: TENSOR_ORDER_NONEAll/Both
tensor_nameSpecify the tensor name for the preprocessing buffer. This is in the case when multiple input tensors in a single network.string; Optionaltensor_name: “input_0”All/Both
frame_scaling_hwCompute hardware to use for scaling frames / object crops to network resolutionenum FrameScalingHW FRAME_SCALING_HW_DEFAULT: Platform default – GPU (dGPU), VIC (Jetson) FRAME_SCALING_HW_GPU FRAME_SCALING_HW_VIC (Jetson only)frame_scaling_hw: FRAME_SCALING_HW_GPUAll/Both
frame_scaling_filterThe filter to use for scaling frames / object crops to network resolutionint32, refer to enum NvBufSurfTransform_Inter in nvbufsurftransform.h for valid valuesframe_scaling_filter: 1All/Both
maintain_aspect_ratioIndicates whether to maintain aspect ratio while scaling input.int32; 0 or 1maintain_aspect_ratio: 0All/Both
symmetric_paddingIndicates whether to pad image symmetrically while scaling input. DeepStream pads the images asymmetrically by default.int32; 0 or 1symmetric_padding: 0All/Both
normalizeNetwork input tensor normalization settings for scale-factors, offsets and mean-subtractionPreProcessParams::ScaleNormalizenormalize \{ scale_factor: 1.0 channel_offsets: [0, 0, 0] \} see details in PreProcessParams::ScaleNormalizeAll/Both

Gst-nvinferserver message PreProcessParams-ScaleNormalize definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
scale_factorPixel normalization factorfloatscale_factor: 0.0078All
Both
channel_offsetsArray of mean values of color components to be subtracted from each pixel. Array length must equal the number of color components in the frame. The plugin multiplies mean values by scale_factor.float array, Optionalchannel_offsets: [77.5, 21.2, 11.8]All
Both
mean_filePathname of mean data file (PPM format)string;
Optional
mean_file: “./model_meanfile.ppm”All
Both

Gst-nvinferserver message InputTensorFromMeta definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
is_first_dim_batchBoolean indicating whether the preprocessed input tensor has first dimension as batch. Set true for batched input, false otherwise.Booleanis_first_dim_batch: trueAll
Preprocessed tensor input mode

Gst-nvinferserver message PostProcessParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
labelfile_pathPathname of a text file containing the labels for the modelstringlabelfile_path: “=/home/ubuntu/model_labels.txt”All
Both
oneof process_typeIndicates one of the postprocessing type
detection;
classification;
segmentation;
other;
NoneN/AAll
Both
detectionSpecify detection parameters for the network.
It must be oneof process_type
DetectionParamsdetection {
num_detected_classes: 4
simple_cluster {
threshold: 0.2
}
}
see details in DetectionParams
Detector
Both
classificationSpecify classification parameters for the network
It is oneof process_type
ClassificationParamsclassification {
threshold: 0.6
}
see details in ClassificationParams
Classifier
Both
segmentationSpecify semantic segmentation parameters for the network
It is oneof process_type
SegmentationParamssegmentation {
threshold: 0.2
num_segmentation_classes: 2
}
Segmentation
Both
otherSpecify other network parameters.
This is for user-defined networks and usually coexists with output_control.output_tensor_meta: true. Tensor output data would be attached into GstBuffer. Data can be parsed in application. User can increase extra.output_buffer_pool_size if need to hold metadata longer.
It is oneof process_type
OtherNetworkParamsother {}
see details in OtherNetworkParams
Others
Both
triton_classificationSpecify Triton classification parameters for the network
It is oneof process_type
TritonClassifyParamsTriton_classification {
topk: 1
}
see details in TritonClassifyParams
Classifier
Both

Gst-nvinferserver message DetectionParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
num_detected_classesDefine number of classes detected by the networkint32, > 0num_detected_classes:4Detector
Both
per_class_paramsMap of specific detection parameters per class. Key-value follows <class_id: per_class_params> order.map<int32, PerClassParams>;
Optional
per_class_params [
{ key: 1,
value { pre_threshold : 0.4}
},
{ key: 2,
value { pre_threshold : 0.5}
}
]
see details for PerClassParams
Detector
Both
custom_parse_bbox_funcName of the custom bounding box parsing function. If not specified, Gst-nvinferserver uses the internal function for the resnet model provided by the SDK.
If specified, also need to set custom_lib to load custom library.
string;custom_parse_bbox_func: “NvDsInferParseCustomTfSSDDetector
Both
oneof clustering_policyIndicates one of the clustering policies from
nms;
dbscan;
group_rectangle;
simple_cluster;
NoneN/ADetector
Both
nmsIndicates clustering bounding boxes by Non-Maximum-Suppression method detected objects.
It is oneof clustering_policy
Nmsnms {
confidence_threshold: 0.3
iou_threshold: 0.4
}
see details in Nms
Detector
Both
dbscanIndicates clustering bounding boxes by DBSCAN method for detected objects.
It is oneof clustering_policy
DbScandbscan {
pre_threshold: 0.3
eps: 0.7
min_boxes: 3
}
see details in DbScan
Detector
Both
group_rectangleIndicates clustering bounding boxes by groupRectangles() function for grouping detected objects
It is oneof clustering_policy
GroupRectanglegroup_rectangle {
confidence_threshold: 0.2
group_threshold: 2
eps: 0.2
}
Detector
Both
simple_clusterIndicates simple clustering method by outlier boxes through thresholdSimpleClustersimple_cluster {
threshold: 0.2
}
Detector
Both

Gst-nvinferserver message DetectionParams-PerClassParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
pre_thresholdDefine confidence threshold per classfloatpre_threshold:0.3Detector
Both
NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
confidence_thresholdDetection score lesser than this threshold would be rejectedfloatconfidence_threshold:0.5Detector/Both
iou_thresholdMaximum IOU score between two proposals after which the proposal with the lower confidence will be rejected.floatiou_threshold: 0.3Detector/Both
topkSpecify top k detection results to keep after nmsint32, >= 0topk: 2; value 0, means keep all.Detector/Both

Gst-nvinferserver message DetectionParams-DbScan definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
pre_thresholdDetection score lesser than this threshold would be rejected before DBSCAN clusteringfloatpre_threshold:0.2Detector
Both
epsDBSCAN epsilon to control merging of overlapping boxes.floateps: 0.7Detector
Both
min_boxesMinimum boxes in DBSCAN cluster to be considered an objectint32, > 0min_boxes: 3;Detector
Both
min_scoreMinimum score in DBSCAN cluster for it to be considered as an objectfloatmin_score: 0.7
Default value is 0
Detector
Both

Gst-nvinferserver message DetectionParams-GroupRectangle definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
confidence_thresholdDetection score lesser than this threshold would be rejectedfloatconfidence_threshold:0.2Detector
Both
group_thresholdThreshold value for rectangle merging for OpenCV grouprectangles() functionint32; >= 0group_threshold: 1Detector
Both
epsEpsilon to control merging of overlapping boxesfloateps: 0.2Detector
Both

Gst-nvinferserver message DetectionParams-SimpleCluster definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
thresholdDetection score lesser than this threshold would be rejectedfloatconfidence_threshold:0.6Detector
Both

Gst-nvinferserver message ClassificationParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
thresholdClassification score lesser than this threshold would be rejectedfloatthreshold: 0.5Classifier
Both
custom_parse_classifier_funcName of the custom classifier output parsing function.
If not specified, Gst-nvinfer uses the internal parsing function with NCHW tensor order for softmax layers. User can reshape other output tensor order to NCHW in Triton config.pbtxt to run internal parsing.
If specified, also need to set custom_lib to load custom library.
stringparse-classifier-func-name: “parse_bbox_softmax”Classifier
Both

Gst-nvinferserver message SegmentationParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
thresholdSegmentation score lesser than this threshold would be rejectedfloatthreshold: 0.5Segmentation
Both
num_segmentation_classesNumber of output classes for the segmentation networkint32, >0num_segmentation_classes: 2Segmentation
Both
custom_parse_segmentation_funcName of the custom segmentation output parsing function. If not specified, Gst-nvinferserver uses the internal function for the UNet model provided by the SDK. If specified, users also need to set custom_lib to load custom library.stringcustom_parse_segmentation_func: “NvDsInferParseCustomPeopleSemSegNetSegmentation
Both

Gst-nvinferserver message OtherNetworkParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
type_nameSpecify a user-defined network namestring; | Optionaltype_name: “face”Others
Both

Gst-nvinferserver message TritonClassifyParams definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
topkSpecify top k elements need to keep from Triton’s native classificationuint32; >=0topk : 1
Value 0 or empty would keep the top 1 result.
Classifier
Both
thresholdClassification score lesser than this threshold would be rejectedfloatthreshold: 0.5Classifier
Both

Gst-nvinferserver message CustomLib definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
pathPathname that points to a custom library for preloadstringpath: “/home/ubuntu/lib_custom_impl.so”All
Both

Gst-nvinferserver message ExtraControl definition details

NameDescriptionType and RangeExample NotesNetwork Types / Applicable to GIEs (Primary/Secondary)
copy_input_to_host_buffersEnable to copy input. If enabled, input tensor would be attached as NvDsInferTensorMeta into GstBuffer with output tensors together tensor data to host buffers.boolcopy_input_to_host_buffers: falseAll
Both
output_buffer_pool_sizeSpecify the buffer pool size for each output tensor.
When infer_config.postprocess.other is specified or output_control.output_tensor_meta is enabled, the output tensor would be attached as NvDsInferTensorMeta into GstBuffer
int32;
Range [2, 10]
output_buffer_pool_size: 4All
Both
custom_process_funcioncustom function to create a specific user-defined processor IInferCustomProcessor.
The function symbol is loaded by infer_config.custom_lib
Stringpath: “libnvdsinfer_custom_impl_fasterRCNN.soAll
Both

LstmParams structures may be changed in future versions

NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
loopsSpecify LSTM loops between input and output tensors.LstmLoop [repeated]loops [ { input: “init_state” output: “out_state” } ] See details in LstmParams::LstmLoopAll/Both
  • Input and output tensors must have same datatype/dimensions, FP16 is not supported
  • LstmParams::LstmLoop structures might be changed in future versions
NameDescriptionType and RangeExample NotesNetwork Types/Applicable to GIEs (Primary/Secondary)
inputSpecify input tensor name of the current loop.stringInput: “init_state”All/Both
outputSpecify input tensor name of the current loop. Tensor data will feedback to the input tensorstringonput: “output_state”All/Both
init_constSpecify the constant values for the input in first frameInitConst \value: floatInit_const { value: 0 }All/Both

Gst Properties

The values set through Gst properties override the values of properties in the configuration file. The application does this for certain properties that it needs to set programmatically. If user set property though plugin, these values would replace the original value in config files. The following table describes the Gst-nvinferserver plugin’s Gst properties.

Gst-nvinferserver plugin Gst properties

PropertyMeaningType and RangeExample Notes
config-file-pathAbsolute pathname of configuration file for the Gst-nvinferserver elementStringconfig-file-path=config_infer_primary.txt
process-modeInfer Processing Mode
(0):None, (1)FullFrame, (2)ClipObject.
If set, it could replace input_control.process_mode
Integer, 0, 1 or 2process-mode=1
unique-idUnique ID identifying metadata generated by this GIE.
If set, it could replace infer_config.unique_id
Integer,
0 to 4,294,967,295
unique-id=1
infer-on-gie-idSee input_control.operate_on_gie_id in the configuration file tableInteger,
0 to 4,294,967,295
infer-on-gie-id=1
operate-on-class-idsSee input_control.operate_on_class_ids in the configuration file tableAn array of colon- separated integers (class-ids)operate-on-class-ids=1:2:4
batch-sizeNumber of frames/objects to be inferred together in a batch.
If set, it could replace infer_config.max_batch_size
Integer,
1 – 4,294,967,295
batch-size=4
IntervalNumber of consecutive batches to be skipped for inference
If set, it could replace input_control.interval
Integer, 0 to 32interval=0
raw-output-generated-callbackPointer to the raw output generated callback functionPointerCannot be set through gst-launch
raw-output-generated-userdataPointer to user data to be supplied with raw-output-generated-callbackPointerCannot be set through gst-launch

DeepStream Triton samples

DeepStream Triton samples are located in the folder samples/configs/deepstream-app-triton. In terms of Triton model specification, all related models and Triton config files(config.pbtxt) must be gathered into same root directory which is samples/triton_model_repo. Follow the instructions in samples/configs/deepstream-app-triton/README to run the samples.

DeepStream Triton gRPC support

In addition to native Triton server, gst-nvinferserver supports the Triton Inference Server running as independent process. Communication to the server happens through gRPC. Config files to run the application in gRPC mode are located at samples/config/deepstream-app-triton-grpc. Follow the instructions in samples/configs/deepstream-app-triton-grpc/README to run the samples.

Triton Ensemble Models

The Gst-nvinferserver plugin can support Triton ensemble models for further custom preprocessing, backend and postprocessing through Triton custom-backends. Triton ensemble model represents a pipeline of one or more models and the connection of input and output tensors between those models, such as “data preprocessing -> inference -> data postprocessing”. See more details https://github.com/triton-inference-server/server/blob/main/docs/user_guide/architecture.md#ensemble-models. To manage memory efficiency and keep clean interface, The Gst-nvinferserver Plugin’s default preprocessing cannot be disabled. Color conversion, datatype conversion, input scaling and object cropping are continue working in nvds_infer_server natively. For example, in the case native normalization is not needed, update scale_factor to 1.0:

infer_config { preprocess {
network_format: IMAGE_FORMAT_RGB
tensor_order: TENSOR_ORDER_LINEAR
normalize { scale_factor: 1.0 } } }

The low level nvds_infer_server library could deliver specified media-format (RGB/BGR/Gray) in any kind of tensor orders and datatypes as a CUDA GPU buffer input to Triton backend. User’s custom-backend must support GPU memory on this input. Triton custom-backend sample identity can work with Gst-nvinferserver plugin.

Custom backend API must have same Triton codebase version (26.04 for Jetson, 26.03 for x86). Read more details from Triton server releases: x86 release and Jetson release.

To learn details how to implement Triton custom-backend, refer to Triton custom-backend.

For Triton model’s output, TRTSERVER_MEMORY_GPU and TRTSERVER_MEMORY_CPU buffer allocation are supported in nvds_infer_server according to Triton output request. This also works for ensemble model’s final output tensors. Finally, inference data can be parsed by default for detection, classification, or semantic segmentation. Alternatively, user can implement custom-backend for postprocessing, then deliver the final output to Gst-nvinferserver plugin to do further processing. Besides that, User can also optionally attach raw tensor output data into metadata for downstream or application to parse.

Custom Process interface IInferCustomProcessor for Extra Input, LSTM Loop, Output Tensor Postprocess

Gst-nvinferserver plugin supports extra(multiple) input tensors custom preprocessing, input / output tensor custom loop processing (LSTM-based) with multiple streams, output tensor data custom parsing and attaching into NvDsBatchMeta. This custom function is loaded though gst-nvinferserver’s config file:

infer_config {
backend {
triton {
model_name: "yolov3-10_onnx"
# option 1: for CAPI inference
# model_repo { root: "./model_repo" }
# option 2: for gRPC inference
# grpc { url: "localhost:8001" }
}
# specify output tensor memory type, MEMORY_TYPE_CPU/MEMORY_TYPE_GPU
output_mem_type: MEMORY_TYPE_CPU
}
preprocess { ... } # specify scale and normalization
# postprocess{ other{} } # skip generic postprocess
# specify custom processing library
custom_lib {
path: "/path/to/libnvdsinferserver_custom_process.so"
}
extra {
# specify custom processing function entrypoint from custom_lib
custom_process_funcion: "CreateInferServerCustomProcess"
}
}

The interface IInferCustomProcessor is defined in sources/includes/nvdsinferserver/infer_custom_process.h.

class IInferCustomProcessor {
virtual void supportInputMemType(InferMemType& type); // return supported memory type for `extraInputs`
virtual bool requireInferLoop() const; // indicate whether LSTM loop is needed. return 'false' if not needed.
// custom implementation for extra input tensors processing, `primaryInputs` is processed by preprocess{} from config file.
// param `options` is helpful to carry extra information such as stream_ids, `NvBufSurface`, `NvDsBatchMeta`, `GstBuffer`
virtual NvDsInferStatus extraInputProcess(const vector<IBatchBuffer*>& primaryInputs, vector<IBatchBuffer*>& extraInputs, const IOptions* options) = 0;
// param `outputs` is a array of all batched output tensors. param `inOptions` is same as extraInputProcess
virtual NvDsInferStatus inferenceDone(const IBatchArray* outputs, const IOptions* inOptions) = 0;
virtual void notifyError(NvDsInferStatus status) = 0;
};

Users need derive from IInferCustomProcessor to implement their own extra preprocessing through extraInputProcess and fully postprocessing through inferenceDone. the param structured in IOptions carry all information from GstBuffer and NvDsBatchMeta. Users can query them through IOptions for each frame and batch. see more examples in /opt/nvidia/deepstream/deepstream/sources/TritonOnnxYolo/nvdsinferserver_custom_impl_yolo/nvdsinferserver_custom_process_yolo.cpp

Take a example for a simple postprocessing to add output tensors.

#include <inttypes.h>
#include <unistd.h>
#include <cassert>
#include <unordered_map>
#include "infer_custom_process.h"
#include "nvbufsurface.h"
#include "nvdsmeta.h"
typedef struct _GstBuffer GstBuffer;
using namespace nvdsinferserver;
#define INFER_ASSERT assert
class NvInferServerCustomProcess : public IInferCustomProcessor {
// memtype for ``extraInputs``, set ``kGpuCuda`` for performance
void supportInputMemType(InferMemType& type) override { type = InferMemType::kGpuCuda; }
// for LSTM loop. return false if not required.
bool requireInferLoop() const override { return false; }
// skip extraInputProcess if there is no extra input tensors
NvDsInferStatus extraInputProcess(const std::vector<IBatchBuffer*>& primaryInputs, std::vector<IBatchBuffer*>& extraInputs, const IOptions* options) override {
return NVDSINFER_SUCCESS;
}
// output tensor postprocessing function.
NvDsInferStatus inferenceDone(const IBatchArray* outputs, const IOptions* inOptions) override
{
GstBuffer* gstBuf = nullptr;
std::vector<uint64_t> streamIds;
NvDsBatchMeta* batchMeta = nullptr;
std::vector<NvDsFrameMeta*> frameMetaList;
NvBufSurface* bufSurf = nullptr;
std::vector<NvBufSurfaceParams*> surfParamsList;
int64_t unique_id = 0;
INFER_ASSERT (inOptions->getValueArray(OPTION_NVDS_SREAM_IDS, streamIds) == NVDSINFER_SUCCESS);
INFER_ASSERT(inOptions->getObj(OPTION_NVDS_BUF_SURFACE, bufSurf) == NVDSINFER_SUCCESS);
INFER_ASSERT(inOptions->getObj(OPTION_NVDS_BATCH_META, batchMeta) == NVDSINFER_SUCCESS);
INFER_ASSERT(inOptions->getInt(OPTION_NVDS_UNIQUE_ID, unique_id) == NVDSINFER_SUCCESS);
INFER_ASSERT(inOptions->getValueArray(OPTION_NVDS_BUF_SURFACE_PARAMS_LIST, surfParamsList) == NVDSINFER_SUCCESS);
INFER_ASSERT(inOptions->getValueArray(OPTION_NVDS_FRAME_META_LIST, frameMetaList) == NVDSINFER_SUCCESS);
uint64_t nsTimestamp = UINT64_MAX; // nano-seconds
if (inOptions->hasValue(OPTION_TIMESTAMP)) {
INFER_ASSERT(inOptions->getUInt(OPTION_TIMESTAMP, nsTimestamp) == NVDSINFER_SUCCESS);
}
std::unordered_map<std::string, SharedIBatchBuffer> tensors;
for (uint32_t i = 0; i < outputs->getSize(); ++i) {
SharedIBatchBuffer outTensor = outputs->getSafeBuf(i);
INFER_ASSERT(outTensor);
auto desc = outTensor->getBufDesc();
tensors.emplace(desc.name, outTensor);
}
// parsing output tensors
float* boxesPtr = (float*)tensors["output_bbox"]->getBufPtr(0);
auto& bboxDesc = tensors["output_bbox"]->getBufDesc();
float* scoresPtr = (float*)tensors["output_score"]->getBufPtr(0);
float* numPtr = (float*)tensors["output_bbox_num"]->getBufPtr(0);
int32_t batchSize = bboxDesc.dims.d[0]; // e.g. tensor shape [Batch, num, 4]
std::vector<std::vector<NvDsInferObjectDetectionInfo>> batchedObjs(batchSize);
// parsing data into batchedObjs
...
// attach to NvDsBatchMeta
for (int iB = 0; iB < batchSize; ++iB) {
const auto& objs = batchedObjs[iB];
for (const auto& obj : objs) {
NvDsObjectMeta* objMeta = nvds_acquire_obj_meta_from_pool(batchMeta);
objMeta->unique_component_id = unique_id;
objMeta->confidence = obj.detectionConfidence;
objMeta->class_id = obj.classId;
objMeta->rect_params.left = obj.left;
objMeta->rect_params.top = obj.top;
objMeta->rect_params.width = obj.width;
objMeta->rect_params.height = obj.height;
// other settings
...
// add NvDsObjectMeta obj into NvDsFrameMeta frame.
nvds_add_obj_meta_to_frame(frameMetaList[iB], objMeta, NULL);
}
}
}
};
extern "C" {
IInferCustomProcessor* CreateInferServerCustomProcess(const char* config, uint32_t configLen)
{
return new NvInferServerCustomProcess();
} }
  • For extra input tensors preprocess: If the model requires multiple tensor inputs more than the primary image input, Users can derive from this interface IInferCustomProcessor and implement extraInputProcess() to process extra inputs tensors. This function is for extra input process only. the parameter IOptions* options would carry all the information from GstBuffer, NvDsBatchMeta, NvDsFrameMeta, NvDsObjectMeta and so on. User can leverage all of the information from options to fill the extra input tensors. All of the input tensor memory is allocated by nvdsinferserver low-level lib.

  • For output tensor postprocess(parsing and metadata attaching): If user want to do custom parsing on output tensors into user metadata and attach them into GstBuffer, NvDsBatchMeta, NvDsFrameMeta or NvDsObjectMeta. User can implement ‘inferenceDone(outputs, inOptions)’ to parse all output tensors in outputs, and get above GstBuffer, NvDsBatchMeta and other DeepStream information from inOptions. Then attach the parsed user metadata into NvDs metadata. This function supports multiple-streams parsing and attaching. See examples in /opt/nvidia/deepstream/deepstream/sources/TritonOnnxYolo/nvdsinferserver_custom_impl_yolo/nvdsinferserver_custom_process_yolo.cpp: NvInferServerCustomProcess::inferenceDone() how to parse and attach output metadata.

If user need specific memory type(e.g. CPU) for output tensors in inferenceDone(). Update config file.

text infer_config { backend { output_mem_type: MEMORY_TYPE_CPU } }

  • For multi-stream custom loop process: If the model is LSTM based, and next frame’s inputs are generated by previous frame’s output data. User can derive interface IInferCustomProcessor, then implement extraInputProcess() and inferenceDone() for loop process. extraInputProcess() could initialize first input tensor states. Then 'inferenceDone()' can get the output data and do post processing and store the result into the context. When next 'extraInputProcess()' is coming, it can check the stored results and feedback into tensor states. When user override bool requireInferLoop() const { return true; }. The nvdsinferver low-level lib shall keep the extraInputProcess and inferenceDone running in sequence along with its nvds_stream_ids which could be get from options->getValueArray(OPTION_NVDS_SREAM_IDS, streamIds). see examples and details in /opt/nvidia/deepstream/deepstream/sources/TritonOnnxYolo/nvdsinferserver_custom_impl_yolo/nvdsinferserver_custom_process_yolo.cpp. Inside this example, see function NvInferServerCustomProcess::feedbackStreamInput how to feedback output into next input loop.

Tensor Metadata Output for Downstream Plugins

The Gst-nvinferserver plugin can attach raw output tensor data generated by the inference backend as metadata. It is added as an NvDsInferTensorMeta in the frame_user_meta_list member of NvDsFrameMeta for primary (full frame) mode, or in the obj_user_meta_list member of NvDsObjectMeta for secondary (object) mode. It uses same metadata structure with Gst-nvinferserver plugin.

Gst-nvinferserver plugin does not attach device buffer pointer NvDsInferTensorMeta::attach out_buf_ptrs_dev at this moment.

To read or parse inference raw tensor data of output layers

  1. Enable the following fields in the configuration file for the Gst-nvinferserver plugin:

    output_control { output_tensor_meta : true }

    If native postprocessing need be disabled, update:

    infer_config { postprocess { other {} } }
  2. When operating as primary GIE, NvDsInferTensorMeta is attached to each frame’s (each NvDsFrameMeta object’s) frame_user_meta_list. When operating as secondary GIE, NvDsInferTensorMeta is attached to each NvDsObjectMeta object’s obj_user_meta_list.

    Metadata attached by Gst-nvinferserver can be accessed in a GStreamer pad probe attached downstream from the Gst-nvinferserver instance.

  3. The NvDsInferTensorMeta object’s metadata type is set to NVDSINFER_TENSOR_OUTPUT_META. To get this metadata you must iterate over the NvDsUserMeta user metadata objects in the list referenced by frame_user_meta_list or obj_user_meta_list.

For more information about Gst-infer tensor metadata usage, see the source code in sources/apps/sample_apps/deepstream_infer_tensor_meta-test.cpp, provided in the DeepStream SDK samples.

Segmentation Metadata

The Gst-nvinferserver plugin attaches the output of the semantic segmentation model as user metadata in an instance of NvDsInferSegmentationMeta with meta_type set to NVDSINFER_SEGMENTATION_META. The user metadata is added to the frame_user_meta_list member of NvDsFrameMeta for primary (full frame) mode, or the obj_user_meta_list member of NvDsObjectMeta for secondary (object) mode. For guidance on how to access user metadata, see User/Custom Metadata Addition Inside NvDsMatchMeta and Tensor Metadata, above.