From f9306abac533cbeed4f4881bfa46c2558c97e87d Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sun, 28 Mar 2021 13:22:22 -0400 Subject: [PATCH] move gl flags to correct location --- CHANGELOG.md | 1 + demo/browser.js | 4 ++-- src/draw/draw.ts | 9 +++++++-- src/human.ts | 14 ++++++-------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac29b2d8..ed100625 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Repository: **** ### **HEAD -> main** 2021/03/28 mandic00@live.com +- remove debug output - new face rotation calculations - cleanup - rotationmatrixtoeulerangle, and fixes diff --git a/demo/browser.js b/demo/browser.js index c30f9481..0f1ccaef 100644 --- a/demo/browser.js +++ b/demo/browser.js @@ -7,7 +7,7 @@ const userConfig = { backend: 'webgl' }; // add any user configuration overrides /* const userConfig = { - backend: 'webgl', + backend: 'humangl', async: false, profile: false, warmup: 'full', @@ -24,7 +24,7 @@ const userConfig = { body: { enabled: false }, // body: { enabled: true, modelPath: '../models/blazepose.json' }, // body: { enabled: true, modelPath: '../models/efficientpose.json' }, - object: { enabled: false }, + object: { enabled: true }, }; */ diff --git a/src/draw/draw.ts b/src/draw/draw.ts index 7685f455..3842c54c 100644 --- a/src/draw/draw.ts +++ b/src/draw/draw.ts @@ -231,19 +231,24 @@ export async function body(inCanvas: HTMLCanvasElement, result: Array) { if (drawOptions.drawPolygons && result[i].keypoints) { let part; const points: any[] = []; - // torso + // shoulder line points.length = 0; part = result[i].keypoints.find((a) => a.part === 'leftShoulder'); if (part && part.score > defaults.body.scoreThreshold) points.push([part.position.x, part.position.y]); part = result[i].keypoints.find((a) => a.part === 'rightShoulder'); if (part && part.score > defaults.body.scoreThreshold) points.push([part.position.x, part.position.y]); + curves(ctx, points); + // torso main + points.length = 0; + part = result[i].keypoints.find((a) => a.part === 'rightShoulder'); + if (part && part.score > defaults.body.scoreThreshold) points.push([part.position.x, part.position.y]); part = result[i].keypoints.find((a) => a.part === 'rightHip'); if (part && part.score > defaults.body.scoreThreshold) points.push([part.position.x, part.position.y]); part = result[i].keypoints.find((a) => a.part === 'leftHip'); if (part && part.score > defaults.body.scoreThreshold) points.push([part.position.x, part.position.y]); part = result[i].keypoints.find((a) => a.part === 'leftShoulder'); if (part && part.score > defaults.body.scoreThreshold) points.push([part.position.x, part.position.y]); - if (points.length === 5) lines(ctx, points); // only draw if we have complete torso + if (points.length === 4) lines(ctx, points); // only draw if we have complete torso // leg left points.length = 0; part = result[i].keypoints.find((a) => a.part === 'leftHip'); diff --git a/src/human.ts b/src/human.ts index de5c3b10..38f0856c 100644 --- a/src/human.ts +++ b/src/human.ts @@ -270,8 +270,10 @@ export class Human { */ if (this.config.backend && this.config.backend !== '') { + // force browser vs node backend if (this.tf.ENV.flags.IS_BROWSER && this.config.backend === 'tensorflow') this.config.backend = 'webgl'; if (this.tf.ENV.flags.IS_NODE && (this.config.backend === 'webgl' || this.config.backend === 'wasm')) this.config.backend = 'tensorflow'; + if (this.config.debug) log('setting backend:', this.config.backend); if (this.config.backend === 'wasm') { @@ -291,18 +293,14 @@ export class Human { } } this.tf.enableProdMode(); - /* debug mode is really too mcuh - this.tf.enableDebugMode(); - */ - this.tf.ENV.set('CHECK_COMPUTATION_FOR_ERRORS', false); - this.tf.ENV.set('WEBGL_PACK_DEPTHWISECONV', true); - if (this.tf.getBackend() === 'webgl') { + // this.tf.enableDebugMode(); + if (this.tf.getBackend() === 'webgl' || this.tf.getBackend() === 'humangl') { + this.tf.ENV.set('CHECK_COMPUTATION_FOR_ERRORS', false); + this.tf.ENV.set('WEBGL_PACK_DEPTHWISECONV', true); if (this.config.deallocate) { log('changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:', this.config.deallocate); this.tf.ENV.set('WEBGL_DELETE_TEXTURE_THRESHOLD', this.config.deallocate ? 0 : -1); } - // this.tf.ENV.set('WEBGL_FORCE_F16_TEXTURES', true); - // this.tf.ENV.set('WEBGL_PACK_DEPTHWISECONV', true); const gl = await this.tf.backend().getGPGPUContext().gl; if (this.config.debug) log(`gl version:${gl.getParameter(gl.VERSION)} renderer:${gl.getParameter(gl.RENDERER)}`); }