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
c493d1fd
Commit
c493d1fd
authored
Jun 07, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last fixes for architecture
parent
45c9d6f8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
13 deletions
+14
-13
index.ts
src/faceDetectionNet/index.ts
+4
-5
mobileNetV1.ts
src/faceDetectionNet/mobileNetV1.ts
+2
-1
outputLayer.ts
src/faceDetectionNet/outputLayer.ts
+6
-6
pointwiseConvLayer.ts
src/faceDetectionNet/pointwiseConvLayer.ts
+2
-1
No files found.
src/faceDetectionNet/index.ts
View file @
c493d1fd
...
@@ -67,7 +67,6 @@ export function faceDetectionNet(weights: Float32Array) {
...
@@ -67,7 +67,6 @@ export function faceDetectionNet(weights: Float32Array) {
})
})
}
}
// TODO debug output
function
forward
(
input
:
ImageData
|
ImageData
[]
|
number
[])
{
function
forward
(
input
:
ImageData
|
ImageData
[]
|
number
[])
{
return
tf
.
tidy
(
return
tf
.
tidy
(
()
=>
forwardTensor
(
getImgTensor
(
input
))
()
=>
forwardTensor
(
getImgTensor
(
input
))
...
@@ -100,10 +99,10 @@ export function faceDetectionNet(weights: Float32Array) {
...
@@ -100,10 +99,10 @@ export function faceDetectionNet(weights: Float32Array) {
.
map
(({
score
,
idx
})
=>
({
.
map
(({
score
,
idx
})
=>
({
score
,
score
,
box
:
{
box
:
{
left
:
Math
.
max
(
0
,
width
*
boxes
.
get
(
idx
,
0
)),
top
:
Math
.
max
(
0
,
height
*
boxes
.
get
(
idx
,
0
)),
right
:
Math
.
min
(
width
,
width
*
boxes
.
get
(
idx
,
1
)),
left
:
Math
.
max
(
0
,
width
*
boxes
.
get
(
idx
,
1
)),
top
:
Math
.
max
(
0
,
height
*
boxes
.
get
(
idx
,
2
)),
bottom
:
Math
.
min
(
height
,
height
*
boxes
.
get
(
idx
,
2
)),
bottom
:
Math
.
min
(
height
,
height
*
boxes
.
get
(
idx
,
3
))
right
:
Math
.
min
(
width
,
width
*
boxes
.
get
(
idx
,
3
))
}
}
}))
}))
...
...
src/faceDetectionNet/mobileNetV1.ts
View file @
c493d1fd
...
@@ -21,7 +21,7 @@ function depthwiseConvLayer(
...
@@ -21,7 +21,7 @@ function depthwiseConvLayer(
params
.
batch_norm_scale
,
params
.
batch_norm_scale
,
params
.
batch_norm_offset
params
.
batch_norm_offset
)
)
return
tf
.
relu
(
out
)
return
tf
.
clipByValue
(
out
,
0
,
6
)
})
})
}
}
...
@@ -35,6 +35,7 @@ export function mobileNetV1(x: tf.Tensor4D, params: FaceDetectionNet.MobileNetV1
...
@@ -35,6 +35,7 @@ export function mobileNetV1(x: tf.Tensor4D, params: FaceDetectionNet.MobileNetV1
let
conv11
=
null
let
conv11
=
null
let
out
=
pointwiseConvLayer
(
x
,
params
.
conv_0_params
,
[
2
,
2
])
let
out
=
pointwiseConvLayer
(
x
,
params
.
conv_0_params
,
[
2
,
2
])
params
.
conv_pair_params
.
forEach
((
param
,
i
)
=>
{
params
.
conv_pair_params
.
forEach
((
param
,
i
)
=>
{
const
layerIdx
=
i
+
1
const
layerIdx
=
i
+
1
const
depthwiseConvStrides
=
getStridesForLayerIdx
(
layerIdx
)
const
depthwiseConvStrides
=
getStridesForLayerIdx
(
layerIdx
)
...
...
src/faceDetectionNet/outputLayer.ts
View file @
c493d1fd
...
@@ -30,17 +30,17 @@ function decodeBoxesLayer(x0: tf.Tensor2D, x1: tf.Tensor2D) {
...
@@ -30,17 +30,17 @@ function decodeBoxesLayer(x0: tf.Tensor2D, x1: tf.Tensor2D) {
const
vec
=
tf
.
unstack
(
tf
.
transpose
(
x1
,
[
1
,
0
]))
const
vec
=
tf
.
unstack
(
tf
.
transpose
(
x1
,
[
1
,
0
]))
const
div0_out
=
tf
.
div
(
tf
.
mul
(
tf
.
exp
(
tf
.
div
(
vec
[
2
],
tf
.
scalar
(
5
))),
sizes
[
0
]),
tf
.
scalar
(
2
))
const
div0_out
=
tf
.
div
(
tf
.
mul
(
tf
.
exp
(
tf
.
div
(
vec
[
2
],
tf
.
scalar
(
5
))),
sizes
[
0
]),
tf
.
scalar
(
2
))
const
add0_out
=
tf
.
add
(
tf
.
mul
(
tf
.
exp
(
tf
.
div
(
vec
[
0
],
tf
.
scalar
(
10
)
)),
sizes
[
0
]),
centers
[
0
])
const
add0_out
=
tf
.
add
(
tf
.
mul
(
tf
.
div
(
vec
[
0
],
tf
.
scalar
(
10
)),
sizes
[
0
]),
centers
[
0
])
const
div1_out
=
tf
.
div
(
tf
.
mul
(
tf
.
exp
(
tf
.
div
(
vec
[
3
],
tf
.
scalar
(
5
))),
sizes
[
1
]),
tf
.
scalar
(
2
))
const
div1_out
=
tf
.
div
(
tf
.
mul
(
tf
.
exp
(
tf
.
div
(
vec
[
3
],
tf
.
scalar
(
5
))),
sizes
[
1
]),
tf
.
scalar
(
2
))
const
add1_out
=
tf
.
add
(
tf
.
mul
(
tf
.
exp
(
tf
.
div
(
vec
[
1
],
tf
.
scalar
(
10
)
)),
sizes
[
1
]),
centers
[
1
])
const
add1_out
=
tf
.
add
(
tf
.
mul
(
tf
.
div
(
vec
[
1
],
tf
.
scalar
(
10
)),
sizes
[
1
]),
centers
[
1
])
return
tf
.
transpose
(
return
tf
.
transpose
(
tf
.
stack
([
tf
.
stack
([
tf
.
sub
(
div0_out
,
add
0_out
),
tf
.
sub
(
add0_out
,
div
0_out
),
tf
.
sub
(
div1_out
,
add
1_out
),
tf
.
sub
(
add1_out
,
div
1_out
),
tf
.
add
(
div0_out
,
add
0_out
),
tf
.
add
(
add0_out
,
div
0_out
),
tf
.
add
(
div1_out
,
add
1_out
)
tf
.
add
(
add1_out
,
div
1_out
)
]),
]),
[
1
,
0
]
[
1
,
0
]
)
)
...
...
src/faceDetectionNet/pointwiseConvLayer.ts
View file @
c493d1fd
...
@@ -11,7 +11,7 @@ export function pointwiseConvLayer(
...
@@ -11,7 +11,7 @@ export function pointwiseConvLayer(
let
out
=
tf
.
conv2d
(
x
,
params
.
filters
,
strides
,
'same'
)
let
out
=
tf
.
conv2d
(
x
,
params
.
filters
,
strides
,
'same'
)
out
=
tf
.
add
(
out
,
params
.
batch_norm_offset
)
out
=
tf
.
add
(
out
,
params
.
batch_norm_offset
)
return
tf
.
relu
(
out
)
return
tf
.
clipByValue
(
out
,
0
,
6
)
})
})
}
}
\ 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