TypeError: forwardFunc_1 is not a function
See original GitHub issueI am new to face-api.js/Tensorflow.js so I might be overlooking something very obvious.
I installed face-api.js and Tensorflow using:
npm i face-api.js canvas @tensorflow/tfjs-node
Everything worked fine until I added require('@tensorflow/tfjs-node');
at the top of the code.
Here’s the full code:
require('@tensorflow/tfjs-node');
const { loadImage,Canvas, Image, ImageData,createCanvas } = require('canvas')
const fs= require('fs');
const faceapi = require('face-api.js');
faceapi.env.monkeyPatch({ Canvas, Image, ImageData,createCanvas });
Promise.all([
faceapi.nets.ssdMobilenetv1.loadFromDisk('models'),
faceapi.nets.faceRecognitionNet.loadFromDisk('models'),
faceapi.nets.faceLandmark68Net.loadFromDisk('models')
])
.then(async () => {
data={};
const image1= await loadImage("test.png");
const result = await faceapi.detectSingleFace(image1).withFaceLandmarks().withFaceDescriptor();
data["test.png"]={};
let left=result.landmarks.getLeftEye();
data["test.png"].left=left;
let right=result.landmarks.getRightEye();
data["test.png"].right=right;
console.log(data);
});
The code would have worked perfectly fine, had require('@tensorflow/tfjs-node');
not been added. The error I get when I run the full code is:
2021-03-13 09:27:30.500937: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
cpu backend was already registered. Reusing existing backend factory.
Platform node has already been set. Overwriting the platform with [object Object].
(node:1428) UnhandledPromiseRejectionWarning: TypeError: forwardFunc_1 is not a function
at FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3179:55
at FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3002:22
at Engine.scopedRun (FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3012:23)
at Engine.tidy (FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3001:21)
at kernelFunc (FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3179:29)
at FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3200:27
at Engine.scopedRun (FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3012:23)
at Engine.runKernelFunc (FolderName\node_modules\@tensorflow\tfjs-core\dist\tf-core.node.js:3196:14)
at mul_ (FolderName\node_modules\face-api.js\node_modules\@tensorflow\tfjs-core\dist\ops\binary_ops.js:327:28)
at Object.mul (FolderName\node_modules\face-api.js\node_modules\@tensorflow\tfjs-core\dist\ops\operation.js:46:29)
(Use 'node --trace-warnings ...' to show where the warning was created)
(node:1428) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a prom
ise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag '--unhandled-rejections=strict' (see https://nodejs.org/api/cli.html#
cli_unhandled_rejections_mode). (rejection id: 1)
(node:1428) [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-z
ero exit code.
Here’s the list of packages installed: list.txt.
I have uninstalled/re-installed the node modules multiple times. Tried using the previous versions of “@tensorflow/tfjs-node”.
I am using Node.js v14.16.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7
Top Results From Across the Web
forwardFunc_1 is not a function - TensorFlow Forum
Hey all, starting off this is my first time on the forum and I have no clue if this is the correct place...
Read more >TypeError: forwardFunc is not a function · Issue #2329 - GitHub
Hi! I dont know does this problem apply to you, but it seems to be. If it is not, im sorry. So here...
Read more >TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >TypeError: $(...). is not a function - Stack Overflow
I'm trying to track down an error TypeError: $(...).clientSideCaptcha is not a function ...
Read more >Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError - Some selector is not a function - jQuery is not a function - owlCarousel...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
this version of
face-api.js
is not compatible with tfjs 2.0+ or 3.0+, only obsolete 1.x.why it worked before you added
tfjs-node
? becauseface-api.js
actually includes bundled version oftfjs-core
1.x.once you added
tfjs-node
, it overrode globaltf
namespace, but its a much newer version and not compatible.now, you can either install obsolete
tfjs-node
1.x or use newer port offace-api.js
(changes to make it compatible are pretty significant):https://github.com/vladmandic/face-api
https://www.npmjs.com/package/@vladmandic/face-api
Yes, but if the author is no longer maintaining the package, how can they be updated?
It says that explicitly in the readme:
Note
This is updated face-api.js with latest available TensorFlow/JS as the original is not compatible with tfjs 2.0+.
Forked from face-api.js version 0.22.2 which was released on March 22nd, 2020
Currently based on
TensorFlow/JS
3.3.0Why? I needed Face-API that does not cause version conflict with newer versions of TensorFlow
And since original Face-API was open-source, I’ve released this version as well
Changes ended up being too large for a simple pull request
and it ended up being a full-fledged version on its own
Plus many features were added since original inception
Differences
Compared to face-api.js version 0.22.2:
TensorFlow/JS 2.0+ & 3.0+
WebGL
,CPU
andWASM
TFJS Browser backendstfjs-node
andtfjs-node-gpu
TFJS NodeJS backendsTypeScript 4.2
UMD
toESM
+CommonJS
with fallback toIIFE
Resulting code is optimized per-platform instead of being universal Fully tree shakable when imported as anESM
module Browser bundle process usesESBuild
instead ofRollup
ES2018
and instead of dual ES5/ES6 Resulting code is clean ES2018 JavaScript without polyfillskarma
,jasmine
,babel
, etc.)@tensorflow/tfjs-core
batchNorm()
dependencyversion
class that returns JSON object with version of FaceAPI as well as linked TFJSmtcnn
andtinyYolov2
models as they were non-functional in latest public version ofFace-API
Which means valid models are tinyFaceDetector and mobileNetv1 If there is a demand, I can re-implement them back.face angle
calculations that returnsroll
,yaw
andpitch
typdoc
automatic API specification generation during buildchangelog
automatic generation during buildCredits