Face-api.js: Issue loading: TypeError: Nt.makeTensor is not a function

Created on 30 Oct 2019  路  23Comments  路  Source: justadudewhohacks/face-api.js

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!

Most helpful comment

@justadudewhohacks Thanks for the Tip!
I've solved my problem :D

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"
}

All 23 comments

Hi, I just got the same error([email protected]) and I downgraded to [email protected], and this error disappeared, however, a new error rendered. Anyway, you could have a try.

When downgrading tfjs-core to 1.2.9 I get this error when trying to use the library

SsdMobilenetv1.js:26 Uncaught (in promise) Error: SsdMobilenetv1 - load model before inference
at SsdMobilenetv1.forwardInput (SsdMobilenetv1.js:26)
at SsdMobilenetv1. (SsdMobilenetv1.js:81)
at step (tslib.es6.js:196)
at Object.next (tslib.es6.js:127)
at fulfilled (tslib.es6.js:80)

here is the lock file of a project where this library still works.

yarnlockfile.txt

@Spodeopieter, I think your last error has to do with not asynchronously loading in your model. Are you sure it is being loaded in correctly before you try to use it?

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

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

Have the same problem.

Try to delete package-lock.json, node_modules. Then install the latest version (currently 0.21.0)

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/[email protected].

@justadudewhohacks Thanks for the Tip!
I've solved my problem :D

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"
}

I've solved by taking these steps:

  1. delete tensorflow node module
  2. npm i @tensorflow/[email protected]
  3. npm i @tensorflow/[email protected]

The 1.2.9 is the last one supported by latest face-api.js version as @justadudewhohacks said.

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.

@justadudewhohacks Thanks for the Tip!
I've solved my problem :D

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"
}

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

have same problem, resolutions no helped

installing face-api with npm instead of yarn seems to solve the problem for me.

installing face-api with npm instead of yarn seems to solve the problem for me.

I'm running into the same issue with yarn, installing with npm solved me problem as well.

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/[email protected]": (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.

I've solved by taking these steps:

  1. delete tensorflow node module
  2. npm i @tensorflow/[email protected]
  3. npm i @tensorflow/[email protected]

The 1.2.9 is the last one supported by latest face-api.js version as @justadudewhohacks said.

This solved the same issue I was having. Hope this helps somebody.

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!

I have this same issue. I get the error:
image
when I try to load any model.

I have the models in public/models and am trying to access them with

 await faceapi.nets.ssdMobilenetv1.loadFromUri('/models') 

I've tried all the fixes mentioned above and I don't think it's an issue with versioning, or npm.

Is there another way to load the models? Thanks!

Also having the same issue, though my error message reads:

engine_1.ENGINE.makeTensor is not a function

Tried some of the above fixes with no luck. Using tfjs 1.2.9 also.

We need to upgrade to TFJS 1.3.x for other reasons. Any idea what's causing this problem with newer TFJS packages? I don't see makeTensor anywhere in the code here or in tfjs-image-recognition-base
I'm guessing maybe the models need to be regenerated for TF 1.3.x?

I've solved by taking these steps:

  1. delete tensorflow node module
  2. npm i @tensorflow/[email protected]
  3. npm i @tensorflow/[email protected]

The 1.2.9 is the last one supported by latest face-api.js version as @justadudewhohacks said.

It solved my problem.

I upgraded the tfjs-core version the latest release. Also I decided to move tfjs-image-recognition-base to face-api.js, so yarn should not have any reason to install different versions of tfjs-core anymore unless you or one if your dependencies is explicitly installing another version.

I'm getting a "Kt.makeTensor is not a function", more specifically:
Uncaught (in promise) TypeError: Kt.makeTensor is not a function
at Rn (face-api.min.js:2426)
at In (face-api.min.js:2407)
at e (face-api.min.js:11444)
at Vh (face-api.min.js:11445)
at face-api.min.js:12054
at Array.forEach ()
at face-api.min.js:12053
at Array.forEach ()
at face-api.min.js:12047
at face-api.min.js:103

I've tried all these resolutions and none of them worked. Could anyone help please?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SunilKapadia1208 picture SunilKapadia1208  路  7Comments

MilindModi picture MilindModi  路  6Comments

liyinghao666 picture liyinghao666  路  5Comments

XDmoyang picture XDmoyang  路  6Comments

shriyaaa picture shriyaaa  路  7Comments