mirror of https://github.com/vladmandic/human
add optional autodetected custom wasm path
parent
39fd4f5147
commit
1680032088
|
@ -9,8 +9,12 @@
|
|||
|
||||
## Changelog
|
||||
|
||||
### **HEAD -> main** 2021/10/21 mandic00@live.com
|
||||
### **2.3.6** 2021/10/21 mandic00@live.com
|
||||
|
||||
|
||||
### **origin/main** 2021/10/21 mandic00@live.com
|
||||
|
||||
- refactor human.env to a class type
|
||||
- add human.custom.esm using custom tfjs build
|
||||
|
||||
### **2.3.5** 2021/10/19 mandic00@live.com
|
||||
|
|
|
@ -90,7 +90,7 @@ const ui = {
|
|||
autoPlay: false, // start webcam & detection on load
|
||||
|
||||
// internal variables
|
||||
exceptionHandler: false, // should capture all unhandled exceptions
|
||||
exceptionHandler: true, // should capture all unhandled exceptions
|
||||
busy: false, // internal camera busy flag
|
||||
menuWidth: 0, // internal
|
||||
menuHeight: 0, // internal
|
||||
|
|
|
@ -226,7 +226,6 @@ export function analyze(keypoints) { // get estimations of curl / direction for
|
|||
direction: FingerDirection.getName(estimatorRes.directions[fingerIdx]),
|
||||
};
|
||||
}
|
||||
// console.log('finger landmarks', landmarks);
|
||||
return landmarks;
|
||||
}
|
||||
|
||||
|
@ -238,6 +237,5 @@ export function match(keypoints) { // compare gesture description to each known
|
|||
const confidence = gesture.matchAgainst(estimatorRes.curls, estimatorRes.directions);
|
||||
if (confidence >= minConfidence) poses.push({ name: gesture.name, confidence });
|
||||
}
|
||||
// console.log('finger poses', poses);
|
||||
return poses;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ export class HandDetector {
|
|||
const palmBox = tf.slice(t.norm, [index, 0], [1, -1]);
|
||||
const palmLandmarks = tf.tidy(() => tf.reshape(this.normalizeLandmarks(tf.slice(t.predictions, [index, 5], [1, 14]), index), [-1, 2]));
|
||||
hands.push({ box: palmBox, palmLandmarks, confidence: scores[index] });
|
||||
// console.log('handdetector:getBoxes', nms.length, index, scores[index], config.hand.maxDetected, config.hand.iouThreshold, config.hand.minConfidence, palmBox.dataSync());
|
||||
}
|
||||
for (const tensor of Object.keys(t)) tf.dispose(t[tensor]); // dispose all
|
||||
return hands;
|
||||
|
|
|
@ -141,7 +141,6 @@ export class HandPipeline {
|
|||
};
|
||||
hands.push(result);
|
||||
} else {
|
||||
// console.log('handpipeline:estimateHands low', confidence);
|
||||
this.storedBoxes[i] = null;
|
||||
}
|
||||
tf.dispose(keypoints);
|
||||
|
|
|
@ -175,7 +175,9 @@ export class Human {
|
|||
*/
|
||||
constructor(userConfig?: Partial<Config>) {
|
||||
this.env = env;
|
||||
defaults.wasmPath = `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf.version_core}/dist/`;
|
||||
defaults.wasmPath = tf.version_core.includes('-') // custom build or official build
|
||||
? 'https://vladmandic.github.io/tfjs/dist/'
|
||||
: `https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@${tf.version_core}/dist/`;
|
||||
defaults.modelBasePath = env.browser ? '../models/' : 'file://models/';
|
||||
defaults.backend = env.browser ? 'humangl' : 'tensorflow';
|
||||
this.version = app.version; // expose version property on instance of class
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
<div id="state" class="state"></div>
|
||||
<canvas id="canvas" class="canvas" width=256 height=256></canvas>
|
||||
<script type="module">
|
||||
import Human from '../dist/human.esm.js';
|
||||
import Human from '../dist/human.custom.esm.js';
|
||||
|
||||
const config = {
|
||||
async: true,
|
||||
|
@ -36,9 +36,7 @@
|
|||
object: { enabled: true },
|
||||
}
|
||||
|
||||
const backends = ['wasm', 'webgl', 'humangl'];
|
||||
// const backends = ['wasm', 'wasm'];
|
||||
// const backends = ['humangl'];
|
||||
const backends = ['wasm', 'webgl', 'humangl', 'webgpu'];
|
||||
|
||||
const start = performance.now();
|
||||
|
||||
|
@ -91,14 +89,16 @@
|
|||
log('human tests');
|
||||
let res;
|
||||
let human = new Human(config);
|
||||
await human.init();
|
||||
human.env.offscreen = false;
|
||||
human.events.addEventListener('warmup', () => events('warmup'));
|
||||
human.events.addEventListener('image', () => events('image'));
|
||||
human.events.addEventListener('detect', () => events('detect'));
|
||||
const timer = setInterval(() => { document.getElementById('state').innerText = `State: ${human.state}`; }, 10);
|
||||
log({ version: human.version });
|
||||
log({ env: human.env });
|
||||
log({ tfjs: human.tf.version.tfjs });
|
||||
log({ environment: human.env });
|
||||
log({ config: human.config });
|
||||
log({ tfjs: human.tf.version.tfjs, backend: human.config.backend });
|
||||
await human.load();
|
||||
const models = Object.keys(human.models).map((model) => ({ name: model, loaded: (human.models[model] !== null) }));
|
||||
log({ models });
|
||||
|
|
Loading…
Reference in New Issue