added blazepose-upper

pull/91/head
Vladimir Mandic 2021-03-05 07:39:37 -05:00
parent f1f00e8bf1
commit 17dc287e15
31 changed files with 1246 additions and 545 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@ -137,7 +137,7 @@ export default {
body: {
enabled: true,
modelPath: '../models/posenet.json', // can be 'posenet' or 'blazepose'
modelPath: '../models/posenet.json', // can be 'posenet', 'blazepose' or 'blazepose-upper'
inputSize: 257, // fixed value, 257 for posenet and 256 for blazepose
maxDetections: 10, // maximum number of people detected in the input
// should be set to the minimum number for performance

View File

@ -8,20 +8,18 @@ import draw from './draw.js';
import Menu from './menu.js';
import GLBench from './gl-bench.js';
const userConfig = {}; // add any user configuration overrides
// const userConfig = {}; // add any user configuration overrides
/*
const userConfig = {
backend: 'wasm',
async: false,
warmup: 'full',
videoOptimized: false,
face: { enabled: true, iris: { enabled: true }, mesh: { enabled: true }, age: { enabled: true }, gender: { enabled: true }, emotion: { enabled: true }, embedding: { enabled: true } },
hand: { enabled: true },
face: { enabled: false, iris: { enabled: true }, mesh: { enabled: true }, age: { enabled: true }, gender: { enabled: true }, emotion: { enabled: true }, embedding: { enabled: true } },
hand: { enabled: false },
gestures: { enabled: true },
body: { enabled: true, modelType: 'blazepose', modelPath: '../models/blazepose.json' },
body: { enabled: true, modelType: 'blazepose', modelPath: '../models/blazepose-upper.json' },
};
*/
const human = new Human(userConfig);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"inputs": {
"dist/human.esm.js": {
"bytes": 1341917,
"bytes": 1342423,
"imports": []
},
"demo/draw.js": {
@ -17,7 +17,7 @@
"imports": []
},
"demo/browser.js": {
"bytes": 28101,
"bytes": 28106,
"imports": [
{
"path": "dist/human.esm.js",
@ -43,7 +43,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 2051266
"bytes": 2052559
},
"dist/demo-browser-index.js": {
"imports": [],
@ -51,7 +51,7 @@
"entryPoint": "demo/browser.js",
"inputs": {
"dist/human.esm.js": {
"bytesInOutput": 1334439
"bytesInOutput": 1334941
},
"demo/draw.js": {
"bytesInOutput": 7178
@ -63,10 +63,10 @@
"bytesInOutput": 6759
},
"demo/browser.js": {
"bytesInOutput": 18268
"bytesInOutput": 18581
}
},
"bytes": 1384725
"bytes": 1385540
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

390
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

27
dist/human.esm.json vendored
View File

@ -5,7 +5,7 @@
"imports": []
},
"dist/tfjs.esm.js": {
"bytes": 1065627,
"bytes": 1065682,
"imports": []
},
"src/tfjs/backend.ts": {
@ -383,8 +383,12 @@
}
]
},
"src/blazepose/annotations.ts": {
"bytes": 1108,
"imports": []
},
"src/blazepose/blazepose.ts": {
"bytes": 3327,
"bytes": 2879,
"imports": [
{
"path": "src/log.ts",
@ -397,6 +401,10 @@
{
"path": "src/profile.ts",
"kind": "import-statement"
},
{
"path": "src/blazepose/annotations.ts",
"kind": "import-statement"
}
]
},
@ -426,7 +434,7 @@
]
},
"config.js": {
"bytes": 10403,
"bytes": 10422,
"imports": []
},
"src/sample.ts": {
@ -438,7 +446,7 @@
"imports": []
},
"src/human.ts": {
"bytes": 21042,
"bytes": 21043,
"imports": [
{
"path": "src/log.ts",
@ -520,7 +528,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 1948302
"bytes": 1949289
},
"dist/human.esm.js": {
"imports": [],
@ -539,7 +547,7 @@
"bytesInOutput": 252
},
"dist/tfjs.esm.js": {
"bytesInOutput": 1056636
"bytesInOutput": 1056695
},
"src/tfjs/backend.ts": {
"bytesInOutput": 1053
@ -626,7 +634,10 @@
"bytesInOutput": 126985
},
"src/blazepose/blazepose.ts": {
"bytesInOutput": 1613
"bytesInOutput": 1153
},
"src/blazepose/annotations.ts": {
"bytesInOutput": 860
},
"src/gesture/gesture.ts": {
"bytesInOutput": 2391
@ -647,7 +658,7 @@
"bytesInOutput": 2596
}
},
"bytes": 1341917
"bytes": 1342423
}
}
}

27
dist/human.iife.json vendored
View File

@ -5,7 +5,7 @@
"imports": []
},
"dist/tfjs.esm.js": {
"bytes": 1065627,
"bytes": 1065682,
"imports": []
},
"src/tfjs/backend.ts": {
@ -383,8 +383,12 @@
}
]
},
"src/blazepose/annotations.ts": {
"bytes": 1108,
"imports": []
},
"src/blazepose/blazepose.ts": {
"bytes": 3327,
"bytes": 2879,
"imports": [
{
"path": "src/log.ts",
@ -397,6 +401,10 @@
{
"path": "src/profile.ts",
"kind": "import-statement"
},
{
"path": "src/blazepose/annotations.ts",
"kind": "import-statement"
}
]
},
@ -426,7 +434,7 @@
]
},
"config.js": {
"bytes": 10403,
"bytes": 10422,
"imports": []
},
"src/sample.ts": {
@ -438,7 +446,7 @@
"imports": []
},
"src/human.ts": {
"bytes": 21042,
"bytes": 21043,
"imports": [
{
"path": "src/log.ts",
@ -520,7 +528,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 1948313
"bytes": 1949300
},
"dist/human.ts": {
"imports": [],
@ -540,7 +548,7 @@
"bytesInOutput": 252
},
"dist/tfjs.esm.js": {
"bytesInOutput": 1056636
"bytesInOutput": 1056695
},
"src/tfjs/backend.ts": {
"bytesInOutput": 1053
@ -624,7 +632,10 @@
"bytesInOutput": 126985
},
"src/blazepose/blazepose.ts": {
"bytesInOutput": 1613
"bytesInOutput": 1153
},
"src/blazepose/annotations.ts": {
"bytesInOutput": 860
},
"src/gesture/gesture.ts": {
"bytesInOutput": 2391
@ -645,7 +656,7 @@
"bytesInOutput": 2596
}
},
"bytes": 1341959
"bytes": 1342465
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

8
dist/human.node.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

27
dist/human.node.json vendored
View File

@ -5,7 +5,7 @@
"imports": []
},
"dist/tfjs.esm.js": {
"bytes": 690,
"bytes": 737,
"imports": []
},
"src/tfjs/backend.ts": {
@ -383,8 +383,12 @@
}
]
},
"src/blazepose/annotations.ts": {
"bytes": 1108,
"imports": []
},
"src/blazepose/blazepose.ts": {
"bytes": 3327,
"bytes": 2879,
"imports": [
{
"path": "src/log.ts",
@ -397,6 +401,10 @@
{
"path": "src/profile.ts",
"kind": "import-statement"
},
{
"path": "src/blazepose/annotations.ts",
"kind": "import-statement"
}
]
},
@ -426,7 +434,7 @@
]
},
"config.js": {
"bytes": 10403,
"bytes": 10422,
"imports": []
},
"src/sample.ts": {
@ -438,7 +446,7 @@
"imports": []
},
"src/human.ts": {
"bytes": 21042,
"bytes": 21043,
"imports": [
{
"path": "src/log.ts",
@ -520,7 +528,7 @@
"imports": [],
"exports": [],
"inputs": {},
"bytes": 715070
"bytes": 716046
},
"dist/human.node-gpu.js": {
"imports": [],
@ -528,7 +536,7 @@
"entryPoint": "src/human.ts",
"inputs": {
"dist/tfjs.esm.js": {
"bytesInOutput": 551
"bytesInOutput": 598
},
"src/blazeface/facemesh.ts": {
"bytesInOutput": 1585
@ -624,7 +632,10 @@
"bytesInOutput": 126985
},
"src/blazepose/blazepose.ts": {
"bytesInOutput": 1637
"bytesInOutput": 1179
},
"src/blazepose/annotations.ts": {
"bytesInOutput": 860
},
"src/gesture/gesture.ts": {
"bytesInOutput": 2391
@ -645,7 +656,7 @@
"bytesInOutput": 2593
}
},
"bytes": 279471
"bytes": 279967
}
}
}

390
dist/human.ts vendored

File diff suppressed because one or more lines are too long

6
dist/human.ts.map vendored

File diff suppressed because one or more lines are too long

4
dist/tfjs.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

4
dist/tfjs.esm.json vendored
View File

@ -28620,7 +28620,7 @@
"bytesInOutput": 484
},
"node_modules/@tensorflow/tfjs-backend-wasm/dist/backend_wasm.js": {
"bytesInOutput": 4747
"bytesInOutput": 4755
},
"node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/tfjs-backend-wasm-threaded-simd.worker.js": {
"bytesInOutput": 3145
@ -29760,7 +29760,7 @@
"bytesInOutput": 15
}
},
"bytes": 1065627
"bytes": 1065682
}
}
}

BIN
models/blazepose-upper.bin Normal file

Binary file not shown.

631
models/blazepose-upper.json Normal file

File diff suppressed because one or more lines are too long

30
package-lock.json generated
View File

@ -977,9 +977,9 @@
}
},
"es-abstract": {
"version": "1.18.0-next.3",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.3.tgz",
"integrity": "sha512-VMzHx/Bczjg59E6jZOQjHeN3DEoptdhejpARgflAViidlqSpjdq9zA6lKwlhRRs/lOw1gHJv2xkkSFRgvEwbQg==",
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0.tgz",
"integrity": "sha512-LJzK7MrQa8TS0ja2w3YNLzUgJCGPdPOV1yVvezjNnS89D+VR08+Szt2mz3YB2Dck/+w5tfIq/RoUAFqJJGM2yw==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
@ -1027,9 +1027,9 @@
}
},
"esbuild": {
"version": "0.8.54",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.8.54.tgz",
"integrity": "sha512-DJH38OiTgXJxFb/EhHrCrY8eGmtdkTtWymHpN9IYN9AF+4jykT0dQArr7wzFejpVbaB0TMIq2+vfNRWr3LXpvw==",
"version": "0.8.56",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.8.56.tgz",
"integrity": "sha512-PTMdAWK3JI2MNW811znGssGP5GR44tQPr++VQ1rPP0n8Z1cTKbCPD3S/kXPLr3ZZDIwAaVm08fuFym6Rp8l/0A==",
"dev": true
},
"escalade": {
@ -1646,9 +1646,9 @@
}
},
"google-protobuf": {
"version": "3.15.3",
"resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.15.3.tgz",
"integrity": "sha512-+q6w/pTPS8hmdeHe+OWO7PRKOkqtPM4+dxUUOtC9lLgiaLUd7FQq+0EkTt9UmEHf2KMigkbV1fIxSr73t/JG/A==",
"version": "3.15.5",
"resolved": "https://registry.npmjs.org/google-protobuf/-/google-protobuf-3.15.5.tgz",
"integrity": "sha512-6bLpAI4nMIQODlegR7OevgkCoyOj5frLVDArUpeuBWad7XWUNWMGP0v5lz1/aeUI6Yf3cG9XA6acZkPxom4SEw==",
"dev": true
},
"graceful-fs": {
@ -2601,9 +2601,9 @@
"dev": true
},
"simple-git": {
"version": "2.35.2",
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.35.2.tgz",
"integrity": "sha512-UjOKsrz92Bx7z00Wla5V6qLSf5X2XSp0sL2gzKw1Bh7iJfDPDaU7gK5avIup0yo1/sMOSUMQer2b9GcnF6nmTQ==",
"version": "2.36.0",
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.36.0.tgz",
"integrity": "sha512-EJNaUgGYzBnQiyEkNZgbQSg76agbEDqlgHDr8DAXqV8xWvcefydbipye7YXtHMGbbEK998dcFezS8qF0sepZ5Q==",
"dev": true,
"requires": {
"@kwsites/file-exists": "^1.1.1",
@ -2866,9 +2866,9 @@
"dev": true
},
"typescript": {
"version": "4.3.0-dev.20210302",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.0-dev.20210302.tgz",
"integrity": "sha512-j8UsZLmGC3z0dzJ+Ybf3Q0txXvnGLkoIORUYApUfuJLoJlkFI7po/drYmhgh4BFjR3JnBQmniRHipEgcfQOANA==",
"version": "4.3.0-dev.20210305",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.0-dev.20210305.tgz",
"integrity": "sha512-OTALeeen7kl6FU1tcXRk3h+WY1NnE5lwyTGAZUCt9hw6tdaifgLXqEkfw9NHJc0xKV6PnU8GgnYFFVVyHLPSHg==",
"dev": true
},
"unbox-primitive": {

View File

@ -39,7 +39,7 @@
"@vladmandic/pilogger": "^0.2.14",
"chokidar": "^3.5.1",
"dayjs": "^1.10.4",
"esbuild": "^0.8.54",
"esbuild": "^0.8.56",
"eslint": "^7.21.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
@ -48,9 +48,9 @@
"eslint-plugin-promise": "^4.3.1",
"rimraf": "^3.0.2",
"seedrandom": "^3.0.5",
"simple-git": "^2.35.2",
"simple-git": "^2.36.0",
"tslib": "^2.1.0",
"typescript": "^4.3.0-dev.20210302"
"typescript": "^4.3.0-dev.20210305"
},
"scripts": {
"start": "node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",

View File

@ -0,0 +1,75 @@
export const full = [
'nose',
'leftEyeInside',
'leftEye',
'leftEyeOutside',
'rightEyeInside',
'rightEye',
'rightEyeOutside',
'leftEar',
'rightEar',
'leftMouth',
'rightMouth',
'leftShoulder',
'rightShoulder',
'leftElbow',
'rightElbow',
'leftWrist',
'rightWrist',
'leftPalm',
'rightPalm',
'leftIndex',
'rightIndex',
'leftPinky',
'rightPinky',
'leftHip',
'rightHip',
'leftKnee',
'rightKnee',
'leftAnkle',
'rightAnkle',
'leftHeel',
'rightHeel',
'leftFoot',
'rightFoot',
'midHip',
'forehead',
'leftThumb',
'leftHand',
'rightThumb',
'rightHand',
];
export const upper = [
'nose',
'leftEyeInside',
'leftEye',
'leftEyeOutside',
'rightEyeInside',
'rightEye',
'rightEyeOutside',
'leftEar',
'rightEar',
'leftMouth',
'rightMouth',
'leftShoulder',
'rightShoulder',
'leftElbow',
'rightElbow',
'left:15',
'right:16',
'left:17',
'right:18',
'left:19',
'right:20',
'left:21',
'right:22',
'leftChest',
'rightChest',
'neck',
'forehead',
'left:27',
'right:28',
'left:29',
'right:30',
];

View File

@ -1,49 +1,9 @@
import { log } from '../log';
import * as tf from '../../dist/tfjs.esm.js';
import * as profile from '../profile';
import * as annotations from './annotations';
let model;
const labels = [
'nose',
'leftEyeInside',
'leftEye',
'leftEyeOutside',
'rightEyeInside',
'rightEye',
'rightEyeOutside',
'leftEar',
'rightEar',
'leftMouth',
'rightMouth',
'leftShoulder',
'rightShoulder',
'leftElbow',
'rightElbow',
'leftWrist',
'rightWrist',
'leftPalm',
'rightPalm',
'leftIndex',
'rightIndex',
'leftPinky',
'rightPinky',
'leftHip',
'rightHip',
'leftKnee',
'rightKnee',
'leftAnkle',
'rightAnkle',
'leftHeel',
'rightHeel',
'leftFoot',
'rightFoot',
'midHip',
'forehead',
'leftThumb',
'leftHand',
'rightThumb',
'rightHand',
];
export async function load(config) {
if (!model) {
@ -81,17 +41,19 @@ export async function predict(image, config) {
}
normalize.dispose();
const keypoints: Array<{ id, part, position: { x, y, z }, score, presence }> = [];
for (let i = 0; i < points.length / 5; i++) {
const labels = points.length === 195 ? annotations.full : annotations.upper;
const depth = 5;
for (let i = 0; i < points.length / depth; i++) {
keypoints.push({
id: i,
part: labels[i],
position: {
x: Math.trunc(imgSize.width * points[5 * i + 0] / 255),
y: Math.trunc(imgSize.height * points[5 * i + 1] / 255),
z: Math.trunc(points[5 * i + 2]) + 0, // fix negative zero
x: Math.trunc(imgSize.width * points[depth * i + 0] / 255),
y: Math.trunc(imgSize.height * points[depth * i + 1] / 255),
z: Math.trunc(points[depth * i + 2]) + 0, // fix negative zero
},
score: (100 - Math.trunc(100 / (1 + Math.exp(points[5 * i + 3])))) / 100, // reverse sigmoid value
presence: (100 - Math.trunc(100 / (1 + Math.exp(points[5 * i + 4])))) / 100, // reverse sigmoid value
score: (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 3])))) / 100, // reverse sigmoid value
presence: (100 - Math.trunc(100 / (1 + Math.exp(points[depth * i + 4])))) / 100, // reverse sigmoid value
});
}
// console.log('POINTS', imgSize, pts.length, pts);

View File

@ -494,7 +494,7 @@ class Human {
default:
src = null;
}
// src = encodeURI('../assets/human-sample-face.jpg');
// src = encodeURI('../assets/human-sample-upper.jpg');
const img = new Image();
img.onload = async () => {
const canvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(size, size) : document.createElement('canvas');

2
types/blazepose/annotations.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
export declare const full: string[];
export declare const upper: string[];

2
wiki

@ -1 +1 @@
Subproject commit c60f442714b1b5887ae25feb35fa413bc9996402
Subproject commit 870084a1a92e66943076ad41a99b74d32c799761