import tensorflow as tf
with tf.gfile.FastGFile('data/gaze_model.pb', "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
for i in reversed(range(len(graph_def.node))):
if graph_def.node[i].op == 'Const':
del graph_def.node[i]
graph_def.library.Clear()
tf.train.write_graph(graph_def, "", 'data/gaze_model.pbtxt', as_text=True)

error loading to opencv dnn
and loaded my .pb and generated pbtxt file to opencv dnn ang got error

Failed to parse GraphDef file: E:/model.pbtxt in function 'cv::dnn::ReadTFNetParamsFromTextFileOrDie'