Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
face
Project
Overview
Details
Activity
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
Иван Кубота
face
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
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
53 deletions
+56
-53
ComputeFaceDescriptorsTasks.ts
src/globalApi/ComputeFaceDescriptorsTasks.ts
+9
-8
DetectFaceLandmarksTasks.ts
src/globalApi/DetectFaceLandmarksTasks.ts
+13
-12
DetectFacesTasks.ts
src/globalApi/DetectFacesTasks.ts
+8
-8
PredictAgeAndGenderTask.ts
src/globalApi/PredictAgeAndGenderTask.ts
+9
-8
PredictFaceExpressionsTask.ts
src/globalApi/PredictFaceExpressionsTask.ts
+9
-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<
...
@@ -45,12 +45,12 @@ export class ComputeAllFaceDescriptorsTask<
return
descriptors
.
map
((
descriptor
,
i
)
=>
extendWithFaceDescriptor
<
TSource
>
(
parentResults
[
i
],
descriptor
))
return
descriptors
.
map
((
descriptor
,
i
)
=>
extendWithFaceDescriptor
<
TSource
>
(
parentResults
[
i
],
descriptor
))
}
}
withFaceExpressions
()
:
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withAgeAndGender
()
:
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withAgeAndGender
()
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
}
}
...
@@ -75,11 +75,11 @@ export class ComputeSingleFaceDescriptorTask<
...
@@ -75,11 +75,11 @@ export class ComputeSingleFaceDescriptorTask<
return
extendWithFaceDescriptor
(
parentResult
,
descriptor
)
return
extendWithFaceDescriptor
(
parentResult
,
descriptor
)
}
}
withFaceExpressions
()
:
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withAgeAndGender
()
:
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withAgeAndGender
()
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
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<
...
@@ -59,16 +59,16 @@ export class DetectAllFaceLandmarksTask<
)
)
}
}
withFaceExpressions
()
:
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withAgeAndGender
()
:
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withAgeAndGender
()
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withFaceDescriptors
()
:
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceDescriptors
()
{
return
new
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
ComputeAllFaceDescriptorsTask
(
this
,
this
.
input
)
}
}
}
}
...
@@ -95,15 +95,15 @@ export class DetectSingleFaceLandmarksTask<
...
@@ -95,15 +95,15 @@ export class DetectSingleFaceLandmarksTask<
return
extendWithFaceLandmarks
<
TSource
>
(
parentResult
,
landmarks
)
return
extendWithFaceLandmarks
<
TSource
>
(
parentResult
,
landmarks
)
}
}
withFaceExpressions
()
:
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withAgeAndGender
()
:
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withAgeAndGender
()
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withFaceDescriptor
()
:
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceDescriptor
()
{
return
new
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
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[]> {
...
@@ -57,16 +57,16 @@ export class DetectAllFacesTask extends DetectFacesTaskBase<FaceDetection[]> {
})
})
}
}
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
:
DetectAllFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
{
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
{
return
new
DetectAllFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
(
return
new
DetectAllFaceLandmarksTask
(
this
.
runAndExtendWithFaceDetections
(),
this
.
runAndExtendWithFaceDetections
(),
this
.
input
,
this
.
input
,
useTinyLandmarkNet
useTinyLandmarkNet
)
)
}
}
withFaceExpressions
()
:
PredictAllFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
{
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
(
return
new
PredictAllFaceExpressionsTask
(
this
.
runAndExtendWithFaceDetections
(),
this
.
runAndExtendWithFaceDetections
(),
this
.
input
this
.
input
)
)
...
@@ -93,16 +93,16 @@ export class DetectSingleFaceTask extends DetectFacesTaskBase<FaceDetection | un
...
@@ -93,16 +93,16 @@ export class DetectSingleFaceTask extends DetectFacesTaskBase<FaceDetection | un
})
})
}
}
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
:
DetectSingleFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
{
withFaceLandmarks
(
useTinyLandmarkNet
:
boolean
=
false
)
{
return
new
DetectSingleFaceLandmarksTask
<
WithFaceDetection
<
{}
>>
(
return
new
DetectSingleFaceLandmarksTask
(
this
.
runAndExtendWithFaceDetection
(),
this
.
runAndExtendWithFaceDetection
(),
this
.
input
,
this
.
input
,
useTinyLandmarkNet
useTinyLandmarkNet
)
)
}
}
withFaceExpressions
()
:
PredictSingleFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
{
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsTask
<
WithFaceDetection
<
{}
>>
(
return
new
PredictSingleFaceExpressionsTask
(
this
.
runAndExtendWithFaceDetection
(),
this
.
runAndExtendWithFaceDetection
(),
this
.
input
this
.
input
)
)
...
...
src/globalApi/PredictAgeAndGenderTask.ts
View file @
58e1e11b
...
@@ -75,12 +75,12 @@ export class PredictAllAgeAndGenderWithFaceAlignmentTask<
...
@@ -75,12 +75,12 @@ export class PredictAllAgeAndGenderWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictAllAgeAndGenderTask
<
TSource
>
{
>
extends
PredictAllAgeAndGenderTask
<
TSource
>
{
withFaceExpressions
()
:
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceExpressions
()
{
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictAllFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withFaceDescriptors
()
:
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceDescriptors
()
{
return
new
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
ComputeAllFaceDescriptorsTask
(
this
,
this
.
input
)
}
}
}
}
...
@@ -88,11 +88,11 @@ export class PredictSingleAgeAndGenderWithFaceAlignmentTask<
...
@@ -88,11 +88,11 @@ export class PredictSingleAgeAndGenderWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictSingleAgeAndGenderTask
<
TSource
>
{
>
extends
PredictSingleAgeAndGenderTask
<
TSource
>
{
withFaceExpressions
()
:
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceExpressions
()
{
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictSingleFaceExpressionsWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withFaceDescriptor
()
:
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceDescriptor
()
{
return
new
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
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<
...
@@ -73,12 +73,12 @@ export class PredictAllFaceExpressionsWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictAllFaceExpressionsTask
<
TSource
>
{
>
extends
PredictAllFaceExpressionsTask
<
TSource
>
{
withAgeAndGender
()
:
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withAgeAndGender
()
{
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictAllAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withFaceDescriptors
()
:
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceDescriptors
()
{
return
new
ComputeAllFaceDescriptorsTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
ComputeAllFaceDescriptorsTask
(
this
,
this
.
input
)
}
}
}
}
...
@@ -86,11 +86,11 @@ export class PredictSingleFaceExpressionsWithFaceAlignmentTask<
...
@@ -86,11 +86,11 @@ export class PredictSingleFaceExpressionsWithFaceAlignmentTask<
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
TSource
extends
WithFaceLandmarks
<
WithFaceDetection
<
{}
>>
>
extends
PredictSingleFaceExpressionsTask
<
TSource
>
{
>
extends
PredictSingleFaceExpressionsTask
<
TSource
>
{
withAgeAndGender
()
:
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
{
withAgeAndGender
()
{
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
return
new
PredictSingleAgeAndGenderWithFaceAlignmentTask
(
this
,
this
.
input
)
}
}
withFaceDescriptor
()
:
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
{
withFaceDescriptor
()
{
return
new
ComputeSingleFaceDescriptorTask
<
WithFaceLandmarks
<
TSource
>>
(
this
,
this
.
input
)
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> {
...
@@ -55,9 +55,8 @@ export class TinyXception extends NeuralNetwork<TinyXceptionParams> {
return
tf
.
tidy
(()
=>
{
return
tf
.
tidy
(()
=>
{
const
batchTensor
=
input
.
toBatchTensor
(
112
,
true
)
const
batchTensor
=
input
.
toBatchTensor
(
112
,
true
)
const
batchTensorRgb
=
bgrToRgbTensor
(
batchTensor
)
const
meanRgb
=
[
122.782
,
117.001
,
104.298
]
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
]))
let
out
=
tf
.
relu
(
conv
(
normalized
,
params
.
entry_flow
.
conv_in
,
[
2
,
2
]))
out
=
reductionBlock
(
out
,
params
.
entry_flow
.
reduction_block_0
,
false
)
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', () => {
...
@@ -78,15 +78,15 @@ describeWithBackend('tinyFaceDetector', () => {
expectFaceExpressions
(
results
)
expectFaceExpressions
(
results
)
})
})
it
(
'detectAllFaces.withFace
Expressions().withFaceLandmark
s()'
,
async
()
=>
{
it
(
'detectAllFaces.withFace
Landmarks().withFaceExpression
s()'
,
async
()
=>
{
const
options
=
new
TinyFaceDetectorOptions
({
const
options
=
new
TinyFaceDetectorOptions
({
inputSize
:
416
inputSize
:
416
})
})
const
results
=
await
faceapi
const
results
=
await
faceapi
.
detectAllFaces
(
imgEl
,
options
)
.
detectAllFaces
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
expect
(
results
.
length
).
toEqual
(
6
)
expect
(
results
.
length
).
toEqual
(
6
)
expectFaceExpressions
(
results
)
expectFaceExpressions
(
results
)
...
@@ -114,8 +114,8 @@ describeWithBackend('tinyFaceDetector', () => {
...
@@ -114,8 +114,8 @@ describeWithBackend('tinyFaceDetector', () => {
const
results
=
await
faceapi
const
results
=
await
faceapi
.
detectAllFaces
(
imgEl
,
options
)
.
detectAllFaces
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
.
withFaceDescriptors
()
.
withFaceDescriptors
()
expect
(
results
.
length
).
toEqual
(
6
)
expect
(
results
.
length
).
toEqual
(
6
)
...
@@ -183,15 +183,15 @@ describeWithBackend('tinyFaceDetector', () => {
...
@@ -183,15 +183,15 @@ describeWithBackend('tinyFaceDetector', () => {
result
&&
expect
(
result
.
expressions
.
happy
).
toBeGreaterThanOrEqual
(
0.95
)
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
({
const
options
=
new
TinyFaceDetectorOptions
({
inputSize
:
416
inputSize
:
416
})
})
const
result
=
await
faceapi
const
result
=
await
faceapi
.
detectSingleFace
(
imgEl
,
options
)
.
detectSingleFace
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
expect
(
!!
result
).
toBeTruthy
()
expect
(
!!
result
).
toBeTruthy
()
expectFaceDetectionsWithLandmarks
(
expectFaceDetectionsWithLandmarks
(
...
@@ -222,15 +222,15 @@ describeWithBackend('tinyFaceDetector', () => {
...
@@ -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
({
const
options
=
new
TinyFaceDetectorOptions
({
inputSize
:
416
inputSize
:
416
})
})
const
result
=
await
faceapi
const
result
=
await
faceapi
.
detectSingleFace
(
imgEl
,
options
)
.
detectSingleFace
(
imgEl
,
options
)
.
withFaceExpressions
()
.
withFaceLandmarks
()
.
withFaceLandmarks
()
.
withFaceExpressions
()
.
withFaceDescriptor
()
.
withFaceDescriptor
()
expect
(
!!
result
).
toBeTruthy
()
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