hunglc007 / tensorflow-yolov4-tflite

YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
https://github.com/hunglc007/tensorflow-yolov4-tflite
MIT License
2.23k stars 1.24k forks source link

How can I generate the .pbtxt file from .pb saved? #364

Open ELERKSOSY opened 3 years ago

ELERKSOSY commented 3 years ago

Hello,

I used the script "save_model.py" to generate .pb file, which is generated successfully and runs fine.

My problem is, I need to generate the .pbtxt file from the .pb file saved. I already try several ways but nothing work!

This the code I use:

filename = "saved_model.pb"
with gfile.FastGFile(filename,'rb') as f:
        graph_def = tf.compat.v1.GraphDef()
        graph_def.ParseFromString(f.read())
        tf.import_graph_def(graph_def, name='')
        in_dir = os.path.dirname(filename)
        out_filename = "saved_model.pbtxt"
        tf.train.write_graph(graph_def, in_dir, out_filename, as_text=True)

I always get this error: google.protobuf.message.DecodeError: Error parsing message At this line: _graphdef.ParseFromString(f.read())

Can you please advise the method to get the .pbtxt file from the saved .pd file? thanks a lot

MrIronstone commented 2 years ago

Have you solved?