face-api.js: Issue loading: TypeError: Nt.makeTensor is not a function
I just started and in the latest version I am getting the following error in the browser:
tf-core.esm.js:17 Uncaught (in promise) TypeError: Nt.makeTensor is not a function
at Sn (tf-core.esm.js:17)
at kn (tf-core.esm.js:17)
at o (tf-core.esm.js:17)
at Fh (tf-core.esm.js:17)
at tf-core.esm.js:17
at Array.forEach (<anonymous>)
at tf-core.esm.js:17
at Array.forEach (<anonymous>)
at tf-core.esm.js:17
at tf-core.esm.js:17
I installed face-api.js with npm install face-api.js. Now using it as follows:
import * as faceapi from 'face-api.js';
await faceapi.nets.tinyFaceDetector.loadFromUri('/models');
As soon as I try to load the model, I get the type error above. Any idea’s where it is going wrong? I saw this https://github.com/tensorflow/tfjs/issues/2194#issuecomment-546187719 but couldn’t see a solution to that. Thanks!
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 27 (2 by maintainers)
Commits related to this issue
- fix face-api.js by upgrading - https://github.com/justadudewhohacks/face-api.js/issues/455 — committed to DylanVann/mediasoup-demo by DylanVann 4 years ago
- fix face-api.js by upgrading - https://github.com/justadudewhohacks/face-api.js/issues/455 — committed to DylanVann/mediasoup-demo by DylanVann 4 years ago
@justadudewhohacks Thanks for the Tip! I’ve solved my problem 😄
You do not just have to say
"@tensorflow/tfjs-core": "1.2.9"in the dependencies-section of the package.json, you also have to prevent tfjs-image-recognition-base from getting a newer version:@luucv this is how I am loading the models :
loadModels = async () => {const MODEL_URL = "/models";await faceapi.loadSsdMobilenetv1Model(MODEL_URL);await faceapi.loadFaceLandmarkModel(MODEL_URL);await faceapi.loadFaceRecognitionModel(MODEL_URL);};I added the
resolutionssection as suggested above and by this help doc but it was apparently ignored by yarn cuz it resolved to 1.3.1 anyway per yarn.lock. I’ve got a yarn monorepo so I’m sure there’s either some logical reason or some bug as to why that was the case.I was able to get around it by manually editing the
yarn.lockto change the section for"@tensorflow/tfjs-core@^1.2.9":to be identical to the section for"@tensorflow/tfjs-core@1.2.9":(no caret). But that seems super hacky and tenuous. If this is working in npm but not yarn that seems like a yarn bug to me.installing face-api with npm instead of yarn seems to solve the problem for me.
I’ve solved by taking these steps:
npm i @tensorflow/tfjs-node@1.2.9npm i @tensorflow/tfjs-code@1.2.9The 1.2.9 is the last one supported by latest face-api.js version as @justadudewhohacks said.
The issue is most certainly due to your package managers installing a tfjs core version other than 1.2.9 (which is the one the latest face-api.js version uses). May be an issue with yarn?
Try deleting your yarn locks / package locks and do a clean installation. If for some reason the issue still remains, try explicitly installing
npm i @tensorflow/tfjs-core@1.2.9.So for me nothing worked what did work was this
FOR YARN USERS
add “resolutions”: { “tfjs-image-recognition-base/@tensorflow/tfjs-core”: “<=1.2.9” }
in the package add these lines
“dependencies”: { “@tensorflow/tfjs-core”: “1.2.9”, “face-api.js”: “^0.21.0”, “next”: “9.1.4”, “react”: “16.12.0”, “react-dom”: “16.12.0”, “react-stickynode”: “^2.1.1”, “styled-components”: “^4.4.1”, “tfjs-image-recognition-base”: “^0.6.2” }
actually installing tfjs-image-recognition-base worked!
have same problem, resolutions no helped
I have same problem.
5 days ago, It was operating normally.
Have the same problem.
Try to delete package-lock.json, node_modules. Then install the latest version (currently 0.21.0)
@luucv have the same error right now. I installed face-api.js via yarn. I retried it with
npm install face-api.jsand it worked without any problem. I’m using webpack-encore with Symfony.