Postprocessing
Function Description
Typically, a postprocessing code file is provided once a model file is acquired. It is advised to employ the same postprocessing procedure as used during model training to ensure the inference results align with expectations.
Vision SDK encapsulates distinct postprocessing functions for various classic models to carry out their postprocessing operations. The data from model inference is directly passed to the postprocessing interface to obtain the final result, which significantly streamlines the usage process.
For details about related APIs, see Model Postprocessing.
API Calling Process
Figure 1 API calling process


When using the postprocessing function, you need to link the DLL file (.so) for model postprocessing in the CMakeLists.txt file. The following uses YOLOv3 as an example:
target_link_libraries(main mxbase yolov3postprocess ...)
Sample Code
The following is an example of the postprocessing function for YOLOv3 based on Vision SDK. It is for reference only and cannot be directly copied for compilation and running.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // 1. Initialization // Step 1: Construct the input of postprocessing Init. std::map<std::string, std::string> postConfig; postConfig.insert(pair<std::string, std::string>("postProcessConfigPath", yoloV3ConfigPath)); // Path of the model postprocessing configuration file postConfig.insert(pair<std::string, std::string>("labelPath", yoloV3LabelPath)); // Path of the label file // Step 2: Execute the postprocessing Init function. Yolov3PostProcess yolov3PostProcess; yolov3PostProcess.Init(postConfig); // 2. Perform postprocessing. // Step 1: Build postprocessing input tensors based on the YOLOv3 inference result. std::vector<TensorBase> tensors; for (size_t i = 0; i < yoloV3Outputs.size(); i++) { MemoryData memoryData(yoloV3Outputs[i].GetData(), yoloV3Outputs[i].GetByteSize()); TensorBase tensorBase(memoryData, true, yoloV3Outputs[i].GetShape(), TENSOR_DTYPE_INT32); tensors.push_back(tensorBase); } // Step 2: Create a postprocessing output. std::vector<std::vector<ObjectInfo>> objectInfos; // Step 3: Perform postprocessing. yolov3PostProcess.Process(tensors, objectInfos, imagePreProcessInfos); |
Parent topic: Development Using APIs (C++)