1

当我尝试在电子应用程序中使用 tensorflowjs 运行移动网络(使用生产构建脚本)时,出现以下错误。但是,相同的代码在 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
4

0 回答 0