Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
face-api.js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
allan
face-api.js
Commits
731e34fa
Commit
731e34fa
authored
May 07, 2019
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix nodejs tests
parent
eb6c7a17
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
13 deletions
+23
-13
package.json
package.json
+2
-0
ageGenderNet.test.ts
test/tests/ageGenderNet/ageGenderNet.test.ts
+1
-1
detectAllFaces.test.ts
test/tests/globalApi/detectAllFaces.test.ts
+12
-9
detectSingleFace.test.ts
test/tests/globalApi/detectSingleFace.test.ts
+2
-1
utils.ts
test/utils.ts
+6
-2
No files found.
package.json
View file @
731e34fa
...
...
@@ -18,8 +18,10 @@
"test-all-include-uncompressed"
:
"npm run test-browser && npm run test-node"
,
"test-facelandmarknets"
:
"set UUT=faceLandmarkNet&& karma start"
,
"test-facerecognitionnet"
:
"set UUT=faceRecognitionNet&& karma start"
,
"test-agegendernet"
:
"set UUT=ageGenderNet&& karma start"
,
"test-ssdmobilenetv1"
:
"set UUT=ssdMobilenetv1&& karma start"
,
"test-tinyfacedetector"
:
"set UUT=tinyFaceDetector&& karma start"
,
"test-globalapi"
:
"set UUT=globalApi&& karma start"
,
"test-mtcnn"
:
"set UUT=mtcnn&& karma start"
,
"test-cpu"
:
"set BACKEND_CPU=true&& karma start"
,
"test-exclude-uncompressed"
:
"set EXCLUDE_UNCOMPRESSED=true&& karma start"
,
...
...
test/tests/ageGenderNet/ageGenderNet.test.ts
View file @
731e34fa
...
...
@@ -6,7 +6,7 @@ import { loadImage } from '../../env';
import
{
describeWithBackend
,
describeWithNets
,
expectAllTensorsReleased
}
from
'../../utils'
;
function
expectResultsAngry
(
result
:
AgeAndGenderPrediction
)
{
expect
(
result
.
age
).
toBeGreaterThanOrEqual
(
3
8
)
expect
(
result
.
age
).
toBeGreaterThanOrEqual
(
3
6
)
expect
(
result
.
age
).
toBeLessThanOrEqual
(
42
)
expect
(
result
.
gender
).
toEqual
(
'male'
)
expect
(
result
.
genderProbability
).
toBeGreaterThanOrEqual
(
0.9
)
...
...
test/tests/globalApi/detectAllFaces.test.ts
View file @
731e34fa
import
*
as
faceapi
from
'../../../src'
;
import
{
WithAge
}
from
'../../../src/factories/WithAge'
;
import
{
WithFaceDetection
}
from
'../../../src/factories/WithFaceDetection'
;
import
{
WithFaceExpressions
}
from
'../../../src/factories/WithFaceExpressions'
;
import
{
WithGender
}
from
'../../../src/factories/WithGender'
;
import
{
loadImage
}
from
'../../env'
;
...
...
@@ -12,11 +13,12 @@ import {
describeWithNets
,
expectAllTensorsReleased
,
ExpectedFullFaceDescription
,
sortByFaceDetection
,
}
from
'../../utils'
;
import
{
deltas
,
expectedScores
,
faceDetectorOptions
,
withNetArgs
}
from
'./consts'
;
function
expectFaceExpressions
(
results
:
WithFaceExpressions
<
{}
>
[])
{
results
.
forEach
((
result
,
i
)
=>
{
function
expectFaceExpressions
(
results
:
WithFaceExpressions
<
WithFaceDetection
<
{}
>
>
[])
{
sortByFaceDetection
(
results
)
.
forEach
((
result
,
i
)
=>
{
const
{
happy
,
neutral
}
=
result
.
expressions
const
happyProb
=
i
===
4
?
0
:
0.95
...
...
@@ -27,17 +29,18 @@ function expectFaceExpressions(results: WithFaceExpressions<{}>[]) {
})
}
const
ages
=
[
41
,
26
,
37
,
27
,
31
,
34
]
const
agesUnaligned
=
[
3
7
,
30
,
22
,
26
,
36
,
33
]
const
genders
=
[
'
male'
,
'female'
,
'female'
,
'
male'
,
'male'
,
'female'
]
const
ages
=
[
34
,
27
,
41
,
26
,
31
,
37
]
const
agesUnaligned
=
[
3
3
,
26
,
37
,
30
,
36
,
22
]
const
genders
=
[
'
female'
,
'male'
,
'male'
,
'fe
male'
,
'male'
,
'female'
]
function
expectAgesAndGender
(
results
:
WithAge
<
WithGender
<
{}
>>
[],
aligned
=
true
)
{
results
.
forEach
((
result
,
i
)
=>
{
function
expectAgesAndGender
(
results
:
WithAge
<
WithGender
<
WithFaceDetection
<
{}
>
>>
[],
aligned
=
true
)
{
sortByFaceDetection
(
results
)
.
forEach
((
result
,
i
)
=>
{
const
{
age
,
gender
,
genderProbability
}
=
result
expect
(
Math
.
round
(
age
)).
toEqual
(
aligned
?
ages
[
i
]
:
agesUnaligned
[
i
])
const
expectedAge
=
aligned
?
ages
[
i
]
:
agesUnaligned
[
i
]
expect
(
Math
.
abs
(
age
-
expectedAge
)).
toBeLessThanOrEqual
(
5
)
expect
(
gender
).
toEqual
(
genders
[
i
])
expect
(
genderProbability
).
toBeGreaterThanOrEqual
(
i
===
5
?
0.7
:
0.9
)
expect
(
genderProbability
).
toBeGreaterThanOrEqual
(
i
===
0
?
0.65
:
0.9
)
})
}
...
...
test/tests/globalApi/detectSingleFace.test.ts
View file @
731e34fa
...
...
@@ -27,7 +27,8 @@ function expectAgeAndGender(result: WithAge<WithGender<{}>> | undefined, aligned
expect
(
!!
result
).
toBeTruthy
()
if
(
result
)
{
const
{
age
,
gender
,
genderProbability
}
=
result
expect
(
Math
.
round
(
age
)).
toEqual
(
aligned
?
41
:
37
)
const
expectedAge
=
aligned
?
41
:
37
expect
(
Math
.
abs
(
age
-
expectedAge
)).
toBeLessThanOrEqual
(
5
)
expect
(
gender
).
toEqual
(
'male'
)
expect
(
genderProbability
).
toBeGreaterThanOrEqual
(
0.9
)
}
...
...
test/utils.ts
View file @
731e34fa
...
...
@@ -72,8 +72,12 @@ export function sortLandmarks(landmarks: FaceLandmarks[]) {
return
sortByDistanceToOrigin
(
landmarks
,
l
=>
l
.
positions
[
0
])
}
export
function
sortByFaceDetection
<
T
extends
{
detection
:
FaceDetection
}
>
(
descs
:
T
[])
{
return
sortByDistanceToOrigin
(
descs
,
d
=>
d
.
detection
.
box
)
export
function
sortByFaceBox
<
T
extends
{
box
:
IRect
}
>
(
objs
:
T
[])
{
return
sortByDistanceToOrigin
(
objs
,
o
=>
o
.
box
)
}
export
function
sortByFaceDetection
<
T
extends
{
detection
:
FaceDetection
}
>
(
objs
:
T
[])
{
return
sortByDistanceToOrigin
(
objs
,
d
=>
d
.
detection
.
box
)
}
export
type
ExpectedFaceDetectionWithLandmarks
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment