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
e95dd35d
Commit
e95dd35d
authored
Jul 30, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow arbitrary input size
parent
28a77453
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
9 deletions
+10
-9
TinyYolov2.ts
src/tinyYolov2/TinyYolov2.ts
+8
-7
config.ts
src/tinyYolov2/config.ts
+0
-1
types.ts
src/tinyYolov2/types.ts
+2
-1
No files found.
src/tinyYolov2/TinyYolov2.ts
View file @
e95dd35d
...
...
@@ -8,7 +8,7 @@ import { FaceDetection } from '../FaceDetection';
import
{
NetInput
}
from
'../NetInput'
;
import
{
toNetInput
}
from
'../toNetInput'
;
import
{
TNetInput
}
from
'../types'
;
import
{
BOX_ANCHORS
,
INPUT_SIZES
,
IOU_THRESHOLD
,
NUM_BOXES
,
NUM_CELLS
}
from
'./config'
;
import
{
BOX_ANCHORS
,
INPUT_SIZES
,
IOU_THRESHOLD
,
NUM_BOXES
}
from
'./config'
;
import
{
convWithBatchNorm
}
from
'./convWithBatchNorm'
;
import
{
extractParams
}
from
'./extractParams'
;
import
{
getDefaultParams
}
from
'./getDefaultParams'
;
...
...
@@ -59,18 +59,19 @@ export class TinyYolov2 extends NeuralNetwork<NetParams> {
public
async
locateFaces
(
input
:
TNetInput
,
forwardParams
:
TinyYolov2ForwardParams
=
{}):
Promise
<
FaceDetection
[]
>
{
const
{
sizeTyp
e
,
scoreThreshold
}
=
getDefaultParams
(
forwardParams
)
const
{
inputSize
:
_inputSiz
e
,
scoreThreshold
}
=
getDefaultParams
(
forwardParams
)
const
inputSize
=
typeof
_inputSize
===
'string'
?
INPUT_SIZES
[
_inputSize
]
:
_inputSize
const
inputSize
=
INPUT_SIZES
[
sizeType
]
const
numCells
=
NUM_CELLS
[
sizeType
]
if
(
!
inputSize
)
{
throw
new
Error
(
`TinyYolov2 - unkown sizeType:
${
sizeType
}
, expected one of: xs | sm | md | lg`
)
if
(
typeof
inputSize
!==
'number'
)
{
throw
new
Error
(
`TinyYolov2 - unkown inputSize:
${
inputSize
}
, expected number or one of xs | sm | md | lg`
)
}
const
netInput
=
await
toNetInput
(
input
,
true
)
const
out
=
await
this
.
forwardInput
(
netInput
,
inputSize
)
const
numCells
=
out
.
shape
[
1
]
const
[
boxesTensor
,
scoresTensor
]
=
tf
.
tidy
(()
=>
{
const
reshaped
=
out
.
reshape
([
numCells
,
numCells
,
NUM_BOXES
,
6
])
...
...
src/tinyYolov2/config.ts
View file @
e95dd35d
import
{
Point
}
from
'../Point'
;
export
const
INPUT_SIZES
=
{
xs
:
224
,
sm
:
320
,
md
:
416
,
lg
:
608
}
export
const
NUM_CELLS
=
{
xs
:
7
,
sm
:
10
,
md
:
13
,
lg
:
19
}
export
const
NUM_BOXES
=
5
export
const
IOU_THRESHOLD
=
0.4
...
...
src/tinyYolov2/types.ts
View file @
e95dd35d
...
...
@@ -32,6 +32,6 @@ export enum SizeType {
}
export
type
TinyYolov2ForwardParams
=
{
sizeType
?:
SizeType
inputSize
?:
SizeType
|
number
scoreThreshold
?:
number
}
\ 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