added demo node-canvas

pull/193/head
Vladimir Mandic 2021-08-31 14:48:55 -04:00
parent 69d0212555
commit ee79bc0e13
20 changed files with 881 additions and 864 deletions

View File

@ -9,7 +9,10 @@ Repository: **<git+https://github.com/vladmandic/human.git>**
## Changelog
### **HEAD -> main** 2021/08/23 mandic00@live.com
### **HEAD -> main** 2021/08/31 mandic00@live.com
### **origin/main** 2021/08/31 mandic00@live.com
- implement finger poses in hand detection and gestures
- implemented movenet-multipose model

12
TODO.md
View File

@ -25,12 +25,8 @@ WebGL shader optimizations for faster load and initial detection
Enhanced rotation correction for face detection is not working in NodeJS due to missing kernel op in TFJS
Feature is automatically disabled in NodeJS without user impact
- Backend NodeJS missing kernel op `FlipLeftRight`
<https://github.com/tensorflow/tfjs/issues/4066>
*Target: `Human` v2.2 with `TFJS` v3.9*
- Backend NodeJS missing kernel op `RotateWithOffset`
<https://github.com/tensorflow/tfjs/issues/5473>
*Target: N/A*
<br>
@ -39,15 +35,10 @@ Feature is automatically disabled in NodeJS without user impact
Enhanced rotation correction for hand detection is not working in NodeJS due to missing kernel op in TFJS
Feature is automatically disabled in NodeJS without user impact
- Backend NodeJS missing kernel op `FlipLeftRight`
<https://github.com/tensorflow/tfjs/issues/4066>
*Target: `Human` v2.2 with `TFJS` v3.9*
- Backend NodeJS missing kernel op `RotateWithOffset`
<https://github.com/tensorflow/tfjs/issues/5473>
*Target: N/A*
Hand detection using WASM backend has reduced precision due to math rounding errors in backend
*Target: N/A*
<br>
@ -57,7 +48,6 @@ MoveNet MultiPose model does not work with WASM backend due to missing F32 imple
- Backend WASM missing F32 implementation
<https://github.com/tensorflow/tfjs/issues/5516>
*Target: N/A*
### Object Detection
@ -65,10 +55,8 @@ Object detection using CenterNet or NanoDet models is not working when using WAS
- Backend WASM missing kernel op `Mod`
<https://github.com/tensorflow/tfjs/issues/5110>
*Target: `Human` v2.2 with `TFJS` v3.9*
- Backend WASM missing kernel op `SparseToDense`
<https://github.com/tensorflow/tfjs/issues/4824>
*Target: `Human` v2.2 with `TFJS` v3.9*
### WebGPU Backend

View File

@ -4,13 +4,11 @@
const log = require('@vladmandic/pilogger');
const fs = require('fs');
const path = require('path');
const process = require('process');
const canvas = require('canvas');
let fetch; // fetch is dynamically imported later
// const canvas = require('canvas');
// for NodeJS, `tfjs-node` or `tfjs-node-gpu` should be loaded before using Human
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
const tf = require('@tensorflow/tfjs-node'); // or const tf = require('@tensorflow/tfjs-node-gpu');
@ -23,24 +21,18 @@ let human = null;
const myConfig = {
backend: 'tensorflow',
modelBasePath: 'file://models/',
debug: true,
async: false,
filter: {
enabled: true,
flip: true,
},
debug: false,
async: true,
filter: { enabled: false },
face: {
enabled: true,
detector: { enabled: true, rotation: false },
detector: { enabled: true },
mesh: { enabled: true },
iris: { enabled: true },
description: { enabled: true },
emotion: { enabled: true },
},
hand: {
enabled: true,
},
// body: { modelPath: 'blazepose.json', enabled: true },
hand: { enabled: true },
body: { enabled: true },
object: { enabled: true },
};
@ -52,14 +44,13 @@ async function init() {
await human.tf.ready();
// pre-load models
log.info('Human:', human.version);
log.info('Active Configuration', human.config);
await human.load();
const loaded = Object.keys(human.models).filter((a) => human.models[a]);
log.info('Loaded:', loaded);
log.info('Memory state:', human.tf.engine().memory());
}
async function detect(input) {
async function detect(input, output) {
// read input image file and create tensor to be used for processing
let buffer;
log.info('Loading image:', input);
@ -102,59 +93,11 @@ async function detect(input) {
// dispose image tensor as we no longer need it
human.tf.dispose(tensor);
// print data to console
log.data('Results:');
if (result && result.face && result.face.length > 0) {
for (let i = 0; i < result.face.length; i++) {
const face = result.face[i];
const emotion = face.emotion.reduce((prev, curr) => (prev.score > curr.score ? prev : curr));
log.data(` Face: #${i} boxScore:${face.boxScore} faceScore:${face.faceScore} age:${face.age} genderScore:${face.genderScore} gender:${face.gender} emotionScore:${emotion.score} emotion:${emotion.emotion} iris:${face.iris}`);
}
} else {
log.data(' Face: N/A');
}
if (result && result.body && result.body.length > 0) {
for (let i = 0; i < result.body.length; i++) {
const body = result.body[i];
log.data(` Body: #${i} score:${body.score} keypoints:${body.keypoints?.length}`);
}
} else {
log.data(' Body: N/A');
}
if (result && result.hand && result.hand.length > 0) {
for (let i = 0; i < result.hand.length; i++) {
const hand = result.hand[i];
log.data(` Hand: #${i} score:${hand.score} keypoints:${hand.keypoints?.length}`);
}
} else {
log.data(' Hand: N/A');
}
if (result && result.gesture && result.gesture.length > 0) {
for (let i = 0; i < result.gesture.length; i++) {
const [key, val] = Object.entries(result.gesture[i]);
log.data(` Gesture: ${key[0]}#${key[1]} gesture:${val[1]}`);
}
} else {
log.data(' Gesture: N/A');
}
if (result && result.object && result.object.length > 0) {
for (let i = 0; i < result.object.length; i++) {
const object = result.object[i];
log.data(` Object: #${i} score:${object.score} label:${object.label}`);
}
} else {
log.data(' Object: N/A');
}
// print data to console
if (result) {
// invoke persons getter
const persons = result.persons;
// write result objects to file
// fs.writeFileSync('result.json', JSON.stringify(result, null, 2));
log.data('Persons:');
log.data('Detected:');
for (let i = 0; i < persons.length; i++) {
const face = persons[i].face;
const faceTxt = face ? `score:${face.score} age:${face.age} gender:${face.gender} iris:${face.iris}` : null;
@ -164,26 +107,23 @@ async function detect(input) {
}
}
return result;
}
// load and draw original image
const outputCanvas = new canvas.Canvas(tensor.shape[2], tensor.shape[1], 'image'); // decoded tensor shape tells us width and height
const ctx = outputCanvas.getContext('2d');
const original = await canvas.loadImage(buffer); // we already have input as buffer, so lets reuse it
ctx.drawImage(original, 0, 0, outputCanvas.width, outputCanvas.height); // draw original to new canvas
async function test() {
process.on('unhandledRejection', (err) => {
// @ts-ignore // no idea if exception message is compelte
log.error(err?.message || err || 'no error message');
});
// draw human results on canvas
human.setCanvas(outputCanvas); // tell human to use this canvas
human.draw.all(outputCanvas, result); // human will draw results as overlays on canvas
// test with embedded full body image
let result;
// write canvas to new image file
const out = fs.createWriteStream(output);
out.on('finish', () => log.state('Created output image:', output));
out.on('error', (err) => log.error('Error creating image:', output, err));
const stream = outputCanvas.createJPEGStream({ quality: 0.5, progressive: true, chromaSubsampling: true });
stream.pipe(out);
log.state('Processing embedded warmup image: face');
myConfig.warmup = 'face';
result = await human.warmup(myConfig);
log.state('Processing embedded warmup image: full');
myConfig.warmup = 'full';
result = await human.warmup(myConfig);
// no need to print results as they are printed to console during detection from within the library due to human.config.debug set
return result;
}
@ -192,26 +132,14 @@ async function main() {
log.info('Current folder:', process.env.PWD);
fetch = (await import('node-fetch')).default;
await init();
const f = process.argv[2];
if (process.argv.length !== 3) {
log.warn('Parameters: <input image | folder> missing');
await test();
} else if (!fs.existsSync(f) && !f.startsWith('http')) {
const input = process.argv[2];
const output = process.argv[3];
if (process.argv.length !== 4) {
log.error('Parameters: <input-image> <output-image> missing');
} else if (!fs.existsSync(input) && !input.startsWith('http')) {
log.error(`File not found: ${process.argv[2]}`);
} else {
if (fs.existsSync(f)) {
const stat = fs.statSync(f);
if (stat.isDirectory()) {
const dir = fs.readdirSync(f);
for (const file of dir) {
await detect(path.join(f, file));
}
} else {
await detect(f);
}
} else {
await detect(f);
}
await detect(input, output);
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

556
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

556
dist/human.js vendored

File diff suppressed because one or more lines are too long

View File

@ -10409,7 +10409,8 @@ __export(draw_exports, {
hand: () => hand2,
object: () => object,
options: () => options2,
person: () => person
person: () => person,
setCanvas: () => setCanvas
});
var options2 = {
color: "rgba(173, 216, 230, 0.6)",
@ -10430,6 +10431,20 @@ var options2 = {
useCurves: false,
bufferedOutput: true
};
var Canvas;
function setCanvas(obj) {
if (obj.getContext)
Canvas = obj;
else
throw new Error("Human: Canvas is not functional");
}
var checkCanvas = (input) => {
if (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement)
return true;
if (typeof Canvas !== "undefined")
return true;
return false;
};
var rad2deg = (theta) => Math.round(theta * 180 / Math.PI);
function point(ctx, x, y, z = 0, localOptions) {
ctx.fillStyle = localOptions.useDepth && z ? `rgba(${127.5 + 2 * z}, ${127.5 - 2 * z}, 255, 0.3)` : localOptions.color;
@ -10499,7 +10514,7 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10529,7 +10544,7 @@ async function face2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10639,7 +10654,7 @@ async function body2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10771,7 +10786,7 @@ async function hand2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10839,7 +10854,7 @@ async function object(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10868,7 +10883,7 @@ async function person(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10896,7 +10911,7 @@ async function person(inCanvas2, result, drawOptions) {
async function canvas(inCanvas2, outCanvas2) {
if (!inCanvas2 || !outCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement) || !(outCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2) || !checkCanvas(outCanvas2))
return;
const outCtx = inCanvas2.getContext("2d");
outCtx == null ? void 0 : outCtx.drawImage(inCanvas2, 0, 0);
@ -10906,7 +10921,7 @@ async function all(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return null;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return null;
const promise = Promise.all([
face2(inCanvas2, result.face, localOptions),
@ -11804,6 +11819,7 @@ var _Human = class {
__privateAdd(this, _firstRun, void 0);
__privateAdd(this, _lastInputSum, void 0);
__privateAdd(this, _lastCacheDiff, void 0);
this.setCanvas = (canvas2) => setCanvas(canvas2);
this.analyze = (...msg) => {
if (!__privateGet(this, _analyzeMemoryLeaks))
return;

View File

@ -10410,7 +10410,8 @@ __export(draw_exports, {
hand: () => hand2,
object: () => object,
options: () => options2,
person: () => person
person: () => person,
setCanvas: () => setCanvas
});
var options2 = {
color: "rgba(173, 216, 230, 0.6)",
@ -10431,6 +10432,20 @@ var options2 = {
useCurves: false,
bufferedOutput: true
};
var Canvas;
function setCanvas(obj) {
if (obj.getContext)
Canvas = obj;
else
throw new Error("Human: Canvas is not functional");
}
var checkCanvas = (input) => {
if (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement)
return true;
if (typeof Canvas !== "undefined")
return true;
return false;
};
var rad2deg = (theta) => Math.round(theta * 180 / Math.PI);
function point(ctx, x, y, z = 0, localOptions) {
ctx.fillStyle = localOptions.useDepth && z ? `rgba(${127.5 + 2 * z}, ${127.5 - 2 * z}, 255, 0.3)` : localOptions.color;
@ -10500,7 +10515,7 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10530,7 +10545,7 @@ async function face2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10640,7 +10655,7 @@ async function body2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10772,7 +10787,7 @@ async function hand2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10840,7 +10855,7 @@ async function object(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10869,7 +10884,7 @@ async function person(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10897,7 +10912,7 @@ async function person(inCanvas2, result, drawOptions) {
async function canvas(inCanvas2, outCanvas2) {
if (!inCanvas2 || !outCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement) || !(outCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2) || !checkCanvas(outCanvas2))
return;
const outCtx = inCanvas2.getContext("2d");
outCtx == null ? void 0 : outCtx.drawImage(inCanvas2, 0, 0);
@ -10907,7 +10922,7 @@ async function all(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return null;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return null;
const promise = Promise.all([
face2(inCanvas2, result.face, localOptions),
@ -11805,6 +11820,7 @@ var _Human = class {
__privateAdd(this, _firstRun, void 0);
__privateAdd(this, _lastInputSum, void 0);
__privateAdd(this, _lastCacheDiff, void 0);
this.setCanvas = (canvas2) => setCanvas(canvas2);
this.analyze = (...msg) => {
if (!__privateGet(this, _analyzeMemoryLeaks))
return;

34
dist/human.node.js vendored
View File

@ -10409,7 +10409,8 @@ __export(draw_exports, {
hand: () => hand2,
object: () => object,
options: () => options2,
person: () => person
person: () => person,
setCanvas: () => setCanvas
});
var options2 = {
color: "rgba(173, 216, 230, 0.6)",
@ -10430,6 +10431,20 @@ var options2 = {
useCurves: false,
bufferedOutput: true
};
var Canvas;
function setCanvas(obj) {
if (obj.getContext)
Canvas = obj;
else
throw new Error("Human: Canvas is not functional");
}
var checkCanvas = (input) => {
if (typeof HTMLCanvasElement !== "undefined" && input instanceof HTMLCanvasElement)
return true;
if (typeof Canvas !== "undefined")
return true;
return false;
};
var rad2deg = (theta) => Math.round(theta * 180 / Math.PI);
function point(ctx, x, y, z = 0, localOptions) {
ctx.fillStyle = localOptions.useDepth && z ? `rgba(${127.5 + 2 * z}, ${127.5 - 2 * z}, 255, 0.3)` : localOptions.color;
@ -10499,7 +10514,7 @@ async function gesture(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10529,7 +10544,7 @@ async function face2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10639,7 +10654,7 @@ async function body2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10771,7 +10786,7 @@ async function hand2(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10839,7 +10854,7 @@ async function object(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10868,7 +10883,7 @@ async function person(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return;
const ctx = inCanvas2.getContext("2d");
if (!ctx)
@ -10896,7 +10911,7 @@ async function person(inCanvas2, result, drawOptions) {
async function canvas(inCanvas2, outCanvas2) {
if (!inCanvas2 || !outCanvas2)
return;
if (!(inCanvas2 instanceof HTMLCanvasElement) || !(outCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2) || !checkCanvas(outCanvas2))
return;
const outCtx = inCanvas2.getContext("2d");
outCtx == null ? void 0 : outCtx.drawImage(inCanvas2, 0, 0);
@ -10906,7 +10921,7 @@ async function all(inCanvas2, result, drawOptions) {
const localOptions = mergeDeep(options2, drawOptions);
if (!result || !inCanvas2)
return null;
if (!(inCanvas2 instanceof HTMLCanvasElement))
if (!checkCanvas(inCanvas2))
return null;
const promise = Promise.all([
face2(inCanvas2, result.face, localOptions),
@ -11804,6 +11819,7 @@ var _Human = class {
__privateAdd(this, _firstRun, void 0);
__privateAdd(this, _lastInputSum, void 0);
__privateAdd(this, _lastCacheDiff, void 0);
this.setCanvas = (canvas2) => setCanvas(canvas2);
this.analyze = (...msg) => {
if (!__privateGet(this, _analyzeMemoryLeaks))
return;

View File

@ -1,28 +1,22 @@
2021-08-31 12:56:24 INFO:  @vladmandic/human version 2.1.4
2021-08-31 12:56:24 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0
2021-08-31 12:56:24 INFO:  Toolchain: {"tfjs":"3.9.0","esbuild":"0.12.24","typescript":"4.4.2","typedoc":"0.21.9","eslint":"7.32.0"}
2021-08-31 12:56:24 INFO:  Clean: ["dist/*","types/*","typedoc/*"]
2021-08-31 12:56:24 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true}
2021-08-31 12:56:24 STATE: target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 12:56:24 STATE: target: node type: node: {"imports":47,"importBytes":456777,"outputBytes":397014,"outputFiles":"dist/human.node.js"}
2021-08-31 12:56:24 STATE: target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 12:56:24 STATE: target: nodeGPU type: node: {"imports":47,"importBytes":456785,"outputBytes":397018,"outputFiles":"dist/human.node-gpu.js"}
2021-08-31 12:56:24 STATE: target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 12:56:24 STATE: target: nodeWASM type: node: {"imports":47,"importBytes":456852,"outputBytes":397090,"outputFiles":"dist/human.node-wasm.js"}
2021-08-31 12:56:24 STATE: target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2168,"outputBytes":1242,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 12:56:24 STATE: target: browserNoBundle type: esm: {"imports":47,"importBytes":456716,"outputBytes":255649,"outputFiles":"dist/human.esm-nobundle.js"}
2021-08-31 12:56:24 STATE: target: browserBundle type: tfjs: {"modules":1174,"moduleBytes":8150347,"imports":7,"importBytes":2168,"outputBytes":2343932,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 12:56:25 STATE: target: browserBundle type: iife: {"imports":47,"importBytes":2799406,"outputBytes":1391877,"outputFiles":"dist/human.js"}
2021-08-31 12:56:25 STATE: target: browserBundle type: esm: {"imports":47,"importBytes":2799406,"outputBytes":1391869,"outputFiles":"dist/human.esm.js"}
2021-08-31 12:56:25 INFO:  Running Linter: ["server/","src/","tfjs/","test/","demo/"]
2021-08-31 12:56:47 INFO:  Linter complete: files: 83 errors: 0 warnings: 1
2021-08-31 12:56:47 WARN:  
/home/vlado/dev/human/demo/index.js
 953:3 warning Unexpected console statement no-console

✖ 1 problem (0 errors, 1 warning)

2021-08-31 12:56:48 INFO:  Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"]
2021-08-31 12:56:48 INFO:  Generate Typings: ["src/human.ts"] outDir: ["types"]
2021-08-31 12:57:02 INFO:  Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"]
2021-08-31 12:57:15 INFO:  Documentation generated at /home/vlado/dev/human/typedoc 1
2021-08-31 14:47:11 INFO:  @vladmandic/human version 2.1.4
2021-08-31 14:47:11 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0
2021-08-31 14:47:11 INFO:  Toolchain: {"tfjs":"3.9.0","esbuild":"0.12.24","typescript":"4.4.2","typedoc":"0.21.9","eslint":"7.32.0"}
2021-08-31 14:47:11 INFO:  Clean: ["dist/*","types/*","typedoc/*"]
2021-08-31 14:47:11 INFO:  Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true}
2021-08-31 14:47:11 STATE: target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 14:47:11 STATE: target: node type: node: {"imports":47,"importBytes":457046,"outputBytes":397286,"outputFiles":"dist/human.node.js"}
2021-08-31 14:47:11 STATE: target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 14:47:12 STATE: target: nodeGPU type: node: {"imports":47,"importBytes":457054,"outputBytes":397290,"outputFiles":"dist/human.node-gpu.js"}
2021-08-31 14:47:12 STATE: target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 14:47:12 STATE: target: nodeWASM type: node: {"imports":47,"importBytes":457121,"outputBytes":397362,"outputFiles":"dist/human.node-wasm.js"}
2021-08-31 14:47:12 STATE: target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2168,"outputBytes":1242,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 14:47:12 STATE: target: browserNoBundle type: esm: {"imports":47,"importBytes":456985,"outputBytes":255646,"outputFiles":"dist/human.esm-nobundle.js"}
2021-08-31 14:47:12 STATE: target: browserBundle type: tfjs: {"modules":1174,"moduleBytes":8150347,"imports":7,"importBytes":2168,"outputBytes":2343932,"outputFiles":"dist/tfjs.esm.js"}
2021-08-31 14:47:12 STATE: target: browserBundle type: iife: {"imports":47,"importBytes":2799675,"outputBytes":1391880,"outputFiles":"dist/human.js"}
2021-08-31 14:47:13 STATE: target: browserBundle type: esm: {"imports":47,"importBytes":2799675,"outputBytes":1391872,"outputFiles":"dist/human.esm.js"}
2021-08-31 14:47:13 INFO:  Running Linter: ["server/","src/","tfjs/","test/","demo/"]
2021-08-31 14:47:36 INFO:  Linter complete: files: 84 errors: 0 warnings: 0
2021-08-31 14:47:36 INFO:  Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"]
2021-08-31 14:47:36 INFO:  Generate Typings: ["src/human.ts"] outDir: ["types"]
2021-08-31 14:47:50 INFO:  Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"]
2021-08-31 14:48:05 INFO:  Documentation generated at /home/vlado/dev/human/typedoc 1

View File

@ -66,6 +66,19 @@ export const options: DrawOptions = {
bufferedOutput: <boolean>true,
};
let Canvas;
export function setCanvas(obj) {
if (obj.getContext) Canvas = obj;
else throw new Error('Human: Canvas is not functional');
}
const checkCanvas = (input) => {
if ((typeof HTMLCanvasElement !== 'undefined') && (input instanceof HTMLCanvasElement)) return true;
if (typeof Canvas !== 'undefined') return true;
return false;
};
const rad2deg = (theta) => Math.round((theta * 180) / Math.PI);
function point(ctx, x, y, z = 0, localOptions) {
@ -137,7 +150,7 @@ function curves(ctx, points: [number, number, number?][] = [], localOptions) {
export async function gesture(inCanvas: HTMLCanvasElement, result: Array<Gesture>, drawOptions?: DrawOptions) {
const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return;
if (!(inCanvas instanceof HTMLCanvasElement)) return;
if (!checkCanvas(inCanvas)) return;
const ctx = inCanvas.getContext('2d');
if (!ctx) return;
ctx.font = localOptions.font;
@ -164,7 +177,7 @@ export async function gesture(inCanvas: HTMLCanvasElement, result: Array<Gesture
export async function face(inCanvas: HTMLCanvasElement, result: Array<Face>, drawOptions?: DrawOptions) {
const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return;
if (!(inCanvas instanceof HTMLCanvasElement)) return;
if (!checkCanvas(inCanvas)) return;
const ctx = inCanvas.getContext('2d');
if (!ctx) return;
for (const f of result) {
@ -268,7 +281,7 @@ export async function face(inCanvas: HTMLCanvasElement, result: Array<Face>, dra
export async function body(inCanvas: HTMLCanvasElement, result: Array<Body>, drawOptions?: DrawOptions) {
const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return;
if (!(inCanvas instanceof HTMLCanvasElement)) return;
if (!checkCanvas(inCanvas)) return;
const ctx = inCanvas.getContext('2d');
if (!ctx) return;
ctx.lineJoin = 'round';
@ -380,7 +393,7 @@ export async function body(inCanvas: HTMLCanvasElement, result: Array<Body>, dra
export async function hand(inCanvas: HTMLCanvasElement, result: Array<Hand>, drawOptions?: DrawOptions) {
const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return;
if (!(inCanvas instanceof HTMLCanvasElement)) return;
if (!checkCanvas(inCanvas)) return;
const ctx = inCanvas.getContext('2d');
if (!ctx) return;
ctx.lineJoin = 'round';
@ -446,7 +459,7 @@ export async function hand(inCanvas: HTMLCanvasElement, result: Array<Hand>, dra
export async function object(inCanvas: HTMLCanvasElement, result: Array<Item>, drawOptions?: DrawOptions) {
const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return;
if (!(inCanvas instanceof HTMLCanvasElement)) return;
if (!checkCanvas(inCanvas)) return;
const ctx = inCanvas.getContext('2d');
if (!ctx) return;
ctx.lineJoin = 'round';
@ -473,7 +486,7 @@ export async function object(inCanvas: HTMLCanvasElement, result: Array<Item>, d
export async function person(inCanvas: HTMLCanvasElement, result: Array<Person>, drawOptions?: DrawOptions) {
const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return;
if (!(inCanvas instanceof HTMLCanvasElement)) return;
if (!checkCanvas(inCanvas)) return;
const ctx = inCanvas.getContext('2d');
if (!ctx) return;
ctx.lineJoin = 'round';
@ -500,7 +513,7 @@ export async function person(inCanvas: HTMLCanvasElement, result: Array<Person>,
export async function canvas(inCanvas: HTMLCanvasElement, outCanvas: HTMLCanvasElement) {
if (!inCanvas || !outCanvas) return;
if (!(inCanvas instanceof HTMLCanvasElement) || !(outCanvas instanceof HTMLCanvasElement)) return;
if (!checkCanvas(inCanvas) || !checkCanvas(outCanvas)) return;
const outCtx = inCanvas.getContext('2d');
outCtx?.drawImage(inCanvas, 0, 0);
}
@ -509,7 +522,7 @@ export async function all(inCanvas: HTMLCanvasElement, result: Result, drawOptio
const timestamp = now();
const localOptions = mergeDeep(options, drawOptions);
if (!result || !inCanvas) return null;
if (!(inCanvas instanceof HTMLCanvasElement)) return null;
if (!checkCanvas(inCanvas)) return null;
const promise = Promise.all([
face(inCanvas, result.face, localOptions),

View File

@ -190,7 +190,12 @@ export class Human {
this.#lastInputSum = 1;
}
// version = () => Human.version;
/**
* Sets internal canvas methods
*
* @param canvas
*/
setCanvas = (canvas) => draw.setCanvas(canvas);
// helper function: measure tensor leak
/** @hidden */

View File

@ -1,120 +1,120 @@
2021-08-31 13:28:42 INFO:  @vladmandic/human version 2.1.4
2021-08-31 13:28:42 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0
2021-08-31 13:28:42 INFO:  tests: ["test-node.js","test-node-gpu.js","test-node-wasm.js"]
2021-08-31 13:28:42 INFO:  test-node.js start
2021-08-31 13:28:42 STATE: test-node.js passed: create human
2021-08-31 13:28:42 INFO:  test-node.js human version: 2.1.4
2021-08-31 13:28:42 INFO:  test-node.js platform: linux x64 agent: NodeJS v16.5.0
2021-08-31 13:28:42 INFO:  test-node.js tfjs version: 3.9.0
2021-08-31 13:28:42 STATE: test-node.js passed: set backend: tensorflow
2021-08-31 13:28:42 STATE: test-node.js passed: load models
2021-08-31 13:28:42 STATE: test-node.js result: defined models: 14 loaded models: 7
2021-08-31 13:28:42 STATE: test-node.js passed: warmup: none default
2021-08-31 13:28:44 STATE: test-node.js passed: warmup: face default
2021-08-31 13:28:44 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4}
2021-08-31 13:28:44 DATA:  test-node.js result: performance: load: 291 total: 1167
2021-08-31 13:28:45 STATE: test-node.js passed: warmup: body default
2021-08-31 13:28:45 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:28:45 DATA:  test-node.js result: performance: load: 291 total: 1085
2021-08-31 13:28:45 INFO:  test-node.js test body variants
2021-08-31 13:28:46 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:28:46 STATE: test-node.js passed: detect: samples/ai-body.jpg posenet
2021-08-31 13:28:46 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.96,"keypoints":16}
2021-08-31 13:28:46 DATA:  test-node.js result: performance: load: 291 total: 731
2021-08-31 13:28:47 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:28:47 STATE: test-node.js passed: detect: samples/ai-body.jpg movenet
2021-08-31 13:28:47 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:28:47 DATA:  test-node.js result: performance: load: 291 total: 202
2021-08-31 13:28:48 STATE: test-node.js passed: detect: random default
2021-08-31 13:28:48 DATA:  test-node.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0}
2021-08-31 13:28:48 DATA:  test-node.js result: performance: load: 291 total: 593
2021-08-31 13:28:48 INFO:  test-node.js test: first instance
2021-08-31 13:28:48 STATE: test-node.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 13:28:49 STATE: test-node.js passed: detect: samples/ai-upper.jpg default
2021-08-31 13:28:49 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 13:28:49 DATA:  test-node.js result: performance: load: 291 total: 944
2021-08-31 13:28:49 INFO:  test-node.js test: second instance
2021-08-31 13:28:50 STATE: test-node.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 13:28:51 STATE: test-node.js passed: detect: samples/ai-upper.jpg default
2021-08-31 13:28:51 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 13:28:51 DATA:  test-node.js result: performance: load: 4 total: 990
2021-08-31 13:28:51 INFO:  test-node.js test: concurrent
2021-08-31 13:28:51 STATE: test-node.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 13:28:51 STATE: test-node.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 13:28:52 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:28:52 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:28:57 STATE: test-node.js passed: detect: samples/ai-face.jpg default
2021-08-31 13:28:57 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 13:28:57 DATA:  test-node.js result: performance: load: 291 total: 4433
2021-08-31 13:28:57 STATE: test-node.js passed: detect: samples/ai-face.jpg default
2021-08-31 13:28:57 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 5 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 13:28:57 DATA:  test-node.js result: performance: load: 4 total: 4433
2021-08-31 13:28:57 STATE: test-node.js passed: detect: samples/ai-body.jpg default
2021-08-31 13:28:57 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:28:57 DATA:  test-node.js result: performance: load: 291 total: 4433
2021-08-31 13:28:57 STATE: test-node.js passed: detect: samples/ai-body.jpg default
2021-08-31 13:28:57 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:28:57 DATA:  test-node.js result: performance: load: 4 total: 4433
2021-08-31 13:28:57 INFO:  test-node.js test complete: 14689 ms
2021-08-31 13:28:57 INFO:  test-node-gpu.js start
2021-08-31 13:28:57 WARN:  test-node-gpu.js stderr: 2021-08-31 13:28:57.815122: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-08-31 13:28:57 WARN:  test-node-gpu.js stderr: 2021-08-31 13:28:57.864126: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2021-08-31 13:28:57 WARN:  test-node-gpu.js stderr: 2021-08-31 13:28:57.864159: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (wyse): /proc/driver/nvidia/version does not exist
2021-08-31 13:28:57 STATE: test-node-gpu.js passed: create human
2021-08-31 13:28:57 INFO:  test-node-gpu.js human version: 2.1.4
2021-08-31 13:28:57 INFO:  test-node-gpu.js platform: linux x64 agent: NodeJS v16.5.0
2021-08-31 13:28:57 INFO:  test-node-gpu.js tfjs version: 3.9.0
2021-08-31 13:28:58 STATE: test-node-gpu.js passed: set backend: tensorflow
2021-08-31 13:28:58 STATE: test-node-gpu.js passed: load models
2021-08-31 13:28:58 STATE: test-node-gpu.js result: defined models: 14 loaded models: 7
2021-08-31 13:28:58 STATE: test-node-gpu.js passed: warmup: none default
2021-08-31 13:28:59 STATE: test-node-gpu.js passed: warmup: face default
2021-08-31 13:28:59 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4}
2021-08-31 13:28:59 DATA:  test-node-gpu.js result: performance: load: 300 total: 1133
2021-08-31 13:29:00 STATE: test-node-gpu.js passed: warmup: body default
2021-08-31 13:29:00 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:29:00 DATA:  test-node-gpu.js result: performance: load: 300 total: 1090
2021-08-31 13:29:00 INFO:  test-node-gpu.js test body variants
2021-08-31 13:29:01 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:29:02 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg posenet
2021-08-31 13:29:02 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.96,"keypoints":16}
2021-08-31 13:29:02 DATA:  test-node-gpu.js result: performance: load: 300 total: 797
2021-08-31 13:29:03 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:29:03 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg movenet
2021-08-31 13:29:03 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:29:03 DATA:  test-node-gpu.js result: performance: load: 300 total: 213
2021-08-31 13:29:03 STATE: test-node-gpu.js passed: detect: random default
2021-08-31 13:29:04 DATA:  test-node-gpu.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0}
2021-08-31 13:29:04 DATA:  test-node-gpu.js result: performance: load: 300 total: 611
2021-08-31 13:29:04 INFO:  test-node-gpu.js test: first instance
2021-08-31 13:29:04 STATE: test-node-gpu.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 13:29:05 STATE: test-node-gpu.js passed: detect: samples/ai-upper.jpg default
2021-08-31 13:29:05 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 13:29:05 DATA:  test-node-gpu.js result: performance: load: 300 total: 899
2021-08-31 13:29:05 INFO:  test-node-gpu.js test: second instance
2021-08-31 13:29:05 STATE: test-node-gpu.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 13:29:06 STATE: test-node-gpu.js passed: detect: samples/ai-upper.jpg default
2021-08-31 13:29:06 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 13:29:06 DATA:  test-node-gpu.js result: performance: load: 2 total: 882
2021-08-31 13:29:06 INFO:  test-node-gpu.js test: concurrent
2021-08-31 13:29:06 STATE: test-node-gpu.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 13:29:06 STATE: test-node-gpu.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 13:29:07 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:29:08 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 13:29:12 STATE: test-node-gpu.js passed: detect: samples/ai-face.jpg default
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: performance: load: 300 total: 4339
2021-08-31 13:29:12 STATE: test-node-gpu.js passed: detect: samples/ai-face.jpg default
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 5 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: performance: load: 2 total: 4339
2021-08-31 13:29:12 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg default
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: performance: load: 300 total: 4339
2021-08-31 13:29:12 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg default
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 13:29:12 DATA:  test-node-gpu.js result: performance: load: 2 total: 4339
2021-08-31 13:29:12 INFO:  test-node-gpu.js test complete: 14636 ms
2021-08-31 13:29:12 INFO:  test-node-wasm.js start
2021-08-31 13:29:12 ERROR: test-node-wasm.js failed: model server: request to http://localhost:10030/models/ failed, reason: connect ECONNREFUSED 127.0.0.1:10030
2021-08-31 13:29:12 ERROR: test-node-wasm.js aborting test
2021-08-31 13:29:12 INFO:  status: {"passed":46,"failed":1}
2021-08-31 14:48:11 INFO:  @vladmandic/human version 2.1.4
2021-08-31 14:48:11 INFO:  User: vlado Platform: linux Arch: x64 Node: v16.5.0
2021-08-31 14:48:11 INFO:  tests: ["test-node.js","test-node-gpu.js","test-node-wasm.js"]
2021-08-31 14:48:11 INFO:  test-node.js start
2021-08-31 14:48:11 STATE: test-node.js passed: create human
2021-08-31 14:48:11 INFO:  test-node.js human version: 2.1.4
2021-08-31 14:48:11 INFO:  test-node.js platform: linux x64 agent: NodeJS v16.5.0
2021-08-31 14:48:11 INFO:  test-node.js tfjs version: 3.9.0
2021-08-31 14:48:12 STATE: test-node.js passed: set backend: tensorflow
2021-08-31 14:48:12 STATE: test-node.js passed: load models
2021-08-31 14:48:12 STATE: test-node.js result: defined models: 14 loaded models: 7
2021-08-31 14:48:12 STATE: test-node.js passed: warmup: none default
2021-08-31 14:48:13 STATE: test-node.js passed: warmup: face default
2021-08-31 14:48:13 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4}
2021-08-31 14:48:13 DATA:  test-node.js result: performance: load: 299 total: 1150
2021-08-31 14:48:14 STATE: test-node.js passed: warmup: body default
2021-08-31 14:48:14 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:14 DATA:  test-node.js result: performance: load: 299 total: 1171
2021-08-31 14:48:14 INFO:  test-node.js test body variants
2021-08-31 14:48:15 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:16 STATE: test-node.js passed: detect: samples/ai-body.jpg posenet
2021-08-31 14:48:16 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.96,"keypoints":16}
2021-08-31 14:48:16 DATA:  test-node.js result: performance: load: 299 total: 775
2021-08-31 14:48:16 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:17 STATE: test-node.js passed: detect: samples/ai-body.jpg movenet
2021-08-31 14:48:17 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:17 DATA:  test-node.js result: performance: load: 299 total: 215
2021-08-31 14:48:17 STATE: test-node.js passed: detect: random default
2021-08-31 14:48:17 DATA:  test-node.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 0 person: 0 {} {} {"score":0,"keypoints":0}
2021-08-31 14:48:17 DATA:  test-node.js result: performance: load: 299 total: 627
2021-08-31 14:48:17 INFO:  test-node.js test: first instance
2021-08-31 14:48:18 STATE: test-node.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 14:48:19 STATE: test-node.js passed: detect: samples/ai-upper.jpg default
2021-08-31 14:48:19 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 14:48:19 DATA:  test-node.js result: performance: load: 299 total: 995
2021-08-31 14:48:19 INFO:  test-node.js test: second instance
2021-08-31 14:48:19 STATE: test-node.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 14:48:20 STATE: test-node.js passed: detect: samples/ai-upper.jpg default
2021-08-31 14:48:20 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 14:48:20 DATA:  test-node.js result: performance: load: 5 total: 914
2021-08-31 14:48:20 INFO:  test-node.js test: concurrent
2021-08-31 14:48:20 STATE: test-node.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 14:48:20 STATE: test-node.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 14:48:21 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:22 STATE: test-node.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:26 STATE: test-node.js passed: detect: samples/ai-face.jpg default
2021-08-31 14:48:26 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 14:48:26 DATA:  test-node.js result: performance: load: 299 total: 4319
2021-08-31 14:48:26 STATE: test-node.js passed: detect: samples/ai-face.jpg default
2021-08-31 14:48:26 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 5 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 14:48:26 DATA:  test-node.js result: performance: load: 5 total: 4319
2021-08-31 14:48:26 STATE: test-node.js passed: detect: samples/ai-body.jpg default
2021-08-31 14:48:26 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:26 DATA:  test-node.js result: performance: load: 299 total: 4319
2021-08-31 14:48:26 STATE: test-node.js passed: detect: samples/ai-body.jpg default
2021-08-31 14:48:26 DATA:  test-node.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:26 DATA:  test-node.js result: performance: load: 5 total: 4319
2021-08-31 14:48:26 INFO:  test-node.js test complete: 14833 ms
2021-08-31 14:48:26 INFO:  test-node-gpu.js start
2021-08-31 14:48:27 WARN:  test-node-gpu.js stderr: 2021-08-31 14:48:27.542846: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-08-31 14:48:27 WARN:  test-node-gpu.js stderr: 2021-08-31 14:48:27.824919: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
2021-08-31 14:48:27 WARN:  test-node-gpu.js stderr: 2021-08-31 14:48:27.824982: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (wyse): /proc/driver/nvidia/version does not exist
2021-08-31 14:48:27 STATE: test-node-gpu.js passed: create human
2021-08-31 14:48:27 INFO:  test-node-gpu.js human version: 2.1.4
2021-08-31 14:48:27 INFO:  test-node-gpu.js platform: linux x64 agent: NodeJS v16.5.0
2021-08-31 14:48:27 INFO:  test-node-gpu.js tfjs version: 3.9.0
2021-08-31 14:48:28 STATE: test-node-gpu.js passed: set backend: tensorflow
2021-08-31 14:48:28 STATE: test-node-gpu.js passed: load models
2021-08-31 14:48:28 STATE: test-node-gpu.js result: defined models: 14 loaded models: 7
2021-08-31 14:48:28 STATE: test-node-gpu.js passed: warmup: none default
2021-08-31 14:48:29 STATE: test-node-gpu.js passed: warmup: face default
2021-08-31 14:48:29 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.42,"keypoints":4}
2021-08-31 14:48:29 DATA:  test-node-gpu.js result: performance: load: 291 total: 1389
2021-08-31 14:48:30 STATE: test-node-gpu.js passed: warmup: body default
2021-08-31 14:48:30 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:30 DATA:  test-node-gpu.js result: performance: load: 291 total: 1142
2021-08-31 14:48:30 INFO:  test-node-gpu.js test body variants
2021-08-31 14:48:31 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:32 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg posenet
2021-08-31 14:48:32 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.96,"keypoints":16}
2021-08-31 14:48:32 DATA:  test-node-gpu.js result: performance: load: 291 total: 807
2021-08-31 14:48:33 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:33 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg movenet
2021-08-31 14:48:33 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:33 DATA:  test-node-gpu.js result: performance: load: 291 total: 208
2021-08-31 14:48:33 STATE: test-node-gpu.js passed: detect: random default
2021-08-31 14:48:33 DATA:  test-node-gpu.js result: face: 0 body: 1 hand: 0 gesture: 0 object: 1 person: 0 {} {"score":0.72,"class":"person"} {"score":0,"keypoints":0}
2021-08-31 14:48:33 DATA:  test-node-gpu.js result: performance: load: 291 total: 160
2021-08-31 14:48:33 INFO:  test-node-gpu.js test: first instance
2021-08-31 14:48:34 STATE: test-node-gpu.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 14:48:34 STATE: test-node-gpu.js passed: detect: samples/ai-upper.jpg default
2021-08-31 14:48:34 DATA:  test-node-gpu.js result: face: 0 body: 1 hand: 0 gesture: 1 object: 1 person: 0 {} {"score":0.72,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 14:48:34 DATA:  test-node-gpu.js result: performance: load: 291 total: 131
2021-08-31 14:48:34 INFO:  test-node-gpu.js test: second instance
2021-08-31 14:48:34 STATE: test-node-gpu.js passed: load image: samples/ai-upper.jpg [1,720,688,3]
2021-08-31 14:48:35 STATE: test-node-gpu.js passed: detect: samples/ai-upper.jpg default
2021-08-31 14:48:35 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":29.5,"gender":"female"} {"score":0.71,"class":"person"} {"score":0.69,"keypoints":10}
2021-08-31 14:48:35 DATA:  test-node-gpu.js result: performance: load: 2 total: 965
2021-08-31 14:48:35 INFO:  test-node-gpu.js test: concurrent
2021-08-31 14:48:35 STATE: test-node-gpu.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 14:48:35 STATE: test-node-gpu.js passed: load image: samples/ai-face.jpg [1,256,256,3]
2021-08-31 14:48:36 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:37 STATE: test-node-gpu.js passed: load image: samples/ai-body.jpg [1,1200,1200,3]
2021-08-31 14:48:41 STATE: test-node-gpu.js passed: detect: samples/ai-face.jpg default
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 4 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: performance: load: 291 total: 4281
2021-08-31 14:48:41 STATE: test-node-gpu.js passed: detect: samples/ai-face.jpg default
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 5 object: 1 person: 1 {"age":23.6,"gender":"female"} {"score":0.82,"class":"person"} {"score":0.47,"keypoints":17}
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: performance: load: 2 total: 4281
2021-08-31 14:48:41 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg default
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: performance: load: 291 total: 4281
2021-08-31 14:48:41 STATE: test-node-gpu.js passed: detect: samples/ai-body.jpg default
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: face: 1 body: 1 hand: 0 gesture: 3 object: 1 person: 1 {"age":28.5,"gender":"female"} {"score":0.72,"class":"person"} {"score":0.92,"keypoints":17}
2021-08-31 14:48:41 DATA:  test-node-gpu.js result: performance: load: 2 total: 4281
2021-08-31 14:48:41 INFO:  test-node-gpu.js test complete: 13660 ms
2021-08-31 14:48:41 INFO:  test-node-wasm.js start
2021-08-31 14:48:41 ERROR: test-node-wasm.js failed: model server: request to http://localhost:10030/models/ failed, reason: connect ECONNREFUSED 127.0.0.1:10030
2021-08-31 14:48:41 ERROR: test-node-wasm.js aborting test
2021-08-31 14:48:41 INFO:  status: {"passed":46,"failed":1}

File diff suppressed because one or more lines are too long

View File

@ -134,6 +134,7 @@
<li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#match" class="tsd-kind-icon">match</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#next" class="tsd-kind-icon">next</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#segmentation-1" class="tsd-kind-icon">segmentation</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#setCanvas" class="tsd-kind-icon">set<wbr>Canvas</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#similarity" class="tsd-kind-icon">similarity</a></li>
<li class="tsd-kind-method tsd-parent-kind-class"><a href="Human.html#warmup" class="tsd-kind-icon">warmup</a></li>
</ul>
@ -842,6 +843,33 @@
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="setCanvas" class="tsd-anchor"></a>
<h3>set<wbr>Canvas</h3>
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class">
<li class="tsd-signature tsd-kind-icon">set<wbr>Canvas<span class="tsd-signature-symbol">(</span>canvas<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
<aside class="tsd-sources">
</aside>
<div class="tsd-comment tsd-typography">
<div class="lead">
<p>Sets internal canvas methods</p>
</div>
</div>
<h4 class="tsd-parameters-title">Parameters</h4>
<ul class="tsd-parameters">
<li>
<h5>canvas: <span class="tsd-signature-type">any</span></h5>
<div class="tsd-comment tsd-typography">
</div>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4>
</li>
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class">
<a name="similarity" class="tsd-anchor"></a>
<h3>similarity</h3>
@ -1007,6 +1035,9 @@
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="Human.html#segmentation-1" class="tsd-kind-icon">segmentation</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="Human.html#setCanvas" class="tsd-kind-icon">set<wbr>Canvas</a>
</li>
<li class=" tsd-kind-method tsd-parent-kind-class">
<a href="Human.html#similarity" class="tsd-kind-icon">similarity</a>
</li>

View File

@ -42,6 +42,7 @@ export interface DrawOptions {
bufferedOutput: boolean;
}
export declare const options: DrawOptions;
export declare function setCanvas(obj: any): void;
export declare function gesture(inCanvas: HTMLCanvasElement, result: Array<Gesture>, drawOptions?: DrawOptions): Promise<void>;
export declare function face(inCanvas: HTMLCanvasElement, result: Array<Face>, drawOptions?: DrawOptions): Promise<void>;
export declare function body(inCanvas: HTMLCanvasElement, result: Array<Body>, drawOptions?: DrawOptions): Promise<void>;

View File

@ -122,6 +122,12 @@ export declare class Human {
* @param userConfig: {@link Config}
*/
constructor(userConfig?: Config | Record<string, unknown>);
/**
* Sets internal canvas methods
*
* @param canvas
*/
setCanvas: (canvas: any) => void;
/** @hidden */
analyze: (...msg: string[]) => void;
/** Simmilarity method calculates simmilarity between two provided face descriptors (face embeddings)

2
wiki

@ -1 +1 @@
Subproject commit fcc3945dedd5682f06c45c32504a86a1a7e2a20b
Subproject commit 7f55fd1c8aea22f33a767da840147b15aeeed034