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
b65c74c1
Commit
b65c74c1
authored
Jul 12, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dispose image and input tensors on early return
parent
e7d1d043
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
Mtcnn.ts
src/mtcnn/Mtcnn.ts
+11
-9
No files found.
src/mtcnn/Mtcnn.ts
View file @
b65c74c1
...
@@ -54,6 +54,14 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
...
@@ -54,6 +54,14 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
)
)
)
)
const
onReturn
=
(
results
:
any
)
=>
{
// dispose tensors on return
imgTensor
.
dispose
()
input
.
dispose
()
stats
.
total
=
Date
.
now
()
-
tsTotal
return
results
}
const
[
height
,
width
]
=
imgTensor
.
shape
.
slice
(
1
)
const
[
height
,
width
]
=
imgTensor
.
shape
.
slice
(
1
)
const
scales
=
pyramidDown
(
minFaceSize
,
scaleFactor
,
[
height
,
width
])
const
scales
=
pyramidDown
(
minFaceSize
,
scaleFactor
,
[
height
,
width
])
...
@@ -71,8 +79,7 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
...
@@ -71,8 +79,7 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
stats
.
total_stage1
=
Date
.
now
()
-
ts
stats
.
total_stage1
=
Date
.
now
()
-
ts
if
(
!
out1
.
boxes
.
length
)
{
if
(
!
out1
.
boxes
.
length
)
{
stats
.
total
=
Date
.
now
()
-
tsTotal
return
onReturn
({
results
:
[],
stats
})
return
{
results
:
[],
stats
}
}
}
stats
.
stage2_numInputBoxes
=
out1
.
boxes
.
length
stats
.
stage2_numInputBoxes
=
out1
.
boxes
.
length
...
@@ -83,8 +90,7 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
...
@@ -83,8 +90,7 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
stats
.
total_stage2
=
Date
.
now
()
-
ts
stats
.
total_stage2
=
Date
.
now
()
-
ts
if
(
!
out2
.
boxes
.
length
)
{
if
(
!
out2
.
boxes
.
length
)
{
stats
.
total
=
Date
.
now
()
-
tsTotal
return
onReturn
({
results
:
[],
stats
})
return
{
results
:
[],
stats
}
}
}
stats
.
stage3_numInputBoxes
=
out2
.
boxes
.
length
stats
.
stage3_numInputBoxes
=
out2
.
boxes
.
length
...
@@ -93,9 +99,6 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
...
@@ -93,9 +99,6 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
const
out3
=
await
stage3
(
inputCanvas
,
out2
.
boxes
,
scoreThresholds
[
2
],
params
.
onet
,
stats
)
const
out3
=
await
stage3
(
inputCanvas
,
out2
.
boxes
,
scoreThresholds
[
2
],
params
.
onet
,
stats
)
stats
.
total_stage3
=
Date
.
now
()
-
ts
stats
.
total_stage3
=
Date
.
now
()
-
ts
imgTensor
.
dispose
()
input
.
dispose
()
const
results
=
out3
.
boxes
.
map
((
box
,
idx
)
=>
({
const
results
=
out3
.
boxes
.
map
((
box
,
idx
)
=>
({
faceDetection
:
new
FaceDetection
(
faceDetection
:
new
FaceDetection
(
out3
.
scores
[
idx
],
out3
.
scores
[
idx
],
...
@@ -116,8 +119,7 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
...
@@ -116,8 +119,7 @@ export class Mtcnn extends NeuralNetwork<NetParams> {
)
)
}))
}))
stats
.
total
=
Date
.
now
()
-
tsTotal
return
onReturn
({
results
,
stats
})
return
{
results
,
stats
}
}
}
public
async
forward
(
public
async
forward
(
...
...
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