switch to custom tfjs and new typedefs

pull/97/head
Vladimir Mandic 2021-12-01 15:37:52 -05:00
parent f1a2ef34a5
commit e70d9bb18b
185 changed files with 25394 additions and 8770 deletions

View File

@ -10,7 +10,7 @@
"development": ["serve", "watch", "compile"]
},
"clean": {
"locations": ["dist/*", "types/src/*", "typedoc/*"]
"locations": ["dist/*", "typedoc/*", "types/lib/src"]
},
"lint": {
"locations": [ "src/**" ],
@ -31,6 +31,8 @@
"build": {
"global": {
"target": "es2018",
"treeShaking": true,
"ignoreAnnotations": true,
"sourcemap": false,
"banner": { "js": "/*\n Face-API\n homepage: <https://github.com/vladmandic/face-api>\n author: <https://github.com/vladmandic>'\n*/\n" }
},
@ -72,8 +74,7 @@
"platform": "browser",
"format": "esm",
"input": "src/tfjs/tf-version.ts",
"output": "dist/tfjs.version.js",
"external": ["fs", "os", "buffer", "util"]
"output": "dist/tfjs.version.js"
},
{
"name": "tfjs/browser/esm/nobundle",
@ -81,25 +82,22 @@
"format": "esm",
"input": "src/tfjs/tf-browser.ts",
"output": "dist/tfjs.esm.js",
"external": ["fs","buffer","util","os","@tensorflow"]
"external": ["@tensorflow"]
},
{
"name": "faceapi/browser/esm/nobundle",
"platform": "browser",
"format": "esm",
"sourcemap": true,
"input": "src/index.ts",
"output": "dist/face-api.esm-nobundle.js",
"external": ["fs","buffer","util","os","@tensorflow","tfjs.esm.js"]
"external": ["@tensorflow"],
"output": "dist/face-api.esm-nobundle.js"
},
{
"name": "tfjs/browser/esm/bundle",
"platform": "browser",
"format": "esm",
"sourcemap": true,
"input": "src/tfjs/tf-browser.ts",
"output": "dist/tfjs.esm.js",
"external": ["fs","buffer","util","os"]
"input": "src/tfjs/tf-custom.ts",
"output": "dist/tfjs.esm.js"
},
{
"name": "faceapi/browser/iife/bundle",
@ -109,7 +107,7 @@
"minify": true,
"input": "src/index.ts",
"output": "dist/face-api.js",
"external": ["fs","buffer","util","os"]
"external": ["@tensorflow"]
},
{
"name": "faceapi/browser/esm/bundle",
@ -118,9 +116,9 @@
"sourcemap": true,
"input": "src/index.ts",
"output": "dist/face-api.esm.js",
"external": ["fs","buffer","util","os"],
"typings": "types",
"typedoc": "typedoc"
"typings": "types/lib",
"typedoc": "typedoc",
"external": ["@tensorflow"]
}
]
},

View File

@ -2,3 +2,4 @@ node_modules
pnpm-lock.yaml
typedoc
test
types/lib

View File

@ -9,12 +9,12 @@
## Changelog
### **HEAD -> master** 2021/12/01 mandic00@live.com
### **1.5.8** 2021/11/30 mandic00@live.com
### **origin/master** 2021/10/28 mandic00@live.com
### **1.5.7** 2021/10/28 mandic00@live.com

38
api-extractor.json Normal file
View File

@ -0,0 +1,38 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/lib/src/index.d.ts",
"bundledPackages": ["@tensorflow/tfjs-core", "@tensorflow/tfjs-converter", "@types/offscreencanvas"],
"compiler": {
"skipLibCheck": false
},
"newlineKind": "lf",
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "types/face-api.d.ts"
},
"docModel": { "enabled": false },
"tsdocMetadata": {
"enabled": false
},
"apiReport": { "enabled": false },
"messages": {
"compilerMessageReporting": {
"default": {
"logLevel": "warning"
}
},
"extractorMessageReporting": {
"default": {
"logLevel": "warning"
},
"ae-missing-release-tag": {
"logLevel": "none"
}
},
"tsdocMessageReporting": {
"default": {
"logLevel": "warning"
}
}
}
}

49
build.js Normal file
View File

@ -0,0 +1,49 @@
const fs = require('fs');
const log = require('@vladmandic/pilogger');
const Build = require('@vladmandic/build').Build;
const APIExtractor = require('@microsoft/api-extractor');
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
function copy(src, dst) {
if (!fs.existsSync(src)) return;
const buffer = fs.readFileSync(src);
fs.writeFileSync(dst, buffer);
}
const apiIgnoreList = ['ae-forgotten-export', 'ae-unresolved-link', 'tsdoc-param-tag-missing-hyphen'];
async function main() {
// run production build
const build = new Build();
await build.run('production');
// patch tfjs typedefs
log.state('Copy:', { input: 'types/lib/dist/tfjs.esm.d.ts' });
copy('types/lib/dist/tfjs.esm.d.ts', 'dist/tfjs.esm.d.ts');
// run api-extractor to create typedef rollup
const extractorConfig = APIExtractor.ExtractorConfig.loadFileAndPrepare('api-extractor.json');
const extractorResult = APIExtractor.Extractor.invoke(extractorConfig, {
localBuild: true,
showVerboseMessages: false,
messageCallback: (msg) => {
msg.handled = true;
if (msg.logLevel === 'none' || msg.logLevel === 'verbose' || msg.logLevel === 'info') return;
if (msg.sourceFilePath?.includes('/node_modules/')) return;
if (apiIgnoreList.reduce((prev, curr) => prev || msg.messageId.includes(curr), false)) return;
log.data('API', { level: msg.logLevel, category: msg.category, id: msg.messageId, file: msg.sourceFilePath, line: msg.sourceFileLine, text: msg.text });
},
});
log.state('API-Extractor:', { succeeeded: extractorResult.succeeded, errors: extractorResult.errorCount, warnings: extractorResult.warningCount });
// distribute typedefs
/*
log.state('Copy:', { input: 'types/human.d.ts' });
copy('types/human.d.ts', 'dist/human.esm-nobundle.d.ts');
copy('types/human.d.ts', 'dist/human.esm.d.ts');
copy('types/human.d.ts', 'dist/human.d.ts');
copy('types/human.d.ts', 'dist/human.node-gpu.d.ts');
copy('types/human.d.ts', 'dist/human.node.d.ts');
copy('types/human.d.ts', 'dist/human.node-wasm.d.ts');
*/
log.info('FaceAPI Build complete...');
}
main();

View File

@ -4496,4 +4496,3 @@ export {
validateConfig,
version11 as version
};
//# sourceMappingURL=face-api.esm-nobundle.js.map

File diff suppressed because one or more lines are too long

13101
dist/face-api.esm.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

3375
dist/face-api.js vendored

File diff suppressed because one or more lines are too long

23
dist/tfjs.esm.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
import '@tensorflow/tfjs-core';
import '@tensorflow/tfjs-core/dist/types';
import '@tensorflow/tfjs-core/dist/register_all_gradients';
import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops';
import '@tensorflow/tfjs-data';
import '@tensorflow/tfjs-layers';
import '@tensorflow/tfjs-converter';
import '@tensorflow/tfjs-backend-cpu';
import '@tensorflow/tfjs-backend-webgl';
import '@tensorflow/tfjs-backend-wasm';
import '@tensorflow/tfjs-backend-webgpu';
export declare const version: {
'tfjs-core': string;
'tfjs-backend-cpu': string;
'tfjs-backend-webgl': string;
'tfjs-data': string;
'tfjs-layers': string;
'tfjs-converter': string;
tfjs: string;
};
export { Tensor, TensorLike, Rank, Tensor1D, Tensor2D, Tensor3D, Tensor4D, Tensor5D, NamedTensorMap } from '@tensorflow/tfjs-core/dist/index';

15687
dist/tfjs.esm.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
{
"name": "@vladmandic/face-api",
"version": "1.5.8",
"version": "1.6.0",
"description": "FaceAPI: AI-powered Face Detection & Rotation Tracking, Face Description & Recognition, Age & Gender & Emotion Prediction for Browser and NodeJS using TensorFlow/JS",
"sideEffects": false,
"main": "dist/face-api.node.js",
"module": "dist/face-api.esm.js",
"browser": "dist/face-api.esm.js",
"types": "types/src/index.d.ts",
"types": "types/face-api.d.ts",
"author": "Vladimir Mandic <mandic00@live.com>",
"bugs": {
"url": "https://github.com/vladmandic/face-api/issues"
@ -23,7 +23,7 @@
"scripts": {
"start": "node --no-warnings demo/node.js",
"dev": "build --profile development",
"build": "build --profile production",
"build": "node build.js",
"test": "node --trace-warnings test/test-node.js",
"scan": "npx auditjs@latest ossi --dev --quiet"
},
@ -42,10 +42,12 @@
],
"devDependencies": {
"@canvas/image": "^1.0.1",
"@microsoft/api-extractor": "^7.18.19",
"@tensorflow/tfjs": "^3.11.0",
"@tensorflow/tfjs-backend-cpu": "^3.11.0",
"@tensorflow/tfjs-backend-wasm": "^3.11.0",
"@tensorflow/tfjs-backend-webgl": "^3.11.0",
"@tensorflow/tfjs-backend-webgpu": "^0.0.1-alpha.8",
"@tensorflow/tfjs-converter": "^3.11.0",
"@tensorflow/tfjs-core": "^3.11.0",
"@tensorflow/tfjs-data": "^3.11.0",
@ -53,10 +55,12 @@
"@tensorflow/tfjs-node": "^3.11.0",
"@tensorflow/tfjs-node-gpu": "^3.11.0",
"@types/node": "^16.11.11",
"@types/offscreencanvas": "^2019.6.4",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"@vladmandic/build": "^0.6.6",
"@vladmandic/pilogger": "^0.3.5",
"@vladmandic/tfjs": "github:vladmandic/tfjs",
"canvas": "^2.8.0",
"chokidar": "^3.5.2",
"dayjs": "^1.10.7",

View File

@ -1,5 +1,4 @@
import * as tf from '../../dist/tfjs.esm';
import * as tf from '../../dist/tfjs.esm.js';
import { fullyConnectedLayer } from '../common/fullyConnectedLayer';
import { seperateWeightMaps } from '../faceProcessor/util';
import { TinyXception } from '../xception/TinyXception';

4
src/tfjs/tf-custom.ts Normal file
View File

@ -0,0 +1,4 @@
/** Creates tfjs bundle used by Human browser build target
* @external
*/
export * from '@vladmandic/tfjs';

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
export * from '@tensorflow/tfjs';

1784
types/face-api.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

23
types/lib/dist/tfjs.esm.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
import '@tensorflow/tfjs-core';
import '@tensorflow/tfjs-core/dist/types';
import '@tensorflow/tfjs-core/dist/register_all_gradients';
import '@tensorflow/tfjs-core/dist/public/chained_ops/register_all_chained_ops';
import '@tensorflow/tfjs-data';
import '@tensorflow/tfjs-layers';
import '@tensorflow/tfjs-converter';
import '@tensorflow/tfjs-backend-cpu';
import '@tensorflow/tfjs-backend-webgl';
import '@tensorflow/tfjs-backend-wasm';
import '@tensorflow/tfjs-backend-webgpu';
export declare const version: {
'tfjs-core': string;
'tfjs-backend-cpu': string;
'tfjs-backend-webgl': string;
'tfjs-data': string;
'tfjs-layers': string;
'tfjs-converter': string;
tfjs: string;
};
export { Tensor, TensorLike, Rank, Tensor1D, Tensor2D, Tensor3D, Tensor4D, Tensor5D, NamedTensorMap } from '@tensorflow/tfjs-core/dist/index';

View File

@ -1,4 +1,4 @@
import * as tf from '../../dist/tfjs.esm';
import * as tf from '../../dist/tfjs.esm.js';
import { TinyXception } from '../xception/TinyXception';
import { AgeAndGenderPrediction, NetOutput, NetParams } from './types';
import { NeuralNetwork } from '../NeuralNetwork';
@ -16,14 +16,14 @@ export declare class AgeGenderNet extends NeuralNetwork<NetParams> {
loadClassifierParams(weights: Float32Array): void;
extractClassifierParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("../common").ParamMapping[];
paramMappings: import("../common/types.js").ParamMapping[];
};
protected extractParamsFromWeightMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: import("../common").ParamMapping[];
paramMappings: import("../common/types.js").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("../common").ParamMapping[];
paramMappings: import("../common/types.js").ParamMapping[];
};
}

Some files were not shown because too many files have changed in this diff Show More