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
e7d1d043
Commit
e7d1d043
authored
Jul 12, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
concat score tensors before getting their data, apparently it's faster this way
parent
0e899bd2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
stage2.ts
src/mtcnn/stage2.ts
+7
-2
stage3.ts
src/mtcnn/stage3.ts
+7
-2
No files found.
src/mtcnn/stage2.ts
View file @
e7d1d043
import
{
tf
}
from
'..'
;
import
{
BoundingBox
}
from
'./BoundingBox'
;
import
{
BoundingBox
}
from
'./BoundingBox'
;
import
{
extractImagePatches
}
from
'./extractImagePatches'
;
import
{
extractImagePatches
}
from
'./extractImagePatches'
;
import
{
nms
}
from
'./nms'
;
import
{
nms
}
from
'./nms'
;
...
@@ -26,8 +27,12 @@ export async function stage2(
...
@@ -26,8 +27,12 @@ export async function stage2(
)
)
stats
.
stage2_rnet
=
Date
.
now
()
-
ts
stats
.
stage2_rnet
=
Date
.
now
()
-
ts
const
scoreDatas
=
await
Promise
.
all
(
rnetOuts
.
map
(
out
=>
out
.
scores
.
data
()))
const
scoresTensor
=
rnetOuts
.
length
>
1
const
scores
=
scoreDatas
.
map
(
arr
=>
Array
.
from
(
arr
)).
reduce
((
all
,
arr
)
=>
all
.
concat
(
arr
))
?
tf
.
concat
(
rnetOuts
.
map
(
out
=>
out
.
scores
))
:
rnetOuts
[
0
].
scores
const
scores
=
Array
.
from
(
await
scoresTensor
.
data
())
scoresTensor
.
dispose
()
const
indices
=
scores
const
indices
=
scores
.
map
((
score
,
idx
)
=>
({
score
,
idx
}))
.
map
((
score
,
idx
)
=>
({
score
,
idx
}))
.
filter
(
c
=>
c
.
score
>
scoreThreshold
)
.
filter
(
c
=>
c
.
score
>
scoreThreshold
)
...
...
src/mtcnn/stage3.ts
View file @
e7d1d043
...
@@ -4,6 +4,7 @@ import { extractImagePatches } from './extractImagePatches';
...
@@ -4,6 +4,7 @@ import { extractImagePatches } from './extractImagePatches';
import
{
nms
}
from
'./nms'
;
import
{
nms
}
from
'./nms'
;
import
{
ONet
}
from
'./ONet'
;
import
{
ONet
}
from
'./ONet'
;
import
{
ONetParams
}
from
'./types'
;
import
{
ONetParams
}
from
'./types'
;
import
{
tf
}
from
'..'
;
export
async
function
stage3
(
export
async
function
stage3
(
img
:
HTMLCanvasElement
,
img
:
HTMLCanvasElement
,
...
@@ -27,8 +28,12 @@ export async function stage3(
...
@@ -27,8 +28,12 @@ export async function stage3(
)
)
stats
.
stage3_onet
=
Date
.
now
()
-
ts
stats
.
stage3_onet
=
Date
.
now
()
-
ts
const
scoreDatas
=
await
Promise
.
all
(
onetOuts
.
map
(
out
=>
out
.
scores
.
data
()))
const
scoresTensor
=
onetOuts
.
length
>
1
const
scores
=
scoreDatas
.
map
(
arr
=>
Array
.
from
(
arr
)).
reduce
((
all
,
arr
)
=>
all
.
concat
(
arr
))
?
tf
.
concat
(
onetOuts
.
map
(
out
=>
out
.
scores
))
:
onetOuts
[
0
].
scores
const
scores
=
Array
.
from
(
await
scoresTensor
.
data
())
scoresTensor
.
dispose
()
const
indices
=
scores
const
indices
=
scores
.
map
((
score
,
idx
)
=>
({
score
,
idx
}))
.
map
((
score
,
idx
)
=>
({
score
,
idx
}))
.
filter
(
c
=>
c
.
score
>
scoreThreshold
)
.
filter
(
c
=>
c
.
score
>
scoreThreshold
)
...
...
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