当我尝试在电子应用程序中使用tensorflowjs运行mobilenet(使用生产内置的脚本)时,出现以下错误。但是,相同的代码可以在Chrome和Firefox中运行,没有任何问题
这是我的package.json的样子:
{
"name": "tfjs",
"version": "0.1.0",
"description": "mobilenet",
"main": "index.js",
"scripts": {
"start": "electron .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@tensorflow/tfjs": "^0.11.2",
"connect": "^3.6.6",
"electron": "^2.0.2",
"express": "^4.16.3",
"node-cmd": "^3.0.0",
"serve-static": "^1.13.2",
"vega-embed": "^3.14.0"
},
"devDependencies": {
"electron-builder": "^20.28.3",
"electron-packager": "^12.1.1"
}
}
完整的错误消息:
tf-core.esm.js:17 Uncaught (in promise) Error: The shape of dict['input'] provided in model.execute(dict) must be [1,224,224,3], but was [1,224,224,3]
at Object.assert (tf-core.esm.js:17)
at tf-converter.esm.js:17
at Array.forEach (<anonymous>)
at e.checkInputShapeAndType (tf-converter.esm.js:17)
at e.execute (tf-converter.esm.js:17)
at e.execute (tf-converter.esm.js:17)
at e.predict (tf-converter.esm.js:17)
at tf.tidy (index.js:181)
at tf-core.esm.js:17
at e.scopedRun (tf-core.esm.js:17)
assert @ tf-core.esm.js:17
(anonymous) @ tf-converter.esm.js:17
e.checkInputShapeAndType @ tf-converter.esm.js:17
e.execute @ tf-converter.esm.js:17
e.execute @ tf-converter.esm.js:17
e.predict @ tf-converter.esm.js:17
tf.tidy @ index.js:181
(anonymous) @ tf-core.esm.js:17
e.scopedRun @ tf-core.esm.js:17
e.tidy @ tf-core.esm.js:17
e.tidy @ tf-core.esm.js:17
main @ index.js:180