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
7152e12d
Commit
7152e12d
authored
Jul 03, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added face recognition net tests to identify memory leaks
parent
d3ddbb5d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
141 additions
and
0 deletions
+141
-0
faceRecognitionNet.test.ts
test/tests/e2e/faceRecognitionNet.test.ts
+141
-0
No files found.
test/tests/e2e/faceRecognitionNet.test.ts
View file @
7152e12d
import
*
as
tf
from
'@tensorflow/tfjs-core'
;
import
*
as
faceapi
from
'../../../src'
;
import
{
NetInput
}
from
'../../../src/NetInput'
;
import
{
expectAllTensorsReleased
}
from
'../../utils'
;
import
{
toNetInput
}
from
'../../../src'
;
describe
(
'faceRecognitionNet'
,
()
=>
{
...
...
@@ -153,4 +156,141 @@ describe('faceRecognitionNet', () => {
})
describe
(
'no memory leaks'
,
()
=>
{
let
faceRecognitionNet
:
faceapi
.
FaceRecognitionNet
beforeAll
(
async
()
=>
{
const
res
=
await
fetch
(
'base/weights/uncompressed/face_recognition_model.weights'
)
const
weights
=
new
Float32Array
(
await
res
.
arrayBuffer
())
faceRecognitionNet
=
faceapi
.
faceRecognitionNet
(
weights
)
})
describe
(
'forwardInput'
,
()
=>
{
it
(
'single image element'
,
async
()
=>
{
await
expectAllTensorsReleased
(
async
()
=>
{
const
netInput
=
(
new
NetInput
([
imgEl1
])).
managed
()
const
outTensor
=
await
faceRecognitionNet
.
forwardInput
(
netInput
)
outTensor
.
dispose
()
})
})
it
(
'multiple image elements'
,
async
()
=>
{
await
expectAllTensorsReleased
(
async
()
=>
{
const
netInput
=
(
new
NetInput
([
imgEl1
,
imgEl1
,
imgEl1
])).
managed
()
const
outTensor
=
await
faceRecognitionNet
.
forwardInput
(
netInput
)
outTensor
.
dispose
()
})
})
it
(
'single tf.Tensor3D'
,
async
()
=>
{
const
tensor
=
tf
.
fromPixels
(
imgEl1
)
await
expectAllTensorsReleased
(
async
()
=>
{
const
netInput
=
(
new
NetInput
([
tensor
])).
managed
()
const
outTensor
=
await
faceRecognitionNet
.
forwardInput
(
netInput
)
outTensor
.
dispose
()
})
tensor
.
dispose
()
})
it
(
'multiple tf.Tensor3Ds'
,
async
()
=>
{
const
tensors
=
[
imgEl1
,
imgEl1
,
imgEl1
].
map
(
el
=>
tf
.
fromPixels
(
el
))
await
expectAllTensorsReleased
(
async
()
=>
{
const
netInput
=
(
new
NetInput
(
tensors
)).
managed
()
const
outTensor
=
await
faceRecognitionNet
.
forwardInput
(
netInput
)
outTensor
.
dispose
()
})
tensors
.
forEach
(
t
=>
t
.
dispose
())
})
it
(
'single batch size 1 tf.Tensor4Ds'
,
async
()
=>
{
const
tensor
=
tf
.
tidy
(()
=>
tf
.
fromPixels
(
imgEl1
).
expandDims
())
as
tf
.
Tensor4D
await
expectAllTensorsReleased
(
async
()
=>
{
const
outTensor
=
await
faceRecognitionNet
.
forwardInput
(
await
toNetInput
(
tensor
,
true
))
outTensor
.
dispose
()
})
tensor
.
dispose
()
})
it
(
'multiple batch size 1 tf.Tensor4Ds'
,
async
()
=>
{
const
tensors
=
[
imgEl1
,
imgEl1
,
imgEl1
]
.
map
(
el
=>
tf
.
tidy
(()
=>
tf
.
fromPixels
(
el
).
expandDims
()))
as
tf
.
Tensor4D
[]
await
expectAllTensorsReleased
(
async
()
=>
{
const
outTensor
=
await
faceRecognitionNet
.
forwardInput
(
await
toNetInput
(
tensors
,
true
))
outTensor
.
dispose
()
})
tensors
.
forEach
(
t
=>
t
.
dispose
())
})
})
describe
(
'computeFaceDescriptor'
,
()
=>
{
it
(
'single image element'
,
async
()
=>
{
await
expectAllTensorsReleased
(
async
()
=>
{
await
faceRecognitionNet
.
computeFaceDescriptor
(
imgEl1
)
})
})
it
(
'multiple image elements'
,
async
()
=>
{
await
expectAllTensorsReleased
(
async
()
=>
{
await
faceRecognitionNet
.
computeFaceDescriptor
([
imgEl1
,
imgEl1
,
imgEl1
])
})
})
it
(
'single tf.Tensor3D'
,
async
()
=>
{
const
tensor
=
tf
.
fromPixels
(
imgEl1
)
await
expectAllTensorsReleased
(
async
()
=>
{
await
faceRecognitionNet
.
computeFaceDescriptor
(
tensor
)
})
tensor
.
dispose
()
})
it
(
'multiple tf.Tensor3Ds'
,
async
()
=>
{
const
tensors
=
[
imgEl1
,
imgEl1
,
imgEl1
].
map
(
el
=>
tf
.
fromPixels
(
el
))
await
expectAllTensorsReleased
(
async
()
=>
{
await
faceRecognitionNet
.
computeFaceDescriptor
(
tensors
)
})
tensors
.
forEach
(
t
=>
t
.
dispose
())
})
it
(
'single batch size 1 tf.Tensor4Ds'
,
async
()
=>
{
const
tensor
=
tf
.
tidy
(()
=>
tf
.
fromPixels
(
imgEl1
).
expandDims
())
as
tf
.
Tensor4D
await
expectAllTensorsReleased
(
async
()
=>
{
await
faceRecognitionNet
.
computeFaceDescriptor
(
tensor
)
})
tensor
.
dispose
()
})
it
(
'multiple batch size 1 tf.Tensor4Ds'
,
async
()
=>
{
const
tensors
=
[
imgEl1
,
imgEl1
,
imgEl1
]
.
map
(
el
=>
tf
.
tidy
(()
=>
tf
.
fromPixels
(
el
).
expandDims
()))
as
tf
.
Tensor4D
[]
await
expectAllTensorsReleased
(
async
()
=>
{
await
faceRecognitionNet
.
computeFaceDescriptor
(
tensors
)
})
tensors
.
forEach
(
t
=>
t
.
dispose
())
})
})
})
})
\ No newline at end of file
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