Closed AnthonyLzq closed 1 year ago
i'm going to assume this is similar to other issue you've just created - https://github.com/vladmandic/human/issues/328 make sure that models are actually correctly loaded, not just last error message.
In fact, this isn't similar, this is just a type error.
ok, i'll take a look
i just tried to reproduce using your script and it works just fine here:
node_modules/.bin/ts-node --esm test.ts
input images: vlado1.jpg vlado2.jpg
distance between most prominant detected faces: 0.4469153942760356
similarity between most prominant detected faces: 0.5530846057239645
i guess it up to project setup
please share full reproduction project that i can just clone (tsconfig.json
& package.json
are key)
any updates?
Hi there, last week was crazy for me, did not have time to check it, I will review it right away. Sorry for the delay.
Here is the repo with the issue.
ok, i see what the issue is, but i don't see a way to resolve it without major change on how face-api
is built.
the error is misleading, the core issue is that Tensor
type signatures are not the same in @tensorflow/tfjs
(browser package) and @tensorflow/tfjs-node
(nodejs package)
you can confirm by basically doing:
const tensor = tf.node.decodeImage(buffer, 3) as faceApi.tf.Tensor3D
easiest temporary solution is to relax that typecheck:
const faces = await faceApi.detectAllFaces(tensor as any, optionsSSDMobileNet)
extracting and bundling different typedefs for different flavors of tfjs
during faceapi
build would be out-of-scope for now. i did restructure some typedefs, so do a git pull anyhow.
btw, off-topic, but if you're building for node and using esm, you may want to import node flavor of faceapi
explictly as its auto import resolver may pick browser esm version:
import faceApi from '@vladmandic/face-api/dist/face-api.node'
as per previous note, i'm closing the issue as its cosmetic only and full fix would be out of scope for now.
Issue Description
I'm trying to run the
demo/node-face-compare.js
script, but I have migrated it to TS. However, TypeScript is complaining about the type of the tensor with the following error:Image for reference:
Steps to Reproduce
Try to run this script with
ts-node
or something.Expected Behavior
To work, I guess, I suppose this is an issue with the types.
Environment
@vladmandic/face-api": "^1.7.8
and"@tensorflow/tfjs-node": "^4.2.0"
.js
,esm
,esm-nobundle
)? CommonJS.tsc
andts-node
executing it directly.