mirror of https://github.com/vladmandic/human
71 lines
3.4 KiB
HTML
71 lines
3.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Human Embedding Tests</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
<meta name="viewport" content="width=device-width, shrink-to-fit=yes">
|
|
<style>
|
|
html { font-size: 10px; font-variant: small-caps; }
|
|
body { margin: 0; background: black; color: white; width: 100vw; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="log" style="line-height: 150%; overflow-x: hidden; white-space: pre-wrap"></pre>
|
|
<script type="module">
|
|
import { Human } from '../dist/human.esm.js';
|
|
|
|
const testConfig = {
|
|
debug: true,
|
|
async: false,
|
|
modelBasePath: 'https://vladmandic.github.io/human-models/models/',
|
|
cacheSensitivity: 0,
|
|
cacheModels: false,
|
|
warmup: 'face',
|
|
face: { iris: { enabled: false }, emotion: { enabled: false }, mesh: { enabled: true }, descriptior: { enabled: true } },
|
|
body: { enabled: false },
|
|
hand: { enabled: false },
|
|
object: { enabled: false },
|
|
segmentation: { enabled: false },
|
|
gestures: { enabled: false },
|
|
};
|
|
|
|
function str(...msg) {
|
|
if (!Array.isArray(msg)) return msg;
|
|
let line = '';
|
|
for (const entry of msg) {
|
|
if (typeof entry === 'object') line += ' ' + JSON.stringify(entry, null, 0).replace(/"/g, '').replace(/,/g, ', ').replace(/:/g, ': ');
|
|
else line += ' ' + entry;
|
|
}
|
|
return line + '\n';
|
|
}
|
|
|
|
async function log(...msgs) {
|
|
document.getElementById('log').innerHTML += str(...msgs);
|
|
document.documentElement.scrollTop = document.documentElement.scrollHeight;
|
|
console.log(...msgs); // eslint-disable-line no-console
|
|
}
|
|
|
|
async function main() {
|
|
const human = new Human(testConfig);
|
|
const ops = await human.check();
|
|
if (ops && ops.length > 0) log(backend, { backend: human.tf.getBackend(), ops });
|
|
const env = JSON.parse(JSON.stringify(human.env));
|
|
env.kernels = human.env.kernels.length;
|
|
// log(backend, { backend: human.tf.getBackend(), env, tfjs: human.tf.env().flags });
|
|
let res;
|
|
res = await human.warmup({ warmup: 'none' });
|
|
if (Array.isArray(res?.face?.[0]?.embedding) && (res?.face?.[0]?.embedding.length === 1024)) res.face[0].embedding.length = 10;
|
|
log({ backend: human.tf.getBackend(), warmup: human.config.warmup, gender: res?.face?.[0]?.gender, genderScore: res?.face?.[0]?.genderScore, age: res?.face?.[0]?.age, embedding: res?.face?.[0]?.embedding });
|
|
res = await human.warmup({ warmup: 'face' });
|
|
if (Array.isArray(res?.face?.[0]?.embedding) && (res?.face?.[0]?.embedding.length === 1024)) res.face[0].embedding.length = 10;
|
|
log({ backend: human.tf.getBackend(), warmup: human.config.warmup, gender: res?.face?.[0]?.gender, genderScore: res?.face?.[0]?.genderScore, age: res?.face?.[0]?.age, embedding: res?.face?.[0]?.embedding });
|
|
res = await human.warmup({ warmup: 'body' });
|
|
if (Array.isArray(res?.face?.[0]?.embedding) && (res?.face?.[0]?.embedding.length === 1024)) res.face[0].embedding.length = 10;
|
|
log({ backend: human.tf.getBackend(), warmup: human.config.warmup, gender: res?.face?.[0]?.gender, genderScore: res?.face?.[0]?.genderScore, age: res?.face?.[0]?.age, embedding: res?.face?.[0]?.embedding });
|
|
}
|
|
|
|
main();
|
|
</script>
|
|
</body>
|
|
</html>
|