update hand landmarks model

pull/280/head
Vladimir Mandic 2021-10-31 09:06:33 -04:00
parent f773ef3dbe
commit be767fb02d
7 changed files with 303 additions and 6 deletions

View File

@ -9,9 +9,15 @@ import Human from "../../dist/human.esm.js";
var config = {
modelBasePath: "../../models",
backend: "humangl",
async: true
async: true,
face: { enabled: true },
body: { enabled: true },
hand: { enabled: true },
object: { enabled: false },
gesture: { enabled: true }
};
var human = new Human(config);
human.env.perfadd = false;
var result;
var dom = {
video: document.getElementById("video"),
@ -80,7 +86,6 @@ async function drawLoop() {
async function main() {
log("human version:", human.version, "tfjs:", human.tf.version_core);
log("platform:", human.env.platform, "agent:", human.env.agent);
human.env.perfadd = true;
status("loading...");
await human.load();
status("initializing...");

View File

@ -7,15 +7,23 @@
* @license MIT
*/
/// <reference path="../../types/src//human.d.ts" />
import Human from '../../dist/human.esm.js'; // equivalent of @vladmandic/human
const config = {
modelBasePath: '../../models',
backend: 'humangl',
async: true,
face: { enabled: true },
body: { enabled: true },
hand: { enabled: true },
object: { enabled: false },
gesture: { enabled: true },
};
const human = new Human(config);
human.env.perfadd = false;
let result;
const dom = {
@ -88,7 +96,6 @@ async function drawLoop() {
async function main() {
log('human version:', human.version, 'tfjs:', human.tf.version_core);
log('platform:', human.env.platform, 'agent:', human.env.agent);
human.env.perfadd = true;
status('loading...');
await human.load();
status('initializing...');

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -348,7 +348,7 @@ const config: Config = {
modelPath: 'handtrack.json',
},
skeleton: {
modelPath: 'handskeleton.json',
modelPath: 'handlandmark-full.json',
},
},
object: {

View File

@ -156,7 +156,7 @@ async function detectFingers(input: Tensor, h: HandDetectResult, config: Config)
t.crop = tf.image.cropAndResize(input, [h.boxCrop], [0], [inputSize[1][0], inputSize[1][1]], 'bilinear');
t.cast = tf.cast(t.crop, 'float32');
t.div = tf.div(t.cast, 255);
[t.score, t.keypoints] = models[1].execute(t.div) as Tensor[];
[t.score, t.keypoints] = models[1].execute(t.div, ['Identity_1', 'Identity']) as Tensor[];
const rawScore = (await t.score.data())[0];
const score = (100 - Math.trunc(100 / (1 + Math.exp(rawScore)))) / 100; // reverse sigmoid value
if (score >= (config.hand.minConfidence || 0)) {

View File

@ -409,7 +409,7 @@ export async function hand(inCanvas: AnyCanvas, result: Array<HandResult>, drawO
if (!part || part.length === 0 || !part[0]) return;
for (let i = 0; i < part.length; i++) {
ctx.beginPath();
ctx.strokeStyle = localOptions.useDepth ? `rgba(${127.5 + (2 * part[i][2])}, ${127.5 - (2 * part[i][2])}, 255, 0.5)` : localOptions.color;
ctx.strokeStyle = localOptions.useDepth ? `rgba(${127.5 + (i * part[i][2])}, ${127.5 - (i * part[i][2])}, 255, 0.5)` : localOptions.color;
ctx.moveTo(part[i > 0 ? i - 1 : 0][0], part[i > 0 ? i - 1 : 0][1]);
ctx.lineTo(part[i][0], part[i][1]);
ctx.stroke();