Open Panepo opened 5 years ago
Just tried tensorflow KNN classifier for face matching process, but do not know which is better. Anyone have ideas? Thanks
A part of the training code is as follows
const classifier = knnClassifier.create()
await Promise.all(
this.props.train.face.map(async face => {
const image = await faceapi.fetchImage(face)
const descriptors = await faceapi.computeFaceDescriptor(image)
const tensor = tf.tensor(descriptors)
classifier.addExample(tensor, 'Name')
})
)
A part of the recognizing code is as follows
const results = await faceapi
.detectAllFaces(
image,
new faceapi.TinyFaceDetectorOptions({
inputSize: environment.tinyInputSize,
scoreThreshold: environment.tinyThreshold
})
)
.withFaceLandmarks(true)
.withFaceDescriptors()
if (results) {
faceapi.matchDimensions(canvas, image)
const resizedResults = faceapi.resizeResults(results, image)
resizedResults.forEach(async ({ detection, descriptor }) => {
const tensor = tf.tensor(descriptor)
const predict = await this.classifier.predictClass(tensor, 1)
const label = predict.label.toString()
const options = { label }
const drawBox = new faceapi.draw.DrawBox(detection.box, options)
drawBox.draw(canvas)
})
}
Hi @justadudewhohacks
As you wrote before. The face match process is computing the every euclidean distance between the descriptor of your photo and the descriptors from your database.
The computation time will increase with the database growing. Is there any methods to speed up the face matching process ?
Thanks