switch to custom tfjs for demos

pull/233/head
Vladimir Mandic 2021-10-26 15:08:05 -04:00
parent d9b179a08f
commit 4e05fa40fe
47 changed files with 149761 additions and 49613 deletions

View File

@ -111,34 +111,13 @@
"sourcemap": true, "sourcemap": true,
"external": ["@tensorflow", "fs", "os", "buffer", "util"] "external": ["@tensorflow", "fs", "os", "buffer", "util"]
}, },
{
"name": "tfjs/browser/esm/custom",
"platform": "browser",
"format": "esm",
"input": "tfjs/tf-custom.ts",
"output": "dist/tfjs.esm.js",
"sourcemap": true,
"external": ["fs", "os", "buffer", "util"]
},
{
"name": "human/browser/esm/custom",
"platform": "browser",
"format": "esm",
"input": "src/human.ts",
"output": "dist/human.custom.esm.js",
"sourcemap": true,
"minify": true,
"external": ["fs", "os", "buffer", "util"]
},
{ {
"name": "tfjs/browser/esm/bundle", "name": "tfjs/browser/esm/bundle",
"platform": "browser", "platform": "browser",
"format": "esm", "format": "esm",
"input": "tfjs/tf-browser.ts", "input": "tfjs/tf-browser.ts",
"output": "dist/tfjs.esm.js", "output": "dist/tfjs.esm.js",
"minify": true, "minify": false,
"sourcemap": true, "sourcemap": true,
"external": ["fs", "os", "buffer", "util"] "external": ["fs", "os", "buffer", "util"]
}, },
@ -158,7 +137,28 @@
"format": "esm", "format": "esm",
"input": "src/human.ts", "input": "src/human.ts",
"output": "dist/human.esm.js", "output": "dist/human.esm.js",
"minify": true,
"sourcemap": true, "sourcemap": true,
"external": ["fs", "os", "buffer", "util"]
},
{
"name": "tfjs/browser/esm/custom",
"platform": "browser",
"format": "esm",
"input": "tfjs/tf-custom.ts",
"output": "dist/tfjs.esm.js",
"sourcemap": false,
"external": ["fs", "os", "buffer", "util"]
},
{
"name": "human/browser/esm/custom",
"platform": "browser",
"format": "esm",
"input": "src/human.ts",
"output": "dist/human.custom.esm.js",
"sourcemap": true,
"minify": false,
"external": ["fs", "os", "buffer", "util"], "external": ["fs", "os", "buffer", "util"],
"typings": "types", "typings": "types",
"typedoc": "typedoc" "typedoc": "typedoc"

View File

@ -11,7 +11,8 @@
"ecmaVersion": 2021 "ecmaVersion": 2021
}, },
"plugins": [ "plugins": [
"@typescript-eslint" "@typescript-eslint",
"html"
], ],
"extends": [ "extends": [
"airbnb-base", "airbnb-base",

View File

@ -5,7 +5,7 @@
"browserslist": [ "browserslist": [
"chrome >= 90", "chrome >= 90",
"edge >= 90", "edge >= 90",
"firefox >= 90", "firefox >= 100",
"android >= 90", "android >= 90",
"safari >= 15" "safari >= 15"
], ],

View File

@ -9,11 +9,15 @@
## Changelog ## Changelog
### **HEAD -> main** 2021/10/25 mandic00@live.com
### **release: 2.4.1** 2021/10/25 mandic00@live.com
### **2.4.1** 2021/10/25 mandic00@live.com ### **2.4.1** 2021/10/25 mandic00@live.com
- refactoring plus jsdoc comments
### **origin/main** 2021/10/25 mandic00@live.com
- increase face similarity match resolution - increase face similarity match resolution
- time based caching - time based caching
- turn on minification - turn on minification

View File

@ -2,11 +2,12 @@
## Work in Progress ## Work in Progress
- Switch to custom `tfjs` for main `human` ESM bundle
<br> <br>
### Exploring ### Exploring
- Switch to custom `tfjs` for main `human` ESM bundle
- Optical Flow: <https://docs.opencv.org/3.3.1/db/d7f/tutorial_js_lucas_kanade.html> - Optical Flow: <https://docs.opencv.org/3.3.1/db/d7f/tutorial_js_lucas_kanade.html>
- Histogram Equalization: Regular, Adaptive, Contrast Limited - Histogram Equalization: Regular, Adaptive, Contrast Limited
- TFLite Models: <https://js.tensorflow.org/api_tflite/0.0.1-alpha.4/> - TFLite Models: <https://js.tensorflow.org/api_tflite/0.0.1-alpha.4/>
@ -22,6 +23,9 @@ Experimental support only until support is officially added in Chromium
## Known Issues ## Known Issues
- `tfjs.esm.d.ts` missing namespace `OptimizerConstructors`
- exports from `match` are marked as private
<br> <br>
### Face Detection ### Face Detection

View File

@ -12,7 +12,6 @@
<link rel="manifest" href="../manifest.webmanifest"> <link rel="manifest" href="../manifest.webmanifest">
<link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="../../favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="../../assets/icon.png"> <link rel="apple-touch-icon" href="../../assets/icon.png">
<script type="module" src="browser.js"></script>
<style> <style>
@font-face { font-family: 'Lato'; font-display: swap; font-style: normal; font-weight: 100; src: local('Lato'), url('../../assets/lato-light.woff2') } @font-face { font-family: 'Lato'; font-display: swap; font-style: normal; font-weight: 100; src: local('Lato'), url('../../assets/lato-light.woff2') }
html { font-family: 'Lato', 'Segoe UI'; font-size: 16px; font-variant: small-caps; } html { font-family: 'Lato', 'Segoe UI'; font-size: 16px; font-variant: small-caps; }
@ -26,5 +25,56 @@
<div id="status" class="status"></div> <div id="status" class="status"></div>
<img id="image" src="../../samples/in/group-1.jpg" alt="test image" style="display: none"> <img id="image" src="../../samples/in/group-1.jpg" alt="test image" style="display: none">
<div id="log" class="log"></div> <div id="log" class="log"></div>
<script>
import Human from '../../dist/human.custom.esm.js';
const loop = 20;
// eslint-disable-next-line no-console
const log = (...msg) => console.log(...msg);
const myConfig = {
backend: 'humangl',
modelBasePath: 'https://vladmandic.github.io/human/models',
wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.9.0/dist/',
debug: true,
async: true,
cacheSensitivity: 0,
filter: { enabled: false },
face: {
enabled: true,
detector: { enabled: true, rotation: false },
mesh: { enabled: true },
iris: { enabled: true },
description: { enabled: true },
emotion: { enabled: false },
},
hand: { enabled: true, rotation: false },
body: { enabled: true },
object: { enabled: false },
};
async function main() {
const human = new Human(myConfig);
await human.tf.ready();
log('Human:', human.version);
await human.load();
const loaded = Object.keys(human.models).filter((a) => human.models[a]);
log('Loaded:', loaded);
log('Memory state:', human.tf.engine().memory());
const element = document.getElementById('image');
const processed = await human.image(element);
const t0 = human.now();
await human.detect(processed.tensor, myConfig);
const t1 = human.now();
log('Backend:', human.tf.getBackend());
log('Warmup:', Math.round(t1 - t0));
for (let i = 0; i < loop; i++) await human.detect(processed.tensor, myConfig);
const t2 = human.now();
log('Average:', Math.round((t2 - t1) / loop));
}
window.onload = main;
</script>
</body> </body>
</html> </html>

View File

@ -1,49 +0,0 @@
import Human from '../../dist/human.custom.esm.js';
const loop = 20;
// eslint-disable-next-line no-console
const log = (...msg) => console.log(...msg);
const myConfig = {
backend: 'humangl',
modelBasePath: 'https://vladmandic.github.io/human/models',
wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.9.0/dist/',
debug: true,
async: true,
cacheSensitivity: 0,
filter: { enabled: false },
face: {
enabled: true,
detector: { enabled: true, rotation: false },
mesh: { enabled: true },
iris: { enabled: true },
description: { enabled: true },
emotion: { enabled: false },
},
hand: { enabled: true, rotation: false },
body: { enabled: true },
object: { enabled: false },
};
async function main() {
const human = new Human(myConfig);
await human.tf.ready();
log('Human:', human.version);
await human.load();
const loaded = Object.keys(human.models).filter((a) => human.models[a]);
log('Loaded:', loaded);
log('Memory state:', human.tf.engine().memory());
const element = document.getElementById('image');
const processed = await human.image(element);
const t0 = human.now();
await human.detect(processed.tensor, myConfig);
const t1 = human.now();
log('Backend:', human.tf.getBackend());
log('Warmup:', Math.round(t1 - t0));
for (let i = 0; i < loop; i++) await human.detect(processed.tensor, myConfig);
const t2 = human.now();
log('Average:', Math.round((t2 - t1) / loop));
}
main();

View File

@ -8,7 +8,7 @@
import { DoubleSide, Mesh, MeshBasicMaterial, OrthographicCamera, Scene, sRGBEncoding, VideoTexture, WebGLRenderer, BufferGeometry, BufferAttribute } from '../helpers/three.js'; import { DoubleSide, Mesh, MeshBasicMaterial, OrthographicCamera, Scene, sRGBEncoding, VideoTexture, WebGLRenderer, BufferGeometry, BufferAttribute } from '../helpers/three.js';
import { OrbitControls } from '../helpers/three-orbitControls.js'; import { OrbitControls } from '../helpers/three-orbitControls.js';
import Human from '../../dist/human.esm.js'; // equivalent of @vladmandic/human import Human from '../../dist/human.custom.esm.js'; // equivalent of @vladmandic/human
const userConfig = { const userConfig = {
backend: 'wasm', backend: 'wasm',

View File

@ -1,12 +1,12 @@
// @ts-nocheck // typescript checks disabled as this is pure javascript // @ts-nocheck
/** /**
* Human demo for browsers * Human demo for browsers
* *
* Demo for face descriptor analysis and face simmilarity analysis * Demo for face descriptor analysis and face simmilarity analysis
*/ */
import Human from '../../dist/human.esm.js'; /** @type {Human} */
import Human from '../../dist/human.custom.esm.js';
const userConfig = { const userConfig = {
backend: 'wasm', backend: 'wasm',
@ -15,7 +15,6 @@ const userConfig = {
cacheSensitivity: 0, cacheSensitivity: 0,
debug: true, debug: true,
modelBasePath: '../../models/', modelBasePath: '../../models/',
// wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.9.0/dist/',
face: { face: {
enabled: true, enabled: true,
detector: { rotation: true, return: true, maxDetected: 50 }, detector: { rotation: true, return: true, maxDetected: 50 },
@ -165,6 +164,7 @@ async function AddFaceCanvas(index, res, fileName) {
await human.tf.browser.toPixels(res.face[i].tensor, canvas); await human.tf.browser.toPixels(res.face[i].tensor, canvas);
document.getElementById('faces').appendChild(canvas); document.getElementById('faces').appendChild(canvas);
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
if (!ctx) return false;
ctx.font = 'small-caps 0.8rem "Lato"'; ctx.font = 'small-caps 0.8rem "Lato"';
ctx.fillStyle = 'rgba(255, 255, 255, 1)'; ctx.fillStyle = 'rgba(255, 255, 255, 1)';
ctx.fillText(`${res.face[i].age}y ${(100 * (res.face[i].genderScore || 0)).toFixed(1)}% ${res.face[i].gender}`, 4, canvas.height - 6); ctx.fillText(`${res.face[i].age}y ${(100 * (res.face[i].genderScore || 0)).toFixed(1)}% ${res.face[i].gender}`, 4, canvas.height - 6);
@ -258,6 +258,8 @@ async function main() {
title(''); title('');
log('Ready'); log('Ready');
human.validate(userConfig);
human.similarity([], []);
} }
window.onload = main; window.onload = main;

View File

@ -37,7 +37,7 @@ const UISVG = `
class GLBench { class GLBench {
/** GLBench constructor /** GLBench constructor
* @param { WebGLRenderingContext | WebGL2RenderingContext } gl context * @param { WebGLRenderingContext | WebGL2RenderingContext | null } gl context
* @param { Object | undefined } settings additional settings * @param { Object | undefined } settings additional settings
*/ */
constructor(gl, settings = {}) { constructor(gl, settings = {}) {

View File

@ -1,5 +1,3 @@
//@ts-nocheck
let instance = 0; let instance = 0;
let CSScreated = false; let CSScreated = false;
@ -86,6 +84,7 @@ class Menu {
} }
createMenu(parent, title = '', position = { top: null, left: null, bottom: null, right: null }) { createMenu(parent, title = '', position = { top: null, left: null, bottom: null, right: null }) {
/** @type {HTMLDivElement} */
this.menu = document.createElement('div'); this.menu = document.createElement('div');
this.menu.id = `menu-${instance}`; this.menu.id = `menu-${instance}`;
this.menu.className = 'menu'; this.menu.className = 'menu';
@ -120,6 +119,7 @@ class Menu {
this.menu.appendChild(this.container); this.menu.appendChild(this.container);
if (typeof parent === 'object') parent.appendChild(this.menu); if (typeof parent === 'object') parent.appendChild(this.menu);
// @ts-ignore undefined
else document.getElementById(parent).appendChild(this.menu); else document.getElementById(parent).appendChild(this.menu);
} }
@ -133,11 +133,11 @@ class Menu {
} }
get width() { get width() {
return this.menu.offsetWidth || 0; return this.menu ? this.menu.offsetWidth : 0;
} }
get height() { get height() {
return this.menu.offsetHeight || 0; return this.menu ? this.menu.offsetHeight : 0;
} }
hide() { hide() {
@ -184,6 +184,7 @@ class Menu {
this.hidden = !this.hidden; this.hidden = !this.hidden;
const all = document.getElementsByClassName('menu'); const all = document.getElementsByClassName('menu');
for (const item of all) { for (const item of all) {
// @ts-ignore
item.style.display = this.hidden ? 'none' : 'block'; item.style.display = this.hidden ? 'none' : 'block';
} }
}); });
@ -205,8 +206,10 @@ class Menu {
el.innerHTML = `<div class="menu-checkbox"><input class="menu-checkbox" type="checkbox" id="${this.newID}" ${object[variable] ? 'checked' : ''}/><label class="menu-checkbox-label" for="${this.ID}"></label></div>${title}`; el.innerHTML = `<div class="menu-checkbox"><input class="menu-checkbox" type="checkbox" id="${this.newID}" ${object[variable] ? 'checked' : ''}/><label class="menu-checkbox-label" for="${this.ID}"></label></div>${title}`;
if (this.container) this.container.appendChild(el); if (this.container) this.container.appendChild(el);
el.addEventListener('change', (evt) => { el.addEventListener('change', (evt) => {
object[variable] = evt.target.checked; if (evt.target) {
if (callback) callback(evt.target.checked); object[variable] = evt.target['checked'];
if (callback) callback(evt.target['checked']);
}
}); });
return el; return el;
} }
@ -225,7 +228,7 @@ class Menu {
el.style.fontVariant = document.body.style.fontVariant; el.style.fontVariant = document.body.style.fontVariant;
if (this.container) this.container.appendChild(el); if (this.container) this.container.appendChild(el);
el.addEventListener('change', (evt) => { el.addEventListener('change', (evt) => {
if (callback) callback(items[evt.target.selectedIndex]); if (callback && evt.target) callback(items[evt.target['selectedIndex']]);
}); });
return el; return el;
} }
@ -237,12 +240,13 @@ class Menu {
if (this.container) this.container.appendChild(el); if (this.container) this.container.appendChild(el);
el.addEventListener('change', (evt) => { el.addEventListener('change', (evt) => {
if (evt.target) { if (evt.target) {
object[variable] = parseInt(evt.target.value) === parseFloat(evt.target.value) ? parseInt(evt.target.value) : parseFloat(evt.target.value); object[variable] = parseInt(evt.target['value']) === parseFloat(evt.target['value']) ? parseInt(evt.target['value']) : parseFloat(evt.target['value']);
evt.target.setAttribute('value', evt.target.value); // @ts-ignore
if (callback) callback(evt.target.value); evt.target.setAttribute('value', evt.target['value']);
if (callback) callback(evt.target['value']);
} }
}); });
el.input = el.children[0]; el['input'] = el.children[0];
return el; return el;
} }
@ -302,9 +306,12 @@ class Menu {
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
async updateChart(id, values) { async updateChart(id, values) {
if (!values || (values.length === 0)) return; if (!values || (values.length === 0)) return;
/** @type {HTMLCanvasElement} */
// @ts-ignore undefined
const canvas = document.getElementById(`menu-canvas-${id}`); const canvas = document.getElementById(`menu-canvas-${id}`);
if (!canvas) return; if (!canvas) return;
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
if (!ctx) return;
ctx.fillStyle = theme.background; ctx.fillStyle = theme.background;
ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillRect(0, 0, canvas.width, canvas.height);
const width = canvas.width / values.length; const width = canvas.width / values.length;
@ -318,7 +325,7 @@ class Menu {
ctx.fillRect(i * width, 0, width - 4, canvas.height); ctx.fillRect(i * width, 0, width - 4, canvas.height);
ctx.fillStyle = theme.background; ctx.fillStyle = theme.background;
ctx.font = `${width / 1.5}px "Segoe UI"`; ctx.font = `${width / 1.5}px "Segoe UI"`;
ctx.fillText(Math.round(values[i]), i * width + 1, canvas.height - 1, width - 1); ctx.fillText(Math.round(values[i]).toString(), i * width + 1, canvas.height - 1, width - 1);
} }
} }
} }

View File

@ -1,12 +1,17 @@
/// <reference lib="webworker" /> /**
* Web worker used by main demo app
* Loaded from index.js
*/
/// <reference lib="webworker"/>
// load Human using IIFE script as Chome Mobile does not support Modules as Workers // load Human using IIFE script as Chome Mobile does not support Modules as Workers
// import Human from '../dist/human.esm.js'; /** @type {Human} */
const Human = {};
self.importScripts('../dist/human.js'); self.importScripts('../dist/human.js');
let busy = false; let busy = false;
// @ts-ignore // Human is registered as global namespace using IIFE script // eslint-disable-next-line new-cap
// eslint-disable-next-line no-undef, new-cap
const human = new Human.default(); const human = new Human.default();
onmessage = async (msg) => { // receive message from main thread onmessage = async (msg) => { // receive message from main thread

View File

@ -4,9 +4,8 @@
* @description Demo app that enables all Human modules and runs them in separate worker threads * @description Demo app that enables all Human modules and runs them in separate worker threads
* *
*/ */
// @ts-nocheck // typescript checks disabled as this is pure javascript
import Human from '../../dist/human.esm.js'; // equivalent of @vladmandic/human import Human from '../../dist/human.custom.esm.js'; // equivalent of @vladmandic/human
import GLBench from '../helpers/gl-bench.js'; import GLBench from '../helpers/gl-bench.js';
const workerJS = './worker.js'; const workerJS = './worker.js';
@ -92,9 +91,13 @@ const busy = {
}; };
const workers = { const workers = {
/** @type {Worker | null} */
face: null, face: null,
/** @type {Worker | null} */
body: null, body: null,
/** @type {Worker | null} */
hand: null, hand: null,
/** @type {Worker | null} */
object: null, object: null,
}; };
@ -138,7 +141,8 @@ async function drawResults() {
time.draw = Math.round(1 + human.now() - start.draw); time.draw = Math.round(1 + human.now() - start.draw);
const fps = Math.round(10 * 1000 / time.main) / 10; const fps = Math.round(10 * 1000 / time.main) / 10;
const draw = Math.round(10 * 1000 / time.draw) / 10; const draw = Math.round(10 * 1000 / time.draw) / 10;
document.getElementById('log').innerText = `Human: version ${human.version} | Performance: Main ${time.main}ms Face: ${time.face}ms Body: ${time.body}ms Hand: ${time.hand}ms Object ${time.object}ms | FPS: ${fps} / ${draw}`; const div = document.getElementById('log');
if (div) div.innerText = `Human: version ${human.version} | Performance: Main ${time.main}ms Face: ${time.face}ms Body: ${time.body}ms Hand: ${time.hand}ms Object ${time.object}ms | FPS: ${fps} / ${draw}`;
requestAnimationFrame(drawResults); requestAnimationFrame(drawResults);
} }
@ -152,7 +156,7 @@ async function runDetection() {
start.main = human.now(); start.main = human.now();
if (!bench) { if (!bench) {
bench = new GLBench(null, { trackGPU: false, chartHz: 20, chartLen: 20 }); bench = new GLBench(null, { trackGPU: false, chartHz: 20, chartLen: 20 });
bench.begin(); bench.begin('human');
} }
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, canvas.width, canvas.height); ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
@ -160,22 +164,22 @@ async function runDetection() {
if (!busy.face) { if (!busy.face) {
busy.face = true; busy.face = true;
start.face = human.now(); start.face = human.now();
workers.face.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.face, type: 'face' }, [imageData.data.buffer.slice(0)]); if (workers.face) workers.face.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.face, type: 'face' }, [imageData.data.buffer.slice(0)]);
} }
if (!busy.body) { if (!busy.body) {
busy.body = true; busy.body = true;
start.body = human.now(); start.body = human.now();
workers.body.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.body, type: 'body' }, [imageData.data.buffer.slice(0)]); if (workers.body) workers.body.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.body, type: 'body' }, [imageData.data.buffer.slice(0)]);
} }
if (!busy.hand) { if (!busy.hand) {
busy.hand = true; busy.hand = true;
start.hand = human.now(); start.hand = human.now();
workers.hand.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.hand, type: 'hand' }, [imageData.data.buffer.slice(0)]); if (workers.hand) workers.hand.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.hand, type: 'hand' }, [imageData.data.buffer.slice(0)]);
} }
if (!busy.object) { if (!busy.object) {
busy.object = true; busy.object = true;
start.object = human.now(); start.object = human.now();
workers.object.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.object, type: 'object' }, [imageData.data.buffer.slice(0)]); if (workers.object) workers.object.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.object, type: 'object' }, [imageData.data.buffer.slice(0)]);
} }
time.main = Math.round(human.now() - start.main); time.main = Math.round(human.now() - start.main);
@ -204,27 +208,29 @@ async function setupCamera() {
try { try {
stream = await navigator.mediaDevices.getUserMedia(constraints); stream = await navigator.mediaDevices.getUserMedia(constraints);
} catch (err) { } catch (err) {
output.innerText += `\n${err.name}: ${err.message}`; if (output) output.innerText += `\n${err.name}: ${err.message}`;
status(err.name);
log('camera error:', err); log('camera error:', err);
} }
const tracks = stream.getVideoTracks(); if (stream) {
log('enumerated viable tracks:', tracks); const tracks = stream.getVideoTracks();
const track = stream.getVideoTracks()[0]; log('enumerated viable tracks:', tracks);
const settings = track.getSettings(); const track = stream.getVideoTracks()[0];
log('selected video source:', track, settings); const settings = track.getSettings();
log('selected video source:', track, settings);
} else {
log('missing video stream');
}
const promise = !stream || new Promise((resolve) => { const promise = !stream || new Promise((resolve) => {
video.onloadeddata = () => { video.onloadeddata = () => {
if (settings.width > settings.height) canvas.style.width = '100vw'; canvas.style.height = '100vh';
else canvas.style.height = '100vh';
canvas.width = video.videoWidth; canvas.width = video.videoWidth;
canvas.height = video.videoHeight; canvas.height = video.videoHeight;
video.play(); video.play();
resolve(); resolve(true);
}; };
}); });
// attach input to video element // attach input to video element
if (stream) video.srcObject = stream; if (stream && video) video['srcObject'] = stream;
return promise; return promise;
} }
@ -240,21 +246,13 @@ async function startWorkers() {
} }
async function main() { async function main() {
window.addEventListener('unhandledrejection', (evt) => {
// eslint-disable-next-line no-console
console.error(evt.reason || evt);
document.getElementById('log').innerHTML = evt.reason.message || evt.reason || evt;
status('exception error');
evt.preventDefault();
});
if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') { if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') {
status('workers are not supported');
return; return;
} }
human = new Human(config.main); human = new Human(config.main);
document.getElementById('log').innerText = `Human: version ${human.version}`; const div = document.getElementById('log');
if (div) div.innerText = `Human: version ${human.version}`;
await startWorkers(); await startWorkers();
await setupCamera(); await setupCamera();

View File

@ -1,8 +1,6 @@
// load Human using IIFE script as Chome Mobile does not support Modules as Workers
/// <reference lib="webworker" /> /// <reference lib="webworker" />
// import Human from '../dist/human.esm.js'; // load Human using IIFE script as Chome Mobile does not support Modules as Workers
self.importScripts('../../dist/human.js'); self.importScripts('../../dist/human.js');
let human; let human;

View File

@ -7,7 +7,7 @@
* config={}: contains all model configuration used by human * config={}: contains all model configuration used by human
*/ */
import Human from '../../dist/human.esm.js'; // equivalent of @vladmandic/human import Human from '../../dist/human.custom.esm.js'; // equivalent of @vladmandic/human
import webRTC from '../helpers/webrtc.js'; // handle webrtc handshake and connects to webrtc stream import webRTC from '../helpers/webrtc.js'; // handle webrtc handshake and connects to webrtc stream
const config = { // use default values for everything just specify models location const config = { // use default values for everything just specify models location

View File

@ -4,8 +4,8 @@
* @description Experimental Demo app for Human using WebGPU * @description Experimental Demo app for Human using WebGPU
* *
*/ */
// @ts-nocheck // typescript checks disabled as this is pure javascript
/** @type {Human} */
import Human from '../../dist/human.custom.esm.js'; import Human from '../../dist/human.custom.esm.js';
import GLBench from '../helpers/gl-bench.js'; import GLBench from '../helpers/gl-bench.js';
@ -100,9 +100,13 @@ const busy = {
}; };
const workers = { const workers = {
/** @type {Worker | null} */
face: null, face: null,
/** @type {Worker | null} */
body: null, body: null,
/** @type {Worker | null} */
hand: null, hand: null,
/** @type {Worker | null} */
object: null, object: null,
}; };
@ -146,7 +150,8 @@ async function drawResults() {
time.draw = Math.round(1 + human.now() - start.draw); time.draw = Math.round(1 + human.now() - start.draw);
const fps = Math.round(10 * 1000 / time.main) / 10; const fps = Math.round(10 * 1000 / time.main) / 10;
const draw = Math.round(10 * 1000 / time.draw) / 10; const draw = Math.round(10 * 1000 / time.draw) / 10;
document.getElementById('log').innerText = `Human: version ${human.version} | Performance: Main ${time.main}ms Face: ${time.face}ms Body: ${time.body}ms Hand: ${time.hand}ms Object ${time.object}ms | FPS: ${fps} / ${draw}`; const div = document.getElementById('log');
if (div) div.innerText = `Human: version ${human.version} | Performance: Main ${time.main}ms Face: ${time.face}ms Body: ${time.body}ms Hand: ${time.hand}ms Object ${time.object}ms | FPS: ${fps} / ${draw}`;
requestAnimationFrame(drawResults); requestAnimationFrame(drawResults);
} }
@ -160,7 +165,7 @@ async function runDetection() {
start.main = human.now(); start.main = human.now();
if (!bench) { if (!bench) {
bench = new GLBench(null, { trackGPU: false, chartHz: 20, chartLen: 20 }); bench = new GLBench(null, { trackGPU: false, chartHz: 20, chartLen: 20 });
bench.begin(); bench.begin('human');
} }
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
// const image = await human.image(video); // const image = await human.image(video);
@ -170,22 +175,22 @@ async function runDetection() {
if (!busy.face) { if (!busy.face) {
busy.face = true; busy.face = true;
start.face = human.now(); start.face = human.now();
workers.face.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.face, type: 'face' }, [imageData.data.buffer.slice(0)]); if (workers.face) workers.face.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.face, type: 'face' }, [imageData.data.buffer.slice(0)]);
} }
if (!busy.body) { if (!busy.body) {
busy.body = true; busy.body = true;
start.body = human.now(); start.body = human.now();
workers.body.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.body, type: 'body' }, [imageData.data.buffer.slice(0)]); if (workers.body) workers.body.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.body, type: 'body' }, [imageData.data.buffer.slice(0)]);
} }
if (!busy.hand) { if (!busy.hand) {
busy.hand = true; busy.hand = true;
start.hand = human.now(); start.hand = human.now();
workers.hand.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.hand, type: 'hand' }, [imageData.data.buffer.slice(0)]); if (workers.hand) workers.hand.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.hand, type: 'hand' }, [imageData.data.buffer.slice(0)]);
} }
if (!busy.object) { if (!busy.object) {
busy.object = true; busy.object = true;
start.object = human.now(); start.object = human.now();
workers.object.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.object, type: 'object' }, [imageData.data.buffer.slice(0)]); if (workers.object) workers.object.postMessage({ image: imageData.data.buffer, width: canvas.width, height: canvas.height, config: config.object, type: 'object' }, [imageData.data.buffer.slice(0)]);
} }
time.main = Math.round(human.now() - start.main); time.main = Math.round(human.now() - start.main);
@ -194,8 +199,8 @@ async function runDetection() {
} }
async function setupCamera() { async function setupCamera() {
video = document.getElementById('video'); video = document.getElementById('video') || document.createElement('video');
canvas = document.getElementById('canvas'); canvas = document.getElementById('canvas') || document.createElement('canvas');
const output = document.getElementById('log'); const output = document.getElementById('log');
let stream; let stream;
const constraints = { const constraints = {
@ -214,28 +219,30 @@ async function setupCamera() {
try { try {
stream = await navigator.mediaDevices.getUserMedia(constraints); stream = await navigator.mediaDevices.getUserMedia(constraints);
} catch (err) { } catch (err) {
output.innerText += `\n${err.name}: ${err.message}`; if (output) output.innerText += `\n${err.name}: ${err.message}`;
status(err.name);
log('camera error:', err); log('camera error:', err);
} }
const tracks = stream.getVideoTracks(); if (stream) {
log('enumerated viable tracks:', tracks); const tracks = stream.getVideoTracks();
const track = stream.getVideoTracks()[0]; log('enumerated viable tracks:', tracks);
const settings = track.getSettings(); const track = stream.getVideoTracks()[0];
log('selected video source:', track, settings); const settings = track.getSettings();
const promise = !stream || new Promise((resolve) => { log('selected video source:', track, settings);
video.onloadeddata = () => { const promise = new Promise((resolve) => {
if (settings.width > settings.height) canvas.style.width = '100vw'; video.onloadeddata = () => {
else canvas.style.height = '100vh'; if (settings.width && settings.height && settings.width > settings.height) canvas.style.width = '100vw';
canvas.width = video.videoWidth; else canvas.style.height = '100vh';
canvas.height = video.videoHeight; canvas.width = video.videoWidth;
video.play(); canvas.height = video.videoHeight;
resolve(); video.play();
}; resolve(true);
}); };
// attach input to video element });
if (stream) video.srcObject = stream; // attach input to video element
return promise; video['srcObject'] = stream;
return promise;
}
return false;
} }
async function startWorkers() { async function startWorkers() {
@ -261,12 +268,12 @@ async function main() {
*/ */
if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') { if (typeof Worker === 'undefined' || typeof OffscreenCanvas === 'undefined') {
status('workers are not supported');
return; return;
} }
human = new Human(config.main); human = new Human(config.main);
document.getElementById('log').innerText = `Human: version ${human.version}`; const div = document.getElementById('log');
if (div) div.innerText = `Human: version ${human.version}`;
await startWorkers(); await startWorkers();
await setupCamera(); await setupCamera();

View File

@ -1,8 +1,7 @@
/// <reference lib="webworker" /> /// <reference lib="webworker" />
// import Human from '../../dist/human.esm'; // load Human using IIFE script as Chome Mobile does not support Modules as Workers // load Human using IIFE script as Chome Mobile does not support Modules as Workers
// self.importScripts('../../dist/human.js'); // self.importScripts('../../dist/human.js');
import * as Human from '../../dist/human.custom.esm.js'; import * as Human from '../../dist/human.custom.esm.js';
let human; let human;

79819
dist/human.custom.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -108,6 +108,7 @@ function mergeDeep(...objects) {
} }
// src/config.ts // src/config.ts
var timeFact = 1e3;
var config = { var config = {
backend: "", backend: "",
modelBasePath: "", modelBasePath: "",
@ -147,7 +148,7 @@ var config = {
rotation: true, rotation: true,
maxDetected: 1, maxDetected: 1,
skipFrames: 99, skipFrames: 99,
skipTime: 2500, skipTime: 2.5 * timeFact,
minConfidence: 0.2, minConfidence: 0.2,
iouThreshold: 0.1, iouThreshold: 0.1,
return: false return: false
@ -164,20 +165,20 @@ var config = {
enabled: true, enabled: true,
minConfidence: 0.1, minConfidence: 0.1,
skipFrames: 99, skipFrames: 99,
skipTime: 1500, skipTime: 1.5 * timeFact,
modelPath: "emotion.json" modelPath: "emotion.json"
}, },
description: { description: {
enabled: true, enabled: true,
modelPath: "faceres.json", modelPath: "faceres.json",
skipFrames: 99, skipFrames: 99,
skipTime: 3e3, skipTime: 3 * timeFact,
minConfidence: 0.1 minConfidence: 0.1
}, },
antispoof: { antispoof: {
enabled: false, enabled: false,
skipFrames: 99, skipFrames: 99,
skipTime: 4e3, skipTime: 4 * timeFact,
modelPath: "antispoof.json" modelPath: "antispoof.json"
} }
}, },
@ -190,13 +191,13 @@ var config = {
maxDetected: -1, maxDetected: -1,
minConfidence: 0.3, minConfidence: 0.3,
skipFrames: 1, skipFrames: 1,
skipTime: 200 skipTime: 0.2 * timeFact
}, },
hand: { hand: {
enabled: true, enabled: true,
rotation: true, rotation: true,
skipFrames: 99, skipFrames: 99,
skipTime: 2e3, skipTime: 2 * timeFact,
minConfidence: 0.5, minConfidence: 0.5,
iouThreshold: 0.2, iouThreshold: 0.2,
maxDetected: -1, maxDetected: -1,
@ -215,7 +216,7 @@ var config = {
iouThreshold: 0.4, iouThreshold: 0.4,
maxDetected: 10, maxDetected: 10,
skipFrames: 99, skipFrames: 99,
skipTime: 1e3 skipTime: 1 * timeFact
}, },
segmentation: { segmentation: {
enabled: false, enabled: false,
@ -11814,18 +11815,18 @@ function calc2(newResult, config3) {
function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
let sum2 = 0; let sum2 = 0;
for (let i = 0; i < descriptor1.length; i++) { for (let i = 0; i < descriptor1.length; i++) {
const diff = options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]); const diff = !options3.order || options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]);
sum2 += options3.order === 2 ? diff * diff : diff ** options3.order; sum2 += !options3.order || options3.order === 2 ? diff * diff : diff ** options3.order;
} }
return (options3.multiplier || 20) * sum2; return (options3.multiplier || 20) * sum2;
} }
function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
const dist = distance(descriptor1, descriptor2, options3); const dist = distance(descriptor1, descriptor2, options3);
const root = options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order); const root = !options3.order || options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order);
const invert = Math.max(0, 100 - root) / 100; const invert = Math.max(0, 100 - root) / 100;
return invert; return invert;
} }
function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, multiplier: 20 }) { function match2(descriptor, descriptors, options3 = { order: 2, multiplier: 20, threshold: 0 }) {
if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) { if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) {
return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 }; return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 };
} }
@ -11837,10 +11838,10 @@ function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, mu
best = res; best = res;
index = i; index = i;
} }
if (best < options3.threshold) if (best < (options3.threshold || 0))
break; break;
} }
best = options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order); best = !options3.order || options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order);
return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 }; return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 };
} }
@ -12863,7 +12864,7 @@ var Human = class {
if (this.config.debug) if (this.config.debug)
log("configuration:", this.config); log("configuration:", this.config);
if (this.config.debug) if (this.config.debug)
log("tf flags:", this.tf.ENV.flags); log("tf flags:", this.tf.ENV["flags"]);
} }
} }
await load15(this); await load15(this);

File diff suppressed because one or more lines are too long

43944
dist/human.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1870
dist/human.js vendored

File diff suppressed because one or more lines are too long

View File

@ -143,6 +143,7 @@ function mergeDeep(...objects) {
} }
// src/config.ts // src/config.ts
var timeFact = 1e3;
var config = { var config = {
backend: "", backend: "",
modelBasePath: "", modelBasePath: "",
@ -182,7 +183,7 @@ var config = {
rotation: true, rotation: true,
maxDetected: 1, maxDetected: 1,
skipFrames: 99, skipFrames: 99,
skipTime: 2500, skipTime: 2.5 * timeFact,
minConfidence: 0.2, minConfidence: 0.2,
iouThreshold: 0.1, iouThreshold: 0.1,
return: false return: false
@ -199,20 +200,20 @@ var config = {
enabled: true, enabled: true,
minConfidence: 0.1, minConfidence: 0.1,
skipFrames: 99, skipFrames: 99,
skipTime: 1500, skipTime: 1.5 * timeFact,
modelPath: "emotion.json" modelPath: "emotion.json"
}, },
description: { description: {
enabled: true, enabled: true,
modelPath: "faceres.json", modelPath: "faceres.json",
skipFrames: 99, skipFrames: 99,
skipTime: 3e3, skipTime: 3 * timeFact,
minConfidence: 0.1 minConfidence: 0.1
}, },
antispoof: { antispoof: {
enabled: false, enabled: false,
skipFrames: 99, skipFrames: 99,
skipTime: 4e3, skipTime: 4 * timeFact,
modelPath: "antispoof.json" modelPath: "antispoof.json"
} }
}, },
@ -225,13 +226,13 @@ var config = {
maxDetected: -1, maxDetected: -1,
minConfidence: 0.3, minConfidence: 0.3,
skipFrames: 1, skipFrames: 1,
skipTime: 200 skipTime: 0.2 * timeFact
}, },
hand: { hand: {
enabled: true, enabled: true,
rotation: true, rotation: true,
skipFrames: 99, skipFrames: 99,
skipTime: 2e3, skipTime: 2 * timeFact,
minConfidence: 0.5, minConfidence: 0.5,
iouThreshold: 0.2, iouThreshold: 0.2,
maxDetected: -1, maxDetected: -1,
@ -250,7 +251,7 @@ var config = {
iouThreshold: 0.4, iouThreshold: 0.4,
maxDetected: 10, maxDetected: 10,
skipFrames: 99, skipFrames: 99,
skipTime: 1e3 skipTime: 1 * timeFact
}, },
segmentation: { segmentation: {
enabled: false, enabled: false,
@ -11872,18 +11873,18 @@ function calc2(newResult, config3) {
function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
let sum2 = 0; let sum2 = 0;
for (let i = 0; i < descriptor1.length; i++) { for (let i = 0; i < descriptor1.length; i++) {
const diff = options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]); const diff = !options3.order || options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]);
sum2 += options3.order === 2 ? diff * diff : diff ** options3.order; sum2 += !options3.order || options3.order === 2 ? diff * diff : diff ** options3.order;
} }
return (options3.multiplier || 20) * sum2; return (options3.multiplier || 20) * sum2;
} }
function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
const dist = distance(descriptor1, descriptor2, options3); const dist = distance(descriptor1, descriptor2, options3);
const root = options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order); const root = !options3.order || options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order);
const invert = Math.max(0, 100 - root) / 100; const invert = Math.max(0, 100 - root) / 100;
return invert; return invert;
} }
function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, multiplier: 20 }) { function match2(descriptor, descriptors, options3 = { order: 2, multiplier: 20, threshold: 0 }) {
if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) { if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) {
return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 }; return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 };
} }
@ -11895,10 +11896,10 @@ function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, mu
best = res; best = res;
index = i; index = i;
} }
if (best < options3.threshold) if (best < (options3.threshold || 0))
break; break;
} }
best = options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order); best = !options3.order || options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order);
return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 }; return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 };
} }
@ -12922,7 +12923,7 @@ var Human = class {
if (this.config.debug) if (this.config.debug)
log("configuration:", this.config); log("configuration:", this.config);
if (this.config.debug) if (this.config.debug)
log("tf flags:", this.tf.ENV.flags); log("tf flags:", this.tf.ENV["flags"]);
} }
} }
await load15(this); await load15(this);

View File

@ -144,6 +144,7 @@ function mergeDeep(...objects) {
} }
// src/config.ts // src/config.ts
var timeFact = 1e3;
var config = { var config = {
backend: "", backend: "",
modelBasePath: "", modelBasePath: "",
@ -183,7 +184,7 @@ var config = {
rotation: true, rotation: true,
maxDetected: 1, maxDetected: 1,
skipFrames: 99, skipFrames: 99,
skipTime: 2500, skipTime: 2.5 * timeFact,
minConfidence: 0.2, minConfidence: 0.2,
iouThreshold: 0.1, iouThreshold: 0.1,
return: false return: false
@ -200,20 +201,20 @@ var config = {
enabled: true, enabled: true,
minConfidence: 0.1, minConfidence: 0.1,
skipFrames: 99, skipFrames: 99,
skipTime: 1500, skipTime: 1.5 * timeFact,
modelPath: "emotion.json" modelPath: "emotion.json"
}, },
description: { description: {
enabled: true, enabled: true,
modelPath: "faceres.json", modelPath: "faceres.json",
skipFrames: 99, skipFrames: 99,
skipTime: 3e3, skipTime: 3 * timeFact,
minConfidence: 0.1 minConfidence: 0.1
}, },
antispoof: { antispoof: {
enabled: false, enabled: false,
skipFrames: 99, skipFrames: 99,
skipTime: 4e3, skipTime: 4 * timeFact,
modelPath: "antispoof.json" modelPath: "antispoof.json"
} }
}, },
@ -226,13 +227,13 @@ var config = {
maxDetected: -1, maxDetected: -1,
minConfidence: 0.3, minConfidence: 0.3,
skipFrames: 1, skipFrames: 1,
skipTime: 200 skipTime: 0.2 * timeFact
}, },
hand: { hand: {
enabled: true, enabled: true,
rotation: true, rotation: true,
skipFrames: 99, skipFrames: 99,
skipTime: 2e3, skipTime: 2 * timeFact,
minConfidence: 0.5, minConfidence: 0.5,
iouThreshold: 0.2, iouThreshold: 0.2,
maxDetected: -1, maxDetected: -1,
@ -251,7 +252,7 @@ var config = {
iouThreshold: 0.4, iouThreshold: 0.4,
maxDetected: 10, maxDetected: 10,
skipFrames: 99, skipFrames: 99,
skipTime: 1e3 skipTime: 1 * timeFact
}, },
segmentation: { segmentation: {
enabled: false, enabled: false,
@ -11873,18 +11874,18 @@ function calc2(newResult, config3) {
function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
let sum2 = 0; let sum2 = 0;
for (let i = 0; i < descriptor1.length; i++) { for (let i = 0; i < descriptor1.length; i++) {
const diff = options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]); const diff = !options3.order || options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]);
sum2 += options3.order === 2 ? diff * diff : diff ** options3.order; sum2 += !options3.order || options3.order === 2 ? diff * diff : diff ** options3.order;
} }
return (options3.multiplier || 20) * sum2; return (options3.multiplier || 20) * sum2;
} }
function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
const dist = distance(descriptor1, descriptor2, options3); const dist = distance(descriptor1, descriptor2, options3);
const root = options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order); const root = !options3.order || options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order);
const invert = Math.max(0, 100 - root) / 100; const invert = Math.max(0, 100 - root) / 100;
return invert; return invert;
} }
function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, multiplier: 20 }) { function match2(descriptor, descriptors, options3 = { order: 2, multiplier: 20, threshold: 0 }) {
if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) { if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) {
return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 }; return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 };
} }
@ -11896,10 +11897,10 @@ function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, mu
best = res; best = res;
index = i; index = i;
} }
if (best < options3.threshold) if (best < (options3.threshold || 0))
break; break;
} }
best = options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order); best = !options3.order || options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order);
return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 }; return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 };
} }
@ -12923,7 +12924,7 @@ var Human = class {
if (this.config.debug) if (this.config.debug)
log("configuration:", this.config); log("configuration:", this.config);
if (this.config.debug) if (this.config.debug)
log("tf flags:", this.tf.ENV.flags); log("tf flags:", this.tf.ENV["flags"]);
} }
} }
await load15(this); await load15(this);

29
dist/human.node.js vendored
View File

@ -143,6 +143,7 @@ function mergeDeep(...objects) {
} }
// src/config.ts // src/config.ts
var timeFact = 1e3;
var config = { var config = {
backend: "", backend: "",
modelBasePath: "", modelBasePath: "",
@ -182,7 +183,7 @@ var config = {
rotation: true, rotation: true,
maxDetected: 1, maxDetected: 1,
skipFrames: 99, skipFrames: 99,
skipTime: 2500, skipTime: 2.5 * timeFact,
minConfidence: 0.2, minConfidence: 0.2,
iouThreshold: 0.1, iouThreshold: 0.1,
return: false return: false
@ -199,20 +200,20 @@ var config = {
enabled: true, enabled: true,
minConfidence: 0.1, minConfidence: 0.1,
skipFrames: 99, skipFrames: 99,
skipTime: 1500, skipTime: 1.5 * timeFact,
modelPath: "emotion.json" modelPath: "emotion.json"
}, },
description: { description: {
enabled: true, enabled: true,
modelPath: "faceres.json", modelPath: "faceres.json",
skipFrames: 99, skipFrames: 99,
skipTime: 3e3, skipTime: 3 * timeFact,
minConfidence: 0.1 minConfidence: 0.1
}, },
antispoof: { antispoof: {
enabled: false, enabled: false,
skipFrames: 99, skipFrames: 99,
skipTime: 4e3, skipTime: 4 * timeFact,
modelPath: "antispoof.json" modelPath: "antispoof.json"
} }
}, },
@ -225,13 +226,13 @@ var config = {
maxDetected: -1, maxDetected: -1,
minConfidence: 0.3, minConfidence: 0.3,
skipFrames: 1, skipFrames: 1,
skipTime: 200 skipTime: 0.2 * timeFact
}, },
hand: { hand: {
enabled: true, enabled: true,
rotation: true, rotation: true,
skipFrames: 99, skipFrames: 99,
skipTime: 2e3, skipTime: 2 * timeFact,
minConfidence: 0.5, minConfidence: 0.5,
iouThreshold: 0.2, iouThreshold: 0.2,
maxDetected: -1, maxDetected: -1,
@ -250,7 +251,7 @@ var config = {
iouThreshold: 0.4, iouThreshold: 0.4,
maxDetected: 10, maxDetected: 10,
skipFrames: 99, skipFrames: 99,
skipTime: 1e3 skipTime: 1 * timeFact
}, },
segmentation: { segmentation: {
enabled: false, enabled: false,
@ -11872,18 +11873,18 @@ function calc2(newResult, config3) {
function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function distance(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
let sum2 = 0; let sum2 = 0;
for (let i = 0; i < descriptor1.length; i++) { for (let i = 0; i < descriptor1.length; i++) {
const diff = options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]); const diff = !options3.order || options3.order === 2 ? descriptor1[i] - descriptor2[i] : Math.abs(descriptor1[i] - descriptor2[i]);
sum2 += options3.order === 2 ? diff * diff : diff ** options3.order; sum2 += !options3.order || options3.order === 2 ? diff * diff : diff ** options3.order;
} }
return (options3.multiplier || 20) * sum2; return (options3.multiplier || 20) * sum2;
} }
function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) { function similarity(descriptor1, descriptor2, options3 = { order: 2, multiplier: 20 }) {
const dist = distance(descriptor1, descriptor2, options3); const dist = distance(descriptor1, descriptor2, options3);
const root = options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order); const root = !options3.order || options3.order === 2 ? Math.sqrt(dist) : dist ** (1 / options3.order);
const invert = Math.max(0, 100 - root) / 100; const invert = Math.max(0, 100 - root) / 100;
return invert; return invert;
} }
function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, multiplier: 20 }) { function match2(descriptor, descriptors, options3 = { order: 2, multiplier: 20, threshold: 0 }) {
if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) { if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) {
return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 }; return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 };
} }
@ -11895,10 +11896,10 @@ function match2(descriptor, descriptors, options3 = { order: 2, threshold: 0, mu
best = res; best = res;
index = i; index = i;
} }
if (best < options3.threshold) if (best < (options3.threshold || 0))
break; break;
} }
best = options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order); best = !options3.order || options3.order === 2 ? Math.sqrt(best) : best ** (1 / options3.order);
return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 }; return { index, distance: best, similarity: Math.max(0, 100 - best) / 100 };
} }
@ -12922,7 +12923,7 @@ var Human = class {
if (this.config.debug) if (this.config.debug)
log("configuration:", this.config); log("configuration:", this.config);
if (this.config.debug) if (this.config.debug)
log("tf flags:", this.tf.ENV.flags); log("tf flags:", this.tf.ENV["flags"]);
} }
} }
await load15(this); await load15(this);

68864
dist/tfjs.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -66,16 +66,18 @@
"@tensorflow/tfjs-layers": "^3.10.0", "@tensorflow/tfjs-layers": "^3.10.0",
"@tensorflow/tfjs-node": "^3.10.0", "@tensorflow/tfjs-node": "^3.10.0",
"@tensorflow/tfjs-node-gpu": "^3.10.0", "@tensorflow/tfjs-node-gpu": "^3.10.0",
"@types/node": "^16.11.5", "@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.2.0", "@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0", "@typescript-eslint/parser": "^5.2.0",
"@vladmandic/build": "^0.6.3", "@vladmandic/build": "^0.6.3",
"@vladmandic/pilogger": "^0.3.3", "@vladmandic/pilogger": "^0.3.3",
"canvas": "^2.8.0", "canvas": "^2.8.0",
"dayjs": "^1.10.7", "dayjs": "^1.10.7",
"long": "^4.0.0",
"esbuild": "^0.13.9", "esbuild": "^0.13.9",
"eslint": "8.1.0", "eslint": "8.1.0",
"eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-html": "^6.2.0",
"eslint-plugin-import": "^2.25.2", "eslint-plugin-import": "^2.25.2",
"eslint-plugin-json": "^3.1.0", "eslint-plugin-json": "^3.1.0",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
@ -88,6 +90,5 @@
"typescript": "4.4.4" "typescript": "4.4.4"
}, },
"dependencies": { "dependencies": {
"long": "^4.0.0"
} }
} }

View File

@ -1,5 +1,6 @@
/** Face descriptor type as number array */ /** Face descriptor type as number array */
export type Descriptor = Array<number> export type Descriptor = Array<number>
export type Options = { order?: number, threshold?: number, multiplier?: number } | undefined;
/** Calculates distance between two descriptors /** Calculates distance between two descriptors
* @param {object} options * @param {object} options
@ -9,12 +10,12 @@ export type Descriptor = Array<number>
* - default is 20 which normalizes results to similarity above 0.5 can be considered a match * - default is 20 which normalizes results to similarity above 0.5 can be considered a match
* @returns {number} * @returns {number}
*/ */
export function distance(descriptor1: Descriptor, descriptor2: Descriptor, options = { order: 2, multiplier: 20 }) { export function distance(descriptor1: Descriptor, descriptor2: Descriptor, options: Options = { order: 2, multiplier: 20 }) {
// general minkowski distance, euclidean distance is limited case where order is 2 // general minkowski distance, euclidean distance is limited case where order is 2
let sum = 0; let sum = 0;
for (let i = 0; i < descriptor1.length; i++) { for (let i = 0; i < descriptor1.length; i++) {
const diff = (options.order === 2) ? (descriptor1[i] - descriptor2[i]) : (Math.abs(descriptor1[i] - descriptor2[i])); const diff = (!options.order || options.order === 2) ? (descriptor1[i] - descriptor2[i]) : (Math.abs(descriptor1[i] - descriptor2[i]));
sum += (options.order === 2) ? (diff * diff) : (diff ** options.order); sum += (!options.order || options.order === 2) ? (diff * diff) : (diff ** options.order);
} }
return (options.multiplier || 20) * sum; return (options.multiplier || 20) * sum;
} }
@ -27,9 +28,9 @@ export function distance(descriptor1: Descriptor, descriptor2: Descriptor, optio
* - default is 20 which normalizes results to similarity above 0.5 can be considered a match * - default is 20 which normalizes results to similarity above 0.5 can be considered a match
* @returns {number} similarity between two face descriptors normalized to 0..1 range where 0 is no similarity and 1 is perfect similarity * @returns {number} similarity between two face descriptors normalized to 0..1 range where 0 is no similarity and 1 is perfect similarity
*/ */
export function similarity(descriptor1: Descriptor, descriptor2: Descriptor, options = { order: 2, multiplier: 20 }) { export function similarity(descriptor1: Descriptor, descriptor2: Descriptor, options: Options = { order: 2, multiplier: 20 }) {
const dist = distance(descriptor1, descriptor2, options); const dist = distance(descriptor1, descriptor2, options);
const root = (options.order === 2) ? Math.sqrt(dist) : dist ** (1 / options.order); const root = (!options.order || options.order === 2) ? Math.sqrt(dist) : dist ** (1 / options.order);
const invert = Math.max(0, 100 - root) / 100.0; const invert = Math.max(0, 100 - root) / 100.0;
return invert; return invert;
} }
@ -45,7 +46,7 @@ export function similarity(descriptor1: Descriptor, descriptor2: Descriptor, opt
* - {@link distance} calculated `distance` of given descriptor to the best match * - {@link distance} calculated `distance` of given descriptor to the best match
* - {@link similarity} calculated normalized `similarity` of given descriptor to the best match * - {@link similarity} calculated normalized `similarity` of given descriptor to the best match
*/ */
export function match(descriptor: Descriptor, descriptors: Array<Descriptor>, options = { order: 2, threshold: 0, multiplier: 20 }) { export function match(descriptor: Descriptor, descriptors: Array<Descriptor>, options: Options = { order: 2, multiplier: 20, threshold: 0 }) {
if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) { // validate input if (!Array.isArray(descriptor) || !Array.isArray(descriptors) || descriptor.length < 64 || descriptors.length === 0 || descriptor.length !== descriptors[0].length) { // validate input
return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 }; return { index: -1, distance: Number.POSITIVE_INFINITY, similarity: 0 };
} }
@ -57,8 +58,8 @@ export function match(descriptor: Descriptor, descriptors: Array<Descriptor>, op
best = res; best = res;
index = i; index = i;
} }
if (best < options.threshold) break; if (best < (options.threshold || 0)) break;
} }
best = (options.order === 2) ? Math.sqrt(best) : best ** (1 / options.order); best = (!options.order || options.order === 2) ? Math.sqrt(best) : best ** (1 / options.order);
return { index, distance: best, similarity: Math.max(0, 100 - best) / 100.0 }; return { index, distance: best, similarity: Math.max(0, 100 - best) / 100.0 };
} }

39
src/human.d.ts vendored Normal file
View File

@ -0,0 +1,39 @@
/* eslint-disable node/no-missing-import */
/*
declare module '@vladmandic/human/dist/tfjs.esm' {
export * from '@vladmandic/human/types/dist/tfjs.esm';
}
*/
declare module '@vladmandic/human/dist/human.esm' {
export * from '@vladmandic/human/types/src/human';
}
declare module '@vladmandic/human/dist/human.esm-nobundle' {
export * from '@vladmandic/human/types/src/human';
}
declare module '@vladmandic/human/dist/human' {
export * from '@vladmandic/human/types/src/human';
}
declare module '@vladmandic/human/dist/human.node' {
export * from '@vladmandic/human/types/src/human';
}
declare module '@vladmandic/human/dist/human.node-gpu' {
export * from '@vladmandic/human/types/src/human';
}
declare module '@vladmandic/human/dist/human.node-wasm' {
export * from '@vladmandic/human/types/src/human';
}
declare module '@vladmandic/human/dist/human.custom.esm' {
export * from '@vladmandic/human/types/src/human';
}
declare module '@vladmandic/human/dist/human.custom.esm' {
export * from '@vladmandic/human/types/src/human';
}

View File

@ -212,7 +212,7 @@ export class Human {
} }
/** Validate current configuration schema */ /** Validate current configuration schema */
public validate(userConfig?: Partial<Config>) { validate(userConfig?: Partial<Config>) {
return validate(defaults, userConfig || this.config); return validate(defaults, userConfig || this.config);
} }
@ -294,7 +294,7 @@ export class Human {
await tf.ready(); await tf.ready();
if (this.env.browser) { if (this.env.browser) {
if (this.config.debug) log('configuration:', this.config); if (this.config.debug) log('configuration:', this.config);
if (this.config.debug) log('tf flags:', this.tf.ENV.flags); if (this.config.debug) log('tf flags:', this.tf.ENV['flags']);
} }
} }

View File

@ -34,7 +34,7 @@
debug: true, debug: true,
cacheSensitivity: 0, cacheSensitivity: 0,
object: { enabled: true }, object: { enabled: true },
} };
const backends = ['wasm', 'webgl', 'humangl', 'webgpu']; const backends = ['wasm', 'webgl', 'humangl', 'webgpu'];
@ -55,7 +55,8 @@
const dt = new Date(); const dt = new Date();
const ts = `${dt.getHours().toString().padStart(2, '0')}:${dt.getMinutes().toString().padStart(2, '0')}:${dt.getSeconds().toString().padStart(2, '0')}.${dt.getMilliseconds().toString().padStart(3, '0')}`; const ts = `${dt.getHours().toString().padStart(2, '0')}:${dt.getMinutes().toString().padStart(2, '0')}:${dt.getSeconds().toString().padStart(2, '0')}.${dt.getMilliseconds().toString().padStart(3, '0')}`;
const elap = (dt - last).toString().padStart(5, '0'); const elap = (dt - last).toString().padStart(5, '0');
document.getElementById('log').innerHTML += ts + ' +' + elap + 'ms' + '&nbsp' + str(...msgs); document.getElementById('log').innerHTML += ts + ' +' + elap + 'ms &nbsp' + str(...msgs);
// eslint-disable-next-line no-console
console.log(ts, elap, ...msgs); console.log(ts, elap, ...msgs);
last = dt; last = dt;
} }
@ -63,7 +64,7 @@
async function image(url) { async function image(url) {
const el = document.createElement('img'); const el = document.createElement('img');
el.id = 'image'; el.id = 'image';
const loaded = new Promise((resolve) => { el.onload = () => resolve(true) }); const loaded = new Promise((resolve) => { el.onload = () => resolve(true); });
el.src = url; el.src = url;
await loaded; await loaded;
return el; return el;
@ -88,7 +89,7 @@
async function main() { async function main() {
log('human tests'); log('human tests');
let res; let res;
let human = new Human(config); const human = new Human(config);
await human.init(); await human.init();
human.events.addEventListener('warmup', () => events('warmup')); human.events.addEventListener('warmup', () => events('warmup'));
human.events.addEventListener('image', () => events('image')); human.events.addEventListener('image', () => events('image'));
@ -110,7 +111,7 @@
log({ memory: human.tf.memory() }); log({ memory: human.tf.memory() });
res = await human.validate(); res = await human.validate();
log({ validate: res }); log({ validate: res });
res = await human.warmup({ warmup: 'face'}); res = await human.warmup({ warmup: 'face' });
draw(res.canvas); draw(res.canvas);
log({ warmup: 'face' }); log({ warmup: 'face' });
let img = await image('../../samples/in/ai-body.jpg'); let img = await image('../../samples/in/ai-body.jpg');
@ -119,11 +120,11 @@
draw(res.canvas); draw(res.canvas);
res = await human.detect(input.tensor); res = await human.detect(input.tensor);
log({ detect: true }); log({ detect: true });
const interpolated = human.next(); human.next();
log({ interpolated: true }); log({ interpolated: true });
const persons = res.persons; const persons = res.persons;
log({ persons: true }); log({ persons: true });
log({ summary: { persons: persons.length, face: res.face.length, body: res.body.length, hand: res.hand.length, object: res.object.length, gesture: res.gesture.length }}); log({ summary: { persons: persons.length, face: res.face.length, body: res.body.length, hand: res.hand.length, object: res.object.length, gesture: res.gesture.length } });
log({ performance: human.performance }); log({ performance: human.performance });
human.tf.dispose(input.tensor); human.tf.dispose(input.tensor);
draw(); draw();

View File

@ -1,26 +1,26 @@
2021-10-25 13:20:16 INFO:  @vladmandic/human version 2.4.1 2021-10-26 15:02:47 INFO:  @vladmandic/human version 2.4.1
2021-10-25 13:20:16 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.10.0 2021-10-26 15:02:47 INFO:  User: vlado Platform: linux Arch: x64 Node: v17.0.1
2021-10-25 13:20:16 INFO:  Application: {"name":"@vladmandic/human","version":"2.4.1"} 2021-10-26 15:02:47 INFO:  Application: {"name":"@vladmandic/human","version":"2.4.1"}
2021-10-25 13:20:16 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true} 2021-10-26 15:02:47 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2021-10-25 13:20:16 INFO:  Toolchain: {"build":"0.6.3","esbuild":"0.13.9","typescript":"4.4.4","typedoc":"0.22.7","eslint":"8.1.0"} 2021-10-26 15:02:47 INFO:  Toolchain: {"build":"0.6.3","esbuild":"0.13.9","typescript":"4.4.4","typedoc":"0.22.7","eslint":"8.1.0"}
2021-10-25 13:20:16 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]} 2021-10-26 15:02:47 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2021-10-25 13:20:16 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]} 2021-10-26 15:02:47 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]}
2021-10-25 13:20:16 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1275} 2021-10-26 15:02:47 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":102,"outputBytes":1275}
2021-10-25 13:20:16 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":55,"inputBytes":524815,"outputBytes":438967} 2021-10-26 15:02:47 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":55,"inputBytes":525089,"outputBytes":439140}
2021-10-25 13:20:16 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1283} 2021-10-26 15:02:47 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":110,"outputBytes":1283}
2021-10-25 13:20:16 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":55,"inputBytes":524823,"outputBytes":438971} 2021-10-26 15:02:47 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":55,"inputBytes":525097,"outputBytes":439144}
2021-10-25 13:20:16 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1350} 2021-10-26 15:02:47 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":1,"inputBytes":149,"outputBytes":1350}
2021-10-25 13:20:16 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":55,"inputBytes":524890,"outputBytes":439043} 2021-10-26 15:02:47 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":55,"inputBytes":525164,"outputBytes":439216}
2021-10-25 13:20:16 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1652} 2021-10-26 15:02:47 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1063,"outputBytes":1652}
2021-10-25 13:20:16 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":2323,"outputBytes":973} 2021-10-26 15:02:47 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":2323,"outputBytes":973}
2021-10-25 13:20:16 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":55,"inputBytes":524513,"outputBytes":440910} 2021-10-26 15:02:47 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":55,"inputBytes":524787,"outputBytes":441083}
2021-10-25 13:20:17 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":2572202,"outputBytes":2491625} 2021-10-26 15:02:48 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":2323,"outputBytes":2411208}
2021-10-25 13:20:17 STATE: Compile: {"name":"human/browser/esm/custom","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.custom.esm.js","files":55,"inputBytes":3015165,"outputBytes":1607407} 2021-10-26 15:02:48 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":55,"inputBytes":2935022,"outputBytes":1433161}
2021-10-25 13:20:17 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":8,"inputBytes":2323,"outputBytes":1155160} 2021-10-26 15:02:49 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":55,"inputBytes":2935022,"outputBytes":1433151}
2021-10-25 13:20:18 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":55,"inputBytes":1678700,"outputBytes":1431091} 2021-10-26 15:02:49 STATE: Compile: {"name":"tfjs/browser/esm/custom","format":"esm","platform":"browser","input":"tfjs/tf-custom.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":2577343,"outputBytes":2496714}
2021-10-25 13:20:18 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":55,"inputBytes":1678700,"outputBytes":1879499} 2021-10-26 15:02:49 STATE: Compile: {"name":"human/browser/esm/custom","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.custom.esm.js","files":55,"inputBytes":3020528,"outputBytes":2941349}
2021-10-25 13:20:29 STATE: Typings: {"input":"src/human.ts","output":"types","files":96} 2021-10-26 15:03:08 STATE: Typings: {"input":"src/human.ts","output":"types","files":96}
2021-10-25 13:20:34 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":48,"generated":true} 2021-10-26 15:03:15 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":48,"generated":true}
2021-10-25 13:21:01 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":91,"errors":0,"warnings":0} 2021-10-26 15:03:55 STATE: Lint: {"locations":["*.json","src/**/*.ts","test/**/*.js","demo/**/*.js"],"files":91,"errors":0,"warnings":0}
2021-10-25 13:21:01 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"} 2021-10-26 15:03:55 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2021-10-25 13:21:01 INFO:  Done... 2021-10-26 15:03:55 INFO:  Done...

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@
"outDir": "types", "outDir": "types",
"baseUrl": "./", "baseUrl": "./",
"paths": { "tslib": ["./node_modules/tslib/tslib.d.ts"] }, "paths": { "tslib": ["./node_modules/tslib/tslib.d.ts"] },
"lib": ["es2020", "dom", "webworker"],
"allowJs": true, "allowJs": true,
"allowSyntheticDefaultImports": false, "allowSyntheticDefaultImports": false,
"allowUnreachableCode": false, "allowUnreachableCode": false,
@ -50,7 +51,7 @@
"tabSize": 2 "tabSize": 2
}, },
"exclude": ["node_modules/", "types/", "tfjs/", "dist/"], "exclude": ["node_modules/", "types/", "tfjs/", "dist/"],
"include": ["src"], "include": ["src", "types/human.d.ts"],
"typedocOptions": { "typedocOptions": {
"externalPattern": ["node_modules/", "tfjs/"] "externalPattern": ["node_modules/", "tfjs/"]
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3137
types/dist/tfjs.esm.d.ts vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -216,7 +216,7 @@ export interface Config {
/** {@link SegmentationConfig} */ /** {@link SegmentationConfig} */
segmentation: Partial<SegmentationConfig>; segmentation: Partial<SegmentationConfig>;
} }
/** - [See all default Config values...](https://github.com/vladmandic/human/blob/main/src/config.ts#L250) */ /** - [See all default Config values...](https://github.com/vladmandic/human/blob/main/src/config.ts#L252) */
declare const config: Config; declare const config: Config;
export { config as defaults }; export { config as defaults };
//# sourceMappingURL=config.d.ts.map //# sourceMappingURL=config.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAGA,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,oGAAoG;IACpG,UAAU,EAAE,MAAM,CAAC;IACnB,yGAAyG;IACzG,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,4EAA4E;IAC5E,QAAQ,EAAE,OAAO,CAAC;IAClB,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,aAAa,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,YAAY,EAAE,MAAM,CAAC;IACrB,mGAAmG;IACnG,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAe,SAAQ,aAAa;CAAG;AAExD,sCAAsC;AACtC,MAAM,WAAW,cAAe,SAAQ,aAAa;CAAG;AAExD;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,oFAAoF;IACpF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,yCAAyC;AACzC,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,oFAAoF;IACpF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAoB,SAAQ,aAAa;CAAG;AAE7D,+HAA+H;AAC/H,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,QAAQ,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,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ID,6GAA6G;AAC7G,QAAA,MAAM,MAAM,EAAE,MAmLb,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,CAAC"}

View File

@ -1,5 +1,10 @@
/** Face descriptor type as number array */ /** Face descriptor type as number array */
export declare type Descriptor = Array<number>; export declare type Descriptor = Array<number>;
export declare type Options = {
order?: number;
threshold?: number;
multiplier?: number;
} | undefined;
/** Calculates distance between two descriptors /** Calculates distance between two descriptors
* @param {object} options * @param {object} options
* @param {number} options.order algorithm to use * @param {number} options.order algorithm to use
@ -8,10 +13,7 @@ export declare type Descriptor = Array<number>;
* - default is 20 which normalizes results to similarity above 0.5 can be considered a match * - default is 20 which normalizes results to similarity above 0.5 can be considered a match
* @returns {number} * @returns {number}
*/ */
export declare function distance(descriptor1: Descriptor, descriptor2: Descriptor, options?: { export declare function distance(descriptor1: Descriptor, descriptor2: Descriptor, options?: Options): number;
order: number;
multiplier: number;
}): number;
/** Calculates normalized similarity between two face descriptors based on their `distance` /** Calculates normalized similarity between two face descriptors based on their `distance`
* @param {object} options * @param {object} options
* @param {number} options.order algorithm to use * @param {number} options.order algorithm to use
@ -20,10 +22,7 @@ export declare function distance(descriptor1: Descriptor, descriptor2: Descripto
* - default is 20 which normalizes results to similarity above 0.5 can be considered a match * - default is 20 which normalizes results to similarity above 0.5 can be considered a match
* @returns {number} similarity between two face descriptors normalized to 0..1 range where 0 is no similarity and 1 is perfect similarity * @returns {number} similarity between two face descriptors normalized to 0..1 range where 0 is no similarity and 1 is perfect similarity
*/ */
export declare function similarity(descriptor1: Descriptor, descriptor2: Descriptor, options?: { export declare function similarity(descriptor1: Descriptor, descriptor2: Descriptor, options?: Options): number;
order: number;
multiplier: number;
}): number;
/** Matches given descriptor to a closest entry in array of descriptors /** Matches given descriptor to a closest entry in array of descriptors
* @param descriptor face descriptor * @param descriptor face descriptor
* @param descriptors array of face descriptors to commpare given descriptor to * @param descriptors array of face descriptors to commpare given descriptor to
@ -35,11 +34,7 @@ export declare function similarity(descriptor1: Descriptor, descriptor2: Descrip
* - {@link distance} calculated `distance` of given descriptor to the best match * - {@link distance} calculated `distance` of given descriptor to the best match
* - {@link similarity} calculated normalized `similarity` of given descriptor to the best match * - {@link similarity} calculated normalized `similarity` of given descriptor to the best match
*/ */
export declare function match(descriptor: Descriptor, descriptors: Array<Descriptor>, options?: { export declare function match(descriptor: Descriptor, descriptors: Array<Descriptor>, options?: Options): {
order: number;
threshold: number;
multiplier: number;
}): {
index: number; index: number;
distance: number; distance: number;
similarity: number; similarity: number;

View File

@ -1 +1 @@
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/face/match.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,oBAAY,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;AAEtC;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO;;;CAA+B,UAQhH;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO;;;CAA+B,UAKlH;AAED;;;;;;;;;;EAUE;AACF,wBAAgB,KAAK,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,OAAO;;;;CAA6C;;;;EAgBjI"} {"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/face/match.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,oBAAY,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAA;AACtC,oBAAY,OAAO,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC;AAE9F;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,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