full rebuild

pull/39/head v0.12.7
Vladimir Mandic 2021-02-17 09:46:43 -05:00
parent ee4bbe8749
commit 586dcdf477
8 changed files with 23 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/face-api.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@ const modelPath = 'https://vladmandic.github.io/face-api/model/'; // path to mod
// const modelPath = '../model/'; // path to model folder that will be loaded using http // const modelPath = '../model/'; // path to model folder that will be loaded using http
const imgSize = 512; // maximum image size in pixels const imgSize = 512; // maximum image size in pixels
const minScore = 0.1; // minimum score const minScore = 0.1; // minimum score
const maxResults = 5; // maximum number of results to return const maxResults = 10; // maximum number of results to return
const samples = ['sample (1).jpg', 'sample (2).jpg', 'sample (3).jpg', 'sample (4).jpg', 'sample (5).jpg', 'sample (6).jpg']; // sample images to be loaded using http const samples = ['sample (1).jpg', 'sample (2).jpg', 'sample (3).jpg', 'sample (4).jpg', 'sample (5).jpg', 'sample (6).jpg']; // sample images to be loaded using http
// helper function to pretty-print json object to string // helper function to pretty-print json object to string
@ -122,8 +122,8 @@ async function main() {
await faceapi.tf.ready(); await faceapi.tf.ready();
// check version // check version
log(`Version: TensorFlow/JS ${str(faceapi.tf?.version_core || '(not loaded)')} FaceAPI ${str(faceapi?.version || '(not loaded)')} Backend: ${str(faceapi.tf?.getBackend() || '(not loaded)')}`); log(`Version: FaceAPI ${str(faceapi?.version.faceapi || '(not loaded)')} TensorFlow/JS ${str(faceapi?.tf?.version_core || '(not loaded)')} Backend: ${str(faceapi?.tf?.getBackend() || '(not loaded)')}`);
log(`Flags: ${JSON.stringify(faceapi.tf.ENV.flags)}`); log(`Flags: ${JSON.stringify(faceapi?.tf?.ENV.flags || { tf: 'not loaded' })}`);
// load face-api models // load face-api models
log('Loading FaceAPI models'); log('Loading FaceAPI models');

View File

@ -7,9 +7,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=yes">
<script src="./webcam.js" type="module"></script> <script src="./webcam.js" type="module"></script>
</head> </head>
<body style="font-family: monospace; background: black; color: white; font-size: 16px; line-height: 22px; margin: 0;"> <body style="font-family: monospace; background: black; color: white; font-size: 16px; line-height: 22px; margin: 0; overflow: hidden">
<video id="video" playsinline class="video"></video> <video id="video" playsinline class="video"></video>
<canvas id="canvas" class="canvas" style="position: fixed; top: 0; left: 0; z-index: 10"></canvas> <canvas id="canvas" class="canvas" style="position: fixed; top: 0; left: 0; z-index: 10"></canvas>
<div id="log"></div> <div id="log" style="overflow-y: scroll; height: 16.5rem"></div>
</body> </body>
</html> </html>

View File

@ -116,6 +116,17 @@ async function setupCamera() {
const settings = track.getSettings(); const settings = track.getSettings();
log(`Camera active: ${track.label} ${str(constraints)}`); log(`Camera active: ${track.label} ${str(constraints)}`);
log(`Camera settings: ${str(settings)}`); log(`Camera settings: ${str(settings)}`);
canvas.addEventListener('click', () => {
// @ts-ignore
if (video && video.readyState >= 2) {
// @ts-ignore
if (video.paused) video.play();
// @ts-ignore
else video.pause();
}
// @ts-ignore
log(`Camera state: ${video.paused ? 'paused' : 'playing'}`);
});
return new Promise((resolve) => { return new Promise((resolve) => {
video.onloadeddata = async () => { video.onloadeddata = async () => {
// @ts-ignore // @ts-ignore
@ -162,8 +173,8 @@ async function main() {
await faceapi.tf.ready(); await faceapi.tf.ready();
// check version // check version
log(`Version: TensorFlow/JS ${str(faceapi.tf?.version_core || '(not loaded)')} FaceAPI ${str(faceapi?.version || '(not loaded)')} Backend: ${str(faceapi.tf?.getBackend() || '(not loaded)')}`); log(`Version: FaceAPI ${str(faceapi?.version.faceapi || '(not loaded)')} TensorFlow/JS ${str(faceapi?.tf?.version_core || '(not loaded)')} Backend: ${str(faceapi?.tf?.getBackend() || '(not loaded)')}`);
log(`Flags: ${str(faceapi.tf.ENV.flags)}`); log(`Flags: ${JSON.stringify(faceapi?.tf?.ENV.flags || { tf: 'not loaded' })}`);
setupFaceAPI(); setupFaceAPI();
setupCamera(); setupCamera();