NVIDIA DeepStream SDK API Reference

4.0.1 Release

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
Custom Model API

Detailed Description

An API for implementing custom models.

Data Structures

struct  NvDsInferParseDetectionParams
 Holds the detection parameters required for parsing objects. More...
 
union  NvDsInferPluginFactoryCaffe
 Holds the pointer to a heap allocated Plugin Factory object required during Caffemodel parsing. More...
 
union  NvDsInferPluginFactoryUff
 Holds the pointer to a heap allocated Plugin Factory object required during UFF model parsing. More...
 

Macros

#define CHECK_CUSTOM_PARSE_FUNC_PROTOTYPE(customParseFunc)
 Macro to validate the custom parser function definition. More...
 
#define CHECK_CUSTOM_CLASSIFIER_PARSE_FUNC_PROTOTYPE(customParseFunc)
 Macro to validate the classifier custom parser function definition. More...
 

Typedefs

typedef bool(* NvDsInferParseCustomFunc )(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, NvDsInferParseDetectionParams const &detectionParams, std::vector< NvDsInferObjectDetectionInfo > &objectList)
 Function definition for the custom bounding box parsing function. More...
 
typedef bool(* NvDsInferClassiferParseCustomFunc )(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, float classifierThreshold, std::vector< NvDsInferAttribute > &attrList, std::string &descString)
 Function definition for the custom classifier output parsing function. More...
 
typedef struct
_NvDsInferContextInitParams 
NvDsInferContextInitParams
 

Enumerations

enum  NvDsInferPluginFactoryType {
  PLUGIN_FACTORY,
  PLUGIN_FACTORY_EXT,
  PLUGIN_FACTORY_V2
}
 Specifies the type of the Plugin Factory. More...
 

Functions

bool NvDsInferPluginFactoryCaffeGet (NvDsInferPluginFactoryCaffe &pluginFactory, NvDsInferPluginFactoryType &type)
 Returns an instance of a newly allocated Plugin Factory interface to be used during parsing of caffe models. More...
 
void NvDsInferPluginFactoryCaffeDestroy (NvDsInferPluginFactoryCaffe &pluginFactory)
 Destroy the Plugin Factory instance returned in NvDsInferPluginFactoryCaffeGet More...
 
bool NvDsInferPluginFactoryUffGet (NvDsInferPluginFactoryUff &pluginFactory, NvDsInferPluginFactoryType &type)
 Returns an instance of a newly allocated Plugin Factory interface to be used during parsing of UFF models. More...
 
void NvDsInferPluginFactoryUffDestroy (NvDsInferPluginFactoryUff &pluginFactory)
 Destroy the Plugin Factory instance returned in NvDsInferPluginFactoryUffGet More...
 
bool NvDsInferPluginFactoryRuntimeGet (nvinfer1::IPluginFactory *&pluginFactory)
 Returns an instance of a newly allocated Plugin Factory interface to be used during parsing deserialization of cuda engines. More...
 
void NvDsInferPluginFactoryRuntimeDestroy (nvinfer1::IPluginFactory *pluginFactory)
 Destroy the PluginFactory instance returned in NvDsInferPluginFactoryRuntimeGet More...
 
bool NvDsInferInitializeInputLayers (std::vector< NvDsInferLayerInfo > const &inputLayersInfo, NvDsInferNetworkInfo const &networkInfo, unsigned int maxBatchSize)
 Initialize the input layers for inference. More...
 
bool NvDsInferCudaEngineGet (nvinfer1::IBuilder *builder, NvDsInferContextInitParams *initParams, nvinfer1::DataType dataType, nvinfer1::ICudaEngine *&cudaEngine)
 Build and return CudaEngine for custom models. More...
 

Macro Definition Documentation

#define CHECK_CUSTOM_CLASSIFIER_PARSE_FUNC_PROTOTYPE (   customParseFunc)
Value:
static void checkFunc_ ## customParseFunc (NvDsInferClassiferParseCustomFunc func = customParseFunc) \
{ checkFunc_ ## customParseFunc (); }; \
extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
NvDsInferNetworkInfo const &networkInfo, \
float classifierThreshold, \
std::vector<NvDsInferAttribute> &attrList, \
std::string &descString);
bool(* NvDsInferClassiferParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, float classifierThreshold, std::vector< NvDsInferAttribute > &attrList, std::string &descString)
Function definition for the custom classifier output parsing function.
Holds information about the model network.
Definition: nvdsinfer.h:102

Macro to validate the classifier custom parser function definition.

Should be called after defining the function.

Definition at line 189 of file nvdsinfer_custom_impl.h.

#define CHECK_CUSTOM_PARSE_FUNC_PROTOTYPE (   customParseFunc)
Value:
static void checkFunc_ ## customParseFunc (NvDsInferParseCustomFunc func = customParseFunc) \
{ checkFunc_ ## customParseFunc (); }; \
extern "C" bool customParseFunc (std::vector<NvDsInferLayerInfo> const &outputLayersInfo, \
NvDsInferNetworkInfo const &networkInfo, \
NvDsInferParseDetectionParams const &detectionParams, \
std::vector<NvDsInferObjectDetectionInfo> &objectList);
Holds the detection parameters required for parsing objects.
bool(* NvDsInferParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, NvDsInferParseDetectionParams const &detectionParams, std::vector< NvDsInferObjectDetectionInfo > &objectList)
Function definition for the custom bounding box parsing function.
Holds information about the model network.
Definition: nvdsinfer.h:102

Macro to validate the custom parser function definition.

Should be called after defining the function.

Definition at line 158 of file nvdsinfer_custom_impl.h.

Typedef Documentation

typedef bool(* NvDsInferClassiferParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, float classifierThreshold, std::vector< NvDsInferAttribute > &attrList, std::string &descString)

Function definition for the custom classifier output parsing function.

Parameters
[in]outputLayersInfoVector containing information on the output layers of the model.
[in]networkInfoNetwork information.
[in]classifierThresholdClassification confidence threshold
[out]attrListReference to a vector in which the function should add the parsed attributes.
[out]descStringReference to a string object in which the function may place a description string.

Definition at line 178 of file nvdsinfer_custom_impl.h.

typedef bool(* NvDsInferParseCustomFunc)(std::vector< NvDsInferLayerInfo > const &outputLayersInfo, NvDsInferNetworkInfo const &networkInfo, NvDsInferParseDetectionParams const &detectionParams, std::vector< NvDsInferObjectDetectionInfo > &objectList)

Function definition for the custom bounding box parsing function.

Parameters
[in]outputLayersInfoVector containing information on the output layers of the model.
[in]networkInfoNetwork information.
[in]detectionParamsDetection parameters required for parsing objects.
[out]objectListReference to a vector in which the function should add the parsed objects.

Definition at line 148 of file nvdsinfer_custom_impl.h.

Enumeration Type Documentation

Specifies the type of the Plugin Factory.

Enumerator
PLUGIN_FACTORY 

nvcaffeparser1::IPluginFactory / nvuffparser::IPluginFactory

PLUGIN_FACTORY_EXT 

nvcaffeparser1::IPluginFactoryExt / nvuffparser::IPluginFactoryExt

PLUGIN_FACTORY_V2 

Only for caffe models.

nvcaffeparser1::IPluginFactoryV2

Definition at line 201 of file nvdsinfer_custom_impl.h.

Function Documentation

bool NvDsInferCudaEngineGet ( nvinfer1::IBuilder *  builder,
NvDsInferContextInitParams initParams,
nvinfer1::DataType  dataType,
nvinfer1::ICudaEngine *&  cudaEngine 
)

Build and return CudaEngine for custom models.

The implementation of this interface should build the nvinfer1::ICudaEngine instance using supplied nvinfer1::IBuilder instance. The builder instance is managed by the caller. The implementation should not destroy the instance.

Properties like MaxBatchSize, MaxWorkspaceSize, INT8/FP16 precision parameters, DLA parameters if applicable will already be set on the builder before being passed to the interface. The corresponding Get functions of nvinfer1::IBuilder interface can be used to get the property values.

The implementation should make sure not to reduce the MaxBatchSize of the returned CudaEngine.

Parameters
[in]buildernvinfer1::IBuilder instance
[in]initParamsPointer to the structure used for initializing the NvDsInferContext instance.
[in]dataTypeData precision
[out]cudaEnginePointer to the built nvinfer1::ICudaEngine instance.
Returns
Boolean indicating that engine build was successful.
bool NvDsInferInitializeInputLayers ( std::vector< NvDsInferLayerInfo > const &  inputLayersInfo,
NvDsInferNetworkInfo const &  networkInfo,
unsigned int  maxBatchSize 
)

Initialize the input layers for inference.

This function is only called once during before the first inference call.

Parameters
[in]inputLayersInfoVector containing information on the input layers of the model. This does not contain the NvDsInferLayerInfo structure for the layer for video frame input.
[in]networkInfoNetwork information.
[in]maxBatchSizeMaximum batch size for inference. The buffers for input layers are allocated for this batch size.
Returns
Boolean indicating that input layers were successfully initialized.
void NvDsInferPluginFactoryCaffeDestroy ( NvDsInferPluginFactoryCaffe pluginFactory)

Destroy the Plugin Factory instance returned in NvDsInferPluginFactoryCaffeGet

Parameters
[in]pluginFactoryReference to NvDsInferPluginFactoryCaffe union holding the pointer to the Plugin Factory instance returned in NvDsInferPluginFactoryCaffeGet.
bool NvDsInferPluginFactoryCaffeGet ( NvDsInferPluginFactoryCaffe pluginFactory,
NvDsInferPluginFactoryType type 
)

Returns an instance of a newly allocated Plugin Factory interface to be used during parsing of caffe models.

The function must set the correct type and the correct field inside the NvDsInferPluginFactoryCaffe union based on the type of the Plugin Factory (i.e. one of pluginFactory, pluginFactoryExt or pluginFactoryV2).

Parameters
[out]pluginFactoryA reference to the NvDsInferPluginFactoryCaffe union
[out]typeEnum indicating the type of the returned Plugin Factory instance (i.e. the valid field in the NvDsInferPluginFactoryCaffe union)
Returns
Boolean indicating that the creation of the Plugin Factory was successful.
void NvDsInferPluginFactoryRuntimeDestroy ( nvinfer1::IPluginFactory *  pluginFactory)

Destroy the PluginFactory instance returned in NvDsInferPluginFactoryRuntimeGet

Parameters
[in]pluginFactoryPluginFactory instance returned in NvDsInferPluginFactoryRuntimeGet
bool NvDsInferPluginFactoryRuntimeGet ( nvinfer1::IPluginFactory *&  pluginFactory)

Returns an instance of a newly allocated Plugin Factory interface to be used during parsing deserialization of cuda engines.

Parameters
[out]pluginFactoryA reference to nvinfer1::IPluginFactory* in which the function must place the pointer to the instance.
Returns
Boolean indicating that the creation of the Plugin Factory was successful.
void NvDsInferPluginFactoryUffDestroy ( NvDsInferPluginFactoryUff pluginFactory)

Destroy the Plugin Factory instance returned in NvDsInferPluginFactoryUffGet

Parameters
[in]pluginFactoryReference to NvDsInferPluginFactoryUff union holding the pointer to the Plugin Factory instance returned in NvDsInferPluginFactoryUffGet.
bool NvDsInferPluginFactoryUffGet ( NvDsInferPluginFactoryUff pluginFactory,
NvDsInferPluginFactoryType type 
)

Returns an instance of a newly allocated Plugin Factory interface to be used during parsing of UFF models.

The function must set the correct type and the correct field inside the NvDsInferPluginFactoryUff union based on the type of the Plugin Factory (i.e. one of pluginFactory or pluginFactoryExt)

Parameters
[out]pluginFactoryA reference to the NvDsInferPluginFactoryUff union
[out]typeEnum indicating the type of the returned Plugin Factory instance (i.e. the valid field in the NvDsInferPluginFactoryUff union)
Returns
Boolean indicating that the creation of the Plugin Factory was successful.