Base Classes for Post-processing Plugins
A model postprocessing plugin is used to postprocess the output tensor of model inference and write the corresponding result to the metadata. The input and output types required for postprocessing of different inference job types are different. Therefore, different postprocessing plugins are required. To facilitate reuse, MindX SDK has extracted some APIs and members to the postprocessing base class. For each type of job, such as the object detection job, the postprocessing .so file is dynamically loaded to support polymorphism of various models (such as YOLOv3, Faster R-CNN, and SsdVgg-16).
|
Function |
Performs postprocessing on the output tensor of model inference. |
|---|---|
|
Constraints |
The postprocessing plugins can be used after being connected to the mxpi_tensorinfer inference plugin. Only MxpiTensorPackageList can be used as the metadata input. The parent class does not generate plugins, and the child class inherits the plugins generated by the parent class. |
|
Parent Class |
MxModelPostProcessorBase and MxImagePostProcessorBase (image postprocessing base class, inherited from MxModelPostProcessorBase) |
|
Input/Output |
Input: buffer (data type: MxpiBuffer) and metadata (data type: MxpiTensorPackageList) Output: buffer (data type: MxpiBuffer) and metadata (data type: MxpiObjectList, MxpiClassList, MxpiImageMaskList, or MxpiTextObjectList) |
|
Port Format (Caps) |
Static input: {"metadata/tensor"} Static output: subclass overriding |
|
Property |
For details, see Table 1. |
|
Property Name |
Description |
Mandatory or Not |
Modifiable or Not |
|---|---|---|---|
|
deviceId |
Ascend device ID, which is specified by the deviceId property in the stream_config field. You do not need to set the ID. |
No |
Yes |
|
postProcessLibPath |
Path of the .so file of the postprocessing DLL. If this property is not specified, the model inference result is directly written to the metadata MxpiTensorPackageList and output to the position specified by outputDeviceId. |
Yes |
Yes |
|
labelPath |
Path of the postprocessing class label |
No |
Yes |
|
dataSource |
Index of the input data (generally the name of the upstream element). The default value is the key value of the output port of the upstream plugin. |
No |
Yes |
|
postProcessConfigPath |
Path of the postprocessing configuration file |
Generally required |
Yes |
|
postProcessConfigContent |
Post-processing configuration |
No |
Yes |
|
dataSourceResize |
This property is available only in the subclass plugins that inherit MxImagePostProcessorBase (image postprocessing base class). Whether to map the coordinates in the postprocessing of the model back to the image before scaling. If this property is not set, the value is obtained from the previous plugin of the inference plugin by default. If the value cannot be obtained, the coordinates are not scaled. |
No |
Yes |
|
dataSourceRoiBoxes |
This property is available only in the subclass plugins that inherit MxImagePostProcessorBase (image postprocessing base class). Specifies whether to map the coordinates of the model inference to the source image before cropping. If this property is not set, the image is not mapped to the source image by default. To map the image, set the property to the name of the image cropping plugin. |
No |
Yes |
|
dataSourceImage |
It is under internal debugging. Do not use it. |
No |
No |
|
Property Name |
Description |
Mandatory or Not |
Modifiable or Not |
|---|---|---|---|
|
funcLanguage |
Development language of the postprocessing plugin, that is, C++ or Python |
No |
Yes |
|
postProcessLibPath |
Directory of the postprocessing DLL SO file. This directory contains the postprocessing Python file or SO file |
Yes |
Yes |
|
className |
Post-processing class name |
Yes |
Yes |
|
pythonModule |
Name of the loaded postprocessing module, which is the same as the module name in Python or SO file |
Yes |
Yes |
|
labelPath |
Path of the postprocessing class label |
No |
Yes |
|
dataSource |
Index of the input data (generally the name of the upstream element) |
Recommended |
Yes |
|
postProcessConfigPath |
Path of the postprocessing configuration file |
Generally required |
Yes |
|
deviceId |
Ascend device ID, which is specified by the deviceId property in the stream_config field. You do not need to set the ID. |
No |
Yes |
|
dataSourceResize |
This property is available only in the subclass plugins that inherit MxImagePostProcessorBase (image postprocessing base class). Whether to map the coordinates in the postprocessing of the model back to the image before scaling. If this property is not set, the value is obtained from the previous plugin of the inference plugin by default. If the value cannot be obtained, the coordinates are not scaled. |
No |
Yes |
|
dataSourceRoiBoxes |
This property is available only in the subclass plugins that inherit MxImagePostProcessorBase (image postprocessing base class). Specifies whether to map the coordinates of the model inference to the source image before cropping. If this property is not set, the image is not mapped to the source image by default. To map the image, set the property to the name of the image cropping plugin. |
No |
Yes |