Winform Support
Hi, Thanks for the great package and easy to follow examples. When I ran a mock model in console application - I get nicely callback output (verbose 1, epoch runs) in the console window. However, when I tried the same in a winform application, there is no output. It still compiles and runs but there is no output. For eg:
public void PrepareData()
{
int batch_size = 32;
TensorShape img_dim = (180, 180);
//var data_dir = @"C:/Users/haipi/.keras/datasets/flower_photos";
var data_dir = @"C:\flowers";
var train_ds = keras.preprocessing.image_dataset_from_directory(data_dir, validation_split: 0.2f,
subset: "training",
seed: 123,
image_size: img_dim,
batch_size: batch_size);
var val_ds = keras.preprocessing.image_dataset_from_directory(data_dir,
validation_split: 0.2f,
subset: "validation",
seed: 123,
image_size: img_dim,
batch_size: batch_size);
train_ds = train_ds.cache().shuffle(100).prefetch(buffer_size: -1);
val_ds = val_ds.cache().prefetch(buffer_size: -1);
foreach (var (img, label) in train_ds)
{
print("batch images: " + img.TensorShape);
print("labels: " + label);
tbConsole.AppendText("batch images: " + img.TensorShape);
tbConsole.AppendText(Environment.NewLine);
tbConsole.AppendText("labels: " + label);
tbConsole.AppendText(Environment.NewLine);
}
int num_classes = 5;
// var normalization_layer = tf.keras.layers.Rescaling(1.0f / 255);
var layers = keras.layers;
var model = keras.Sequential(new List<ILayer>
{
layers.Rescaling(1.0f / 255, input_shape: (img_dim.dims[0], img_dim.dims[1], 3)),
layers.Conv2D(16, 3, padding: "same", activation: keras.activations.Relu),
layers.MaxPooling2D(),
/*layers.Conv2D(32, 3, padding: "same", activation: "relu"),
layers.MaxPooling2D(),
layers.Conv2D(64, 3, padding: "same", activation: "relu"),
layers.MaxPooling2D(),*/
layers.Flatten(),
layers.Dense(128, activation: keras.activations.Relu),
layers.Dense(num_classes)
});
model.compile(loss: keras.losses.SparseCategoricalCrossentropy(from_logits: true),
optimizer: keras.optimizers.Adam(), metrics: new[] { "accuracy" });
model.summary();
model.fit(train_ds, validation_data: val_ds, epochs: 2, verbose: 1);
}

I would like to know if there is a way to get the console outputs in a winform application.
Thanks, Veeru
I've created a PR #764 which could solve your problem.
Hi lsylusiyao, Thank you for creating pull request for solving the problem. I have a very stupid (newbie) question, how can I use your code change in my project - should I download the repository, compile and then import the dll into my project ?
I downloaded the repository and tried packing tensorflow.keras to generate TensorFlow.Keras.0.5.0.nupkg in the debug folder of the project but I was not able to install it on my project. I am sure I am missing something, new to this so it will take time. I appreciate your help. Thanks,
It seems that you've already finished compiling and created the useful nupkg. Then you can just search for how to install local nuget package in visual studio and you'll find the answer. :)