As title states I'm trying to use my Keras (tf backend) pretrained model for predicitions in c#. What's the best approach?
I've tried IronPython but it gave me errors, after search I found it isn't supported. Simply calling python script won't work since target Windows devices won't have python interpreters installed.
This question is somewhat vague, but I'll try to answer it the best I can:
Tensorflow core is written in c++ and exposes an interface, which can be consumed by a client written in whichever language (although yes, the Python one is the most developed so far).
What could you do:
You mentioned:
[...] devices won't have python interpreters installed.
Well, okay. You could, however, define an boot process that would cascade the installation of the necessary dependencies (cpython included). Some applications do that to set databases, for example. In this case, you could create a microservice that boots tensorflow and answers to prediction requests through a file, pipe or socket. Your c# application would then connect to your microservice and request predictions.
Try Keras.NET. That uses C# numpy and calls the installed Keras and backend.
https://github.com/SciSharp/Keras.NET
I have used it succesfully to train and predict with Keras directly from C#. Not ideal but it works.
it does not work like that, since you wont even be able to install tensorflow in a C# project. Abandon C# stack and learn framework in python stack instead, ex. if if you need to consume the prediction result in a web app, learn Flask or Django
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.