fix linting and tests

pull/94/head
Vladimir Mandic 2021-04-03 10:49:14 -04:00
parent 65ecd7f3c0
commit 9945d2e206
6 changed files with 77 additions and 12 deletions

View File

@ -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",

3
.npmignore Normal file
View File

@ -0,0 +1,3 @@
node_modules
private
pnpm-lock.yaml

View File

@ -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
<br>
![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)

View File

@ -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",

View File

@ -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);

59
test/test-node.js Normal file
View File

@ -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();