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
58e1e11b
Commit
58e1e11b
authored
May 05, 2019
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests + let typescript automatically figure out return values of composable tasks
parent
52858047
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
53 deletions
+52
-53
ComputeFaceDescriptorsTasks.ts
src/globalApi/ComputeFaceDescriptorsTasks.ts
+8
-8
DetectFaceLandmarksTasks.ts
src/globalApi/DetectFaceLandmarksTasks.ts
+12
-12
DetectFacesTasks.ts
src/globalApi/DetectFacesTasks.ts
+8
-8
PredictAgeAndGenderTask.ts
src/globalApi/PredictAgeAndGenderTask.ts
+8
-8
PredictFaceExpressionsTask.ts
src/globalApi/PredictFaceExpressionsTask.ts
+8
-8
TinyXception.ts
src/xception/TinyXception.ts
+1
-2
tinyFaceDetector.test.ts
test/tests/tinyFaceDetector/tinyFaceDetector.test.ts
+7
-7
No files found.
src/globalApi/ComputeFaceDescriptorsTasks.ts
View file @
58e1e11b
...
...
@@ -45,12 +45,12 @@ export class ComputeAllFaceDescriptorsTask<
return
descriptors
.
map
((
descriptor
,
i
)
=>
extendWithFaceDescriptor
<
TSource
>
(
parentResults
[
i
],
descriptor
))
}
withFaceExpressions
()
:
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withAgeAndGender
()
:
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withAgeAndGender
()
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
...
...
@@ -75,11 +75,11 @@ export class ComputeSingleFaceDescriptorTask<
return
extendWithFaceDescriptor
(
parentResult
,
descriptor
)
}
withFaceExpressions
()
:
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withAgeAndGender
()
:
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withAgeAndGender
()
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
\ No newline at end of file
src/globalApi/DetectFaceLandmarksTasks.ts
View file @
58e1e11b
...
...
@@ -59,16 +59,16 @@ export class DetectAllFaceLandmarksTask<
)
}
withFaceExpressions
()
:
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withAgeAndGender
()
:
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withAgeAndGender
()
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withFaceDescriptors
()
:
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceDescriptors
()
{
return
new
ComputeAllFaceDescriptorsTask
(
this
,
this
.
input
)
}
}
...
...
@@ -95,15 +95,15 @@ export class DetectSingleFaceLandmarksTask<
return
extendWithFaceLandmarks
<
TSource
>
(
parentResult
,
landmarks
)
}
withFaceExpressions
()
:
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withAgeAndGender
()
:
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withAgeAndGender
()
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withFaceDescriptor
()
:
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceDescriptor
()
{
return
new
ComputeSingleFaceDescriptorTask
(
this
,
this
.
input
)
}
}
\ No newline at end of file
src/globalApi/DetectFacesTasks.ts
View file @
58e1e11b
...
...
@@ -57,16 +57,16 @@ export class DetectAllFacesTask extends DetectFacesTaskBase<FaceDetection[]> {
})
}
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
:
DetectAllFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
{
return
new
DetectAllFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
(
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
{
return
new
DetectAllFaceLandmarksTask
(
this
.
runAndExtendWithFaceDetections
(),
this
.
input
,
useTinyLandmarkNet
)
}
withFaceExpressions
()
:
PredictAllFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
{
return
new
PredictAllFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
(
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsTask
(
this
.
runAndExtendWithFaceDetections
(),
this
.
input
)
...
...
@@ -93,16 +93,16 @@ export class DetectSingleFaceTask extends DetectFacesTaskBase<FaceDetection | un
})
}
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
:
DetectSingleFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
{
return
new
DetectSingleFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
(
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
{
return
new
DetectSingleFaceLandmarksTask
(
this
.
runAndExtendWithFaceDetection
(),
this
.
input
,
useTinyLandmarkNet
)
}
withFaceExpressions
()
:
PredictSingleFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
{
return
new
PredictSingleFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
(
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsTask
(
this
.
runAndExtendWithFaceDetection
(),
this
.
input
)
...
...
src/globalApi/PredictAgeAndGenderTask.ts
View file @
58e1e11b
...
...
@@ -75,12 +75,12 @@ export class PredictAllAgeAndGenderWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictAllAgeAndGenderTask
<
TSource
>
{
withFaceExpressions
()
:
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withFaceDescriptors
()
:
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceDescriptors
()
{
return
new
ComputeAllFaceDescriptorsTask
(
this
,
this
.
input
)
}
}
...
...
@@ -88,11 +88,11 @@ export class PredictSingleAgeAndGenderWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictSingleAgeAndGenderTask
<
TSource
>
{
withFaceExpressions
()
:
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withFaceDescriptor
()
:
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceDescriptor
()
{
return
new
ComputeSingleFaceDescriptorTask
(
this
,
this
.
input
)
}
}
\ No newline at end of file
src/globalApi/PredictFaceExpressionsTask.ts
View file @
58e1e11b
...
...
@@ -73,12 +73,12 @@ export class PredictAllFaceExpressionsWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictAllFaceExpressionsTask
<
TSource
>
{
withAgeAndGender
()
:
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withAgeAndGender
()
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withFaceDescriptors
()
:
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceDescriptors
()
{
return
new
ComputeAllFaceDescriptorsTask
(
this
,
this
.
input
)
}
}
...
...
@@ -86,11 +86,11 @@ export class PredictSingleFaceExpressionsWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictSingleFaceExpressionsTask
<
TSource
>
{
withAgeAndGender
()
:
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withAgeAndGender
()
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
withFaceDescriptor
()
:
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
{
return
new
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
withFaceDescriptor
()
{
return
new
ComputeSingleFaceDescriptorTask
(
this
,
this
.
input
)
}
}
\ No newline at end of file
src/xception/TinyXception.ts
View file @
58e1e11b
...
...
@@ -55,9 +55,8 @@ export class TinyXception extends NeuralNetwork<TinyXceptionParams> {
return
tf
.
tidy
(()
=>
{
const
batchTensor
=
input
.
toBatchTensor
(
112
,
true
)
const
batchTensorRgb
=
bgrToRgbTensor
(
batchTensor
)
const
meanRgb
=
[
122.782
,
117.001
,
104.298
]
const
normalized
=
normalize
(
batchTensor
Rgb
,
meanRgb
).
div
(
tf
.
scalar
(
256
))
as
tf
.
Tensor4D
const
normalized
=
normalize
(
batchTensor
,
meanRgb
).
div
(
tf
.
scalar
(
256
))
as
tf
.
Tensor4D
let
out
=
tf
.
relu
(
conv
(
normalized
,
params
.
entry_flow
.
conv_in
,
[
2
,
2
]))
out
=
reductionBlock
(
out
,
params
.
entry_flow
.
reduction_block_0
,
false
)
...
...
test/tests/tinyFaceDetector/tinyFaceDetector.test.ts
View file @
58e1e11b
...
...
@@ -78,15 +78,15 @@ describeWithBackend('tinyFaceDetector', () => {
expectFaceExpressions
(
results
)
})
it
(
'detectAllFaces.withFace
Expressions().withFaceLandmark
s()'
,
async
()
=>
{
it
(
'detectAllFaces.withFace
Landmarks().withFaceExpression
s()'
,
async
()
=>
{
const
options
=
new
TinyFaceDetectorOptions
({
inputSize
:
416
})
const
results
=
await
faceapi
.
detectAllFaces
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
expect
(
results
.
length
).
toEqual
(
6
)
expectFaceExpressions
(
results
)
...
...
@@ -114,8 +114,8 @@ describeWithBackend('tinyFaceDetector', () => {
const
results
=
await
faceapi
.
detectAllFaces
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
.
withFaceDescriptors
()
expect
(
results
.
length
).
toEqual
(
6
)
...
...
@@ -183,15 +183,15 @@ describeWithBackend('tinyFaceDetector', () => {
result
&&
expect
(
result
.
expressions
.
happy
).
toBeGreaterThanOrEqual
(
0.95
)
})
it
(
'detectSingleFace.withFace
Expressions().withFaceLandmark
s()'
,
async
()
=>
{
it
(
'detectSingleFace.withFace
Landmarks().withFaceExpression
s()'
,
async
()
=>
{
const
options
=
new
TinyFaceDetectorOptions
({
inputSize
:
416
})
const
result
=
await
faceapi
.
detectSingleFace
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
expect
(
!!
result
).
toBeTruthy
()
expectFaceDetectionsWithLandmarks
(
...
...
@@ -222,15 +222,15 @@ describeWithBackend('tinyFaceDetector', () => {
)
})
it
(
'detectSingleFace.withFace
Expressions().withFaceLandmark
s().withFaceDescriptor()'
,
async
()
=>
{
it
(
'detectSingleFace.withFace
Landmarks().withFaceExpression
s().withFaceDescriptor()'
,
async
()
=>
{
const
options
=
new
TinyFaceDetectorOptions
({
inputSize
:
416
})
const
result
=
await
faceapi
.
detectSingleFace
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
.
withFaceDescriptor
()
expect
(
!!
result
).
toBeTruthy
()
...
...
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