Hello I’ve been trying to convert my object_detection ssd model from tensorflow 1.8,
I’ve converted the layers using the following python script. All the parameters are carefully matched to the tensorflow model.
import graphsurgeon as gs
import tensorflow as tf
Input = gs.create_node(
"Input",
op="Placeholder",
dtype=tf.float32,
shape=[1, 3, 1600, 1600])
PriorBox = gs.create_node(
"PriorBox",
numLayers=6,
minScale=0.1,
maxScale=0.2,
aspectRatios=[1.0, 2.0, 0.5],
layerVariances=[0.1, 0.1, 0.2, 0.2],
featureMapShapes=[200, 100, 50, 25, 13, 6])
NMS = gs.create_node(
"NMS",
numClasses=13,
iouThreshold=0.6,
scoreThreshold=1e-8,
maxDetectionsPerClass=100,
maxTotalDetections=100,
scoreConverter="SIGMOID")
concat_box_loc = gs.create_node("concat_box_loc")
concat_box_conf = gs.create_node("concat_box_conf")
concat_priorbox = gs.create_node("concat_priorbox", dtype=tf.float32, axis=2)
namespace_plugin_map = {
"Postprocessor": NMS,
"Preprocessor": Input,
"concat": concat_box_loc,
"concat_1": concat_box_conf,
"Concatenate/concat": concat_priorbox,
"MultipleGridAnchorGenerator": PriorBox,
}
namespace_remove = {
"ToFloat",
"image_tensor",
"Preprocessor/map/TensorArrayStack_1/TensorArrayGatherV3",
}
def preprocess(dynamic_graph):
# remove the unrelated or error layers
dynamic_graph.remove(
dynamic_graph.find_nodes_by_path(namespace_remove),
remove_exclusive_dependencies=False)
# Now create a new graph by collapsing namespaces
dynamic_graph.collapse_namespaces(namespace_plugin_map)
# Remove the outputs, so we just have a single output node (NMS).
dynamic_graph.remove(dynamic_graph.graph_outputs, remove_exclusive_dependencies=False)
# Remove the Squeeze to avoid "Assertion `isPlugin(layerName)' failed"
Squeeze = dynamic_graph.find_node_inputs_by_name(dynamic_graph.graph_outputs[0], 'Squeeze')
dynamic_graph.forward_inputs(Squeeze)
which gives me the following result
Loading resnet_w_frozen_inference_graph.pb
Using output node NMS
Converting to UFF graph
Warning: No conversion function registered for layer: NMS yet.
Converting as custom op NMS NMS
name: "NMS"
op: "NMS"
input: "concat_box_loc"
input: "concat_priorbox"
input: "concat_box_conf"
attr {
key: "iouThreshold_u_float"
value {
f: 0.6000000238418579
}
}
attr {
key: "maxDetectionsPerClass_u_int"
value {
i: 100
}
}
attr {
key: "maxTotalDetections_u_int"
value {
i: 100
}
}
attr {
key: "numClasses_u_int"
value {
i: 13
}
}
attr {
key: "scoreConverter_u_str"
value {
s: "SIGMOID"
}
}
attr {
key: "scoreThreshold_u_float"
value {
f: 9.99999993922529e-09
}
}
Warning: No conversion function registered for layer: concat_box_conf yet.
Converting as custom op concat_box_conf concat_box_conf
name: "concat_box_conf"
op: "concat_box_conf"
input: "BoxPredictor_0/Reshape_1"
input: "BoxPredictor_1/Reshape_1"
input: "BoxPredictor_2/Reshape_1"
input: "BoxPredictor_3/Reshape_1"
input: "BoxPredictor_4/Reshape_1"
input: "BoxPredictor_5/Reshape_1"
Warning: No conversion function registered for layer: concat_priorbox yet.
Converting as custom op concat_priorbox concat_priorbox
name: "concat_priorbox"
op: "concat_priorbox"
input: "PriorBox"
attr {
key: "axis_u_int"
value {
i: 2
}
}
attr {
key: "dtype"
value {
type: DT_FLOAT
}
}
Warning: No conversion function registered for layer: PriorBox yet.
Converting as custom op PriorBox PriorBox
name: "PriorBox"
op: "PriorBox"
input: "Const"
attr {
key: "aspectRatios_u_flist"
value {
list {
f: 1.0
f: 2.0
f: 0.5
}
}
}
attr {
key: "featureMapShapes_u_ilist"
value {
list {
i: 200
i: 100
i: 50
i: 25
i: 13
i: 6
}
}
}
attr {
key: "layerVariances_u_flist"
value {
list {
f: 0.10000000149011612
f: 0.10000000149011612
f: 0.20000000298023224
f: 0.20000000298023224
}
}
}
attr {
key: "maxScale_u_float"
value {
f: 0.20000000298023224
}
}
attr {
key: "minScale_u_float"
value {
f: 0.10000000149011612
}
}
attr {
key: "numLayers_u_int"
value {
i: 6
}
}
Warning: No conversion function registered for layer: concat_box_loc yet.
Converting as custom op concat_box_loc concat_box_loc
name: "concat_box_loc"
op: "concat_box_loc"
input: "BoxPredictor_0/Reshape"
input: "BoxPredictor_1/Reshape"
input: "BoxPredictor_2/Reshape"
input: "BoxPredictor_3/Reshape"
input: "BoxPredictor_4/Reshape"
input: "BoxPredictor_5/Reshape"
No. nodes: 292
UFF Output written to resnet_w_frozen_inference_graph.pb.uff
As you can see I’m interested in bigger images 1600x1600, i’ve changed the code to handle that and even started the optimization process, I’m however stuck at this point
INFO: Formats and tactics selection completed in 11.507 seconds.
INFO: After reformat layers: 57 layers
INFO: Block size 1073741824
INFO: Block size 81920000
INFO: Block size 30835456
INFO: Block size 5546240
INFO: Block size 5120000
INFO: Block size 2720000
INFO: Block size 2080000
INFO: Block size 680192
INFO: Block size 640000
INFO: Block size 170240
INFO: Block size 160000
INFO: Block size 46080
INFO: Block size 40192
INFO: Block size 9984
INFO: Block size 4608
INFO: Total Activation Memory: 1203714816
sample_uff_ssd: NvPluginSSD.cu:795: virtual void nvinfer1::plugin::DetectionOutput::configure(const nvinfer1::Dims*, int, const nvinfer1::Dims*, int, int): Assertion `numPriors*numLocClasses*4 == inputDims[param.inputOrder[0]].d[0]' failed.
and i would like to see what’s under the hood to fix my problem.
I have a good understanding of the code but I can’t find a way to print any useful message from the detection plugin.
Any suggestions on how to solve this, Is there any way to check the dimensions passed ?