From b0362055575f8f16fbb27782a753223d35e3d4bd Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 4 Nov 2020 11:43:51 -0500 Subject: [PATCH] changed demo build process --- README.md | 4 +++- config.js | 6 +++--- demo/browser.js | 11 +++++------ demo/index.html | 31 +++++++++++++++++++++++++------ package.json | 5 +++-- src/handpose/handpose.js | 1 - 6 files changed, 39 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 419a498e..37615531 100644 --- a/README.md +++ b/README.md @@ -161,7 +161,9 @@ If your application resides in a different folder, modify `modelPath` property i Demos are included in `/demo`: **Browser**: -- `index.html`, `browser.js`, `worker.js`: Full demo using Browser with ESM module, includes selectable backends and webworkers +- `index.html`: Full demo using Browser with ESM module, includes selectable backends and webworkers + it loads `dist/demo-browser-index.js` which is built from sources in `demo`, starting with `demo/browser` + alternatively you can load `demo/browser.js` directly *If you want to test `wasm` or `webgpu` backends, enable loading in `index.html`* diff --git a/config.js b/config.js index 0f181fc0..9ac1d3b9 100644 --- a/config.js +++ b/config.js @@ -58,7 +58,7 @@ export default { // as face probably hasn't moved much in short time (10 * 1/25 = 0.25 sec) minConfidence: 0.5, // threshold for discarding a prediction iouThreshold: 0.3, // threshold for deciding whether boxes overlap too much in non-maximum suppression - scoreThreshold: 0.7, // threshold for deciding when to remove boxes based on score in non-maximum suppression + scoreThreshold: 0.5, // threshold for deciding when to remove boxes based on score in non-maximum suppression }, mesh: { enabled: true, @@ -97,7 +97,7 @@ export default { inputResolution: 257, // fixed value outputStride: 16, // fixed value maxDetections: 10, // maximum number of people detected in the input, should be set to the minimum number for performance - scoreThreshold: 0.7, // threshold for deciding when to remove boxes based on score in non-maximum suppression + scoreThreshold: 0.5, // threshold for deciding when to remove boxes based on score in non-maximum suppression nmsRadius: 20, // radius for deciding points are too close in non-maximum suppression }, hand: { @@ -108,7 +108,7 @@ export default { // as the hand probably hasn't moved much in short time (10 * 1/25 = 0.25 sec) minConfidence: 0.5, // threshold for discarding a prediction iouThreshold: 0.3, // threshold for deciding whether boxes overlap too much in non-maximum suppression - scoreThreshold: 0.7, // threshold for deciding when to remove boxes based on score in non-maximum suppression + scoreThreshold: 0.5, // threshold for deciding when to remove boxes based on score in non-maximum suppression enlargeFactor: 1.65, // empiric tuning as skeleton prediction prefers hand box with some whitespace maxHands: 10, // maximum number of hands detected in the input, should be set to the minimum number for performance detector: { diff --git a/demo/browser.js b/demo/browser.js index 10a51731..a9122958 100644 --- a/demo/browser.js +++ b/demo/browser.js @@ -55,15 +55,15 @@ const config = { videoOptimized: true, face: { enabled: true, - detector: { maxFaces: 10, skipFrames: 10, minConfidence: 0.5, iouThreshold: 0.3, scoreThreshold: 0.7 }, + detector: { maxFaces: 10, skipFrames: 10, minConfidence: 0.5, iouThreshold: 0.3, scoreThreshold: 0.5 }, mesh: { enabled: true }, iris: { enabled: true }, age: { enabled: true, skipFrames: 10 }, gender: { enabled: true }, emotion: { enabled: true, minConfidence: 0.5, useGrayscale: true }, }, - body: { enabled: true, maxDetections: 10, scoreThreshold: 0.7, nmsRadius: 20 }, - hand: { enabled: true, skipFrames: 10, minConfidence: 0.5, iouThreshold: 0.3, scoreThreshold: 0.7 }, + body: { enabled: true, maxDetections: 10, scoreThreshold: 0.5, nmsRadius: 20 }, + hand: { enabled: true, skipFrames: 10, minConfidence: 0.5, iouThreshold: 0.3, scoreThreshold: 0.5 }, gesture: { enabled: true }, }; @@ -148,10 +148,8 @@ async function setupCamera() { const canvas = document.getElementById('canvas'); const output = document.getElementById('log'); const live = video.srcObject ? ((video.srcObject.getVideoTracks()[0].readyState === 'live') && (video.readyState > 2) && (!video.paused)) : false; - let msg = `Setting up camera: live: ${live} facing: ${ui.facing ? 'front' : 'back'}`; + let msg = ''; status('starting camera'); - output.innerText += `\n${msg}`; - log(msg); // setup webcam. note that navigator.mediaDevices requires that page is accessed via https if (!navigator.mediaDevices) { msg = 'camera access not supported'; @@ -182,6 +180,7 @@ async function setupCamera() { const track = stream.getVideoTracks()[0]; const settings = track.getSettings(); log('camera settings:', settings); + log('camera track:', track); camera = { name: track.label, width: settings.width, height: settings.height, facing: settings.facingMode === 'user' ? 'front' : 'back' }; return new Promise((resolve) => { video.onloadeddata = async () => { diff --git a/demo/index.html b/demo/index.html index 0315a2ec..35f2e42e 100644 --- a/demo/index.html +++ b/demo/index.html @@ -13,10 +13,14 @@ - - - - + + + + + + + + @@ -48,10 +60,17 @@ +
+
+
+
+
- - +
+ + +
diff --git a/package.json b/package.json index 979b8eda..33109f21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vladmandic/human", - "version": "0.6.7", + "version": "0.7.0", "description": "human: 3D Face Detection, Body Pose, Hand & Finger Tracking, Iris Tracking, Age & Gender Prediction, Emotion Prediction & Gesture Recognition", "sideEffects": false, "main": "dist/human.node.js", @@ -45,7 +45,8 @@ "build-esm-nobundle": "esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:@tensorflow --external:fs --metafile=dist/human.esm-nobundle.json --outfile=dist/human.esm-nobundle.js src/human.js", "build-node": "esbuild --bundle --minify --platform=node --sourcemap --target=esnext --format=cjs --metafile=dist/human.node.json --outfile=dist/human.node.js src/human.js", "build-node-nobundle": "esbuild --bundle --minify --platform=node --sourcemap --target=esnext --format=cjs --external:@tensorflow --metafile=dist/human.node.json --outfile=dist/human.node-nobundle.js src/human.js", - "build": "rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && npm run build-node-nobundle && ls -l dist/", + "build-demo": "esbuild --bundle --minify --platform=browser --sourcemap --target=esnext --format=esm --external:fs --metafile=dist/demo-browser-index.json --outfile=dist/demo-browser-index.js demo/browser.js", + "build": "rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && npm run build-node-nobundle && npm run build-demo && ls -l dist/", "update": "npm update --depth 20 --force && npm dedupe && npm prune && npm audit", "changelog": "node changelog.js" }, diff --git a/src/handpose/handpose.js b/src/handpose/handpose.js index 36c40598..df069fed 100644 --- a/src/handpose/handpose.js +++ b/src/handpose/handpose.js @@ -59,7 +59,6 @@ class HandPose { exports.HandPose = HandPose; async function load(config) { - // maxContinuousChecks = Infinity, detectionConfidence = 0.8, iouThreshold = 0.3, scoreThreshold = 0.5 const [handDetectorModel, handPoseModel] = await Promise.all([ tf.loadGraphModel(config.detector.modelPath, { fromTFHub: config.detector.modelPath.includes('tfhub.dev') }), tf.loadGraphModel(config.skeleton.modelPath, { fromTFHub: config.skeleton.modelPath.includes('tfhub.dev') }),