I need some senior advice here. I want to create an API using JS, but all the ML functionality using Python. I dont want to get rid of the awesome JS libraries like GraphQL, but i dont want to sacrifice the Python performance. I know I can use Tensorflow.js, but as I said, in terms of performance, Python is way better.
I have in mind something like deploying to the cloud a ML model using Python and then fetch the predictions in my JS API or something like that.
Other idea is to create the inference using Python, save it in form of .h5 or .json, and then load them directly with Tensorflow.js in my API.
##### LOCAL #####
inputs = Input(shape=(trainX.shape[1], trainX.shape[2], trainX.shape[3]))
...
Conv2D
Conv2D
Conv2D
...
model = Model(inputs=inputs, outputs=predictions)
model.compile(...)
model.fit(...)
model.save(model.json) # I dont think I can save the weights in Python in the .json format
##### API #####
https.get('SOMEURL', (resp) => {
const model = await tf.loadLayersModel('file://path/to/my-model/model.json');
const { data } = resp
return model.predict(data)
}).on("error", (err) => {
console.log("Error: " + err.message);
});
I dont really know if this could ever work, or there is a better form for this (or is it even possible).
All ideas and advices are appreciated. Thank You.