Reputation: 607
I am attempting to import the protobuf published by Facebook from the DeepFovea project located here: https://raw.githubusercontent.com/facebookresearch/DeepFovea/master/input_graph.pb
Here is my code:
import tensorflow.compat.v1 as tf
from tensorflow.python.platform import gfile
tf.GraphDef.FromString(tf.gfile.Open("./input_graph.pb",'rb').read())
I am receiving this error:
google.protobuf.message.DecodeError: Error parsing message
Should I be loading this protobuf in a different manner?
Upvotes: 0
Views: 278
Reputation: 2555
After much Googling, it turns out you need to parse it like so:
from google.protobuf import text_format
with tf.gfile.GFile(graph_filename, "rb") as f:
graph_def = tf.GraphDef()
graph_str = f.read()
text_format.Merge(graph_str, graph_def)
from code example here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/framework/test_util_test.py#L84
Upvotes: 2