diff --git a/.eslintrc.json b/.eslintrc.json index 8d1b0f33..dbcd90ea 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -24,7 +24,7 @@ "plugin:@typescript-eslint/recommended", "airbnb-base" ], - "ignorePatterns": [ "dist", "assets", "media", "models", "node_modules" ], + "ignorePatterns": [ "dist", "assets", "media", "models", "node_modules", "demo/helpers" ], "rules": { "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/explicit-module-boundary-types": "off", diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..1d2e013f --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +node_modules +private +pnpm-lock.yaml diff --git a/README.md b/README.md index c63be2a5..fe96fab5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -![Version](https://img.shields.io/github/package-json/v/vladmandic/human?style=flat-square?svg=true) -![Last Commit](https://img.shields.io/github/last-commit/vladmandic/human?style=flat-square?svg=true) -![License](https://img.shields.io/github/license/vladmandic/human?style=flat-square?svg=true) -![GitHub Status Checks](https://img.shields.io/github/checks-status/vladmandic/human/main?style=flat-square?svg=true) -![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/vladmandic/human?style=flat-square?svg=true) +![Git Version](https://img.shields.io/github/package-json/v/vladmandic/human?style=flat-square&svg=true&label=git) +![NPM Version](https://img.shields.io/npm/v/@vladmandic/human.png?style=flat-square) +![Last Commit](https://img.shields.io/github/last-commit/vladmandic/human?style=flat-square&svg=true) +![License](https://img.shields.io/github/license/vladmandic/human?style=flat-square&svg=true) +![GitHub Status Checks](https://img.shields.io/github/checks-status/vladmandic/human/main?style=flat-square&svg=true) +![Vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/vladmandic/human?style=flat-square&svg=true) # Human Library @@ -177,6 +178,8 @@ and [**API Specification**](https://vladmandic.github.io/human/typedoc/classes/h
-![Downloads](https://img.shields.io/npm/dm/@vladmandic/human?style=flat-square?svg=true) -![Stars](https://img.shields.io/github/stars/vladmandic/human?style=flat-square?svg=true) -![Code Size](https://img.shields.io/github/languages/code-size/vladmandic/human?style=flat-square?svg=true) +![Stars](https://img.shields.io/github/stars/vladmandic/human?style=flat-square&svg=true) +![Code Size](https://img.shields.io/github/languages/code-size/vladmandic/human?style=flat-square&svg=true) +![Downloads](https://img.shields.io/npm/dw/@vladmandic/human.png?style=flat-square) +![Downloads](https://img.shields.io/npm/dm/@vladmandic/human.png?style=flat-square) +![Downloads](https://img.shields.io/npm/dy/@vladmandic/human.png?style=flat-square) diff --git a/package.json b/package.json index b650796f..79f54fbb 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "dev": "node --trace-warnings --unhandled-rejections=strict --trace-uncaught server/serve.js", "build": "rimraf dist/* typedoc/* types/* && node --trace-warnings --unhandled-rejections=strict --trace-uncaught server/build.js", "lint": "eslint src server demo", - "test": "npm run lint && npm run start" + "test": "node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation test/test-node.js" }, "keywords": [ "tensorflowjs", diff --git a/server/serve.js b/server/serve.js index 1010d88c..56bb5895 100755 --- a/server/serve.js +++ b/server/serve.js @@ -120,7 +120,7 @@ function handle(url) { } } return false; - } + }; const checkFolder = (f) => { result.file = f; if (fs.existsSync(f)) { @@ -131,7 +131,7 @@ function handle(url) { } } return false; - } + }; return new Promise((resolve) => { if (checkFile(path.join(process.cwd(), url))) resolve(result); else if (checkFile(path.join(process.cwd(), url, options.defaultFile))) resolve(result); diff --git a/test/test-node.js b/test/test-node.js new file mode 100644 index 00000000..aacec62e --- /dev/null +++ b/test/test-node.js @@ -0,0 +1,59 @@ +const log = require('@vladmandic/pilogger'); +// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars +const tf = require('@tensorflow/tfjs-node'); +const Human = require('../dist/human.node.js').default; + +const config = { + backend: 'tensorflow', + debug: false, + videoOptimized: false, + async: false, + warmup: 'full', + filter: { + enabled: true, + }, + face: { + enabled: true, + detector: { modelPath: 'file://models/blazeface-back.json', enabled: true, rotation: false }, + mesh: { modelPath: 'file://models/facemesh.json', enabled: true }, + iris: { modelPath: 'file://models/iris.json', enabled: true }, + description: { modelPath: 'file://models/faceres.json', enabled: true }, + emotion: { modelPath: 'file://models/emotion.json', enabled: true }, + }, + hand: { + enabled: true, + detector: { modelPath: 'file://models/handdetect.json' }, + skeleton: { modelPath: 'file://models/handskeleton.json' }, + }, + // body: { modelPath: 'file://models/efficientpose.json', enabled: true }, + // body: { modelPath: 'file://models/blazepose.json', enabled: true }, + body: { modelPath: 'file://models/posenet.json', enabled: true }, + object: { modelPath: 'file://models/nanodet.json', enabled: true }, +}; + +async function test() { + const human = new Human(config); + if (human) log.state('passed: create human'); + else log.error('failed: create human'); + + await human.load(); + if (human.models) { + log.state('passed: load models'); + const keys = Object.keys(human.models); + const loaded = keys.filter((model) => human.models[model]); + log.data(' result: defined models:', keys.length, 'loaded models:', loaded.length); + } else { + log.error('failed: load models'); + } + + const warmup = await human.warmup(); + if (warmup) { + log.state('passed: warmup:', config.warmup); + log.data(' result: face:', warmup.face.length, 'body:', warmup.body.length, 'hand:', warmup.hand.length, 'gesture:', warmup.gesture.length, 'object:', warmup.object.length); + log.data(' result: performance:', 'load:', warmup.performance.load, 'total:', warmup.performance.total); + } else { + log.error('failed: warmup'); + } +} + +test();