I am training yolo model on my set of images as per tensorflow-yolov3 and I have generated the .pb model file. Now I am trying to use the following opencv library for detection:
cv2.dnn.readNetFromTensorflow(_.pb,_.pbtxt)
How would I get the correct .pbtxt file generated from pb?
I have tried the below code
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, ',/',
'name.pbtxt', as_text=True)
which generates a pbtxt file. But when I run below:
cv2.dnn.readNetFromTensorflow(_.pb,_.pbtxt)
I get the following error:
error: (-215:Assertion failed) const_layers.insert(std::make_pair(name, li)).second in function 'addConstNodes'
If instead I use as pbtxt file below:
item { id: 1 name: 'ball' }
I get:
error: (-215:Assertion failed) inputs.size() == requiredOutputs in function 'getMemoryShapes'
Any hints on how to overcome this issue?
Thanks a lot
Detailed description
I am training yolo model on my set of images as per tensorflow-yolov3 and I have generated the .pb model file. Now I am trying to use the following opencv library for detection:
cv2.dnn.readNetFromTensorflow(_.pb,_.pbtxt)
How would I get the correct .pbtxt file generated from pb? I have tried the below codewhich generates a pbtxt file. But when I run below:
cv2.dnn.readNetFromTensorflow(_.pb,_.pbtxt)
I get the following error:error: (-215:Assertion failed) const_layers.insert(std::make_pair(name, li)).second in function 'addConstNodes'
If instead I use as pbtxt file below:
item { id: 1 name: 'ball' }
I get:
error: (-215:Assertion failed) inputs.size() == requiredOutputs in function 'getMemoryShapes'
Any hints on how to overcome this issue? Thanks a lot