TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

How can I implement gfile?

Open softwareeverything opened this issue 6 years ago • 6 comments
trafficstars

In python; (url: https://gist.github.com/madhawav/1546a4b99c8313f06c0b2d7d7b4a09e2)

self.detection_graph = tf.Graph()
.
.
.
with self.detection_graph.as_default():
      od_graph_def = tf.GraphDef()
      with tf.gfile.GFile(self.path_to_ckpt, 'rb') as fid:
             serialized_graph = fid.read()
             od_graph_def.ParseFromString(serialized_graph)
             tf.import_graph_def(od_graph_def, name='')

But I cannot find these methods like GraphDef() and .gfile.GFile(self.path_to_ckpt, 'rb') in TensorFlow.Net on csharp?

How can I find out it?

softwareeverything avatar Oct 04 '19 07:10 softwareeverything

Your usage of GFile essentially does the following:

using System.IO;
var serialized_graph = File.ReadAllText(self.path_to_ckpt);

Nucs avatar Oct 04 '19 07:10 Nucs

Has this resolved your issue?

Nucs avatar Oct 05 '19 12:10 Nucs

@Nucs thanks but it gives error being "There is no ParseFromString() method of od_graph_def" for the line od_graph_def.ParseFromString(serialized_graph)

softwareeverything avatar Oct 06 '19 19:10 softwareeverything

Do we have any updates on this issue because I am also struggling to solve this.

PanMig avatar Oct 24 '19 13:10 PanMig

I am facing the same so. Anyone would give a hand?

cross-hello avatar Nov 24 '21 03:11 cross-hello

Ok, for ParseFromString, you may try this:

var serialized_graph = File.ReadAllText(self.path_to_ckpt);
byte[] bytearray = new byte[](serialized_graph);
od_graph_def= GraphDef.Parser.ParseFrom( bytearray );

cross-hello avatar Nov 24 '21 09:11 cross-hello