update build and lint scripts
parent
7ef748390c
commit
2ac6baa02b
|
@ -3,50 +3,71 @@
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"commonjs": true,
|
"commonjs": true,
|
||||||
"es6": true,
|
|
||||||
"node": true,
|
"node": true,
|
||||||
"es2020": true
|
"es2020": true
|
||||||
},
|
},
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"parserOptions": { "ecmaVersion": 2020 },
|
"parserOptions": { "ecmaVersion": 2020 },
|
||||||
"plugins": ["@typescript-eslint"],
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
"extends": [
|
"extends": [
|
||||||
"eslint:recommended",
|
"eslint:recommended",
|
||||||
"plugin:import/errors",
|
"plugin:import/errors",
|
||||||
"plugin:import/warnings",
|
"plugin:import/warnings",
|
||||||
"plugin:import/typescript",
|
|
||||||
"plugin:node/recommended",
|
"plugin:node/recommended",
|
||||||
"plugin:promise/recommended",
|
"plugin:promise/recommended",
|
||||||
"plugin:json/recommended-with-comments",
|
"plugin:json/recommended-with-comments",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
"airbnb-base"
|
"airbnb-base"
|
||||||
],
|
],
|
||||||
"ignorePatterns": [ "node_modules", "types" ],
|
"ignorePatterns": [ "node_modules", "types" ],
|
||||||
"settings": {
|
|
||||||
"import/resolver": {
|
|
||||||
"node": {
|
|
||||||
"extensions": [".js", ".ts"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"rules": {
|
"rules": {
|
||||||
"max-len": [1, 275, 3],
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/ban-types": "off",
|
||||||
|
"@typescript-eslint/ban-ts-comment": "off",
|
||||||
|
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||||
|
"@typescript-eslint/no-var-requires": "off",
|
||||||
"camelcase": "off",
|
"camelcase": "off",
|
||||||
"class-methods-use-this": "off",
|
"class-methods-use-this": "off",
|
||||||
|
"dot-notation": "off",
|
||||||
|
"func-names": "off",
|
||||||
|
"guard-for-in": "off",
|
||||||
"import/extensions": "off",
|
"import/extensions": "off",
|
||||||
"import/no-cycle": "off",
|
"import/no-extraneous-dependencies": "off",
|
||||||
|
"import/no-named-as-default": "off",
|
||||||
|
"import/no-unresolved": "off",
|
||||||
"import/prefer-default-export": "off",
|
"import/prefer-default-export": "off",
|
||||||
|
"lines-between-class-members": "off",
|
||||||
|
"max-len": [1, 275, 3],
|
||||||
|
"newline-per-chained-call": "off",
|
||||||
|
"no-async-promise-executor": "off",
|
||||||
"no-await-in-loop": "off",
|
"no-await-in-loop": "off",
|
||||||
|
"no-bitwise": "off",
|
||||||
|
"no-case-declarations":"off",
|
||||||
"no-continue": "off",
|
"no-continue": "off",
|
||||||
|
"no-loop-func": "off",
|
||||||
"no-mixed-operators": "off",
|
"no-mixed-operators": "off",
|
||||||
"no-param-reassign": "off",
|
"no-param-reassign":"off",
|
||||||
"no-plusplus": "off",
|
"no-plusplus": "off",
|
||||||
|
"no-regex-spaces": "off",
|
||||||
|
"no-restricted-globals": "off",
|
||||||
"no-restricted-syntax": "off",
|
"no-restricted-syntax": "off",
|
||||||
"no-return-assign": "off",
|
"no-return-assign": "off",
|
||||||
"no-underscore-dangle": "off",
|
"no-underscore-dangle": "off",
|
||||||
"node/no-missing-import": "off",
|
"node/no-missing-import": ["error", { "tryExtensions": [".js", ".json", ".ts"] }],
|
||||||
|
"node/no-unpublished-import": "off",
|
||||||
|
"node/no-unpublished-require": "off",
|
||||||
"node/no-unsupported-features/es-syntax": "off",
|
"node/no-unsupported-features/es-syntax": "off",
|
||||||
|
"no-lonely-if": "off",
|
||||||
|
"node/shebang": "off",
|
||||||
|
"object-curly-newline": "off",
|
||||||
"prefer-destructuring": "off",
|
"prefer-destructuring": "off",
|
||||||
"radix": "off",
|
"prefer-template":"off",
|
||||||
"object-curly-newline": "off"
|
"promise/always-return": "off",
|
||||||
|
"promise/catch-or-return": "off",
|
||||||
|
"promise/no-nesting": "off",
|
||||||
|
"radix": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ Repository: **<git+https://github.com/vladmandic/face-api.git>**
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
### **HEAD -> master** 2021/06/04 mandic00@live.com
|
### **update for tfjs 3.7.0** 2021/06/04 mandic00@live.com
|
||||||
|
|
||||||
|
|
||||||
### **origin/master** 2021/05/28 mandic00@live.com
|
### **origin/master** 2021/05/28 mandic00@live.com
|
||||||
|
|
63
README.md
63
README.md
|
@ -328,15 +328,23 @@ By default it starts HTTP server on port 8000 and HTTPS server on port 8001 and
|
||||||
- <https://localhost:8001/demo/webcam.html>
|
- <https://localhost:8001/demo/webcam.html>
|
||||||
|
|
||||||
```json
|
```json
|
||||||
2021-03-14 08:41:09 INFO: @vladmandic/face-api version 1.0.2
|
2021-06-04 09:15:08 INFO: @vladmandic/face-api version 1.3.0
|
||||||
2021-03-14 08:41:09 INFO: User: vlado Platform: linux Arch: x64 Node: v15.7.0
|
2021-06-04 09:15:08 INFO: User: vlado Platform: linux Arch: x64 Node: v16.0.0
|
||||||
2021-03-14 08:41:09 INFO: Build: file startup all target: es2018
|
2021-06-04 09:15:08 INFO: Build: file startup all target: es2018
|
||||||
2021-03-14 08:41:09 STATE: HTTP server listening: 8000
|
2021-06-04 09:15:08 STATE: HTTP server listening: 8000
|
||||||
2021-03-14 08:41:09 STATE: HTTP2 server listening: 8001
|
2021-06-04 09:15:08 STATE: HTTP2 server listening: 8001
|
||||||
2021-03-14 08:41:09 STATE: Monitoring: [ 'package.json', 'demo', 'src', [length]: 3 ]
|
2021-06-04 09:15:08 STATE: Build for: node type: tfjs: { imports: 1, importBytes: 143, outputBytes: 1327, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
2021-03-14 08:41:10 STATE: Build for: browserBundle type: tfjs: { modules: 1258, moduleBytes: 4040087, imports: 7, importBytes: 276, outputBytes: 1072314, outputFiles: 'dist/tfjs.esm.js' }
|
2021-06-04 09:15:08 STATE: Monitoring: [ 'package.json', 'demo', 'src', [length]: 3 ]
|
||||||
2021-03-14 08:41:10 STATE: Build for: browserBundle type: iife: { imports: 160, importBytes: 1305679, outputBytes: 1151683, outputFiles: 'dist/face-api.js' }
|
2021-06-04 09:15:08 STATE: Build for: node type: node: { imports: 162, importBytes: 234251, outputBytes: 175089, outputFiles: 'dist/face-api.node.js' }
|
||||||
2021-03-14 08:41:10 STATE: Build for: browserBundle type: esm: { imports: 160, importBytes: 1305679, outputBytes: 1151520, outputFiles: 'dist/face-api.esm.js' }
|
2021-06-04 09:15:09 STATE: Build for: nodeGPU type: tfjs: { imports: 1, importBytes: 147, outputBytes: 1335, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
|
2021-06-04 09:15:09 STATE: Build for: nodeGPU type: node: { imports: 162, importBytes: 234259, outputBytes: 175097, outputFiles: 'dist/face-api.node-gpu.js' }
|
||||||
|
2021-06-04 09:15:09 STATE: Build for: nodeCPU type: tfjs: { imports: 1, importBytes: 138, outputBytes: 1326, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
|
2021-06-04 09:15:09 STATE: Build for: nodeCPU type: node: { imports: 162, importBytes: 234250, outputBytes: 175088, outputFiles: 'dist/face-api.node-cpu.js' }
|
||||||
|
2021-06-04 09:15:09 STATE: Build for: browserNoBundle type: tfjs: { imports: 1, importBytes: 276, outputBytes: 277, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
|
2021-06-04 09:15:09 STATE: Build for: browserNoBundle type: esm: { imports: 162, importBytes: 233201, outputBytes: 168707, outputFiles: 'dist/face-api.esm-nobundle.js' }
|
||||||
|
2021-06-04 09:15:09 STATE: Build for: browserBundle type: tfjs: { modules: 1348, moduleBytes: 4323957, imports: 7, importBytes: 276, outputBytes: 2328203, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
|
2021-06-04 09:15:10 STATE: Build for: browserBundle type: iife: { imports: 162, importBytes: 2561127, outputBytes: 2448241, outputFiles: 'dist/face-api.js' }
|
||||||
|
2021-06-04 09:15:11 STATE: Build for: browserBundle type: esm: { imports: 162, importBytes: 2561127, outputBytes: 2327046, outputFiles: 'dist/face-api.esm.js' }
|
||||||
```
|
```
|
||||||
|
|
||||||
<br><hr><br>
|
<br><hr><br>
|
||||||
|
@ -372,23 +380,26 @@ Build process uses script `build.js` that creates optimized build for each targe
|
||||||
```
|
```
|
||||||
|
|
||||||
```json
|
```json
|
||||||
2021-03-14 08:39:21 INFO: @vladmandic/face-api version 1.0.2
|
2021-06-04 09:13:42 INFO: @vladmandic/face-api version 1.3.0
|
||||||
2021-03-14 08:39:21 INFO: User: vlado Platform: linux Arch: x64 Node: v15.7.0
|
2021-06-04 09:13:42 INFO: User: vlado Platform: linux Arch: x64 Node: v16.0.0
|
||||||
2021-03-14 08:39:21 INFO: Build: file startup all target: es2018
|
2021-06-04 09:13:42 INFO: Toolchain: tfjs: 3.7.0 esbuild 0.12.6; typescript 4.2.4; typedoc: 0.20.36 eslint: 7.27.0
|
||||||
2021-03-14 08:39:21 STATE: Build for: node type: tfjs: { imports: 1, importBytes: 143, outputBytes: 731, outputFiles: 'dist/tfjs.esm.js' }
|
2021-06-04 09:13:42 INFO: Build: file startup all target: es2018
|
||||||
2021-03-14 08:39:21 STATE: Build for: node type: node: { imports: 160, importBytes: 234096, outputBytes: 85371, outputFiles: 'dist/face-api.node.js' }
|
2021-06-04 09:13:42 STATE: Build for: node type: tfjs: { imports: 1, importBytes: 143, outputBytes: 1327, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
2021-03-14 08:39:21 STATE: Build for: nodeGPU type: tfjs: { imports: 1, importBytes: 147, outputBytes: 735, outputFiles: 'dist/tfjs.esm.js' }
|
2021-06-04 09:13:42 STATE: Build for: node type: node: { imports: 162, importBytes: 234251, outputBytes: 175089, outputFiles: 'dist/face-api.node.js' }
|
||||||
2021-03-14 08:39:21 STATE: Build for: nodeGPU type: node: { imports: 160, importBytes: 234100, outputBytes: 85379, outputFiles: 'dist/face-api.node-gpu.js' }
|
2021-06-04 09:13:42 STATE: Build for: nodeGPU type: tfjs: { imports: 1, importBytes: 147, outputBytes: 1335, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
2021-03-14 08:39:21 STATE: Build for: nodeCPU type: tfjs: { imports: 1, importBytes: 138, outputBytes: 726, outputFiles: 'dist/tfjs.esm.js' }
|
2021-06-04 09:13:42 STATE: Build for: nodeGPU type: node: { imports: 162, importBytes: 234259, outputBytes: 175097, outputFiles: 'dist/face-api.node-gpu.js' }
|
||||||
2021-03-14 08:39:21 STATE: Build for: nodeCPU type: node: { imports: 160, importBytes: 234091, outputBytes: 85370, outputFiles: 'dist/face-api.node-cpu.js' }
|
2021-06-04 09:13:42 STATE: Build for: nodeCPU type: tfjs: { imports: 1, importBytes: 138, outputBytes: 1326, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
2021-03-14 08:39:21 STATE: Build for: browserNoBundle type: tfjs: { imports: 1, importBytes: 276, outputBytes: 244, outputFiles: 'dist/tfjs.esm.js' }
|
2021-06-04 09:13:42 STATE: Build for: nodeCPU type: node: { imports: 162, importBytes: 234250, outputBytes: 175088, outputFiles: 'dist/face-api.node-cpu.js' }
|
||||||
2021-03-14 08:39:21 STATE: Build for: browserNoBundle type: esm: { imports: 160, importBytes: 233609, outputBytes: 82634, outputFiles: 'dist/face-api.esm-nobundle.js' }
|
2021-06-04 09:13:42 STATE: Build for: browserNoBundle type: tfjs: { imports: 1, importBytes: 276, outputBytes: 277, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
2021-03-14 08:39:22 STATE: Build for: browserBundle type: tfjs: { modules: 1258, moduleBytes: 4040087, imports: 7, importBytes: 276, outputBytes: 1072314, outputFiles: 'dist/tfjs.esm.js' }
|
2021-06-04 09:13:42 STATE: Build for: browserNoBundle type: esm: { imports: 162, importBytes: 233201, outputBytes: 168707, outputFiles: 'dist/face-api.esm-nobundle.js' }
|
||||||
2021-03-14 08:39:22 STATE: Build for: browserBundle type: iife: { imports: 160, importBytes: 1305679, outputBytes: 1151683, outputFiles: 'dist/face-api.js' }
|
2021-06-04 09:13:43 STATE: Build for: browserBundle type: tfjs: { modules: 1348, moduleBytes: 4323957, imports: 7, importBytes: 276, outputBytes: 2328203, outputFiles: 'dist/tfjs.esm.js' }
|
||||||
2021-03-14 08:39:22 STATE: Build for: browserBundle type: esm: { imports: 160, importBytes: 1305679, outputBytes: 1151520, outputFiles: 'dist/face-api.esm.js' }
|
2021-06-04 09:13:44 STATE: Build for: browserBundle type: iife: { imports: 162, importBytes: 2561127, outputBytes: 2448241, outputFiles: 'dist/face-api.js' }
|
||||||
2021-03-14 08:39:22 INFO: Compile typings: [ 'src/index.ts', [length]: 1 ]
|
2021-06-04 09:13:45 STATE: Build for: browserBundle type: esm: { imports: 162, importBytes: 2561127, outputBytes: 2327046, outputFiles: 'dist/face-api.esm.js' }
|
||||||
2021-03-14 08:39:27 INFO: Update Change log: [ '/home/vlado/dev/face-api/CHANGELOG.md', [length]: 1 ]
|
2021-06-04 09:13:45 INFO: Running Linter: [ 'server/', 'demo/', 'src/', 'test/', [length]: 4 ]
|
||||||
2021-03-14 08:39:27 INFO: Generate TypeDocs: [ 'src/index.ts', [length]: 1 ]
|
2021-06-04 09:14:10 INFO: Linter complete: files: 183 errors: 0 warnings: 0
|
||||||
|
2021-06-04 09:14:10 INFO: Compile typings: [ 'src/index.ts', [length]: 1 ]
|
||||||
|
2021-06-04 09:14:15 INFO: Update Change log: [ '/home/vlado/dev/face-api/CHANGELOG.md', [length]: 1 ]
|
||||||
|
2021-06-04 09:14:15 INFO: Generate TypeDocs: [ 'src/index.ts', [length]: 1 ]
|
||||||
```
|
```
|
||||||
|
|
||||||
<br><hr><br>
|
<br><hr><br>
|
||||||
|
|
|
@ -5,7 +5,7 @@ const process = require('process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
||||||
const log = require('@vladmandic/pilogger');
|
const log = require('@vladmandic/pilogger');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require, no-unused-vars
|
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require, no-unused-vars, @typescript-eslint/no-unused-vars
|
||||||
const tf = require('@tensorflow/tfjs-node');
|
const tf = require('@tensorflow/tfjs-node');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
||||||
const canvas = require('canvas');
|
const canvas = require('canvas');
|
||||||
|
|
|
@ -5,7 +5,7 @@ const process = require('process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
||||||
const log = require('@vladmandic/pilogger');
|
const log = require('@vladmandic/pilogger');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require, no-unused-vars
|
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require, no-unused-vars, @typescript-eslint/no-unused-vars
|
||||||
const tf = require('@tensorflow/tfjs');
|
const tf = require('@tensorflow/tfjs');
|
||||||
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require
|
||||||
require('@tensorflow/tfjs-backend-wasm');
|
require('@tensorflow/tfjs-backend-wasm');
|
||||||
|
|
|
@ -63,7 +63,7 @@ async function detect(tensor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
||||||
function detectPromise(tensor) {
|
function detectPromise(tensor) {
|
||||||
return new Promise((resolve) => faceapi
|
return new Promise((resolve) => faceapi
|
||||||
.detectAllFaces(tensor, optionsSSDMobileNet)
|
.detectAllFaces(tensor, optionsSSDMobileNet)
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -25,7 +25,8 @@
|
||||||
"dev": "node --trace-warnings server/serve.js",
|
"dev": "node --trace-warnings server/serve.js",
|
||||||
"build": "rimraf dist/* types/* typedoc/* && node server/build.js",
|
"build": "rimraf dist/* types/* typedoc/* && node server/build.js",
|
||||||
"lint": "eslint src/**/* demo/*.js server/*.js",
|
"lint": "eslint src/**/* demo/*.js server/*.js",
|
||||||
"test": "node --trace-warnings test/test-node.js"
|
"test": "node --trace-warnings test/test-node.js",
|
||||||
|
"scan": "npx auditjs@latest ossi --dev --quiet"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"face-api",
|
"face-api",
|
||||||
|
|
|
@ -5,6 +5,8 @@ const esbuild = require('esbuild');
|
||||||
const ts = require('typescript');
|
const ts = require('typescript');
|
||||||
const log = require('@vladmandic/pilogger');
|
const log = require('@vladmandic/pilogger');
|
||||||
const TypeDoc = require('typedoc');
|
const TypeDoc = require('typedoc');
|
||||||
|
const { ESLint } = require('eslint');
|
||||||
|
const tfjs = require('@tensorflow/tfjs/package.json');
|
||||||
const changelog = require('./changelog');
|
const changelog = require('./changelog');
|
||||||
|
|
||||||
const banner = { js: `
|
const banner = { js: `
|
||||||
|
@ -16,6 +18,7 @@ const banner = { js: `
|
||||||
` };
|
` };
|
||||||
|
|
||||||
let td = null;
|
let td = null;
|
||||||
|
let eslint = null;
|
||||||
|
|
||||||
// tsc configuration
|
// tsc configuration
|
||||||
const tsconfig = {
|
const tsconfig = {
|
||||||
|
@ -36,6 +39,9 @@ const tsconfig = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// common configuration
|
||||||
|
const lintLocations = ['server/', 'demo/', 'src/', 'test/'];
|
||||||
|
|
||||||
// common configuration
|
// common configuration
|
||||||
const common = {
|
const common = {
|
||||||
banner,
|
banner,
|
||||||
|
@ -165,7 +171,7 @@ async function getStats(json) {
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compile(fileNames, options) {
|
function typings(fileNames, options) {
|
||||||
log.info('Compile typings:', fileNames);
|
log.info('Compile typings:', fileNames);
|
||||||
const program = ts.createProgram(fileNames, options);
|
const program = ts.createProgram(fileNames, options);
|
||||||
const emit = program.emit();
|
const emit = program.emit();
|
||||||
|
@ -186,6 +192,22 @@ function compile(fileNames, options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function lint() {
|
||||||
|
log.info('Running Linter:', lintLocations);
|
||||||
|
if (!eslint) {
|
||||||
|
eslint = new ESLint();
|
||||||
|
}
|
||||||
|
const results = await eslint.lintFiles(lintLocations);
|
||||||
|
const errors = results.reduce((prev, curr) => prev += curr.errorCount, 0);
|
||||||
|
const warnings = results.reduce((prev, curr) => prev += curr.warningCount, 0);
|
||||||
|
log.info('Linter complete: files:', results.length, 'errors:', errors, 'warnings:', warnings);
|
||||||
|
if (errors > 0 || warnings > 0) {
|
||||||
|
const formatter = await eslint.loadFormatter('stylish');
|
||||||
|
const text = formatter.format(results);
|
||||||
|
log.warn(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function typedoc(entryPoint) {
|
async function typedoc(entryPoint) {
|
||||||
log.info('Generate TypeDocs:', entryPoint);
|
log.info('Generate TypeDocs:', entryPoint);
|
||||||
if (!td) {
|
if (!td) {
|
||||||
|
@ -219,11 +241,11 @@ async function build(f, msg, dev = false) {
|
||||||
if (require.main === module) process.exit(1);
|
if (require.main === module) process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dev) {
|
if (!dev) { // only for prod builds, skipped for dev build
|
||||||
// generate typings & typedoc only when run as explict build
|
await lint(); // run linter
|
||||||
await compile(targets.browserBundle.esm.entryPoints, tsconfig);
|
await typings(targets.browserBundle.esm.entryPoints, tsconfig); // generate typings
|
||||||
await changelog.update('../CHANGELOG.md');
|
await changelog.update('../CHANGELOG.md'); // generate changelog
|
||||||
await typedoc(targets.browserBundle.esm.entryPoints);
|
await typedoc(targets.browserBundle.esm.entryPoints); // generate typedoc
|
||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) process.exit(0);
|
if (require.main === module) process.exit(0);
|
||||||
|
@ -231,6 +253,7 @@ async function build(f, msg, dev = false) {
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
log.header();
|
log.header();
|
||||||
|
log.info(`Toolchain: tfjs: ${tfjs.version} esbuild ${esbuild.version}; typescript ${ts.version}; typedoc: ${TypeDoc.Application.VERSION} eslint: ${ESLint.version}`);
|
||||||
build('all', 'startup');
|
build('all', 'startup');
|
||||||
} else {
|
} else {
|
||||||
exports.build = build;
|
exports.build = build;
|
||||||
|
|
|
@ -62,7 +62,7 @@ export abstract class NeuralNetwork<TNetParams> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public dispose(throwOnRedispose: boolean = true) {
|
public dispose(throwOnRedispose = true) {
|
||||||
this.getParamList().forEach((param) => {
|
this.getParamList().forEach((param) => {
|
||||||
if (throwOnRedispose && param.tensor.isDisposed) {
|
if (throwOnRedispose && param.tensor.isDisposed) {
|
||||||
throw new Error(`param tensor has already been disposed for path ${param.path}`);
|
throw new Error(`param tensor has already been disposed for path ${param.path}`);
|
||||||
|
|
|
@ -85,7 +85,7 @@ export class AgeGenderNet extends NeuralNetwork<NetParams> {
|
||||||
return 'age_gender_model';
|
return 'age_gender_model';
|
||||||
}
|
}
|
||||||
|
|
||||||
public dispose(throwOnRedispose: boolean = true) {
|
public dispose(throwOnRedispose = true) {
|
||||||
this.faceFeatureExtractor.dispose(throwOnRedispose);
|
this.faceFeatureExtractor.dispose(throwOnRedispose);
|
||||||
super.dispose(throwOnRedispose);
|
super.dispose(throwOnRedispose);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ export interface IBoundingBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BoundingBox extends Box<BoundingBox> implements IBoundingBox {
|
export class BoundingBox extends Box<BoundingBox> implements IBoundingBox {
|
||||||
constructor(left: number, top: number, right: number, bottom: number, allowNegativeDimensions: boolean = false) {
|
constructor(left: number, top: number, right: number, bottom: number, allowNegativeDimensions = false) {
|
||||||
super({
|
super({
|
||||||
left, top, right, bottom,
|
left, top, right, bottom,
|
||||||
}, allowNegativeDimensions);
|
}, allowNegativeDimensions);
|
||||||
|
|
|
@ -9,7 +9,7 @@ export class Box<BoxType = any> implements IBoundingBox, IRect {
|
||||||
return !!rect && [rect.x, rect.y, rect.width, rect.height].every(isValidNumber);
|
return !!rect && [rect.x, rect.y, rect.width, rect.height].every(isValidNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static assertIsValidBox(box: any, callee: string, allowNegativeDimensions: boolean = false) {
|
public static assertIsValidBox(box: any, callee: string, allowNegativeDimensions = false) {
|
||||||
if (!Box.isRect(box)) {
|
if (!Box.isRect(box)) {
|
||||||
throw new Error(`${callee} - invalid box: ${JSON.stringify(box)}, expected object with properties x, y, width, height`);
|
throw new Error(`${callee} - invalid box: ${JSON.stringify(box)}, expected object with properties x, y, width, height`);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ export class Box<BoxType = any> implements IBoundingBox, IRect {
|
||||||
|
|
||||||
private _height: number
|
private _height: number
|
||||||
|
|
||||||
constructor(_box: IBoundingBox | IRect, allowNegativeDimensions: boolean = true) {
|
constructor(_box: IBoundingBox | IRect, allowNegativeDimensions = true) {
|
||||||
const box = (_box || {}) as any;
|
const box = (_box || {}) as any;
|
||||||
|
|
||||||
const isBbox = [box.left, box.top, box.right, box.bottom].every(isValidNumber);
|
const isBbox = [box.left, box.top, box.right, box.bottom].every(isValidNumber);
|
||||||
|
|
|
@ -19,7 +19,7 @@ export class FaceMatch implements IFaceMatch {
|
||||||
|
|
||||||
public get distance(): number { return this._distance; }
|
public get distance(): number { return this._distance; }
|
||||||
|
|
||||||
public toString(withDistance: boolean = true): string {
|
public toString(withDistance = true): string {
|
||||||
return `${this.label}${withDistance ? ` (${round(this.distance)})` : ''}`;
|
return `${this.label}${withDistance ? ` (${round(this.distance)})` : ''}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ export interface IRect {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Rect extends Box<Rect> implements IRect {
|
export class Rect extends Box<Rect> implements IRect {
|
||||||
constructor(x: number, y: number, width: number, height: number, allowNegativeDimensions: boolean = false) {
|
constructor(x: number, y: number, width: number, height: number, allowNegativeDimensions = false) {
|
||||||
super({
|
super({
|
||||||
x, y, width, height,
|
x, y, width, height,
|
||||||
}, allowNegativeDimensions);
|
}, allowNegativeDimensions);
|
||||||
|
|
|
@ -6,7 +6,7 @@ export function convLayer(
|
||||||
x: tf.Tensor4D,
|
x: tf.Tensor4D,
|
||||||
params: ConvParams,
|
params: ConvParams,
|
||||||
padding: 'valid' | 'same' = 'same',
|
padding: 'valid' | 'same' = 'same',
|
||||||
withRelu: boolean = false,
|
withRelu = false,
|
||||||
): tf.Tensor4D {
|
): tf.Tensor4D {
|
||||||
return tf.tidy(() => {
|
return tf.tidy(() => {
|
||||||
const out = tf.add(
|
const out = tf.add(
|
||||||
|
|
|
@ -15,13 +15,13 @@ export class NetInput {
|
||||||
|
|
||||||
private _batchSize: number
|
private _batchSize: number
|
||||||
|
|
||||||
private _treatAsBatchInput: boolean = false
|
private _treatAsBatchInput = false
|
||||||
|
|
||||||
private _inputDimensions: number[][] = []
|
private _inputDimensions: number[][] = []
|
||||||
|
|
||||||
private _inputSize: number
|
private _inputSize: number
|
||||||
|
|
||||||
constructor(inputs: Array<TResolvedNetInput>, treatAsBatchInput: boolean = false) {
|
constructor(inputs: Array<TResolvedNetInput>, treatAsBatchInput = false) {
|
||||||
if (!Array.isArray(inputs)) {
|
if (!Array.isArray(inputs)) {
|
||||||
throw new Error(`NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have ${inputs}`);
|
throw new Error(`NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have ${inputs}`);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ export class NetInput {
|
||||||
* both sides of the minor dimension oof the image.
|
* both sides of the minor dimension oof the image.
|
||||||
* @returns The batch tensor.
|
* @returns The batch tensor.
|
||||||
*/
|
*/
|
||||||
public toBatchTensor(inputSize: number, isCenterInputs: boolean = true): tf.Tensor4D {
|
public toBatchTensor(inputSize: number, isCenterInputs = true): tf.Tensor4D {
|
||||||
this._inputSize = inputSize;
|
this._inputSize = inputSize;
|
||||||
|
|
||||||
return tf.tidy(() => {
|
return tf.tidy(() => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { createCanvas, createCanvasFromMedia } from './createCanvas';
|
||||||
import { getContext2dOrThrow } from './getContext2dOrThrow';
|
import { getContext2dOrThrow } from './getContext2dOrThrow';
|
||||||
import { getMediaDimensions } from './getMediaDimensions';
|
import { getMediaDimensions } from './getMediaDimensions';
|
||||||
|
|
||||||
export function imageToSquare(input: HTMLImageElement | HTMLCanvasElement, inputSize: number, centerImage: boolean = false) {
|
export function imageToSquare(input: HTMLImageElement | HTMLCanvasElement, inputSize: number, centerImage = false) {
|
||||||
const { Image, Canvas } = env.getEnv();
|
const { Image, Canvas } = env.getEnv();
|
||||||
|
|
||||||
if (!(input instanceof Image || input instanceof Canvas)) {
|
if (!(input instanceof Image || input instanceof Canvas)) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { IDimensions } from '../classes/index';
|
import { IDimensions } from '../classes/index';
|
||||||
import { getMediaDimensions } from './getMediaDimensions';
|
import { getMediaDimensions } from './getMediaDimensions';
|
||||||
|
|
||||||
export function matchDimensions(input: IDimensions, reference: IDimensions, useMediaDimensions: boolean = false) {
|
export function matchDimensions(input: IDimensions, reference: IDimensions, useMediaDimensions = false) {
|
||||||
const { width, height } = useMediaDimensions
|
const { width, height } = useMediaDimensions
|
||||||
? getMediaDimensions(reference)
|
? getMediaDimensions(reference)
|
||||||
: reference;
|
: reference;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Point } from '../classes/index';
|
||||||
export function drawContour(
|
export function drawContour(
|
||||||
ctx: CanvasRenderingContext2D,
|
ctx: CanvasRenderingContext2D,
|
||||||
points: Point[],
|
points: Point[],
|
||||||
isClosed: boolean = false,
|
isClosed = false,
|
||||||
) {
|
) {
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { DenseBlock3Params, DenseBlock4Params } from './types';
|
||||||
export function denseBlock3(
|
export function denseBlock3(
|
||||||
x: tf.Tensor4D,
|
x: tf.Tensor4D,
|
||||||
denseBlockParams: DenseBlock3Params,
|
denseBlockParams: DenseBlock3Params,
|
||||||
isFirstLayer: boolean = false,
|
isFirstLayer = false,
|
||||||
): tf.Tensor4D {
|
): tf.Tensor4D {
|
||||||
return tf.tidy(() => {
|
return tf.tidy(() => {
|
||||||
const out1 = tf.relu(
|
const out1 = tf.relu(
|
||||||
|
@ -30,8 +30,8 @@ export function denseBlock3(
|
||||||
export function denseBlock4(
|
export function denseBlock4(
|
||||||
x: tf.Tensor4D,
|
x: tf.Tensor4D,
|
||||||
denseBlockParams: DenseBlock4Params,
|
denseBlockParams: DenseBlock4Params,
|
||||||
isFirstLayer: boolean = false,
|
isFirstLayer = false,
|
||||||
isScaleDown: boolean = true,
|
isScaleDown = true,
|
||||||
): tf.Tensor4D {
|
): tf.Tensor4D {
|
||||||
return tf.tidy(() => {
|
return tf.tidy(() => {
|
||||||
const out1 = tf.relu(
|
const out1 = tf.relu(
|
||||||
|
|
|
@ -5,7 +5,7 @@ export function extractorsFactory(extractWeights: ExtractWeightsFunction, paramM
|
||||||
const extractConvParams = extractConvParamsFactory(extractWeights, paramMappings);
|
const extractConvParams = extractConvParamsFactory(extractWeights, paramMappings);
|
||||||
const extractSeparableConvParams = extractSeparableConvParamsFactory(extractWeights, paramMappings);
|
const extractSeparableConvParams = extractSeparableConvParamsFactory(extractWeights, paramMappings);
|
||||||
|
|
||||||
function extractDenseBlock3Params(channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer: boolean = false): DenseBlock3Params {
|
function extractDenseBlock3Params(channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer = false): DenseBlock3Params {
|
||||||
const conv0 = isFirstLayer
|
const conv0 = isFirstLayer
|
||||||
? extractConvParams(channelsIn, channelsOut, 3, `${mappedPrefix}/conv0`)
|
? extractConvParams(channelsIn, channelsOut, 3, `${mappedPrefix}/conv0`)
|
||||||
: extractSeparableConvParams(channelsIn, channelsOut, `${mappedPrefix}/conv0`);
|
: extractSeparableConvParams(channelsIn, channelsOut, `${mappedPrefix}/conv0`);
|
||||||
|
@ -15,7 +15,7 @@ export function extractorsFactory(extractWeights: ExtractWeightsFunction, paramM
|
||||||
return { conv0, conv1, conv2 };
|
return { conv0, conv1, conv2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractDenseBlock4Params(channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer: boolean = false): DenseBlock4Params {
|
function extractDenseBlock4Params(channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer = false): DenseBlock4Params {
|
||||||
const { conv0, conv1, conv2 } = extractDenseBlock3Params(channelsIn, channelsOut, mappedPrefix, isFirstLayer);
|
const { conv0, conv1, conv2 } = extractDenseBlock3Params(channelsIn, channelsOut, mappedPrefix, isFirstLayer);
|
||||||
const conv3 = extractSeparableConvParams(channelsOut, channelsOut, `${mappedPrefix}/conv3`);
|
const conv3 = extractSeparableConvParams(channelsOut, channelsOut, `${mappedPrefix}/conv3`);
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ export function loadParamsFactory(weightMap: any, paramMappings: ParamMapping[])
|
||||||
const extractConvParams = loadConvParamsFactory(extractWeightEntry);
|
const extractConvParams = loadConvParamsFactory(extractWeightEntry);
|
||||||
const extractSeparableConvParams = loadSeparableConvParamsFactory(extractWeightEntry);
|
const extractSeparableConvParams = loadSeparableConvParamsFactory(extractWeightEntry);
|
||||||
|
|
||||||
function extractDenseBlock3Params(prefix: string, isFirstLayer: boolean = false): DenseBlock3Params {
|
function extractDenseBlock3Params(prefix: string, isFirstLayer = false): DenseBlock3Params {
|
||||||
const conv0 = isFirstLayer
|
const conv0 = isFirstLayer
|
||||||
? extractConvParams(`${prefix}/conv0`)
|
? extractConvParams(`${prefix}/conv0`)
|
||||||
: extractSeparableConvParams(`${prefix}/conv0`);
|
: extractSeparableConvParams(`${prefix}/conv0`);
|
||||||
|
@ -18,7 +18,7 @@ export function loadParamsFactory(weightMap: any, paramMappings: ParamMapping[])
|
||||||
return { conv0, conv1, conv2 };
|
return { conv0, conv1, conv2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractDenseBlock4Params(prefix: string, isFirstLayer: boolean = false): DenseBlock4Params {
|
function extractDenseBlock4Params(prefix: string, isFirstLayer = false): DenseBlock4Params {
|
||||||
const conv0 = isFirstLayer
|
const conv0 = isFirstLayer
|
||||||
? extractConvParams(`${prefix}/conv0`)
|
? extractConvParams(`${prefix}/conv0`)
|
||||||
: extractSeparableConvParams(`${prefix}/conv0`);
|
: extractSeparableConvParams(`${prefix}/conv0`);
|
||||||
|
|
|
@ -45,7 +45,7 @@ export abstract class FaceProcessor<
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public dispose(throwOnRedispose: boolean = true) {
|
public dispose(throwOnRedispose = true) {
|
||||||
this.faceFeatureExtractor.dispose(throwOnRedispose);
|
this.faceFeatureExtractor.dispose(throwOnRedispose);
|
||||||
super.dispose(throwOnRedispose);
|
super.dispose(throwOnRedispose);
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ function extractorsFactory(extractWeights: ExtractWeightsFunction, paramMappings
|
||||||
numFilters: number,
|
numFilters: number,
|
||||||
filterSize: number,
|
filterSize: number,
|
||||||
mappedPrefix: string,
|
mappedPrefix: string,
|
||||||
isDown: boolean = false,
|
isDown = false,
|
||||||
): ResidualLayerParams {
|
): ResidualLayerParams {
|
||||||
const conv1 = extractConvLayerParams((isDown ? 0.5 : 1) * numFilterValues, numFilters, filterSize, `${mappedPrefix}/conv1`);
|
const conv1 = extractConvLayerParams((isDown ? 0.5 : 1) * numFilterValues, numFilters, filterSize, `${mappedPrefix}/conv1`);
|
||||||
const conv2 = extractConvLayerParams(numFilterValues, numFilters, filterSize, `${mappedPrefix}/conv2`);
|
const conv2 = extractConvLayerParams(numFilterValues, numFilters, filterSize, `${mappedPrefix}/conv2`);
|
||||||
|
|
|
@ -38,7 +38,7 @@ export class DetectAllFacesTask extends DetectFacesTaskBase<FaceDetection[]> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
withFaceLandmarks(useTinyLandmarkNet: boolean = false) {
|
withFaceLandmarks(useTinyLandmarkNet = false) {
|
||||||
return new DetectAllFaceLandmarksTask(
|
return new DetectAllFaceLandmarksTask(
|
||||||
this.runAndExtendWithFaceDetections(),
|
this.runAndExtendWithFaceDetections(),
|
||||||
this.input,
|
this.input,
|
||||||
|
@ -79,7 +79,7 @@ export class DetectSingleFaceTask extends DetectFacesTaskBase<FaceDetection | un
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
withFaceLandmarks(useTinyLandmarkNet: boolean = false) {
|
withFaceLandmarks(useTinyLandmarkNet = false) {
|
||||||
return new DetectSingleFaceLandmarksTask(
|
return new DetectSingleFaceLandmarksTask(
|
||||||
this.runAndExtendWithFaceDetection(),
|
this.runAndExtendWithFaceDetection(),
|
||||||
this.input,
|
this.input,
|
||||||
|
|
|
@ -10,7 +10,7 @@ export class FaceMatcher {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
inputs: LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>,
|
inputs: LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>,
|
||||||
distanceThreshold: number = 0.6,
|
distanceThreshold = 0.6,
|
||||||
) {
|
) {
|
||||||
this._distanceThreshold = distanceThreshold;
|
this._distanceThreshold = distanceThreshold;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Box } from '../classes/Box';
|
import { Box } from '../classes/Box';
|
||||||
|
|
||||||
export function iou(box1: Box, box2: Box, isIOU: boolean = true) {
|
export function iou(box1: Box, box2: Box, isIOU = true) {
|
||||||
const width = Math.max(0.0, Math.min(box1.right, box2.right) - Math.max(box1.left, box2.left));
|
const width = Math.max(0.0, Math.min(box1.right, box2.right) - Math.max(box1.left, box2.left));
|
||||||
const height = Math.max(0.0, Math.min(box1.bottom, box2.bottom) - Math.max(box1.top, box2.top));
|
const height = Math.max(0.0, Math.min(box1.bottom, box2.bottom) - Math.max(box1.top, box2.top));
|
||||||
const interSection = width * height;
|
const interSection = width * height;
|
||||||
|
|
|
@ -5,7 +5,7 @@ export function nonMaxSuppression(
|
||||||
boxes: Box[],
|
boxes: Box[],
|
||||||
scores: number[],
|
scores: number[],
|
||||||
iouThreshold: number,
|
iouThreshold: number,
|
||||||
isIOU: boolean = true,
|
isIOU = true,
|
||||||
): number[] {
|
): number[] {
|
||||||
let indicesSortedByScore = scores
|
let indicesSortedByScore = scores
|
||||||
.map((score, boxIndex) => ({ score, boxIndex }))
|
.map((score, boxIndex) => ({ score, boxIndex }))
|
||||||
|
|
|
@ -10,7 +10,7 @@ import * as tf from '../../dist/tfjs.esm';
|
||||||
*/
|
*/
|
||||||
export function padToSquare(
|
export function padToSquare(
|
||||||
imgTensor: tf.Tensor4D,
|
imgTensor: tf.Tensor4D,
|
||||||
isCenterImage: boolean = false,
|
isCenterImage = false,
|
||||||
): tf.Tensor4D {
|
): tf.Tensor4D {
|
||||||
return tf.tidy(() => {
|
return tf.tidy(() => {
|
||||||
const [height, width] = imgTensor.shape.slice(1);
|
const [height, width] = imgTensor.shape.slice(1);
|
||||||
|
|
|
@ -4,7 +4,7 @@ export interface ISsdMobilenetv1Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SsdMobilenetv1Options {
|
export class SsdMobilenetv1Options {
|
||||||
protected _name: string = 'SsdMobilenetv1Options'
|
protected _name = 'SsdMobilenetv1Options'
|
||||||
|
|
||||||
private _minConfidence: number
|
private _minConfidence: number
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ export type PointwiseConvParams = {
|
||||||
batch_norm_offset: tf.Tensor1D
|
batch_norm_offset: tf.Tensor1D
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||||
export namespace MobileNetV1 {
|
export namespace MobileNetV1 {
|
||||||
|
|
||||||
export type DepthwiseConvParams = {
|
export type DepthwiseConvParams = {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { ITinyYolov2Options, TinyYolov2Options } from '../tinyYolov2/index';
|
import { ITinyYolov2Options, TinyYolov2Options } from '../tinyYolov2/index';
|
||||||
|
|
||||||
export interface ITinyFaceDetectorOptions extends ITinyYolov2Options {}
|
export type ITinyFaceDetectorOptions = ITinyYolov2Options
|
||||||
|
|
||||||
export class TinyFaceDetectorOptions extends TinyYolov2Options {
|
export class TinyFaceDetectorOptions extends TinyYolov2Options {
|
||||||
protected _name: string = 'TinyFaceDetectorOptions'
|
protected _name = 'TinyFaceDetectorOptions'
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { ITinyYolov2Options } from './TinyYolov2Options';
|
||||||
import { TinyYolov2NetParams } from './types';
|
import { TinyYolov2NetParams } from './types';
|
||||||
|
|
||||||
export class TinyYolov2 extends TinyYolov2Base {
|
export class TinyYolov2 extends TinyYolov2Base {
|
||||||
constructor(withSeparableConvs: boolean = true) {
|
constructor(withSeparableConvs = true) {
|
||||||
const config = {
|
const config = {
|
||||||
withSeparableConvs,
|
withSeparableConvs,
|
||||||
iouThreshold: IOU_THRESHOLD,
|
iouThreshold: IOU_THRESHOLD,
|
||||||
|
|
|
@ -4,7 +4,7 @@ export interface ITinyYolov2Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TinyYolov2Options {
|
export class TinyYolov2Options {
|
||||||
protected _name: string = 'TinyYolov2Options'
|
protected _name = 'TinyYolov2Options'
|
||||||
|
|
||||||
private _inputSize: number
|
private _inputSize: number
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ export * from './config';
|
||||||
export * from './types';
|
export * from './types';
|
||||||
export { TinyYolov2 };
|
export { TinyYolov2 };
|
||||||
|
|
||||||
export function createTinyYolov2(weights: Float32Array, withSeparableConvs: boolean = true) {
|
export function createTinyYolov2(weights: Float32Array, withSeparableConvs = true) {
|
||||||
const net = new TinyYolov2(withSeparableConvs);
|
const net = new TinyYolov2(withSeparableConvs);
|
||||||
net.extractWeights(weights);
|
net.extractWeights(weights);
|
||||||
return net;
|
return net;
|
||||||
|
|
|
@ -31,7 +31,7 @@ export function isEven(num: number) {
|
||||||
return num % 2 === 0;
|
return num % 2 === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function round(num: number, prec: number = 2) {
|
export function round(num: number, prec = 2) {
|
||||||
const f = 10 ** prec;
|
const f = 10 ** prec;
|
||||||
return Math.floor(num * f) / f;
|
return Math.floor(num * f) / f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ function conv(x: tf.Tensor4D, params: ConvParams, stride: [number, number]): tf.
|
||||||
return tf.add(tf.conv2d(x, params.filters, stride, 'same'), params.bias);
|
return tf.add(tf.conv2d(x, params.filters, stride, 'same'), params.bias);
|
||||||
}
|
}
|
||||||
|
|
||||||
function reductionBlock(x: tf.Tensor4D, params: ReductionBlockParams, isActivateInput: boolean = true): tf.Tensor4D {
|
function reductionBlock(x: tf.Tensor4D, params: ReductionBlockParams, isActivateInput = true): tf.Tensor4D {
|
||||||
let out = isActivateInput ? tf.relu(x) : x;
|
let out = isActivateInput ? tf.relu(x) : x;
|
||||||
out = depthwiseSeparableConv(out, params.separable_conv0, [1, 1]);
|
out = depthwiseSeparableConv(out, params.separable_conv0, [1, 1]);
|
||||||
out = depthwiseSeparableConv(tf.relu(out), params.separable_conv1, [1, 1]);
|
out = depthwiseSeparableConv(tf.relu(out), params.separable_conv1, [1, 1]);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -129,7 +129,6 @@
|
||||||
<li class="tsd-kind-interface"><a href="interfaces/ipoint.html" class="tsd-kind-icon">IPoint</a></li>
|
<li class="tsd-kind-interface"><a href="interfaces/ipoint.html" class="tsd-kind-icon">IPoint</a></li>
|
||||||
<li class="tsd-kind-interface"><a href="interfaces/irect.html" class="tsd-kind-icon">IRect</a></li>
|
<li class="tsd-kind-interface"><a href="interfaces/irect.html" class="tsd-kind-icon">IRect</a></li>
|
||||||
<li class="tsd-kind-interface"><a href="interfaces/issdmobilenetv1options.html" class="tsd-kind-icon">ISsd<wbr>Mobilenetv1<wbr>Options</a></li>
|
<li class="tsd-kind-interface"><a href="interfaces/issdmobilenetv1options.html" class="tsd-kind-icon">ISsd<wbr>Mobilenetv1<wbr>Options</a></li>
|
||||||
<li class="tsd-kind-interface"><a href="interfaces/itinyfacedetectoroptions.html" class="tsd-kind-icon">ITiny<wbr>Face<wbr>Detector<wbr>Options</a></li>
|
|
||||||
<li class="tsd-kind-interface"><a href="interfaces/itinyyolov2options.html" class="tsd-kind-icon">ITiny<wbr>Yolov2<wbr>Options</a></li>
|
<li class="tsd-kind-interface"><a href="interfaces/itinyyolov2options.html" class="tsd-kind-icon">ITiny<wbr>Yolov2<wbr>Options</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
@ -144,6 +143,7 @@
|
||||||
<li class="tsd-kind-type-alias"><a href="index.html#facedetectionfunction" class="tsd-kind-icon">Face<wbr>Detection<wbr>Function</a></li>
|
<li class="tsd-kind-type-alias"><a href="index.html#facedetectionfunction" class="tsd-kind-icon">Face<wbr>Detection<wbr>Function</a></li>
|
||||||
<li class="tsd-kind-type-alias"><a href="index.html#facedetectionoptions" class="tsd-kind-icon">Face<wbr>Detection<wbr>Options</a></li>
|
<li class="tsd-kind-type-alias"><a href="index.html#facedetectionoptions" class="tsd-kind-icon">Face<wbr>Detection<wbr>Options</a></li>
|
||||||
<li class="tsd-kind-type-alias"><a href="index.html#filesystem" class="tsd-kind-icon">File<wbr>System</a></li>
|
<li class="tsd-kind-type-alias"><a href="index.html#filesystem" class="tsd-kind-icon">File<wbr>System</a></li>
|
||||||
|
<li class="tsd-kind-type-alias"><a href="index.html#itinyfacedetectoroptions" class="tsd-kind-icon">ITiny<wbr>Face<wbr>Detector<wbr>Options</a></li>
|
||||||
<li class="tsd-kind-type-alias"><a href="index.html#mobilenetparams" class="tsd-kind-icon">Mobilenet<wbr>Params</a></li>
|
<li class="tsd-kind-type-alias"><a href="index.html#mobilenetparams" class="tsd-kind-icon">Mobilenet<wbr>Params</a></li>
|
||||||
<li class="tsd-kind-type-alias"><a href="index.html#netoutput" class="tsd-kind-icon">Net<wbr>Output</a></li>
|
<li class="tsd-kind-type-alias"><a href="index.html#netoutput" class="tsd-kind-icon">Net<wbr>Output</a></li>
|
||||||
<li class="tsd-kind-type-alias"><a href="index.html#netparams" class="tsd-kind-icon">Net<wbr>Params</a></li>
|
<li class="tsd-kind-type-alias"><a href="index.html#netparams" class="tsd-kind-icon">Net<wbr>Params</a></li>
|
||||||
|
@ -448,6 +448,16 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<section class="tsd-panel tsd-member tsd-kind-type-alias">
|
||||||
|
<a name="itinyfacedetectoroptions" class="tsd-anchor"></a>
|
||||||
|
<h3>ITiny<wbr>Face<wbr>Detector<wbr>Options</h3>
|
||||||
|
<div class="tsd-signature tsd-kind-icon">ITiny<wbr>Face<wbr>Detector<wbr>Options<span class="tsd-signature-symbol">:</span> <a href="interfaces/itinyyolov2options.html" class="tsd-signature-type" data-tsd-kind="Interface">ITinyYolov2Options</a></div>
|
||||||
|
<aside class="tsd-sources">
|
||||||
|
<ul>
|
||||||
|
<li>Defined in <a href="https://github.com/vladmandic/face-api/blob/main/src/tinyFaceDetector/TinyFaceDetectorOptions.ts#L3">tinyFaceDetector/TinyFaceDetectorOptions.ts:3</a></li>
|
||||||
|
</ul>
|
||||||
|
</aside>
|
||||||
|
</section>
|
||||||
<section class="tsd-panel tsd-member tsd-kind-type-alias">
|
<section class="tsd-panel tsd-member tsd-kind-type-alias">
|
||||||
<a name="mobilenetparams" class="tsd-anchor"></a>
|
<a name="mobilenetparams" class="tsd-anchor"></a>
|
||||||
<h3>Mobilenet<wbr>Params</h3>
|
<h3>Mobilenet<wbr>Params</h3>
|
||||||
|
@ -3088,9 +3098,6 @@
|
||||||
<li class=" tsd-kind-interface">
|
<li class=" tsd-kind-interface">
|
||||||
<a href="interfaces/issdmobilenetv1options.html" class="tsd-kind-icon">ISsd<wbr>Mobilenetv1<wbr>Options</a>
|
<a href="interfaces/issdmobilenetv1options.html" class="tsd-kind-icon">ISsd<wbr>Mobilenetv1<wbr>Options</a>
|
||||||
</li>
|
</li>
|
||||||
<li class=" tsd-kind-interface">
|
|
||||||
<a href="interfaces/itinyfacedetectoroptions.html" class="tsd-kind-icon">ITiny<wbr>Face<wbr>Detector<wbr>Options</a>
|
|
||||||
</li>
|
|
||||||
<li class=" tsd-kind-interface">
|
<li class=" tsd-kind-interface">
|
||||||
<a href="interfaces/itinyyolov2options.html" class="tsd-kind-icon">ITiny<wbr>Yolov2<wbr>Options</a>
|
<a href="interfaces/itinyyolov2options.html" class="tsd-kind-icon">ITiny<wbr>Yolov2<wbr>Options</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -3118,6 +3125,9 @@
|
||||||
<li class=" tsd-kind-type-alias">
|
<li class=" tsd-kind-type-alias">
|
||||||
<a href="index.html#filesystem" class="tsd-kind-icon">File<wbr>System</a>
|
<a href="index.html#filesystem" class="tsd-kind-icon">File<wbr>System</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class=" tsd-kind-type-alias">
|
||||||
|
<a href="index.html#itinyfacedetectoroptions" class="tsd-kind-icon">ITiny<wbr>Face<wbr>Detector<wbr>Options</a>
|
||||||
|
</li>
|
||||||
<li class=" tsd-kind-type-alias">
|
<li class=" tsd-kind-type-alias">
|
||||||
<a href="index.html#mobilenetparams" class="tsd-kind-icon">Mobilenet<wbr>Params</a>
|
<a href="index.html#mobilenetparams" class="tsd-kind-icon">Mobilenet<wbr>Params</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,175 +0,0 @@
|
||||||
<!doctype html>
|
|
||||||
<html class="default no-js">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<title>ITinyFaceDetectorOptions | @vladmandic/face-api</title>
|
|
||||||
<meta name="description" content="Documentation for @vladmandic/face-api">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
<link rel="stylesheet" href="../assets/css/main.css">
|
|
||||||
<script async src="../assets/js/search.js" id="search-script"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<header>
|
|
||||||
<div class="tsd-page-toolbar">
|
|
||||||
<div class="container">
|
|
||||||
<div class="table-wrap">
|
|
||||||
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
|
|
||||||
<div class="field">
|
|
||||||
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
|
|
||||||
<input id="tsd-search-field" type="text" />
|
|
||||||
</div>
|
|
||||||
<ul class="results">
|
|
||||||
<li class="state loading">Preparing search index...</li>
|
|
||||||
<li class="state failure">The search index is not available</li>
|
|
||||||
</ul>
|
|
||||||
<a href="../index.html" class="title">@vladmandic/face-api</a>
|
|
||||||
</div>
|
|
||||||
<div class="table-cell" id="tsd-widgets">
|
|
||||||
<div id="tsd-filter">
|
|
||||||
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
|
|
||||||
<div class="tsd-filter-group">
|
|
||||||
<div class="tsd-select" id="tsd-filter-visibility">
|
|
||||||
<span class="tsd-select-label">All</span>
|
|
||||||
<ul class="tsd-select-list">
|
|
||||||
<li data-value="public">Public</li>
|
|
||||||
<li data-value="protected">Public/Protected</li>
|
|
||||||
<li data-value="private" class="selected">All</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<input type="checkbox" id="tsd-filter-inherited" checked />
|
|
||||||
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="tsd-page-title">
|
|
||||||
<div class="container">
|
|
||||||
<ul class="tsd-breadcrumb">
|
|
||||||
<li>
|
|
||||||
<a href="../index.html">@vladmandic/face-api</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="itinyfacedetectoroptions.html">ITinyFaceDetectorOptions</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<h1>Interface ITinyFaceDetectorOptions</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
<div class="container container-main">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-8 col-content">
|
|
||||||
<section class="tsd-panel tsd-hierarchy">
|
|
||||||
<h3>Hierarchy</h3>
|
|
||||||
<ul class="tsd-hierarchy">
|
|
||||||
<li>
|
|
||||||
<a href="itinyyolov2options.html" class="tsd-signature-type" data-tsd-kind="Interface">ITinyYolov2Options</a>
|
|
||||||
<ul class="tsd-hierarchy">
|
|
||||||
<li>
|
|
||||||
<span class="target">ITinyFaceDetectorOptions</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
<section class="tsd-panel-group tsd-index-group">
|
|
||||||
<h2>Index</h2>
|
|
||||||
<section class="tsd-panel tsd-index-panel">
|
|
||||||
<div class="tsd-index-content">
|
|
||||||
<section class="tsd-index-section tsd-is-inherited">
|
|
||||||
<h3>Properties</h3>
|
|
||||||
<ul class="tsd-index-list">
|
|
||||||
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-inherited"><a href="itinyfacedetectoroptions.html#inputsize" class="tsd-kind-icon">input<wbr>Size</a></li>
|
|
||||||
<li class="tsd-kind-property tsd-parent-kind-interface tsd-is-inherited"><a href="itinyfacedetectoroptions.html#scorethreshold" class="tsd-kind-icon">score<wbr>Threshold</a></li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
<section class="tsd-panel-group tsd-member-group tsd-is-inherited">
|
|
||||||
<h2>Properties</h2>
|
|
||||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-inherited">
|
|
||||||
<a name="inputsize" class="tsd-anchor"></a>
|
|
||||||
<h3><span class="tsd-flag ts-flagOptional">Optional</span> input<wbr>Size</h3>
|
|
||||||
<div class="tsd-signature tsd-kind-icon">input<wbr>Size<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
|
||||||
<aside class="tsd-sources">
|
|
||||||
<p>Inherited from <a href="itinyyolov2options.html">ITinyYolov2Options</a>.<a href="itinyyolov2options.html#inputsize">inputSize</a></p>
|
|
||||||
<ul>
|
|
||||||
<li>Defined in <a href="https://github.com/vladmandic/face-api/blob/main/src/tinyYolov2/TinyYolov2Options.ts#L2">tinyYolov2/TinyYolov2Options.ts:2</a></li>
|
|
||||||
</ul>
|
|
||||||
</aside>
|
|
||||||
</section>
|
|
||||||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface tsd-is-inherited">
|
|
||||||
<a name="scorethreshold" class="tsd-anchor"></a>
|
|
||||||
<h3><span class="tsd-flag ts-flagOptional">Optional</span> score<wbr>Threshold</h3>
|
|
||||||
<div class="tsd-signature tsd-kind-icon">score<wbr>Threshold<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span></div>
|
|
||||||
<aside class="tsd-sources">
|
|
||||||
<p>Inherited from <a href="itinyyolov2options.html">ITinyYolov2Options</a>.<a href="itinyyolov2options.html#scorethreshold">scoreThreshold</a></p>
|
|
||||||
<ul>
|
|
||||||
<li>Defined in <a href="https://github.com/vladmandic/face-api/blob/main/src/tinyYolov2/TinyYolov2Options.ts#L3">tinyYolov2/TinyYolov2Options.ts:3</a></li>
|
|
||||||
</ul>
|
|
||||||
</aside>
|
|
||||||
</section>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
|
||||||
<nav class="tsd-navigation primary">
|
|
||||||
<ul>
|
|
||||||
<li class=" ">
|
|
||||||
<a href="../index.html">Exports</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
<nav class="tsd-navigation secondary menu-sticky">
|
|
||||||
<ul class="before-current">
|
|
||||||
</ul>
|
|
||||||
<ul class="current">
|
|
||||||
<li class="current tsd-kind-interface">
|
|
||||||
<a href="itinyfacedetectoroptions.html" class="tsd-kind-icon">ITiny<wbr>Face<wbr>Detector<wbr>Options</a>
|
|
||||||
<ul>
|
|
||||||
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-inherited">
|
|
||||||
<a href="itinyfacedetectoroptions.html#inputsize" class="tsd-kind-icon">input<wbr>Size</a>
|
|
||||||
</li>
|
|
||||||
<li class=" tsd-kind-property tsd-parent-kind-interface tsd-is-inherited">
|
|
||||||
<a href="itinyfacedetectoroptions.html#scorethreshold" class="tsd-kind-icon">score<wbr>Threshold</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<ul class="after-current">
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<footer>
|
|
||||||
<div class="container">
|
|
||||||
<h2>Legend</h2>
|
|
||||||
<div class="tsd-legend-group">
|
|
||||||
<ul class="tsd-legend">
|
|
||||||
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
|
|
||||||
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
|
|
||||||
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
|
|
||||||
</ul>
|
|
||||||
<ul class="tsd-legend">
|
|
||||||
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
|
|
||||||
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
|
|
||||||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
|
|
||||||
</ul>
|
|
||||||
<ul class="tsd-legend">
|
|
||||||
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
|
|
||||||
</ul>
|
|
||||||
<ul class="tsd-legend">
|
|
||||||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
<div class="overlay"></div>
|
|
||||||
<script src="../assets/js/main.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -68,11 +68,6 @@
|
||||||
<ul class="tsd-hierarchy">
|
<ul class="tsd-hierarchy">
|
||||||
<li>
|
<li>
|
||||||
<span class="target">ITinyYolov2Options</span>
|
<span class="target">ITinyYolov2Options</span>
|
||||||
<ul class="tsd-hierarchy">
|
|
||||||
<li>
|
|
||||||
<a href="itinyfacedetectoroptions.html" class="tsd-signature-type" data-tsd-kind="Interface">ITinyFaceDetectorOptions</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { ITinyYolov2Options, TinyYolov2Options } from '../tinyYolov2/index';
|
import { ITinyYolov2Options, TinyYolov2Options } from '../tinyYolov2/index';
|
||||||
export interface ITinyFaceDetectorOptions extends ITinyYolov2Options {
|
export declare type ITinyFaceDetectorOptions = ITinyYolov2Options;
|
||||||
}
|
|
||||||
export declare class TinyFaceDetectorOptions extends TinyYolov2Options {
|
export declare class TinyFaceDetectorOptions extends TinyYolov2Options {
|
||||||
protected _name: string;
|
protected _name: string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue