Open
Description
Hello and thanks for this amazing project, I'm eagerly attempting to get something running.
I've attempted to read a JPG using the following tutorial and updated code snippet:
https://programmer.help/blogs/use-tensorflow.net-to-train-your-own-data-set-under-c.html
private static NDArray ReadTensorFromImageFile(string file_name)
{
using (var graph = tf.Graph()/*.as_default()*/)
{
var jpg = tf.image.decode_jpeg(new IoApi().read_file(file_name));
var casted = tf.cast(jpg, TF_DataType.TF_FLOAT);
var dims_expander = tf.expand_dims(casted, 0);
using (var sess = tf.Session(graph))
return sess.run(dims_expander);
//return tf_with(tf.Session(graph), sess => sess.run(dims_expander));
}
}
As you can see, I've tried several variations of this to get it to work. It fails with a NullReferenceException
because tensor.graph
is null here
I could probably read an image and convert the individual pixels to an NDArray, but is there a proper way to read an image?