How do I use createPriorBoxPlugin and createNMSPlugin to get detection boxes?

o Linux distro and version Windows 10
o GPU type Geforce 1660ti
o Nvidia driver version 441.22
o CUDA version 10.2
o CUDNN version 7.6.5
o TensorRT version

For using createPriorBoxPlugin and createNMSPlugin to get detection boxes, I wrote the code below, but it does not work, I got the wrong result. The code with green color is where I think I may make mistakes. So could you tell me where is wrong and how to use these two function rightly. Expecting for the answer, thank you very much.

#include <NvInferPlugin.h>
nvinfer1::ITensor *Trtnet::getNMS(nvinfer1::INetworkDefinition *network, nvinfer1::ITensor *loc, nvinfer1::ITensor *conf)
nvinfer1::ITensor *output;
nvinfer1::plugin::PriorBoxParameters prior_box_params;
float min_size[6] = { 30.72f, 76.8f, 168.96f, 261.12f, 353.28f, 445.44f };
float max_size[6] = { 76.8f, 168.96f, 261.12f, 353.28f, 445.44f, 537.6f };
float aspect_ratio[2] = { 2.0f, 3.0f };
float variance[4] = { 0.1f, 0.1f, 0.2f, 0.2f };
prior_box_params.minSize = min_size;
prior_box_params.maxSize = max_size;
prior_box_params.numMinSize = 6;
prior_box_params.numMaxSize = 6;
prior_box_params.aspectRatios = aspect_ratio;
prior_box_params.numAspectRatios = 2;
prior_box_params.flip = true;
prior_box_params.clip = true;
prior_box_params.imgH = kINPUT_H;
prior_box_params.imgW = kINPUT_W;
prior_box_params.stepH = 8;
prior_box_params.stepW = 8;
prior_box_params.offset = 0;
for (int i = 0; i < 4; i++)
prior_box_params.variance[i] = variance[i];
nvinfer1::IPluginV2 * prior_boxes = createPriorBoxPlugin(prior_box_params);

    nvinfer1::ITensor *prior_boxes_out = network->addPluginV2(NULL, 0, *prior_boxes)->getOutput(0);
    nvinfer1::plugin::DetectionOutputParameters decode_output_params;
    decode_output_params.shareLocation = true;
    decode_output_params.varianceEncodedInTarget = true;
    decode_output_params.backgroundLabelId = -1;
    decode_output_params.numClasses = 81;
    decode_output_params.topK = 300;
    decode_output_params.keepTopK = 50;
    decode_output_params.confidenceThreshold = 0.2;
    decode_output_params.nmsThreshold = 0.45;
    decode_output_params.codeType = nvinfer1::plugin::CodeTypeSSD::CENTER_SIZE;
    decode_output_params.confSigmoid = false;
    for (int i = 0; i < 3; i++)
decode_output_params.inputOrder[i] = i;
    decode_output_params.isNormalized = false;
    nvinfer1::ITensor *inputs[3];
    inputs[0] = loc;
    inputs[1] = conf;
    inputs[2] = prior_boxes_out;
    nvinfer1::IPluginV2 *NMS = createNMSPlugin(decode_output_params);
    output = network->addPluginV2(inputs, 3, *NMS)->getOutput(0);
    return output;



Please refer to below sample for NMS plugin implementation:


Thank you very much, first of all.
I want to use the API derectly but through the uff parser, I think the sample has used NMS through the uff parser, but I do not want to use any parser. Does there any documentation or open source code which could tell me about how to use it derectly in my function?
Thanks again.

I have found some infomations in the sample_ssd_v2.uff.txt, may be it is useful for me, am I right?


Could you please elaborate more on the error you are getting in this case?
Can you give a minimal run-able sample? Or at least open the verbose and paste logs?