faceDescriptors of different faces are exactly the same? What am I doing wrong?
See original GitHub issueHi
I am running
faceapi.detectSingleFace(image).withFaceLandmarks().withAgeAndGender().withFaceDescriptor();
of different images/faces and most not all of them have the exact same faceDescriptor values.
This seems wrong. Looking at their detection object, they clearly are different.
What am I doing wrong?
Here is my code where I try to find unique faces.
export const detectFace = async (image, frameNumber, detectionArray, uniqueFaceArray) => {
// detect expression
const face = await faceapi.detectSingleFace(image).withFaceLandmarks().withAgeAndGender().withFaceDescriptor();
console.log(frameNumber);
// check if a face was detected
if (face !== undefined) {
const { age, gender, descriptor, detection } = face;
const { relativeBox, score } = detection;
const size = Math.round(relativeBox.height * 100);
const scoreInPercent = Math.round(score * 100);
// console.log(face);
if (size < FACE_SIZE_THRESHOLD || scoreInPercent < FACE_DETECTION_CONFIDENCE_SCORE) {
console.log('detected face below size or confidence threshold!');
return undefined;
}
// create full copy of array to be pushed later
const copyOfDescriptor = descriptor.slice();
console.log(detection);
console.log(uniqueFaceArray);
// console.log(copyOfDescriptor);
// initialise the faceId
let faceId = 0;
// check for uniqueness
// if the uniqueFaceArray is empty just push the current descriptor
// else compare the current descriptor to the ones in the uniqueFaceArray
const uniqueFaceArrayLength = uniqueFaceArray.length;
if (uniqueFaceArrayLength === 0) {
uniqueFaceArray.push(copyOfDescriptor);
} else {
// compare descriptor value with all values in the array
for (let i = 0; i < uniqueFaceArrayLength; i += 1) {
const dist = faceapi.euclideanDistance(copyOfDescriptor, uniqueFaceArray[i]);
console.log(`${faceId}, ${frameNumber}`);
console.log(dist);
// if no match was found add the current descriptor to the array marking a unique face
if (dist < FACE_UNIQUENESS_THRESHOLD) {
// console.log(`face matches face ${i}`);
faceId = i;
break;
} else if (i === uniqueFaceArrayLength - 1) {
console.log('face is unique');
uniqueFaceArray.push(copyOfDescriptor);
faceId = uniqueFaceArrayLength;
}
}
}
// console.log(`frameNumber: ${frameNumber}, Score: ${score}, Size: ${size}, Gender: ${gender}, Age: ${age}`);
detectionArray.push({
faceId,
frameNumber,
score: scoreInPercent,
size,
gender,
age: Math.round(age),
})
return detection;
}
console.log('no face detected!');
return undefined;
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
What to do with face descriptors of the same person from ...
The question is NOT how to serialize them, but when there are hundreds of different photos of the same person, yet each yielding...
Read more >Texture mapping, Part 2
The faceVertexUvs property is an array of an array of “face descriptors”. Each face descriptor is an array of exactly three “face texture...
Read more >How to Perform Face Recognition With VGGFace2 in Keras
Face detection is the process of automatically locating faces in a photograph and localizing them by drawing a bounding box around their extent....
Read more >Facial Recognition SPA for BNK48 Idol group using React and ...
Just like fingerprint, Face Descriptor is a unique value of each face. Face Descriptors of same person from different image sources should ...
Read more >Hyperfamiliarity for faces - PMC - NCBI - NIH
Facial familiarity can be dissociated from semantic or autobiographic elements of episodic memory since we may feel that we saw a face before,...
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
Finally I made it work and it seems that reading the images properly also has solved the originally stated issue. I was unfortunately not successful with
node-canvas
, but made it work withtfjs-node
. Thanks to @whyboris for the tip!This is indeed very suspicious, can you post an example image where this issue occurs?
The only two reasons I can think of is, that somethings wrong with your code, or theres something going wrong in the tfjs backend due to your system environment.
Could you give some information about your environment? (browser or nodejs, which browser / nodejs version, your OS and which backend you are using, cpu or webgl)