Post-processing Class Development Procedure

  1. Based on the task type, select a post-processing base class supported by the SDK to derive a new subclass. Supported post-processing base classes are object detection, classification task, semantic segmentation, and text generation. These base classes all inherit from the same parent class, PostProcessBase.

    In the Init function, the Init() API of the parent class needs to be called to read configuration parameters, and then the configData_.GetFileValue() API of the parent class object needs to be called to read the configuration parameters required by the subclass.

    In the Process function, the model output tensors are used as the input, and the corresponding data structure class object is used as the output.

  2. Call the CheckAndMoveTensors() API of the parent class to verify the tensor shapes and transfer the memory to the host. Then, perform corresponding operations to obtain the result.
  3. After the post-processing development is complete, add an external API, for example, GetObjectInstance(), so that the post-processing plugin in the service stream can dynamically load the .so file of the post-processing.

    If the data structure used by the current post-processing base class cannot meet the requirements, you can add a post-processing base class to inherit PostProcessBase and write a new data structure.

// 1. Object detection data structure:
class ObjectInfo {
public:
    float x0;
    float y0;
    float x1;
    float y1;
    float confidence;
    float classId;
    std::string className;
    std::vector<std::vector <int>> mask; // Instance segmentation
};

// 2. Classification task data structure:
class ClassInfo {
public:
    int classId;
    float confidence;
    std::string className;
};

// 3. Semantic segmentation data structure:
class SemanticSegInfo {
public:
    std::vector<std::vector<int>> pixels;
    std::vector<std::string> labelMap;
};

// 4. Text generation (machine translation, optical character recognition, and speech recognition) API:
class TextsInfo {
public:
    std::vector<std::string> text;
};

// 5. Text box detection API:
class TextObjectInfo {
public:
    float x0;
    float y0;
    float x1;
    float y1;
    float x2;
    float y2;
    float x3;
    float y3;
    float confidence;
    std::string result;
};
Figure 1 UML class diagram of supported model post-processing