I have an angular 7 application and I'm trying to load the mobilenet model by following this example.
I installed the tensorflowjs by running npm install @tensorflow/tfjs
(following this instructions) and the mobilenet model by running @tensorflow-models/mobilenet
.
After that I imported the mobile net by doing:
import * as mobilenet from '@tensorflow-models/mobilenet';
And execute the following code in order to load the model:
mobilenet.load().then(() => {
obs.next();
}).catch((err) => {
console.log(err);
console.log("ERROR");
});
But I'm receiving the following 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)
Does anyone know what is the issue?
I found out that the problem was that I had different versions for @tensorflow/tfs and @tensorflow/tfjs-core on my packade.json.
So, I change my package config from:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.0.2",
...
To:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.1.2",
...
And the error vanished.