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

Most upvoted comments

@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:

"resolutions": {
    "tfjs-image-recognition-base/@tensorflow/tfjs-core": "<=1.2.9"
}

@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); };

looks like tfjs-image-recognition-base was secretly installing the latest tfjs behind our backs.

I added the resolutions section 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.lock to 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:

  1. delete tensorflow node module
  2. npm i @tensorflow/tfjs-node@1.2.9
  3. npm i @tensorflow/tfjs-code@1.2.9

The 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

  1. add “resolutions”: { “tfjs-image-recognition-base/@tensorflow/tfjs-core”: “<=1.2.9” }

  2. 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.

"@tensorflow/tfjs-core": "1.2.9",
"@tensorflow/tfjs-node": "1.2.9",
"face-api.js": "^0.21.0",

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.js and it worked without any problem. I’m using webpack-encore with Symfony.