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
b09fbe45
Commit
b09fbe45
authored
Jul 31, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tinyYolov2 face detection examples
parent
e8c494d6
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
441 additions
and
4 deletions
+441
-4
commons.js
examples/public/commons.js
+13
-1
server.js
examples/server.js
+3
-0
mtcnnFaceDetection.html
examples/views/mtcnnFaceDetection.html
+0
-1
tinyYolov2FaceDetection.html
examples/views/tinyYolov2FaceDetection.html
+141
-0
tinyYolov2FaceDetectionVideo.html
examples/views/tinyYolov2FaceDetectionVideo.html
+129
-0
tinyYolov2FaceDetectionWebcam.html
examples/views/tinyYolov2FaceDetectionWebcam.html
+138
-0
globalApi.ts
src/globalApi.ts
+17
-2
No files found.
examples/public/commons.js
View file @
b09fbe45
...
@@ -135,6 +135,18 @@ function renderNavBar(navbarId, exampleUri) {
...
@@ -135,6 +135,18 @@ function renderNavBar(navbarId, exampleUri) {
name
:
'MTCNN Face Recognition Webcam'
name
:
'MTCNN Face Recognition Webcam'
},
},
{
{
uri
:
'tiny_yolov2_face_detection'
,
name
:
'Tiny Yolov2 Face Detection'
},
{
uri
:
'tiny_yolov2_face_detection_video'
,
name
:
'Tiny Yolov2 Face Detection Video'
},
{
uri
:
'tiny_yolov2_face_detection_webcam'
,
name
:
'Tiny Yolov2 Face Detection Webcam'
},
{
uri
:
'batch_face_landmarks'
,
uri
:
'batch_face_landmarks'
,
name
:
'Batch Face Landmarks'
name
:
'Batch Face Landmarks'
},
},
...
@@ -197,7 +209,7 @@ function renderNavBar(navbarId, exampleUri) {
...
@@ -197,7 +209,7 @@ function renderNavBar(navbarId, exampleUri) {
})
})
$
(
'.button-collapse'
).
sideNav
({
$
(
'.button-collapse'
).
sideNav
({
menuWidth
:
2
5
0
menuWidth
:
2
8
0
})
})
}
}
...
...
examples/server.js
View file @
b09fbe45
...
@@ -29,6 +29,9 @@ app.get('/mtcnn_face_detection_video', (req, res) => res.sendFile(path.join(view
...
@@ -29,6 +29,9 @@ app.get('/mtcnn_face_detection_video', (req, res) => res.sendFile(path.join(view
app
.
get
(
'/mtcnn_face_detection_webcam'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'mtcnnFaceDetectionWebcam.html'
)))
app
.
get
(
'/mtcnn_face_detection_webcam'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'mtcnnFaceDetectionWebcam.html'
)))
app
.
get
(
'/mtcnn_face_recognition'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'mtcnnFaceRecognition.html'
)))
app
.
get
(
'/mtcnn_face_recognition'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'mtcnnFaceRecognition.html'
)))
app
.
get
(
'/mtcnn_face_recognition_webcam'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'mtcnnFaceRecognitionWebcam.html'
)))
app
.
get
(
'/mtcnn_face_recognition_webcam'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'mtcnnFaceRecognitionWebcam.html'
)))
app
.
get
(
'/tiny_yolov2_face_detection'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'tinyYolov2FaceDetection.html'
)))
app
.
get
(
'/tiny_yolov2_face_detection_video'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'tinyYolov2FaceDetectionVideo.html'
)))
app
.
get
(
'/tiny_yolov2_face_detection_webcam'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'tinyYolov2FaceDetectionWebcam.html'
)))
app
.
get
(
'/batch_face_landmarks'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'batchFaceLandmarks.html'
)))
app
.
get
(
'/batch_face_landmarks'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'batchFaceLandmarks.html'
)))
app
.
get
(
'/batch_face_recognition'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'batchFaceRecognition.html'
)))
app
.
get
(
'/batch_face_recognition'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'batchFaceRecognition.html'
)))
...
...
examples/views/mtcnnFaceDetection.html
View file @
b09fbe45
...
@@ -58,7 +58,6 @@
...
@@ -58,7 +58,6 @@
let
stage1Threshold
=
0.7
let
stage1Threshold
=
0.7
let
stage2Threshold
=
0.7
let
stage2Threshold
=
0.7
let
stage3Threshold
=
0.7
let
stage3Threshold
=
0.7
let
mtcnn
function
onIncreaseThreshold
()
{
function
onIncreaseThreshold
()
{
minConfidence
=
Math
.
min
(
faceapi
.
round
(
minConfidence
+
0.1
),
1.0
)
minConfidence
=
Math
.
min
(
faceapi
.
round
(
minConfidence
+
0.1
),
1.0
)
...
...
examples/views/tinyYolov2FaceDetection.html
0 → 100644
View file @
b09fbe45
<!DOCTYPE html>
<html>
<head>
<script
src=
"face-api.js"
></script>
<script
src=
"commons.js"
></script>
<link
rel=
"stylesheet"
href=
"styles.css"
>
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css"
>
<script
type=
"text/javascript"
src=
"https://code.jquery.com/jquery-2.1.1.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"
></script>
</head>
<body>
<div
id=
"navbar"
></div>
<div
class=
"center-content page-container"
>
<div
class=
"progress"
id=
"loader"
>
<div
class=
"indeterminate"
></div>
</div>
<div
style=
"position: relative"
class=
"margin"
>
<img
id=
"inputImg"
src=
""
style=
"max-width: 800px;"
/>
<canvas
id=
"overlay"
/>
</div>
<div
class=
"row side-by-side"
>
<div
id=
"selectList"
></div>
<div
class=
"row"
>
<label
for=
"imgUrlInput"
>
Get image from URL:
</label>
<input
id=
"imgUrlInput"
type=
"text"
class=
"bold"
>
</div>
<button
class=
"waves-effect waves-light btn"
onclick=
"loadImageFromUrl()"
>
Ok
</button>
</div>
<div
class=
"row side-by-side"
>
<div
class=
"row input-field"
style=
"margin-right: 20px;"
>
<select
id=
"sizeType"
>
<option
value=
""
disabled
selected
>
Input Size:
</option>
<option
value=
"xs"
>
XS: 224 x 224
</option>
<option
value=
"sm"
>
SM: 320 x 320
</option>
<option
value=
"md"
>
MD: 416 x 416
</option>
<option
value=
"lg"
>
LG: 608 x 608
</option>
</select>
<label>
Input Size
</label>
</div>
<div
class=
"row"
>
<label
for=
"scoreThreshold"
>
Score Threshold:
</label>
<input
disabled
value=
"0.5"
id=
"scoreThreshold"
type=
"text"
class=
"bold"
>
</div>
<button
class=
"waves-effect waves-light btn"
onclick=
"onDecreaseThreshold()"
>
<i
class=
"material-icons left"
>
-
</i>
</button>
<button
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseThreshold()"
>
<i
class=
"material-icons left"
>
+
</i>
</button>
</div>
</div>
<script>
let
scoreThreshold
=
0.5
let
sizeType
=
'lg'
function
onIncreaseThreshold
()
{
scoreThreshold
=
Math
.
min
(
faceapi
.
round
(
scoreThreshold
+
0.1
),
1.0
)
$
(
'#scoreThreshold'
).
val
(
scoreThreshold
)
updateResults
()
}
function
onDecreaseThreshold
()
{
scoreThreshold
=
Math
.
max
(
faceapi
.
round
(
scoreThreshold
-
0.1
),
0.1
)
$
(
'#scoreThreshold'
).
val
(
scoreThreshold
)
updateResults
()
}
function
onSizeTypeChanged
(
e
,
c
)
{
sizeType
=
e
.
target
.
value
$
(
'#sizeType'
).
val
(
sizeType
)
updateResults
()
}
async
function
loadImageFromUrl
(
url
)
{
const
img
=
await
requestExternalImage
(
$
(
'#imgUrlInput'
).
val
())
$
(
'#inputImg'
).
get
(
0
).
src
=
img
.
src
updateResults
()
}
async
function
updateResults
()
{
const
inputImgEl
=
$
(
'#inputImg'
).
get
(
0
)
const
{
width
,
height
}
=
inputImgEl
const
canvas
=
$
(
'#overlay'
).
get
(
0
)
canvas
.
width
=
width
canvas
.
height
=
height
const
forwardParams
=
{
inputSize
:
sizeType
,
scoreThreshold
}
const
detections
=
await
faceapi
.
tinyYolov2
(
inputImgEl
,
forwardParams
)
faceapi
.
drawDetection
(
'overlay'
,
detections
.
map
(
det
=>
det
.
forSize
(
width
,
height
)))
}
async
function
onSelectionChanged
(
uri
)
{
const
imgBuf
=
await
fetchImage
(
uri
)
$
(
`#inputImg`
).
get
(
0
).
src
=
(
await
faceapi
.
bufferToImage
(
imgBuf
)).
src
updateResults
()
}
async
function
run
()
{
await
faceapi
.
loadTinyYolov2Model
(
'/'
)
$
(
'#loader'
).
hide
()
onSelectionChanged
(
$
(
'#selectList select'
).
val
())
}
$
(
document
).
ready
(
function
()
{
renderNavBar
(
'#navbar'
,
'tiny_yolov2_face_detection'
)
renderImageSelectList
(
'#selectList'
,
async
(
uri
)
=>
{
await
onSelectionChanged
(
uri
)
},
'bbt1.jpg'
)
const
sizeTypeSelect
=
$
(
'#sizeType'
)
sizeTypeSelect
.
val
(
sizeType
)
sizeTypeSelect
.
on
(
'change'
,
onSizeTypeChanged
)
sizeTypeSelect
.
material_select
()
run
()
})
</script>
</body>
</html>
\ No newline at end of file
examples/views/tinyYolov2FaceDetectionVideo.html
0 → 100644
View file @
b09fbe45
<!DOCTYPE html>
<html>
<head>
<script
src=
"face-api.js"
></script>
<script
src=
"commons.js"
></script>
<link
rel=
"stylesheet"
href=
"styles.css"
>
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css"
>
<script
type=
"text/javascript"
src=
"https://code.jquery.com/jquery-2.1.1.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"
></script>
</head>
<body>
<div
id=
"navbar"
></div>
<div
class=
"center-content page-container"
>
<div
class=
"progress"
id=
"loader"
>
<div
class=
"indeterminate"
></div>
</div>
<div
style=
"position: relative"
class=
"margin"
>
<video
src=
"media/bbt.mp4"
onplay=
"onPlay(this)"
id=
"inputVideo"
autoplay
muted
></video>
<canvas
id=
"overlay"
/>
</div>
<div
class=
"row side-by-side"
>
<div
class=
"row input-field"
style=
"margin-right: 20px;"
>
<select
id=
"sizeType"
>
<option
value=
""
disabled
selected
>
Input Size:
</option>
<option
value=
"xs"
>
XS: 224 x 224
</option>
<option
value=
"sm"
>
SM: 320 x 320
</option>
<option
value=
"md"
>
MD: 416 x 416
</option>
<option
value=
"lg"
>
LG: 608 x 608
</option>
</select>
<label>
Input Size
</label>
</div>
<div
class=
"row"
>
<label
for=
"scoreThreshold"
>
Score Threshold:
</label>
<input
disabled
value=
"0.5"
id=
"scoreThreshold"
type=
"text"
class=
"bold"
>
</div>
<button
class=
"waves-effect waves-light btn"
onclick=
"onDecreaseThreshold()"
>
<i
class=
"material-icons left"
>
-
</i>
</button>
<button
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseThreshold()"
>
<i
class=
"material-icons left"
>
+
</i>
</button>
</div>
<div
class=
"row side-by-side"
>
<div
class=
"row"
>
<label
for=
"time"
>
Time:
</label>
<input
disabled
value=
"-"
id=
"time"
type=
"text"
class=
"bold"
>
</div>
<div
class=
"row"
>
<label
for=
"fps"
>
Estimated Fps:
</label>
<input
disabled
value=
"-"
id=
"fps"
type=
"text"
class=
"bold"
>
</div>
</div>
</div>
<script>
let
scoreThreshold
=
0.5
let
sizeType
=
'md'
let
modelLoaded
=
false
function
onIncreaseThreshold
()
{
scoreThreshold
=
Math
.
min
(
faceapi
.
round
(
scoreThreshold
+
0.1
),
1.0
)
$
(
'#scoreThreshold'
).
val
(
scoreThreshold
)
}
function
onDecreaseThreshold
()
{
scoreThreshold
=
Math
.
max
(
faceapi
.
round
(
scoreThreshold
-
0.1
),
0.1
)
$
(
'#scoreThreshold'
).
val
(
scoreThreshold
)
}
function
onSizeTypeChanged
(
e
,
c
)
{
sizeType
=
e
.
target
.
value
$
(
'#sizeType'
).
val
(
sizeType
)
}
function
displayTimeStats
(
timeInMs
)
{
$
(
'#time'
).
val
(
`
${
timeInMs
}
ms`
)
$
(
'#fps'
).
val
(
`
${
faceapi
.
round
(
1000
/
timeInMs
)}
`
)
}
async
function
onPlay
(
videoEl
)
{
if
(
videoEl
.
paused
||
videoEl
.
ended
||
!
modelLoaded
)
return
false
const
{
width
,
height
}
=
faceapi
.
getMediaDimensions
(
videoEl
)
const
canvas
=
$
(
'#overlay'
).
get
(
0
)
canvas
.
width
=
width
canvas
.
height
=
height
const
forwardParams
=
{
inputSize
:
sizeType
,
scoreThreshold
}
const
ts
=
Date
.
now
()
result
=
await
faceapi
.
tinyYolov2
(
videoEl
,
forwardParams
)
displayTimeStats
(
Date
.
now
()
-
ts
)
faceapi
.
drawDetection
(
'overlay'
,
result
.
map
(
det
=>
det
.
forSize
(
width
,
height
)))
setTimeout
(()
=>
onPlay
(
videoEl
))
}
async
function
loadNetWeights
(
uri
)
{
return
new
Float32Array
(
await
(
await
fetch
(
uri
)).
arrayBuffer
())
}
async
function
run
()
{
await
faceapi
.
loadTinyYolov2Model
(
'/'
)
modelLoaded
=
true
onPlay
(
$
(
'#inputVideo'
).
get
(
0
))
$
(
'#loader'
).
hide
()
}
$
(
document
).
ready
(
function
()
{
renderNavBar
(
'#navbar'
,
'tiny_yolov2_face_detection_video'
)
const
sizeTypeSelect
=
$
(
'#sizeType'
)
sizeTypeSelect
.
val
(
sizeType
)
sizeTypeSelect
.
on
(
'change'
,
onSizeTypeChanged
)
sizeTypeSelect
.
material_select
()
run
()
})
</script>
</body>
</html>
\ No newline at end of file
examples/views/tinyYolov2FaceDetectionWebcam.html
0 → 100644
View file @
b09fbe45
<!DOCTYPE html>
<html>
<head>
<script
src=
"face-api.js"
></script>
<script
src=
"commons.js"
></script>
<link
rel=
"stylesheet"
href=
"styles.css"
>
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.css"
>
<script
type=
"text/javascript"
src=
"https://code.jquery.com/jquery-2.1.1.min.js"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"
></script>
</head>
<body>
<div
id=
"navbar"
></div>
<div
class=
"center-content page-container"
>
<div
class=
"progress"
id=
"loader"
>
<div
class=
"indeterminate"
></div>
</div>
<div
style=
"position: relative"
class=
"margin"
>
<video
onplay=
"onPlay(this)"
id=
"inputVideo"
autoplay
muted
></video>
<canvas
id=
"overlay"
/>
</div>
<div
class=
"row side-by-side"
>
<div
class=
"row input-field"
style=
"margin-right: 20px;"
>
<select
id=
"sizeType"
>
<option
value=
""
disabled
selected
>
Input Size:
</option>
<option
value=
"160"
>
160 x 160
</option>
<option
value=
"224"
>
224 x 224
</option>
<option
value=
"320"
>
320 x 320
</option>
<option
value=
"416"
>
416 x 416
</option>
<option
value=
"608"
>
608 x 608
</option>
</select>
<label>
Input Size
</label>
</div>
<div
class=
"row"
>
<label
for=
"scoreThreshold"
>
Score Threshold:
</label>
<input
disabled
value=
"0.5"
id=
"scoreThreshold"
type=
"text"
class=
"bold"
>
</div>
<button
class=
"waves-effect waves-light btn"
onclick=
"onDecreaseThreshold()"
>
<i
class=
"material-icons left"
>
-
</i>
</button>
<button
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseThreshold()"
>
<i
class=
"material-icons left"
>
+
</i>
</button>
</div>
<div
class=
"row side-by-side"
>
<div
class=
"row"
>
<label
for=
"time"
>
Time:
</label>
<input
disabled
value=
"-"
id=
"time"
type=
"text"
class=
"bold"
>
</div>
<div
class=
"row"
>
<label
for=
"fps"
>
Estimated Fps:
</label>
<input
disabled
value=
"-"
id=
"fps"
type=
"text"
class=
"bold"
>
</div>
</div>
</div>
<script>
let
scoreThreshold
=
0.5
let
sizeType
=
'160'
let
modelLoaded
=
false
function
onIncreaseThreshold
()
{
scoreThreshold
=
Math
.
min
(
faceapi
.
round
(
scoreThreshold
+
0.1
),
1.0
)
$
(
'#scoreThreshold'
).
val
(
scoreThreshold
)
}
function
onDecreaseThreshold
()
{
scoreThreshold
=
Math
.
max
(
faceapi
.
round
(
scoreThreshold
-
0.1
),
0.1
)
$
(
'#scoreThreshold'
).
val
(
scoreThreshold
)
}
function
onSizeTypeChanged
(
e
,
c
)
{
sizeType
=
e
.
target
.
value
$
(
'#sizeType'
).
val
(
sizeType
)
}
function
displayTimeStats
(
timeInMs
)
{
$
(
'#time'
).
val
(
`
${
timeInMs
}
ms`
)
$
(
'#fps'
).
val
(
`
${
faceapi
.
round
(
1000
/
timeInMs
)}
`
)
}
async
function
onPlay
(
videoEl
)
{
if
(
videoEl
.
paused
||
videoEl
.
ended
||
!
modelLoaded
)
return
false
const
{
width
,
height
}
=
faceapi
.
getMediaDimensions
(
videoEl
)
const
canvas
=
$
(
'#overlay'
).
get
(
0
)
canvas
.
width
=
width
canvas
.
height
=
height
const
forwardParams
=
{
inputSize
:
parseInt
(
sizeType
),
scoreThreshold
}
const
ts
=
Date
.
now
()
result
=
await
faceapi
.
tinyYolov2
(
videoEl
,
forwardParams
)
displayTimeStats
(
Date
.
now
()
-
ts
)
faceapi
.
drawDetection
(
'overlay'
,
result
.
map
(
det
=>
det
.
forSize
(
width
,
height
)))
setTimeout
(()
=>
onPlay
(
videoEl
))
}
async
function
loadNetWeights
(
uri
)
{
return
new
Float32Array
(
await
(
await
fetch
(
uri
)).
arrayBuffer
())
}
async
function
run
()
{
await
faceapi
.
loadTinyYolov2Model
(
'/'
)
modelLoaded
=
true
const
videoEl
=
$
(
'#inputVideo'
).
get
(
0
)
navigator
.
getUserMedia
(
{
video
:
{}
},
stream
=>
videoEl
.
srcObject
=
stream
,
err
=>
console
.
error
(
err
)
)
onPlay
(
$
(
'#inputVideo'
).
get
(
0
))
$
(
'#loader'
).
hide
()
}
$
(
document
).
ready
(
function
()
{
renderNavBar
(
'#navbar'
,
'tiny_yolov2_face_detection_video'
)
const
sizeTypeSelect
=
$
(
'#sizeType'
)
sizeTypeSelect
.
val
(
sizeType
)
sizeTypeSelect
.
on
(
'change'
,
onSizeTypeChanged
)
sizeTypeSelect
.
material_select
()
run
()
})
</script>
</body>
</html>
\ No newline at end of file
src/globalApi.ts
View file @
b09fbe45
...
@@ -10,6 +10,8 @@ import { FullFaceDescription } from './FullFaceDescription';
...
@@ -10,6 +10,8 @@ import { FullFaceDescription } from './FullFaceDescription';
import
{
Mtcnn
}
from
'./mtcnn/Mtcnn'
;
import
{
Mtcnn
}
from
'./mtcnn/Mtcnn'
;
import
{
MtcnnForwardParams
,
MtcnnResult
}
from
'./mtcnn/types'
;
import
{
MtcnnForwardParams
,
MtcnnResult
}
from
'./mtcnn/types'
;
import
{
NetInput
}
from
'./NetInput'
;
import
{
NetInput
}
from
'./NetInput'
;
import
{
TinyYolov2
}
from
'./tinyYolov2/TinyYolov2'
;
import
{
TinyYolov2ForwardParams
}
from
'./tinyYolov2/types'
;
import
{
TNetInput
}
from
'./types'
;
import
{
TNetInput
}
from
'./types'
;
export
const
detectionNet
=
new
FaceDetectionNet
()
export
const
detectionNet
=
new
FaceDetectionNet
()
...
@@ -22,7 +24,8 @@ export const nets = {
...
@@ -22,7 +24,8 @@ export const nets = {
ssdMobilenet
:
detectionNet
,
ssdMobilenet
:
detectionNet
,
faceLandmark68Net
:
landmarkNet
,
faceLandmark68Net
:
landmarkNet
,
faceRecognitionNet
:
recognitionNet
,
faceRecognitionNet
:
recognitionNet
,
mtcnn
:
new
Mtcnn
()
mtcnn
:
new
Mtcnn
(),
tinyYolov2
:
new
TinyYolov2
()
}
}
export
function
loadFaceDetectionModel
(
url
:
string
)
{
export
function
loadFaceDetectionModel
(
url
:
string
)
{
...
@@ -41,12 +44,17 @@ export function loadMtcnnModel(url: string) {
...
@@ -41,12 +44,17 @@ export function loadMtcnnModel(url: string) {
return
nets
.
mtcnn
.
load
(
url
)
return
nets
.
mtcnn
.
load
(
url
)
}
}
export
function
loadTinyYolov2Model
(
url
:
string
)
{
return
nets
.
tinyYolov2
.
load
(
url
)
}
export
function
loadModels
(
url
:
string
)
{
export
function
loadModels
(
url
:
string
)
{
return
Promise
.
all
([
return
Promise
.
all
([
loadFaceDetectionModel
(
url
),
loadFaceDetectionModel
(
url
),
loadFaceLandmarkModel
(
url
),
loadFaceLandmarkModel
(
url
),
loadFaceRecognitionModel
(
url
),
loadFaceRecognitionModel
(
url
),
loadMtcnnModel
(
url
)
loadMtcnnModel
(
url
),
loadTinyYolov2Model
(
url
)
])
])
}
}
...
@@ -77,6 +85,13 @@ export function mtcnn(
...
@@ -77,6 +85,13 @@ export function mtcnn(
return
nets
.
mtcnn
.
forward
(
input
,
forwardParams
)
return
nets
.
mtcnn
.
forward
(
input
,
forwardParams
)
}
}
export
function
tinyYolov2
(
input
:
TNetInput
,
forwardParams
:
TinyYolov2ForwardParams
):
Promise
<
FaceDetection
[]
>
{
return
nets
.
tinyYolov2
.
locateFaces
(
input
,
forwardParams
)
}
export
type
allFacesFunction
=
(
export
type
allFacesFunction
=
(
input
:
tf
.
Tensor
|
NetInput
|
TNetInput
,
input
:
tf
.
Tensor
|
NetInput
|
TNetInput
,
minConfidence
?:
number
,
minConfidence
?:
number
,
...
...
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