Post-processing Class Development Procedure

The development procedure is as follows (for details about the header file, source file, and CMakeLists.txt required by the post-processing dynamic library, see Post-processing Code of the Model Sample):

  1. Inherit the ModelPostProcessorBase base class in ModelPostProcessorBase.h and customize the post-processing class name.

  2. Rewrite the three member functions Init(), DeInit(), and Process() in the base class. For details, see Table 1.

  3. You can rewrite CheckModelCompatibility to verify the output shape of the read model.
  4. Implement the std::shared_ptr<ModelPostProcessorBase> GetInstance() API function in the post-processing class.

Table 1 Member functions

Member Function

Description

Init()

This API is called only once to obtain configuration parameters and initialize service logic.

DeInit()

This API is called only once to deinitialize a job (for example, releasing the memory).

Process()

This API is driven by data and is used to receive data from upstream plugins, process the model output, and write the processing results to the metadata.

MemoryDataToHost

(Optional) This API is used to transfer the inference result tensors transferred by the upstream inference plugin to the host.

LoadConfigDataAndLabelMap

(Optional) This API is called by Init() to obtain configuration parameters.

GetModelTensorsShape

(Optional) This API is called by Init() to obtain the input and output tensor shapes of a model.

CheckModelCompatibility

(Optional) This API is called by Init() to verify the output shapes of the read model.

For object detection models, the post-processing can also depend on the developed ObjectPostProcessorBase base class.

Table 2 Member functions

Member Function

Description

Init()

This API is called only once to obtain configuration parameters.

DeInit()

This API is called only once to deinitialize a job (for example, releasing the memory).

Process()

This API is driven by data and is used to process the model output, such as deduplication, sorting, and filtering, and write the processing results to the metadata.

ObjectDetectionOutput

This API is called by Process() to process the model output, such as deduplication, sorting, and filtering.

Avoid using static variables in post-processing dynamic libraries. Ensure that multiple post-processing dynamic library instances do not interfere with each other.