Merge pull request #34 from patrickhulce/patch-1

fix: return empty descriptor for zero-sized faces
pull/39/head
Vladimir Mandic 2021-01-24 10:13:52 -05:00 committed by GitHub
commit 09b2e8215d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -61,6 +61,10 @@ export class FaceRecognitionNet extends NeuralNetwork<NetParams> {
}
public async computeFaceDescriptor(input: TNetInput): Promise<Float32Array|Float32Array[]> {
// When faces have a detected dimension of 0, tensorflow will crash the whole process.
// Sidestep this by returning an empty descriptor instead.
if (input.shape.some(dimension => dimension <= 0) return new Float32Array(128);
const netInput = await toNetInput(input);
const faceDescriptorTensors = tf.tidy(