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
004ef805
Commit
004ef805
authored
Oct 18, 2018
by
vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge face detection and face landmark detection examples
parent
a95d39d9
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
208 deletions
+62
-208
commons.js
examples/public/js/commons.js
+6
-10
drawing.js
examples/public/js/drawing.js
+1
-2
server.js
examples/server.js
+8
-9
faceAndLandmarkDetection.html
examples/views/faceAndLandmarkDetection.html
+47
-18
faceDetection.html
examples/views/faceDetection.html
+0
-169
No files found.
examples/public/js/commons.js
View file @
004ef805
...
...
@@ -29,22 +29,18 @@ async function requestExternalImage(imageUrl) {
function
renderNavBar
(
navbarId
,
exampleUri
)
{
const
examples
=
[
{
uri
:
'face_detection'
,
name
:
'Face Detection'
},
{
uri
:
'face_extraction'
,
name
:
'Face Extraction'
},
{
uri
:
'face_landmark_detection'
,
name
:
'Face Landmark Detection'
uri
:
'face_and_landmark_detection'
,
name
:
'Face And Landmark Detection'
},
{
uri
:
'face_recognition'
,
name
:
'Face Recognition'
},
{
uri
:
'face_extraction'
,
name
:
'Face Extraction'
},
{
uri
:
'video_face_tracking'
,
name
:
'Video Face Tracking'
},
...
...
examples/public/js/drawing.js
View file @
004ef805
...
...
@@ -19,8 +19,7 @@ function drawLandmarks(dimensions, canvas, results, withBoxes = true) {
const
resizedResults
=
resizeCanvasAndResults
(
dimensions
,
canvas
,
results
)
if
(
withBoxes
)
{
const
alignedFaceRectangles
=
resizedResults
.
map
(
det
=>
det
.
alignedRect
)
faceapi
.
drawDetection
(
canvas
,
alignedFaceRectangles
)
faceapi
.
drawDetection
(
canvas
,
resizedResults
.
map
(
det
=>
det
.
detection
))
}
const
faceLandmarks
=
resizedResults
.
map
(
det
=>
det
.
landmarks
)
...
...
examples/server.js
View file @
004ef805
...
...
@@ -15,19 +15,18 @@ app.use(express.static(path.join(__dirname, '../weights_uncompressed')))
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'../dist'
)))
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'./node_modules/axios/dist'
)))
app
.
get
(
'/'
,
(
req
,
res
)
=>
res
.
redirect
(
'/face_detection'
))
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
(
'/bbt_face_landmark_detection'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceLandmarkDetection.html'
)))
app
.
get
(
'/bbt_face_similarity'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceSimilarity.html'
)))
app
.
get
(
'/bbt_face_matching'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceMatching.html'
)))
app
.
get
(
'/bbt_face_recognition'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceRecognition.html'
)))
app
.
get
(
'/face_detection'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'faceDetection.html'
)))
app
.
get
(
'/'
,
(
req
,
res
)
=>
res
.
redirect
(
'/face_and_landmark_detection'
))
app
.
get
(
'/face_and_landmark_detection'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'faceAndLandmarkDetection.html'
)))
app
.
get
(
'/face_extraction'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'faceExtraction.html'
)))
app
.
get
(
'/face_landmark_detection'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'faceLandmarkDetection.html'
)))
app
.
get
(
'/face_recognition'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'faceRecognition.html'
)))
app
.
get
(
'/video_face_tracking'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'videoFaceTracking.html'
)))
app
.
get
(
'/webcam_face_tracking'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'webcamFaceTracking.html'
)))
app
.
get
(
'/bbt_face_landmark_detection'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceLandmarkDetection.html'
)))
app
.
get
(
'/bbt_face_similarity'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceSimilarity.html'
)))
app
.
get
(
'/bbt_face_matching'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceMatching.html'
)))
app
.
get
(
'/bbt_face_recognition'
,
(
req
,
res
)
=>
res
.
sendFile
(
path
.
join
(
viewsDir
,
'bbtFaceRecognition.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
.
post
(
'/fetch_external_image'
,
async
(
req
,
res
)
=>
{
const
{
imageUrl
}
=
req
.
body
...
...
examples/views/faceLandmarkDetection.html
→
examples/views/face
And
LandmarkDetection.html
View file @
004ef805
...
...
@@ -24,18 +24,6 @@
</div>
<div
class=
"row side-by-side"
>
<!-- face_detector_selection_control -->
<div
id=
"face_detector_selection_control"
class=
"row input-field"
style=
"margin-right: 20px;"
>
<select
id=
"selectFaceDetector"
>
<option
value=
"ssd_mobilenetv1"
>
SSD Mobilenet V1
</option>
<option
value=
"tiny_face_detector"
>
Tiny Face Detector
</option>
<option
value=
"mtcnn"
>
MTCNN
</option>
</select>
<label>
Select Face Detector
</label>
</div>
<!-- face_detector_selection_control -->
<!-- image_selection_control -->
<div
id=
"selectList"
></div>
<div
class=
"row"
>
...
...
@@ -49,6 +37,29 @@
Ok
</button>
<!-- image_selection_control -->
</div>
<div
class=
"row side-by-side"
>
<!-- face_detector_selection_control -->
<div
id=
"face_detector_selection_control"
class=
"row input-field"
style=
"margin-right: 20px;"
>
<select
id=
"selectFaceDetector"
>
<option
value=
"ssd_mobilenetv1"
>
SSD Mobilenet V1
</option>
<option
value=
"tiny_face_detector"
>
Tiny Face Detector
</option>
<option
value=
"mtcnn"
>
MTCNN
</option>
</select>
<label>
Select Face Detector
</label>
</div>
<!-- face_detector_selection_control -->
<!-- check boxes -->
<div
class=
"row"
style=
"width: 220px;"
>
<input
type=
"checkbox"
id=
"withFaceLandmarksCheckbox"
onchange=
"onChangeWithFaceLandmarks(event)"
/>
<label
for=
"withFaceLandmarksCheckbox"
>
Detect Face Landmarks
</label>
<input
type=
"checkbox"
id=
"hideBoundingBoxesCheckbox"
onchange=
"onChangeHideBoundingBoxes(event)"
/>
<label
for=
"hideBoundingBoxesCheckbox"
>
Hide Bounding Boxes
</label>
</div>
<!-- check boxes -->
</div>
...
...
@@ -136,6 +147,18 @@
</body>
<script>
let
withFaceLandmarks
=
false
let
withBoxes
=
true
function
onChangeWithFaceLandmarks
(
e
)
{
withFaceLandmarks
=
$
(
e
.
target
).
prop
(
'checked'
)
updateResults
()
}
function
onChangeHideBoundingBoxes
(
e
)
{
withBoxes
=
!
$
(
e
.
target
).
prop
(
'checked'
)
updateResults
()
}
async
function
updateResults
()
{
if
(
!
isFaceDetectionModelLoaded
())
{
...
...
@@ -145,16 +168,22 @@
const
inputImgEl
=
$
(
'#inputImg'
).
get
(
0
)
const
options
=
getFaceDetectorOptions
()
const
results
=
await
faceapi
.
detectAllFaces
(
inputImgEl
,
options
)
.
withFaceLandmarks
()
const
faceDetectionTask
=
faceapi
.
detectAllFaces
(
inputImgEl
,
options
)
const
results
=
withFaceLandmarks
?
await
faceDetectionTask
.
withFaceLandmarks
()
:
await
faceDetectionTask
const
drawFunction
=
withFaceLandmarks
?
drawLandmarks
:
drawDetections
draw
Landmarks
(
inputImgEl
,
$
(
'#overlay'
).
get
(
0
),
result
s
)
draw
Function
(
inputImgEl
,
$
(
'#overlay'
).
get
(
0
),
results
,
withBoxe
s
)
}
async
function
run
()
{
// load face detection and face landmark models
await
changeFaceDetector
(
selectedFaceDetector
)
await
changeFaceDetector
(
SSD_MOBILENETV1
)
await
faceapi
.
loadFaceLandmarkModel
(
'/'
)
// start processing image
...
...
@@ -162,7 +191,7 @@
}
$
(
document
).
ready
(
function
()
{
renderNavBar
(
'#navbar'
,
'face_landmark_detection'
)
renderNavBar
(
'#navbar'
,
'face_
and_
landmark_detection'
)
initImageSelectionControls
()
initFaceDetectionControls
()
run
()
...
...
examples/views/faceDetection.html
deleted
100644 → 0
View file @
a95d39d9
<!DOCTYPE html>
<html>
<head>
<script
src=
"face-api.js"
></script>
<script
src=
"js/commons.js"
></script>
<script
src=
"js/drawing.js"
></script>
<script
src=
"js/faceDetectionControls.js"
></script>
<script
src=
"js/imageSelectionControls.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"
>
<!-- face_detector_selection_control -->
<div
id=
"face_detector_selection_control"
class=
"row input-field"
style=
"margin-right: 20px;"
>
<select
id=
"selectFaceDetector"
>
<option
value=
"ssd_mobilenetv1"
>
SSD Mobilenet V1
</option>
<option
value=
"tiny_face_detector"
>
Tiny Face Detector
</option>
<option
value=
"mtcnn"
>
MTCNN
</option>
</select>
<label>
Select Face Detector
</label>
</div>
<!-- face_detector_selection_control -->
<!-- image_selection_control -->
<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>
<!-- image_selection_control -->
</div>
<!-- ssd_mobilenetv1_controls -->
<span
id=
"ssd_mobilenetv1_controls"
>
<div
class=
"row side-by-side"
>
<div
class=
"row"
>
<label
for=
"minConfidence"
>
Min Confidence:
</label>
<input
disabled
value=
"0.5"
id=
"minConfidence"
type=
"text"
class=
"bold"
>
</div>
<button
class=
"waves-effect waves-light btn"
onclick=
"onDecreaseMinConfidence()"
>
<i
class=
"material-icons left"
>
-
</i>
</button>
<button
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseMinConfidence()"
>
<i
class=
"material-icons left"
>
+
</i>
</button>
</div>
</span>
<!-- ssd_mobilenetv1_controls -->
<!-- tiny_face_detector_controls -->
<span
id=
"tiny_face_detector_controls"
>
<div
class=
"row side-by-side"
>
<div
class=
"row input-field"
style=
"margin-right: 20px;"
>
<select
id=
"inputSize"
>
<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=
"512"
>
512 x 512
</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=
"onDecreaseScoreThreshold()"
>
<i
class=
"material-icons left"
>
-
</i>
</button>
<button
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseScoreThreshold()"
>
<i
class=
"material-icons left"
>
+
</i>
</button>
</div>
</span>
<!-- tiny_face_detector_controls -->
<!-- mtcnn_controls -->
<span
id=
"mtcnn_controls"
>
<div
class=
"row side-by-side"
>
<div
class=
"row"
>
<label
for=
"minFaceSize"
>
Minimum Face Size:
</label>
<input
disabled
value=
"20"
id=
"minFaceSize"
type=
"text"
class=
"bold"
>
</div>
<button
class=
"waves-effect waves-light btn"
onclick=
"onDecreaseMinFaceSize()"
>
<i
class=
"material-icons left"
>
-
</i>
</button>
<button
class=
"waves-effect waves-light btn"
onclick=
"onIncreaseMinFaceSize()"
>
<i
class=
"material-icons left"
>
+
</i>
</button>
</div>
</span>
<!-- mtcnn_controls -->
</body>
<script>
async
function
updateResults
()
{
if
(
!
isFaceDetectionModelLoaded
())
{
return
}
const
inputImgEl
=
$
(
'#inputImg'
).
get
(
0
)
const
options
=
getFaceDetectorOptions
()
const
detections
=
await
faceapi
.
detectAllFaces
(
inputImgEl
,
options
)
drawDetections
(
inputImgEl
,
$
(
'#overlay'
).
get
(
0
),
detections
)
}
async
function
run
()
{
// load face detection model
await
changeFaceDetector
(
selectedFaceDetector
)
// start processing image
updateResults
()
}
$
(
document
).
ready
(
function
()
{
renderNavBar
(
'#navbar'
,
'face_detection'
)
initImageSelectionControls
()
initFaceDetectionControls
()
run
()
})
</script>
</body>
</html>
\ 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