fetch implementation is missing
See original GitHub issueLike the title says, fetch implemtation is missing.
face-api version: 0.17.1
import * as faceapi from 'face-api.js';
class App {
private MODEL_URL: string;
constructor() {
console.log('starting app...');
console.log(process.env.MODELS);
this.MODEL_URL = process.env.MODELS;
}
start() {
try {
this.loadModels();
console.log(`Models loadedd successfully....`);
} catch (error) {
console.error(error);
}
}
private async loadModels() {
await faceapi.loadSsdMobilenetv1Model(this.MODEL_URL)
}
}
(node:25181) UnhandledPromiseRejectionWarning: Error: fetch - missing fetch implementation for nodejs environment at fetch (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tfjs-image-recognition-base/src/env/createNodejsEnv.ts:24:11) at Object.<anonymous> (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tfjs-image-recognition-base/src/dom/fetchOrThrow.ts:9:21) at step (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tslib/tslib.js:133:27) at Object.next (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tslib/tslib.js:114:57) at /home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tslib/tslib.js:107:75 at new Promise (<anonymous>) at Object.__awaiter (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tslib/tslib.js:103:16) at Object.fetchOrThrow (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tfjs-image-recognition-base/build/commonjs/dom/fetchOrThrow.js:6:20) at Object.<anonymous> (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tfjs-image-recognition-base/src/dom/fetchJson.ts:4:17) at step (/home/Faiz/Organization/Repos/Image_Analysis/using_FaceAPI/node_modules/tslib/tslib.js:133:27) (node:25181) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of anasync function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4) (node:25181) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top GitHub Comments
You don’t need fetch nor monkeypatch. Just use the special API calls to load the model files from local storage (the tutorials don’t mention those, but README at npm does), like this:
Browser
Loading the models on the browser was working fine.
However, I faced the same issue on Node.js.
Node.js
I found the solution by looking through the example code in the repository.