ardianumam/Tensorflow-TensorRT

difficulty generating correct frozen .pb

Closed this issue · 2 comments

I understand that you generated the provided yolov3_gpu_nms.pb using the pretrained coco weights from https://pjreddie.com/media/files/yolov3.weights placed in the checkpoint dir in this repo https://github.com/ardianumam/tensorflow-yolov3

My question is, what exactly did you run in order to generate the .pb? I generated my .pb with python convert_weight.py --convert --freeze but it doesn't give the correct output tensors as illustrated below.

  input_tensor, output_tensors = \
  utils.read_pb_return_tensors(tf.get_default_graph(),
                               GIVEN_ORIGINAL_YOLOv3_MODEL,
                               ["Placeholder:0", "concat_9:0", "mul_9:0"])
  print("\n\ninput_tensor\n", input_tensor)
  print("\n\noutput_tensors\n", output_tensors)

** Output for provided .pb (this works) **
input_tensor
 Tensor("import/Placeholder:0", shape=(1, 416, 416, 3), dtype=float32)

output_tensors
 [<tf.Tensor 'import/concat_9:0' shape=(1, 10647, 4) dtype=float32>, <tf.Tensor 'import/mul_9:0' shape=(1, 10647, 80) dtype=float32>]

** Output for my .pb (this doesn't work - see the output tensors shape)**
input_tensor
 Tensor("import/Placeholder:0", shape=(1, 416, 416, 3), dtype=float32)

output_tensors
 [<tf.Tensor 'import/concat_9:0' shape=(1, 10647, 4) dtype=float32>, <tf.Tensor 'import/mul_9:0' shape=(?,) dtype=int32>]

[ I've tried this conversion using TF 1.11, 1.12, 1.13rc2 - all give the same results]

OK, I have resolved this by specifying: "["Placeholder:0", "concat_9:0", "mul_6:0"]" as the return_elements arg for utils.read_pb_return_tensors()
I guess that ["Placeholder:0", "concat_9:0", "mul_9:0"] was an older definition for the outputs here https://github.com/ardianumam/tensorflow-yolov3 which was used to generate your provided .pb and has now changed?

Hi,

Sorry for late response, was quite crowded recently. But glad that you already solve the issue. Yes, you might be right, those new tensor names may be already changed.