Error: FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>
See original GitHub issueThe documentation for FaceMatcher throws an exception in NodeJS. Although faceapi.detectAllFaces
finds faces, new faceapi.FaceMatcher(faceResults)
throws an exception. Can you please let us know what we should be doing here?
Code:
await faceapi.nets.ssdMobilenetv1.loadFromDisk(modelUrl)
await faceapi.nets.faceLandmark68Net.loadFromDisk(modelUrl)
await faceapi.nets.faceRecognitionNet.loadFromDisk(modelUrl)
const faceBase64 = 'data:image/jpg;base64,' + fs.readFileSync(`./tests/data/face1.jpg`, {encoding: 'base64'})
const faceImage = new Image()
faceImage.src = faceBase64
const faceResults = await faceapi.detectAllFaces(faceImage)
.withFaceLandmarks()
.withFaceDescriptors()
if (!faceResults.length) { // length is 1
return
}
const faceMatcher = new faceapi.FaceMatcher(faceResults) // --> Exception
Error: FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>
at /Users/.../node_modules/face-api.js/src/globalApi/FaceMatcher.ts:40:13
at Array.map (<anonymous>)
at new FaceMatcher (/Users/.../node_modules/face-api.js/src/globalApi/FaceMatcher.ts:27:43)
at ...
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Float32Array - JavaScript - MDN Web Docs
Chrome Edge
Float32Array Full support. Chrome7. Toggle history Full support. Edge12...
Float32Array() constructor Full support. Chrome7. Toggle history Full support. Edge12...
Constructor without parameters Full support....
Read more >FaceMatcher | face-api.js
Constructors. constructor. new FaceMatcher(inputs: LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors ...
Read more >Face recognition in javascript using face api getting "Uncaught ...
Apologies for the delay, my problem was solved by changing the images. The error was because it could not identify a face (descriptor)...
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
Hi @Karthik-tr , thank you for pointing out. I also faced same error after adding your code. Actually
faceResults
is a list with one item and not a json object. So to accessdescriptor
, you need to specify index likefaceResults[0].descriptor
Try below code, it should work.
Yes i use a single face detector. Hence I made the mistake of assuming that the descriptor only has one object. Mine works well. Thanks for the inputs