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

WPF assembly

Open MejlaB opened this issue 2 years ago • 0 comments

Hello all, I recognized unability to call BaseModel.Predict() from WPF application. It is build under net6.0-windows and finishes with error: Python.Runtime.PythonException: 'AttributeError : 'NoneType' object has no attribute 'write''. I try to call prediction from visual thread. Here is a simple example, what am I trying to do:

        var model = Keras.Models.Model.LoadModel("existing path to model h5 file");
        byte[] data = new byte[99 * 162 * 3];

        NDarray t = np.array<byte>(data);
        var tt = t.reshape(new int[] { 1, 162, 99, 3 });
        var prediction = model.Predict(tt);

It works well, when I call the code from console application. I tried to put all Keras functionalities into separated net6.0 library and the behavior is exactly the same. It works well, when I refernce library from console application and failed, when it is referenced to wpf net6.0-windows application.

Thank you

Milan B.

MejlaB avatar May 13 '22 17:05 MejlaB