mirror of https://github.com/vladmandic/human
cleanup demo workflow
parent
086c721a77
commit
3de870633a
|
@ -11,6 +11,8 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
|
||||||
|
|
||||||
### **HEAD -> main** 2021/04/25 mandic00@live.com
|
### **HEAD -> main** 2021/04/25 mandic00@live.com
|
||||||
|
|
||||||
|
- convert blazeface to module
|
||||||
|
- version 1.8 release candidate
|
||||||
- build nodejs deliverables in non-minified form
|
- build nodejs deliverables in non-minified form
|
||||||
- stop building sourcemaps for nodejs deliverables
|
- stop building sourcemaps for nodejs deliverables
|
||||||
- remove deallocate, profile, scoped
|
- remove deallocate, profile, scoped
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
.btn-background:hover { opacity: 1; }
|
.btn-background:hover { opacity: 1; }
|
||||||
.btn-foreground { fill:white; cursor: pointer; opacity: 0.8; }
|
.btn-foreground { fill:white; cursor: pointer; opacity: 0.8; }
|
||||||
.btn-foreground:hover { opacity: 1; }
|
.btn-foreground:hover { opacity: 1; }
|
||||||
.status { position: absolute; width: 100vw; bottom: 10%; text-align: center; font-size: 4rem; font-weight: 100; text-shadow: 2px 2px #303030; }
|
.status { position: absolute; width: 100vw; bottom: 10%; text-align: center; font-size: 3rem; font-weight: 100; text-shadow: 2px 2px #303030; }
|
||||||
.thumbnail { margin: 8px; box-shadow: 0 0 4px 4px dimgrey; }
|
.thumbnail { margin: 8px; box-shadow: 0 0 4px 4px dimgrey; }
|
||||||
.thumbnail:hover { box-shadow: 0 0 8px 8px dimgrey; filter: grayscale(1); }
|
.thumbnail:hover { box-shadow: 0 0 8px 8px dimgrey; filter: grayscale(1); }
|
||||||
.log { position: absolute; bottom: 0; margin: 0.4rem 0.4rem 0 0.4rem; font-size: 0.9rem; }
|
.log { position: absolute; bottom: 0; margin: 0.4rem 0.4rem 0 0.4rem; font-size: 0.9rem; }
|
||||||
|
|
|
@ -6,7 +6,7 @@ import Menu from './helpers/menu.js';
|
||||||
import GLBench from './helpers/gl-bench.js';
|
import GLBench from './helpers/gl-bench.js';
|
||||||
import webRTC from './helpers/webrtc.js';
|
import webRTC from './helpers/webrtc.js';
|
||||||
|
|
||||||
const userConfig = {};
|
const userConfig = { warmup: 'none' };
|
||||||
let human;
|
let human;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -94,9 +94,18 @@ function log(...msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function status(msg) {
|
function status(msg) {
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
const div = document.getElementById('status');
|
const div = document.getElementById('status');
|
||||||
if (div) div.innerText = msg;
|
if (div && msg && msg.length > 0) {
|
||||||
|
log('status', msg);
|
||||||
|
document.getElementById('play').style.display = 'none';
|
||||||
|
document.getElementById('loader').style.display = 'block';
|
||||||
|
div.innerText = msg;
|
||||||
|
} else {
|
||||||
|
const video = document.getElementById('video');
|
||||||
|
document.getElementById('play').style.display = (video.srcObject !== null) && !video.paused ? 'none' : 'block';
|
||||||
|
document.getElementById('loader').style.display = 'none';
|
||||||
|
div.innerText = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const compare = { enabled: false, original: null };
|
const compare = { enabled: false, original: null };
|
||||||
|
@ -210,7 +219,7 @@ async function setupCamera() {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log(err);
|
log(err);
|
||||||
} finally {
|
} finally {
|
||||||
status('');
|
status();
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -264,14 +273,10 @@ async function setupCamera() {
|
||||||
canvas.style.height = canvas.width > canvas.height ? '' : '100vh';
|
canvas.style.height = canvas.width > canvas.height ? '' : '100vh';
|
||||||
ui.menuWidth.input.setAttribute('value', video.width);
|
ui.menuWidth.input.setAttribute('value', video.width);
|
||||||
ui.menuHeight.input.setAttribute('value', video.height);
|
ui.menuHeight.input.setAttribute('value', video.height);
|
||||||
// silly font resizing for paint-on-canvas since viewport can be zoomed
|
|
||||||
if (live) video.play();
|
if (live) video.play();
|
||||||
// eslint-disable-next-line no-use-before-define
|
// eslint-disable-next-line no-use-before-define
|
||||||
if (live && !ui.detectThread) runHumanDetect(video, canvas);
|
if (live && !ui.detectThread) runHumanDetect(video, canvas);
|
||||||
ui.busy = false;
|
ui.busy = false;
|
||||||
// do once more because onresize events can be delayed or skipped
|
|
||||||
// if (video.width > window.innerWidth) await setupCamera();
|
|
||||||
status('');
|
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -337,7 +342,6 @@ function runHumanDetect(input, canvas, timestamp) {
|
||||||
log('memory', human.tf.engine().memory());
|
log('memory', human.tf.engine().memory());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
status('');
|
|
||||||
if (ui.useWorker) {
|
if (ui.useWorker) {
|
||||||
// get image data from video as we cannot send html objects to webworker
|
// get image data from video as we cannot send html objects to webworker
|
||||||
const offscreen = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(canvas.width, canvas.height) : document.createElement('canvas');
|
const offscreen = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(canvas.width, canvas.height) : document.createElement('canvas');
|
||||||
|
@ -348,8 +352,10 @@ function runHumanDetect(input, canvas, timestamp) {
|
||||||
const data = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
const data = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
// perform detection in worker
|
// perform detection in worker
|
||||||
webWorker(input, data, canvas, userConfig, timestamp);
|
webWorker(input, data, canvas, userConfig, timestamp);
|
||||||
|
status();
|
||||||
} else {
|
} else {
|
||||||
human.detect(input, userConfig).then((result) => {
|
human.detect(input, userConfig).then((result) => {
|
||||||
|
status();
|
||||||
if (result.performance && result.performance.total) ui.detectFPS.push(1000 / result.performance.total);
|
if (result.performance && result.performance.total) ui.detectFPS.push(1000 / result.performance.total);
|
||||||
if (ui.detectFPS.length > ui.maxFPSframes) ui.detectFPS.shift();
|
if (ui.detectFPS.length > ui.maxFPSframes) ui.detectFPS.shift();
|
||||||
if (ui.bench) {
|
if (ui.bench) {
|
||||||
|
@ -410,16 +416,14 @@ async function detectVideo() {
|
||||||
const video = document.getElementById('video');
|
const video = document.getElementById('video');
|
||||||
const canvas = document.getElementById('canvas');
|
const canvas = document.getElementById('canvas');
|
||||||
if ((video.srcObject !== null) && !video.paused) {
|
if ((video.srcObject !== null) && !video.paused) {
|
||||||
document.getElementById('play').style.display = 'block';
|
|
||||||
document.getElementById('btnStartText').innerHTML = 'start video';
|
document.getElementById('btnStartText').innerHTML = 'start video';
|
||||||
status('paused');
|
status('paused');
|
||||||
video.pause();
|
video.pause();
|
||||||
} else {
|
} else {
|
||||||
const cameraError = await setupCamera();
|
const cameraError = await setupCamera();
|
||||||
if (!cameraError) {
|
if (!cameraError) {
|
||||||
document.getElementById('play').style.display = 'none';
|
status('starting detection');
|
||||||
for (const m of Object.values(menu)) m.hide();
|
for (const m of Object.values(menu)) m.hide();
|
||||||
status('');
|
|
||||||
document.getElementById('btnStartText').innerHTML = 'pause video';
|
document.getElementById('btnStartText').innerHTML = 'pause video';
|
||||||
await video.play();
|
await video.play();
|
||||||
if (!ui.detectThread) runHumanDetect(video, canvas);
|
if (!ui.detectThread) runHumanDetect(video, canvas);
|
||||||
|
@ -432,7 +436,6 @@ async function detectVideo() {
|
||||||
// just initialize everything and call main function
|
// just initialize everything and call main function
|
||||||
async function detectSampleImages() {
|
async function detectSampleImages() {
|
||||||
userConfig.videoOptimized = false; // force disable video optimizations
|
userConfig.videoOptimized = false; // force disable video optimizations
|
||||||
document.getElementById('play').style.display = 'none';
|
|
||||||
document.getElementById('canvas').style.display = 'none';
|
document.getElementById('canvas').style.display = 'none';
|
||||||
document.getElementById('samples-container').style.display = 'block';
|
document.getElementById('samples-container').style.display = 'block';
|
||||||
log('running detection of sample images');
|
log('running detection of sample images');
|
||||||
|
@ -440,7 +443,7 @@ async function detectSampleImages() {
|
||||||
document.getElementById('samples-container').innerHTML = '';
|
document.getElementById('samples-container').innerHTML = '';
|
||||||
for (const m of Object.values(menu)) m.hide();
|
for (const m of Object.values(menu)) m.hide();
|
||||||
for (const image of ui.samples) await processImage(image);
|
for (const image of ui.samples) await processImage(image);
|
||||||
status('');
|
status();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupMenu() {
|
function setupMenu() {
|
||||||
|
@ -550,7 +553,8 @@ function setupMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resize() {
|
async function resize() {
|
||||||
const viewportScale = Math.min(1, Math.round(100 * window.innerWidth / 960) / 100);
|
window.onresize = null;
|
||||||
|
const viewportScale = 1; // Math.min(1, Math.round(100 * window.innerWidth / 960) / 100);
|
||||||
if (!ui.viewportSet) {
|
if (!ui.viewportSet) {
|
||||||
const viewport = document.querySelector('meta[name=viewport]');
|
const viewport = document.querySelector('meta[name=viewport]');
|
||||||
viewport.setAttribute('content', `width=device-width, shrink-to-fit=yes, minimum-scale=0.2, maximum-scale=2.0, user-scalable=yes, initial-scale=${viewportScale}`);
|
viewport.setAttribute('content', `width=device-width, shrink-to-fit=yes, minimum-scale=0.2, maximum-scale=2.0, user-scalable=yes, initial-scale=${viewportScale}`);
|
||||||
|
@ -574,7 +578,8 @@ async function resize() {
|
||||||
|
|
||||||
human.draw.options.font = `small-caps ${fontSize + 4}px "Segoe UI"`;
|
human.draw.options.font = `small-caps ${fontSize + 4}px "Segoe UI"`;
|
||||||
|
|
||||||
setupCamera();
|
await setupCamera();
|
||||||
|
window.onresize = resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function drawWarmup(res) {
|
async function drawWarmup(res) {
|
||||||
|
@ -646,16 +651,11 @@ async function main() {
|
||||||
if (res && res.canvas && ui.drawWarmup) await drawWarmup(res);
|
if (res && res.canvas && ui.drawWarmup) await drawWarmup(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup camera
|
|
||||||
await setupCamera();
|
|
||||||
|
|
||||||
// ready
|
// ready
|
||||||
status('human: ready');
|
status('human: ready');
|
||||||
document.getElementById('loader').style.display = 'none';
|
document.getElementById('loader').style.display = 'none';
|
||||||
document.getElementById('play').style.display = 'block';
|
document.getElementById('play').style.display = 'block';
|
||||||
log('demo ready...');
|
|
||||||
for (const m of Object.values(menu)) m.hide();
|
for (const m of Object.values(menu)) m.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = main;
|
window.onload = main;
|
||||||
window.onresize = resize;
|
|
||||||
|
|
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
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
|
@ -18223,7 +18223,7 @@ var config2 = {
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
videoOptimized: true,
|
videoOptimized: true,
|
||||||
warmup: "face",
|
warmup: "full",
|
||||||
filter: {
|
filter: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
width: 0,
|
width: 0,
|
||||||
|
|
|
@ -18224,7 +18224,7 @@ var config2 = {
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
videoOptimized: true,
|
videoOptimized: true,
|
||||||
warmup: "face",
|
warmup: "full",
|
||||||
filter: {
|
filter: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
width: 0,
|
width: 0,
|
||||||
|
|
|
@ -18223,7 +18223,7 @@ var config2 = {
|
||||||
debug: true,
|
debug: true,
|
||||||
async: true,
|
async: true,
|
||||||
videoOptimized: true,
|
videoOptimized: true,
|
||||||
warmup: "face",
|
warmup: "full",
|
||||||
filter: {
|
filter: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
width: 0,
|
width: 0,
|
||||||
|
|
|
@ -355,3 +355,20 @@
|
||||||
2021-04-25 16:54:56 [36mINFO: [39m Generate types: ["src/human.ts"]
|
2021-04-25 16:54:56 [36mINFO: [39m Generate types: ["src/human.ts"]
|
||||||
2021-04-25 16:55:01 [36mINFO: [39m Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
|
2021-04-25 16:55:01 [36mINFO: [39m Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
|
||||||
2021-04-25 16:55:01 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"]
|
2021-04-25 16:55:01 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"]
|
||||||
|
2021-04-26 07:18:22 [36mINFO: [39m @vladmandic/human version 1.8.0
|
||||||
|
2021-04-26 07:18:22 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.0.0
|
||||||
|
2021-04-26 07:18:22 [36mINFO: [39m Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: node type: tfjs: {"imports":1,"importBytes":39,"outputBytes":696,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: node type: node: {"imports":35,"importBytes":414277,"outputBytes":373298,"outputFiles":"dist/human.node.js"}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: nodeGPU type: tfjs: {"imports":1,"importBytes":43,"outputBytes":700,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: nodeGPU type: node: {"imports":35,"importBytes":414281,"outputBytes":373302,"outputFiles":"dist/human.node-gpu.js"}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: nodeWASM type: tfjs: {"imports":1,"importBytes":81,"outputBytes":746,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: nodeWASM type: node: {"imports":35,"importBytes":414327,"outputBytes":373352,"outputFiles":"dist/human.node-wasm.js"}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: browserNoBundle type: tfjs: {"imports":1,"importBytes":2488,"outputBytes":1394,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
|
2021-04-26 07:18:22 [35mSTATE:[39m Build for: browserNoBundle type: esm: {"imports":35,"importBytes":414975,"outputBytes":229880,"outputFiles":"dist/human.esm-nobundle.js"}
|
||||||
|
2021-04-26 07:18:23 [35mSTATE:[39m Build for: browserBundle type: tfjs: {"modules":1267,"moduleBytes":4085087,"imports":7,"importBytes":2488,"outputBytes":1101728,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
|
2021-04-26 07:18:24 [35mSTATE:[39m Build for: browserBundle type: iife: {"imports":35,"importBytes":1515309,"outputBytes":1328044,"outputFiles":"dist/human.js"}
|
||||||
|
2021-04-26 07:18:24 [35mSTATE:[39m Build for: browserBundle type: esm: {"imports":35,"importBytes":1515309,"outputBytes":1328002,"outputFiles":"dist/human.esm.js"}
|
||||||
|
2021-04-26 07:18:24 [36mINFO: [39m Generate types: ["src/human.ts"]
|
||||||
|
2021-04-26 07:18:30 [36mINFO: [39m Update Change log: ["/home/vlado/dev/human/CHANGELOG.md"]
|
||||||
|
2021-04-26 07:18:30 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"]
|
||||||
|
|
|
@ -209,7 +209,7 @@ const config: Config = {
|
||||||
// automatically disabled for Image, ImageData, ImageBitmap
|
// automatically disabled for Image, ImageData, ImageBitmap
|
||||||
// skips boundary detection for every n frames
|
// skips boundary detection for every n frames
|
||||||
// while maintaining in-box detection since objects cannot move that fast
|
// while maintaining in-box detection since objects cannot move that fast
|
||||||
warmup: 'face', // what to use for human.warmup(), can be 'none', 'face', 'full'
|
warmup: 'full', // what to use for human.warmup(), can be 'none', 'face', 'full'
|
||||||
// warmup pre-initializes all models for faster inference but can take
|
// warmup pre-initializes all models for faster inference but can take
|
||||||
// significant time on startup
|
// significant time on startup
|
||||||
// only used for `webgl` and `humangl` backends
|
// only used for `webgl` and `humangl` backends
|
||||||
|
|
Loading…
Reference in New Issue