Open
Description
Hi, I want to preprocess the images, flip or change brightness. I took a try but failed
- tf.image.random_brightness: throw System.NullReferenceException
- tf.image.random_flip_left_right: throw System.IndexOutOfRangeException
My Code:
private void Test()
{
var tempPath = @"D:\Temp";
string image_file = "cat.jpg";
var file_contents = tf.io.read_file(image_file);
var image = tf.image.decode_image(file_contents, 3);
var init = tf.global_variables_initializer();
using (var sess = tf.Session())
{
sess.run(init);
//throw System.NullReferenceException
//NumSharp.NDArray nd = sess.run(tf.image.random_brightness(image, 0.3f));
//throw System.IndexOutOfRangeException
NumSharp.NDArray nd2 = sess.run(tf.image.random_flip_left_right(image));
Bitmap bmp = nd2.ToBitmap();
bmp.Save(Path.Combine(tempPath, DateTime.Now.ToString("yyyyMMddHHmmss_"), ".jpg"), ImageFormat.Jpeg);
}
}