mirror of https://github.com/vladmandic/human
swtich to tfjs source import
parent
60f03dc4a8
commit
3451c7b35f
|
@ -28,7 +28,7 @@
|
|||
"@vladmandic/pilogger": "^0.2.7",
|
||||
"chokidar": "^3.4.3",
|
||||
"dayjs": "^1.9.6",
|
||||
"esbuild": "^0.8.8",
|
||||
"esbuild": "^0.8.9",
|
||||
"eslint": "^7.13.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { tf, loadGraphModel } from '../tf.js';
|
||||
import { tf } from '../tf.js';
|
||||
import * as profile from '../profile.js';
|
||||
|
||||
const models = {};
|
||||
|
@ -7,7 +7,7 @@ let frame = Number.MAX_SAFE_INTEGER;
|
|||
|
||||
async function load(config) {
|
||||
if (!models.age) {
|
||||
models.age = await loadGraphModel(config.face.age.modelPath);
|
||||
models.age = await tf.loadGraphModel(config.face.age.modelPath);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Human: load model: ${config.face.age.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { tf, loadGraphModel } from '../tf.js';
|
||||
import { tf } from '../tf.js';
|
||||
import * as profile from '../profile.js';
|
||||
|
||||
const annotations = ['angry', 'disgust', 'fear', 'happy', 'sad', 'surpise', 'neutral'];
|
||||
|
@ -12,7 +12,7 @@ const scale = 1; // score multiplication factor
|
|||
|
||||
async function load(config) {
|
||||
if (!models.emotion) {
|
||||
models.emotion = await loadGraphModel(config.face.emotion.modelPath);
|
||||
models.emotion = await tf.loadGraphModel(config.face.emotion.modelPath);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Human: load model: ${config.face.emotion.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { tf, loadGraphModel } from '../tf.js';
|
||||
import { tf } from '../tf.js';
|
||||
import * as profile from '../profile.js';
|
||||
|
||||
const models = {};
|
||||
|
@ -11,7 +11,7 @@ const rgb = [0.2989, 0.5870, 0.1140]; // factors for red/green/blue colors when
|
|||
|
||||
async function load(config) {
|
||||
if (!models.gender) {
|
||||
models.gender = await loadGraphModel(config.face.gender.modelPath);
|
||||
models.gender = await tf.loadGraphModel(config.face.gender.modelPath);
|
||||
alternative = models.gender.inputs[0].shape[3] === 1;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`Human: load model: ${config.face.gender.modelPath.match(/\/(.*)\./)[1]}`);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
// https://storage.googleapis.com/tfjs-models/demos/handpose/index.html
|
||||
|
||||
import { loadGraphModel } from '../tf.js';
|
||||
import { tf } from '../tf.js';
|
||||
import * as handdetector from './handdetector';
|
||||
import * as pipeline from './handpipeline';
|
||||
import * as anchors from './anchors';
|
||||
|
@ -69,8 +69,8 @@ exports.HandPose = HandPose;
|
|||
|
||||
async function load(config) {
|
||||
const [handDetectorModel, handPoseModel] = await Promise.all([
|
||||
loadGraphModel(config.detector.modelPath, { fromTFHub: config.detector.modelPath.includes('tfhub.dev') }),
|
||||
loadGraphModel(config.skeleton.modelPath, { fromTFHub: config.skeleton.modelPath.includes('tfhub.dev') }),
|
||||
tf.loadGraphModel(config.detector.modelPath, { fromTFHub: config.detector.modelPath.includes('tfhub.dev') }),
|
||||
tf.loadGraphModel(config.skeleton.modelPath, { fromTFHub: config.skeleton.modelPath.includes('tfhub.dev') }),
|
||||
]);
|
||||
const detector = new handdetector.HandDetector(handDetectorModel, config.inputSize, anchors.anchors);
|
||||
const pipe = new pipeline.HandPipeline(detector, handPoseModel, config.inputSize);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { tf, setWasmPaths } from './tf.js';
|
||||
import { tf, wasm } from './tf.js';
|
||||
import * as facemesh from './face/facemesh.js';
|
||||
import * as age from './age/age.js';
|
||||
import * as gender from './gender/gender.js';
|
||||
|
@ -172,7 +172,7 @@ class Human {
|
|||
|
||||
if (this.config.backend === 'wasm') {
|
||||
this.log('settings wasm path:', this.config.wasmPath);
|
||||
setWasmPaths(this.config.wasmPath);
|
||||
wasm.setWasmPaths(this.config.wasmPath);
|
||||
const simd = await tf.env().getAsync('WASM_HAS_SIMD_SUPPORT');
|
||||
if (!simd) this.log('warning: wasm simd support is not enabled');
|
||||
}
|
||||
|
|
31
src/tf.js
31
src/tf.js
|
@ -1,29 +1,4 @@
|
|||
// from esm bundles: bundle 3.3M
|
||||
import * as tf from '@tensorflow/tfjs/dist/tf.es2017.js';
|
||||
import { setWasmPaths } from '@tensorflow/tfjs-backend-wasm/dist/index.js';
|
||||
// wrapper to load tfjs in a single place so version can be changed quickly
|
||||
|
||||
const loadGraphModel = tf.loadGraphModel;
|
||||
// const setWasmPaths = tf.setWasmPaths;
|
||||
export { tf, loadGraphModel, setWasmPaths };
|
||||
|
||||
// modular: bundle 4.2M
|
||||
/*
|
||||
import * as tf from '@tensorflow/tfjs-core/dist/tf-core.es2017.js';
|
||||
import { loadGraphModel } from '@tensorflow/tfjs-converter/dist/tf-converter.es2017.js';
|
||||
import * as tfCPU from '@tensorflow/tfjs-backend-cpu/dist/tf-backend-cpu.es2017.js';
|
||||
import * as tfWebGL from '@tensorflow/tfjs-backend-webgl/dist/tf-backend-webgl.es2017.js';
|
||||
import { setWasmPaths, version_wasm } from '@tensorflow/tfjs-backend-wasm/dist/index.js';
|
||||
|
||||
const version = { core: tf.version, cpu: tfCPU.version_cpu, webgl: tfWebGL.version_webgl, wasm: version_wasm };
|
||||
|
||||
export { tf, setWasmPaths, loadGraphModel, version };
|
||||
*/
|
||||
|
||||
// custom: bundle 3.4M
|
||||
/*
|
||||
import * as tf from '../../../dev-clone/tfjs/tfjs/dist/index.js';
|
||||
import { setWasmPaths } from '@tensorflow/tfjs-backend-wasm/dist/index.js';
|
||||
|
||||
const loadGraphModel = tf.loadGraphModel;
|
||||
export { tf, setWasmPaths, loadGraphModel };
|
||||
*/
|
||||
export * as tf from '@tensorflow/tfjs/dist/index.js';
|
||||
export * as wasm from '@tensorflow/tfjs-backend-wasm/dist/index.js';
|
||||
|
|
Loading…
Reference in New Issue