I would like to use the tensorflow js plugin with cocossd and mobilenet on the server side with nodejs. I've already done a script on the client side that works where when the user submits a form I run tfjs:
const img = new Image(100, 100);
img.src = //base64 encoded image
// Load the model.
mobilenet.load().then(async model => {
const post_predictions = [];
model.classify(img).then(classify_predictions => {
classify_predictions.forEach(function(element){
const each_class = element["className"].split(", ")
each_class.forEach(function(this_element){
post_predictions.push([this_element, (element.probability*100)]);
})
})
cocoSsd.load().then(model => {
// detect objects in the image.
model.detect(img).then(predictions => {
predictions.forEach(function(this_element){
post_predictions.unshift([this_element.class, (this_element.score*100)]);
});
post_predictions.sort(function(a, b) {
return b[1]-a[1];
});
console.log(post_predictions)
});
})
});
});
I would like to do the same on the server side but I have node idea what modules require or how to load an image from it's base 64.
I tried to download cocossd and mobilenet on my server with:
npm i @tensorflow-models/mobilenet
npm i @tensorflow-models/coco-ssd
And then i tried to install tensorflow js for node with:
npm i @tensorflow/tfjs-node
But when i do :
npm i tensorflow
I get this error :
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"linux,darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS: linux,darwin
npm ERR! notsup Valid Arch: any
npm ERR! notsup Actual OS: win32
npm ERR! notsup Actual Arch: x64
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\johan\AppData\Roaming\npm-cache_logs\2020-02-16T05_27_15_276Z-debug.log
Pls someone help me 🙏 Thannks


