我有一个angular 7应用程序,我正在尝试通过下面的this示例加载mobilenet模型。
我通过运行npm install @tensorflow/tfjs
(遵循this说明)安装了tensorflowjs,通过运行@tensorflow-models/mobilenet
安装了mobilenet模型。
在那之后,我通过执行以下操作导入了移动网络:
import * as mobilenet from '@tensorflow-models/mobilenet';
并执行以下代码以加载模型:
mobilenet.load().then(() => {
obs.next();
}).catch((err) => {
console.log(err);
console.log("ERROR");
});
但我收到以下错误:
TypeError: Cannot read property 'fetch' of undefined
at new e (tf-core.esm.js:17)
at browserHTTPRequest (tf-core.esm.js:17)
at httpRequestRouter (tf-core.esm.js:17)
at tf-core.esm.js:17
at Array.forEach (<anonymous>)
at Function.e.getHandlers (tf-core.esm.js:17)
at Function.e.getLoadHandlers (tf-core.esm.js:17)
at Object.getLoadHandlers (tf-core.esm.js:17)
at e.findIOHandler (tf-converter.esm.js:17)
at e.<anonymous> (tf-converter.esm.js:17)
有人知道问题出在哪里吗?
发布于 2019-05-09 03:35:43
我发现问题在于我的packade.json上有不同版本的@tensorflow/tfs和@tensorflow/tfjs-core。
因此,我将我的包配置从:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.0.2",
...
至:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.1.2",
...
错误就消失了。
https://stackoverflow.com/questions/56047654
复制相似问题