How to Modify NMS InputOrder in sampleUffSSD config.py

In TensorRT-6.0.1.5\samples\sampleUffSSD\config.py I find :

NMS = gs.create_plugin_node(name="NMS", op="NMS_TRT",
    shareLocation=1,
    varianceEncodedInTarget=0,
    backgroundLabelId=0,
    confidenceThreshold=1e-8,
    nmsThreshold=0.6,
    topK=100,
    keepTopK=100,
    numClasses=91,
    inputOrder=[0, 2, 1],
    confSigmoid=1,
    isNormalized=1)

What I know is that “inputOrder=[0,2,1]” set the input order of NMS Node,each number represent a node of locData\confData\priorData.But how can I get relationship between number and each node? In other way,What is locData’s number?

Hi,

Specifies the order of inputs {loc_data, conf_data, priorbox_data}.
In other words, inputOrder[0] is for loc_data, inputOrder[1] is for conf_data and inputOrder[2] is for priorbox_data.

For example, if your inputs in the memory are in the order of loc_data, priorbox_data, conf_data, then inputOrder should be [0, 2, 1].

Thanks

Hi @SunilJB:

Yes,I know inputOrder[0] is for loc_data, inputOrder[1] is for conf_data and inputOrder[2] is for priorbox_data.
But how can I know the order of {loc_data, conf_data, priorbox_data} in my memory? I use coverter-to-uff tool to covert a tf modle to uff. In old uff version, the order of {loc_data, conf_data, priorbox_data} will show in console when converting,but in the newest version UFF tool,it only print input node. And I realized the order of {loc_data, conf_data, priorbox_data} in memory maybe different if I use different UFF tool,though I covert form the same PB model.

In my experiment,UFF tool is in TRT 5.0.4.3 and TRT 6.0.1.5. the order of {loc_data, conf_data, priorbox_data} in my memory is [1,2,0] and [0,2,1].

Hi,

The order of {loc_data, conf_data, priorbox_data} will be based on the NMS setting in your .pbtxt file:

For example if:

id: "NMS"
    inputs: "concat_box_conf"
    inputs: "concat_box_loc"
    inputs: "concat_priorbox"

Then {loc_data, conf_data, priorbox_data} will be [1 0 2]

Thanks

Sorry,I don’t know where to find my .pbtxt file.

Which step uses that file?

Dose it use to frozen .ckpt to .pb?

I find code to covert .pb to .pbtxt.

import tensorflow as tf
from tensorflow.python.platform import gfile
from google.protobuf import text_format
 
def convert_pb_to_pbtxt(filename):
  with gfile.FastGFile(filename,'rb') as f:
    graph_def = tf.GraphDef()
 
    graph_def.ParseFromString(f.read())
 
    tf.import_graph_def(graph_def, name='')
 
    tf.train.write_graph(graph_def, './', 'protobuf.pbtxt', as_text=True)
  return
 
def convert_pbtxt_to_pb(filename):
  """Returns a `tf.GraphDef` proto representing the data in the given pbtxt file.
  Args:
    filename: The name of a file containing a GraphDef pbtxt (text-formatted
      `tf.GraphDef` protocol buffer data).
  """
  with tf.gfile.FastGFile(filename, 'r') as f:
    graph_def = tf.GraphDef()
 
    file_content = f.read()
 
    # Merges the human-readable string in `file_content` into `graph_def`.
    text_format.Merge(file_content, graph_def)
    tf.train.write_graph( graph_def , './' , 'protobuf.pb' , as_text = False )

I try it today.