Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load model with ML.NET saved with keras

I have a Neural Network implemented in Python with Keras. Once I have trained it I have exported the model and I have got two files: model.js and model.h5. Now I want to classify in real time inside a .NET project and I want to use the trained Neural Network for it.

Is there a way in ML.NET of loading the model and trained weights exported with python into a model object?

I have seen in the documentation[1] that a previous saved model can be loaded, but apparently is storage in a .zip and I could not find the format (maybe to make a script that takes the model from python and 'translate' it to the ML.NET model.

Apparently the hdf5 format is a standard[2], there is a way to load it with ML.NET?

[1] https://learn.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/consuming-model-ml-net

[2] https://support.hdfgroup.org/HDF5/doc1.6/UG/10_Datasets.html

like image 664
Ignacio Avatar asked Mar 05 '23 02:03

Ignacio


1 Answers

ML.net supports ONNX models, as in this example.

You can convert your keras model to ONNX model via WinMLTools

like image 154
Cihan Yakar Avatar answered Mar 12 '23 12:03

Cihan Yakar