Commit 37609c20 authored by vincent's avatar vincent

move task composition test cases from tinyFaceDetector.test to globalApi test...

move task composition test cases from tinyFaceDetector.test to globalApi test suite + add test cases for withAgeAndGender()
parent 5ff0c5c5
......@@ -11,7 +11,9 @@ import { ComputeAllFaceDescriptorsTask, ComputeSingleFaceDescriptorTask } from '
import { extractAllFacesAndComputeResults, extractSingleFaceAndComputeResult } from './extractFacesAndComputeResults';
import { nets } from './nets';
import {
PredictAllFaceExpressionsTask,
PredictAllFaceExpressionsWithFaceAlignmentTask,
PredictSingleFaceExpressionsTask,
PredictSingleFaceExpressionsWithFaceAlignmentTask,
} from './PredictFaceExpressionsTask';
......@@ -47,6 +49,10 @@ export class PredictAllAgeAndGenderTask<
return extendWithAge(extendWithGender(parentResult, gender, genderProbability), age)
})
}
withFaceExpressions() {
return new PredictAllFaceExpressionsTask(this, this.input)
}
}
export class PredictSingleAgeAndGenderTask<
......@@ -69,6 +75,10 @@ export class PredictSingleAgeAndGenderTask<
return extendWithAge(extendWithGender(parentResult, gender, genderProbability), age)
}
withFaceExpressions() {
return new PredictSingleFaceExpressionsTask(this, this.input)
}
}
export class PredictAllAgeAndGenderWithFaceAlignmentTask<
......
......@@ -10,7 +10,9 @@ import { ComputeAllFaceDescriptorsTask, ComputeSingleFaceDescriptorTask } from '
import { extractAllFacesAndComputeResults, extractSingleFaceAndComputeResult } from './extractFacesAndComputeResults';
import { nets } from './nets';
import {
PredictAllAgeAndGenderTask,
PredictAllAgeAndGenderWithFaceAlignmentTask,
PredictSingleAgeAndGenderTask,
PredictSingleAgeAndGenderWithFaceAlignmentTask,
} from './PredictAgeAndGenderTask';
......@@ -45,6 +47,10 @@ export class PredictAllFaceExpressionsTask<
(parentResult, i) => extendWithFaceExpressions<TSource>(parentResult, faceExpressionsByFace[i])
)
}
withAgeAndGender() {
return new PredictAllAgeAndGenderTask(this, this.input)
}
}
export class PredictSingleFaceExpressionsTask<
......@@ -67,6 +73,10 @@ export class PredictSingleFaceExpressionsTask<
return extendWithFaceExpressions(parentResult, faceExpressions)
}
withAgeAndGender() {
return new PredictSingleAgeAndGenderTask(this, this.input)
}
}
export class PredictAllFaceExpressionsWithFaceAlignmentTask<
......
import { IRect } from '../../../src';
import { sortBoxes } from '../../utils';
import { IRect } from '../src';
import { sortBoxes } from './utils';
export const expectedTinyFaceDetectorBoxes: IRect[] = sortBoxes([
{ x: 29, y: 264, width: 139, height: 137 },
......
import { TinyFaceDetectorOptions } from '../../../src';
export const withNetArgs = {
withAllFacesTinyFaceDetector: true,
withFaceExpressionNet: { quantized: true },
withAgeGenderNet: { quantized: true }
}
export const expectedScores = [0.7, 0.82, 0.93, 0.86, 0.79, 0.84]
export const deltas = {
maxScoreDelta: 0.05,
maxBoxDelta: 5,
maxLandmarksDelta: 10,
maxDescriptorDelta: 0.2
}
export const faceDetectorOptions = new TinyFaceDetectorOptions({
inputSize: 416
})
\ No newline at end of file
import * as faceapi from '../../../src';
import { WithAge } from '../../../src/factories/WithAge';
import { WithFaceExpressions } from '../../../src/factories/WithFaceExpressions';
import { WithGender } from '../../../src/factories/WithGender';
import { loadImage } from '../../env';
import { expectedTinyFaceDetectorBoxes } from '../../expectedTinyFaceDetectorBoxes';
import { expectFaceDetectionsWithLandmarks } from '../../expectFaceDetectionsWithLandmarks';
import { expectFullFaceDescriptions } from '../../expectFullFaceDescriptions';
import {
assembleExpectedFullFaceDescriptions,
describeWithBackend,
describeWithNets,
expectAllTensorsReleased,
ExpectedFullFaceDescription,
} from '../../utils';
import { deltas, expectedScores, faceDetectorOptions, withNetArgs } from './consts';
function expectFaceExpressions(results: WithFaceExpressions<{}>[]) {
results.forEach((result, i) => {
const { happy, neutral } = result.expressions
const happyProb = i === 4 ? 0 : 0.95
const neutralProb = i === 4 ? 0.4 : 0
expect(happy).toBeGreaterThanOrEqual(happyProb)
expect(neutral).toBeGreaterThanOrEqual(neutralProb)
})
}
const ages = [41, 26, 37, 27, 31, 34]
const agesUnaligned = [37, 30, 22, 26, 36, 33]
const genders = ['male', 'female', 'female', 'male', 'male', 'female']
function expectAgesAndGender(results: WithAge<WithGender<{}>>[], aligned = true) {
results.forEach((result, i) => {
const { age, gender, genderProbability } = result
expect(Math.round(age)).toEqual(aligned ? ages[i] : agesUnaligned[i])
expect(gender).toEqual(genders[i])
expect(genderProbability).toBeGreaterThanOrEqual(i === 5 ? 0.7 : 0.9)
})
}
describeWithBackend('globalApi', () => {
let imgEl: HTMLImageElement
let expectedFullFaceDescriptions: ExpectedFullFaceDescription[]
beforeAll(async () => {
imgEl = await loadImage('test/images/faces.jpg')
expectedFullFaceDescriptions = await assembleExpectedFullFaceDescriptions(expectedTinyFaceDetectorBoxes)
})
describeWithNets('detectAllFaces', withNetArgs, () => {
describe('without face alignment', () => {
it('detectAllFaces.withFaceExpressions()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceExpressions()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
})
it('detectAllFaces.withAgeAndGender()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withAgeAndGender()
expect(results.length).toEqual(6)
expectAgesAndGender(results, false)
})
it('detectAllFaces.withFaceExpressions().withAgeAndGender()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceExpressions()
.withAgeAndGender()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectAgesAndGender(results, false)
})
it('detectAllFaces.withAgeAndGender().withFaceExpressions()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withAgeAndGender()
.withFaceExpressions()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectAgesAndGender(results, false)
})
})
describe('with face alignment', () => {
it('detectAllFaces.withFaceLandmarks().withFaceExpressions()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectFaceDetectionsWithLandmarks(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withAgeAndGender()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withAgeAndGender()
expect(results.length).toEqual(6)
expectAgesAndGender(results)
expectFaceDetectionsWithLandmarks(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withFaceDescriptors()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceDescriptors()
expect(results.length).toEqual(6)
expectFullFaceDescriptions(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withFaceExpressions().withAgeAndGender()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withAgeAndGender()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectAgesAndGender(results)
expectFaceDetectionsWithLandmarks(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withAgeAndGender().withFaceExpressions()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withAgeAndGender()
.withFaceExpressions()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectAgesAndGender(results)
expectFaceDetectionsWithLandmarks(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withFaceExpressions().withFaceDescriptors()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withFaceDescriptors()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectFullFaceDescriptions(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withAgeAndGender().withFaceDescriptors()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withAgeAndGender()
.withFaceDescriptors()
expect(results.length).toEqual(6)
expectAgesAndGender(results)
expectFullFaceDescriptions(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withFaceExpressions().withAgeAndGender().withFaceDescriptors()', async () => {
const results = await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withAgeAndGender()
.withFaceDescriptors()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectAgesAndGender(results)
expectFullFaceDescriptions(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
})
describe('no memory leaks', () => {
it('detectAllFaces.withFaceLandmarks().withFaceDescriptors()', async () => {
await expectAllTensorsReleased(async () => {
await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceDescriptors()
})
})
it('detectAllFaces.withFaceLandmarks().withFaceExpressions().withAgeAndGender().withFaceDescriptors()', async () => {
await expectAllTensorsReleased(async () => {
await faceapi
.detectAllFaces(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withAgeAndGender()
.withFaceDescriptors()
})
})
})
})
})
\ No newline at end of file
import * as faceapi from '../../../src';
import { WithAge } from '../../../src/factories/WithAge';
import { WithFaceExpressions } from '../../../src/factories/WithFaceExpressions';
import { WithGender } from '../../../src/factories/WithGender';
import { loadImage } from '../../env';
import { expectedTinyFaceDetectorBoxes } from '../../expectedTinyFaceDetectorBoxes';
import { expectFaceDetectionsWithLandmarks } from '../../expectFaceDetectionsWithLandmarks';
import { expectFullFaceDescriptions } from '../../expectFullFaceDescriptions';
import {
assembleExpectedFullFaceDescriptions,
describeWithBackend,
describeWithNets,
expectAllTensorsReleased,
ExpectedFullFaceDescription,
} from '../../utils';
import { deltas, expectedScores, faceDetectorOptions, withNetArgs } from './consts';
function expectFaceExpressions(result: WithFaceExpressions<{}> | undefined) {
expect(!!result).toBeTruthy()
if (result) {
expect(result.expressions.happy).toBeGreaterThanOrEqual(0.95)
}
}
function expectAgeAndGender(result: WithAge<WithGender<{}>> | undefined, aligned = true) {
expect(!!result).toBeTruthy()
if (result) {
const { age, gender, genderProbability } = result
expect(Math.round(age)).toEqual(aligned ? 41 : 37)
expect(gender).toEqual('male')
expect(genderProbability).toBeGreaterThanOrEqual(0.9)
}
}
describeWithBackend('globalApi', () => {
let imgEl: HTMLImageElement
let expectedFullFaceDescriptions: ExpectedFullFaceDescription[]
beforeAll(async () => {
imgEl = await loadImage('test/images/faces.jpg')
expectedFullFaceDescriptions = await assembleExpectedFullFaceDescriptions(expectedTinyFaceDetectorBoxes)
})
function expectFaceDetectionWithLandmarks(result: faceapi.WithFaceLandmarks<faceapi.WithFaceDetection<{}>> | undefined) {
expect(!!result).toBeTruthy()
if (result) {
expectFaceDetectionsWithLandmarks(
[result],
[expectedFullFaceDescriptions[2]],
[expectedScores[2]],
deltas
)
}
}
function expectFullFaceDescription(result: faceapi.WithFaceDescriptor<faceapi.WithFaceLandmarks<faceapi.WithFaceDetection<{}>>> | undefined) {
expect(!!result).toBeTruthy()
if (result) {
expectFullFaceDescriptions(
[result],
[expectedFullFaceDescriptions[2]],
[expectedScores[2]],
deltas
)
}
}
describeWithNets('detectSingleFace', withNetArgs, () => {
describe('without face alignment', () => {
it('detectSingleFace.withFaceExpressions()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceExpressions()
expectFaceExpressions(result)
})
it('detectSingleFace.withAgeAndGender()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withAgeAndGender()
expectAgeAndGender(result, false)
})
it('detectSingleFace.withFaceExpressions().withAgeAndGender()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceExpressions()
.withAgeAndGender()
expectFaceExpressions(result)
expectAgeAndGender(result, false)
})
it('detectSingleFace.withAgeAndGender().withFaceExpressions()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withAgeAndGender()
.withFaceExpressions()
expectFaceExpressions(result)
expectAgeAndGender(result, false)
})
})
describe('with face alignment', () => {
it('detectSingleFace.withFaceLandmarks().withFaceExpressions()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
expectFaceExpressions(result)
expectFaceDetectionWithLandmarks(result)
})
it('detectSingleFace.withFaceLandmarks().withAgeAndGender()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withAgeAndGender()
expectAgeAndGender(result)
expectFaceDetectionWithLandmarks(result)
})
it('detectSingleFace.withFaceLandmarks().withFaceDescriptor()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceDescriptor()
expectFullFaceDescription(result)
})
it('detectSingleFace.withFaceLandmarks().withFaceExpressions().withAgeAndGender()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withAgeAndGender()
expectFaceExpressions(result)
expectAgeAndGender(result)
expectFaceDetectionWithLandmarks(result)
})
it('detectSingleFace.withFaceLandmarks().withAgeAndGender().withFaceExpressions()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withAgeAndGender()
.withFaceExpressions()
expectFaceExpressions(result)
expectAgeAndGender(result)
expectFaceDetectionWithLandmarks(result)
})
it('detectSingleFace.withFaceLandmarks().withFaceExpressions().withFaceDescriptor()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withFaceDescriptor()
expectFaceExpressions(result)
expectFullFaceDescription(result)
})
it('detectSingleFace.withFaceLandmarks().withAgeAndGender().withFaceDescriptor()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withAgeAndGender()
.withFaceDescriptor()
expectAgeAndGender(result)
expectFullFaceDescription(result)
})
it('detectSingleFace.withFaceLandmarks().withFaceExpressions().withAgeAndGender().withFaceDescriptor()', async () => {
const result = await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withAgeAndGender()
.withFaceDescriptor()
expectFaceExpressions(result)
expectAgeAndGender(result)
expectFullFaceDescription(result)
})
})
describe('no memory leaks', () => {
it('detectSingleFace.withFaceLandmarks().withFaceDescriptor()', async () => {
await expectAllTensorsReleased(async () => {
await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceDescriptor()
})
})
it('detectSingleFace.withFaceLandmarks().withFaceExpressions().withAgeAndGender().withFaceDescriptor()', async () => {
await expectAllTensorsReleased(async () => {
await faceapi
.detectSingleFace(imgEl, faceDetectorOptions)
.withFaceLandmarks()
.withFaceExpressions()
.withAgeAndGender()
.withFaceDescriptor()
})
})
})
})
})
\ No newline at end of file
......@@ -2,7 +2,7 @@ import * as faceapi from '../../../src';
import { loadImage } from '../../env';
import { expectFaceDetections } from '../../expectFaceDetections';
import { describeWithBackend, describeWithNets } from '../../utils';
import { expectedTinyFaceDetectorBoxes } from './expectedBoxes';
import { expectedTinyFaceDetectorBoxes } from '../../expectedTinyFaceDetectorBoxes';
describeWithBackend('tinyFaceDetector.locateFaces', () => {
......
......@@ -4,7 +4,7 @@ import { TinyFaceDetectorOptions, createCanvasFromMedia } from '../../../src';
import { expectFaceDetections } from '../../expectFaceDetections';
import { expectFullFaceDescriptions } from '../../expectFullFaceDescriptions';
import { expectFaceDetectionsWithLandmarks } from '../../expectFaceDetectionsWithLandmarks';
import { expectedTinyFaceDetectorBoxes } from './expectedBoxes';
import { expectedTinyFaceDetectorBoxes } from '../../expectedTinyFaceDetectorBoxes';
import { loadImage } from '../../env';
import * as tf from '@tensorflow/tfjs-core';
......@@ -88,7 +88,7 @@ describe('tinyFaceDetector - node', () => {
maxLandmarksDelta: 10,
maxDescriptorDelta: 0.2
}
expect(!!result).toBeTruthy()
expectFullFaceDescriptions(
result ? [result] : [],
......
......@@ -4,21 +4,8 @@ import { TinyFaceDetectorOptions } from '../../../src';
import { expectFaceDetections } from '../../expectFaceDetections';
import { expectFullFaceDescriptions } from '../../expectFullFaceDescriptions';
import { expectFaceDetectionsWithLandmarks } from '../../expectFaceDetectionsWithLandmarks';
import { expectedTinyFaceDetectorBoxes } from './expectedBoxes';
import { expectedTinyFaceDetectorBoxes } from '../../expectedTinyFaceDetectorBoxes';
import { loadImage } from '../../env';
import { WithFaceExpressions } from '../../../src/factories/WithFaceExpressions';
function expectFaceExpressions(results: WithFaceExpressions<{}>[]) {
results.forEach((result, i) => {
const { happy, neutral } = result.expressions
const happyProb = i === 4 ? 0 : 0.95
const neutralProb = i === 4 ? 0.4 : 0
expect(happy).toBeGreaterThanOrEqual(happyProb)
expect(neutral).toBeGreaterThanOrEqual(neutralProb)
})
}
describeWithBackend('tinyFaceDetector', () => {
......@@ -37,7 +24,7 @@ describeWithBackend('tinyFaceDetector', () => {
expectedFullFaceDescriptions = await assembleExpectedFullFaceDescriptions(expectedTinyFaceDetectorBoxes)
})
describeWithNets('globalApi', { withAllFacesTinyFaceDetector: true, withFaceExpressionNet: { quantized: true } }, () => {
describeWithNets('tinyFaceDetector', { withAllFacesTinyFaceDetector: true, withFaceExpressionNet: { quantized: true } }, () => {
describe('detectAllFaces', () => {
......@@ -65,34 +52,6 @@ describeWithBackend('tinyFaceDetector', () => {
expectFaceDetectionsWithLandmarks(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceExpressions()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
})
const results = await faceapi
.detectAllFaces(imgEl, options)
.withFaceExpressions()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
})
it('detectAllFaces.withFaceLandmarks().withFaceExpressions()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
})
const results = await faceapi
.detectAllFaces(imgEl, options)
.withFaceLandmarks()
.withFaceExpressions()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectFaceDetectionsWithLandmarks(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withFaceDescriptors()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
......@@ -107,22 +66,6 @@ describeWithBackend('tinyFaceDetector', () => {
expectFullFaceDescriptions(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
it('detectAllFaces.withFaceLandmarks().withFaceExpressions()withFaceDescriptors()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
})
const results = await faceapi
.detectAllFaces(imgEl, options)
.withFaceLandmarks()
.withFaceExpressions()
.withFaceDescriptors()
expect(results.length).toEqual(6)
expectFaceExpressions(results)
expectFullFaceDescriptions(results, expectedFullFaceDescriptions, expectedScores, deltas)
})
})
describe('detectSingleFace', () => {
......@@ -163,46 +106,6 @@ describeWithBackend('tinyFaceDetector', () => {
)
})
it('detectSingleFace.withFaceExpressions()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
})
const result = await faceapi
.detectSingleFace(imgEl, options)
.withFaceExpressions()
expect(!!result).toBeTruthy()
expectFaceDetections(
result ? [result.detection] : [],
[expectedTinyFaceDetectorBoxes[2]],
[expectedScores[2]],
deltas.maxScoreDelta,
deltas.maxBoxDelta
)
result && expect(result.expressions.happy).toBeGreaterThanOrEqual(0.95)
})
it('detectSingleFace.withFaceLandmarks().withFaceExpressions()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
})
const result = await faceapi
.detectSingleFace(imgEl, options)
.withFaceLandmarks()
.withFaceExpressions()
expect(!!result).toBeTruthy()
expectFaceDetectionsWithLandmarks(
result ? [result] : [],
[expectedFullFaceDescriptions[2]],
[expectedScores[2]],
deltas
)
result && expect(result.expressions.happy).toBeGreaterThanOrEqual(0.95)
})
it('detectSingleFace.withFaceLandmarks().withFaceDescriptor()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
......@@ -222,27 +125,6 @@ describeWithBackend('tinyFaceDetector', () => {
)
})
it('detectSingleFace.withFaceLandmarks().withFaceExpressions().withFaceDescriptor()', async () => {
const options = new TinyFaceDetectorOptions({
inputSize: 416
})
const result = await faceapi
.detectSingleFace(imgEl, options)
.withFaceLandmarks()
.withFaceExpressions()
.withFaceDescriptor()
expect(!!result).toBeTruthy()
expectFullFaceDescriptions(
result ? [result] : [],
[expectedFullFaceDescriptions[2]],
[expectedScores[2]],
deltas
)
result && expect(result.expressions.happy).toBeGreaterThanOrEqual(0.95)
})
})
describe('no memory leaks', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment