human/test/test-node-wasm.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-09-13 19:28:35 +02:00
const tf = require('@tensorflow/tfjs'); // wasm backend requires tfjs to be loaded first
const wasm = require('@tensorflow/tfjs-backend-wasm'); // wasm backend does not get auto-loaded in nodejs
const { Canvas, Image } = require('canvas');
const Human = require('../dist/human.node-wasm.js');
2021-04-14 18:53:00 +02:00
const test = require('./test-main.js').test;
// @ts-ignore
2021-09-13 19:28:35 +02:00
Human.env.Canvas = Canvas;
// @ts-ignore
2021-09-13 19:28:35 +02:00
Human.env.Image = Image;
2021-04-14 18:53:00 +02:00
const config = {
2021-09-13 19:28:35 +02:00
// modelBasePath: 'http://localhost:10030/models/',
modelBasePath: 'https://vladmandic.github.io/human/models/',
2021-04-14 18:53:00 +02:00
backend: 'wasm',
2021-05-18 14:22:33 +02:00
wasmPath: 'node_modules/@tensorflow/tfjs-backend-wasm/dist/',
2021-08-31 19:00:06 +02:00
// wasmPath: 'https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@3.9.0/dist/',
2021-04-14 18:53:00 +02:00
debug: false,
async: false,
face: {
enabled: true,
2021-09-19 20:07:53 +02:00
detector: { rotation: false },
2021-04-14 18:53:00 +02:00
mesh: { enabled: true },
iris: { enabled: true },
description: { enabled: true },
emotion: { enabled: true },
},
hand: { enabled: true, rotation: false },
2021-04-14 18:53:00 +02:00
body: { enabled: true },
2021-09-20 15:42:34 +02:00
object: { enabled: true },
2021-06-05 23:51:46 +02:00
segmentation: { enabled: true },
filter: { enabled: false },
2021-04-14 18:53:00 +02:00
};
2021-09-13 19:28:35 +02:00
async function main() {
wasm.setWasmPaths(config.wasmPath);
await tf.setBackend('wasm');
await tf.ready();
test(Human.Human, config);
}
2021-09-13 19:28:35 +02:00
main();