【发布时间】:2020-05-31 09:29:21
【问题描述】:
我想在服务器端使用带有 cocossd 的 tensorflow js 插件和带有 nodejs 的 mobilenet。 我已经在客户端完成了一个脚本,当用户提交表单时我运行 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)
});
})
});
});
我想在服务器端做同样的事情,但我知道节点需要什么模块或如何从它的 base 64 加载图像。
我尝试在我的服务器上下载 cocossd 和 mobilenet:
npm i @tensorflow-models/mobilenet
npm i @tensorflow-models/coco-ssd
然后我尝试为节点安装 tensorflow js:
npm i @tensorflow/tfjs-node
但是当我这样做时:
npm 我张量流
我收到此错误:
npm 错误!代码EBADPLATFORM
npm 错误! notsup 不支持 tensorflow@0.7.0 的平台:想要 {"os":"linux,darwin","arch":"any"}(当前:{"os":"win32","arch":"x64"} )
npm 错误! notsup 有效操作系统:linux,darwin
npm 错误! notsup 有效拱门:任何
npm 错误! notsup 实际操作系统:win32
npm 错误! notsup 实际拱门:x64
npm 错误!可以在以下位置找到此运行的完整日志:
npm 错误! C:\Users\johan\AppData\Roaming\npm-cache_logs\2020-02-16T05_27_15_276Z-debug.log
请有人帮助我吗???? 谢谢
【问题讨论】:
标签: javascript node.js image tensorflow artificial-intelligence