I followed this tutorial to implement Yolo object detector: https://github.com/thtrieu/darkflow/ and I completed it successfully.
The created .pb file can be used to migrate the graph to mobile devices (JAVA / C++ / Objective-C++). The name of input tensor and output tensor are respectively 'input' and 'output'.
I want to load the network with OpenCV (c++). The readNetFromTensorflow() method needs two files: .pb and .pbtxt. The latter is not generated by the implementation indicated above. Similarly, to use the readNetFromDarknet() method it is necessary to have two files: .cfg and .weights. The latter is not generated by the implementation indicated above.
So, how can I migrate the yolo network from python to c++ using opencv?
I also tried to generate the .pbtxt file directly from the .pb file but the readNetFromTensorflow() method is not successful (A generic exception is generated without useful information)
Reference exception thrown:
[Exception thrown at 0x00007FFFB80C9129 in Object_detection_inference_cpp.exe: Microsoft C++ exception: cv::Exception at memory location 0x000000CBC18FDC90.]
Thanks in advance.
This is the code I have used to convert .pb file into .pbtxt file:
import tensorflow as tf
from google.protobuf import text_format
from tensorflow.python.platform import gfile
def graphdef_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, 'pbtxt/', 'tiny-yolov2-trial3-test.pbtxt', as_text=True)
return
graphdef_to_pbtxt('tiny-yolov2-trial3-test.pb')
To use tf_text_xxx.py It is necessary to have .config file. I have only .cfg file from the tutorial above. For this reason I can not use those three function you reported. Am I doing something wrong?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.