added faceapi.version object

pull/13/head
Vladimir Mandic 2020-09-09 09:50:10 -04:00
parent 987912e69a
commit 85006365c1
15 changed files with 100 additions and 83 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@vladmandic/face-api",
"version": "0.4.6",
"version": "0.5.1",
"description": "JavaScript module for Face Detection and Face Recognition Using Tensorflow/JS",
"main": "dist/face-api.cjs",
"module": "dist/face-api.ejs",

View File

@ -20,7 +20,9 @@ export * from './NeuralNetwork';
export * from './resizeResults';
export declare const version: {
faceapi: string;
tfjs_core: string;
env: import("@tensorflow/tfjs-core/dist/environment").Flags;
node: string | boolean;
browser: string | boolean;
tfjs: string;
backend: string;
};
//# sourceMappingURL=index.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAE3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAGhC,eAAO,MAAM,OAAO;;;;CAA+E,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAE3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAKhC,eAAO,MAAM,OAAO;;;;;;CAA2F,CAAC"}

View File

@ -1,3 +1,5 @@
// const os = require('os');
// const process = require('process');
import * as tf from '@tensorflow/tfjs-core';
import * as draw from './draw';
import * as utils from './utils';
@ -19,5 +21,7 @@ export * from './euclideanDistance';
export * from './NeuralNetwork';
export * from './resizeResults';
import * as pkg from '../package.json';
export const version = { faceapi: pkg.version, tfjs_core: tf.version_core, env: tf.ENV.getFlags() };
const node = typeof process !== 'undefined' ? process.version : false;
const browser = typeof navigator !== 'undefined' ? navigator.userAgent : false;
export const version = { faceapi: pkg.version, node, browser, tfjs: tf.version_core, backend: tf.getBackend() };
//# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAA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AmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAEhC,OAAO,KAAK,GAAG,MAAM,iBAAiB,CAAC;AACvC,MAAM,IAAI,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAA;AACrE,MAAM,OAAO,GAAG,OAAO,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAA;AAC9E,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC,UAAU,EAAE,EAAE,CAAC"}

60
dist/face-api.cjs vendored
View File

@ -627,7 +627,7 @@ var require_seedrandom = __commonJS((exports2, module2) => {
}
return tostring(out);
} catch (e) {
var browser = global2.navigator, plugins = browser && browser.plugins;
var browser2 = global2.navigator, plugins = browser2 && browser2.plugins;
return [+new Date(), global2, plugins, global2.screen, tostring(pool3)];
}
}
@ -1744,16 +1744,16 @@ function getFilteredNodesXToY(tape2, xs, y) {
tensorsFromX[xs[i].id] = true;
}
for (let i = 0; i < tape2.length; i++) {
const node = tape2[i];
const nodeInputs = node.inputs;
const node2 = tape2[i];
const nodeInputs = node2.inputs;
for (const inputName in nodeInputs) {
const input = nodeInputs[inputName];
let anyInputFromX = false;
for (let j = 0; j < xs.length; j++) {
if (tensorsFromX[input.id]) {
node.outputs.forEach((output) => tensorsFromX[output.id] = true);
node2.outputs.forEach((output) => tensorsFromX[output.id] = true);
anyInputFromX = true;
nodesFromX[node.id] = true;
nodesFromX[node2.id] = true;
break;
}
}
@ -1766,13 +1766,13 @@ function getFilteredNodesXToY(tape2, xs, y) {
tensorsLeadToY[y.id] = true;
const nodesToY = {};
for (let i = tape2.length - 1; i >= 0; i--) {
const node = tape2[i];
const nodeInputs = node.inputs;
for (let j = 0; j < node.outputs.length; j++) {
if (tensorsLeadToY[node.outputs[j].id]) {
const node2 = tape2[i];
const nodeInputs = node2.inputs;
for (let j = 0; j < node2.outputs.length; j++) {
if (tensorsLeadToY[node2.outputs[j].id]) {
for (const inputName in nodeInputs) {
tensorsLeadToY[nodeInputs[inputName].id] = true;
nodesToY[node.id] = true;
nodesToY[node2.id] = true;
}
break;
}
@ -1780,18 +1780,18 @@ function getFilteredNodesXToY(tape2, xs, y) {
}
const filteredTape = [];
for (let i = 0; i < tape2.length; i++) {
const node = tape2[i];
if (nodesFromX[node.id] && nodesToY[node.id]) {
const node2 = tape2[i];
if (nodesFromX[node2.id] && nodesToY[node2.id]) {
const prunedInputs = {};
for (const inputName in node.inputs) {
const nodeInput = node.inputs[inputName];
for (const inputName in node2.inputs) {
const nodeInput = node2.inputs[inputName];
if (tensorsFromX[nodeInput.id]) {
prunedInputs[inputName] = nodeInput;
}
}
const prunedNode = Object.assign({}, node);
const prunedNode = Object.assign({}, node2);
prunedNode.inputs = prunedInputs;
prunedNode.outputs = node.outputs;
prunedNode.outputs = node2.outputs;
filteredTape.push(prunedNode);
}
}
@ -1799,9 +1799,9 @@ function getFilteredNodesXToY(tape2, xs, y) {
}
function backpropagateGradients(tensorAccumulatedGradientMap, filteredTape, tidy2, add29) {
for (let i = filteredTape.length - 1; i >= 0; i--) {
const node = filteredTape[i];
const node2 = filteredTape[i];
const dys = [];
node.outputs.forEach((o) => {
node2.outputs.forEach((o) => {
const gradTensor = tensorAccumulatedGradientMap[o.id];
if (gradTensor != null) {
dys.push(gradTensor);
@ -1809,21 +1809,21 @@ function backpropagateGradients(tensorAccumulatedGradientMap, filteredTape, tidy
dys.push(null);
}
});
if (node.gradient == null) {
throw new Error(`Cannot compute gradient: gradient function not found for ${node.kernelName}.`);
if (node2.gradient == null) {
throw new Error(`Cannot compute gradient: gradient function not found for ${node2.kernelName}.`);
}
const inputGradients = node.gradient(dys);
for (const inputName in node.inputs) {
const inputGradients = node2.gradient(dys);
for (const inputName in node2.inputs) {
if (!(inputName in inputGradients)) {
throw new Error(`Cannot backprop through input ${inputName}. Available gradients found: ${Object.keys(inputGradients)}.`);
}
const dx = tidy2(() => inputGradients[inputName]());
if (dx.dtype !== "float32") {
throw new Error(`Error in gradient for op ${node.kernelName}. The gradient of input ${inputName} must have 'float32' dtype, but has '${dx.dtype}'`);
throw new Error(`Error in gradient for op ${node2.kernelName}. The gradient of input ${inputName} must have 'float32' dtype, but has '${dx.dtype}'`);
}
const x = node.inputs[inputName];
const x = node2.inputs[inputName];
if (!arraysEqual(dx.shape, x.shape)) {
throw new Error(`Error in gradient for op ${node.kernelName}. The gradient of input '${inputName}' has shape '${dx.shape}', which does not match the shape of the input '${x.shape}'`);
throw new Error(`Error in gradient for op ${node2.kernelName}. The gradient of input '${inputName}' has shape '${dx.shape}', which does not match the shape of the input '${x.shape}'`);
}
if (tensorAccumulatedGradientMap[x.id] == null) {
tensorAccumulatedGradientMap[x.id] = dx;
@ -2977,8 +2977,8 @@ class Engine {
backpropagateGradients(accumulatedGradientMap, filteredTape, (f2) => this.tidy(f2), add);
const grads2 = xs.map((x) => accumulatedGradientMap[x.id]);
if (this.state.gradientDepth === 0) {
this.state.activeTape.forEach((node) => {
for (const tensor17 of node.saved) {
this.state.activeTape.forEach((node2) => {
for (const tensor17 of node2.saved) {
tensor17.dispose();
}
});
@ -24254,7 +24254,7 @@ function resizeResults(results, dimensions) {
}
// build/package.json
var version2 = "0.4.6";
var version2 = "0.5.1";
// build/src/index.js
__export(exports, {
@ -24380,5 +24380,7 @@ __export(exports, {
validateConfig: () => validateConfig,
version: () => version3
});
const version3 = {faceapi: version2, tfjs_core: version, env: ENV.getFlags()};
const node = typeof process !== "undefined" ? process.version : false;
const browser = typeof navigator !== "undefined" ? navigator.userAgent : false;
const version3 = {faceapi: version2, node, browser, tfjs: version, backend: getBackend()};
//# sourceMappingURL=face-api.cjs.map

File diff suppressed because one or more lines are too long

60
dist/face-api.ejs vendored
View File

@ -631,7 +631,7 @@ var require_seedrandom = __commonJS((exports, module) => {
}
return tostring(out);
} catch (e) {
var browser = global2.navigator, plugins = browser && browser.plugins;
var browser2 = global2.navigator, plugins = browser2 && browser2.plugins;
return [+new Date(), global2, plugins, global2.screen, tostring(pool3)];
}
}
@ -1748,16 +1748,16 @@ function getFilteredNodesXToY(tape2, xs, y) {
tensorsFromX[xs[i].id] = true;
}
for (let i = 0; i < tape2.length; i++) {
const node = tape2[i];
const nodeInputs = node.inputs;
const node2 = tape2[i];
const nodeInputs = node2.inputs;
for (const inputName in nodeInputs) {
const input = nodeInputs[inputName];
let anyInputFromX = false;
for (let j = 0; j < xs.length; j++) {
if (tensorsFromX[input.id]) {
node.outputs.forEach((output) => tensorsFromX[output.id] = true);
node2.outputs.forEach((output) => tensorsFromX[output.id] = true);
anyInputFromX = true;
nodesFromX[node.id] = true;
nodesFromX[node2.id] = true;
break;
}
}
@ -1770,13 +1770,13 @@ function getFilteredNodesXToY(tape2, xs, y) {
tensorsLeadToY[y.id] = true;
const nodesToY = {};
for (let i = tape2.length - 1; i >= 0; i--) {
const node = tape2[i];
const nodeInputs = node.inputs;
for (let j = 0; j < node.outputs.length; j++) {
if (tensorsLeadToY[node.outputs[j].id]) {
const node2 = tape2[i];
const nodeInputs = node2.inputs;
for (let j = 0; j < node2.outputs.length; j++) {
if (tensorsLeadToY[node2.outputs[j].id]) {
for (const inputName in nodeInputs) {
tensorsLeadToY[nodeInputs[inputName].id] = true;
nodesToY[node.id] = true;
nodesToY[node2.id] = true;
}
break;
}
@ -1784,18 +1784,18 @@ function getFilteredNodesXToY(tape2, xs, y) {
}
const filteredTape = [];
for (let i = 0; i < tape2.length; i++) {
const node = tape2[i];
if (nodesFromX[node.id] && nodesToY[node.id]) {
const node2 = tape2[i];
if (nodesFromX[node2.id] && nodesToY[node2.id]) {
const prunedInputs = {};
for (const inputName in node.inputs) {
const nodeInput = node.inputs[inputName];
for (const inputName in node2.inputs) {
const nodeInput = node2.inputs[inputName];
if (tensorsFromX[nodeInput.id]) {
prunedInputs[inputName] = nodeInput;
}
}
const prunedNode = Object.assign({}, node);
const prunedNode = Object.assign({}, node2);
prunedNode.inputs = prunedInputs;
prunedNode.outputs = node.outputs;
prunedNode.outputs = node2.outputs;
filteredTape.push(prunedNode);
}
}
@ -1803,9 +1803,9 @@ function getFilteredNodesXToY(tape2, xs, y) {
}
function backpropagateGradients(tensorAccumulatedGradientMap, filteredTape, tidy2, add29) {
for (let i = filteredTape.length - 1; i >= 0; i--) {
const node = filteredTape[i];
const node2 = filteredTape[i];
const dys = [];
node.outputs.forEach((o) => {
node2.outputs.forEach((o) => {
const gradTensor = tensorAccumulatedGradientMap[o.id];
if (gradTensor != null) {
dys.push(gradTensor);
@ -1813,21 +1813,21 @@ function backpropagateGradients(tensorAccumulatedGradientMap, filteredTape, tidy
dys.push(null);
}
});
if (node.gradient == null) {
throw new Error(`Cannot compute gradient: gradient function not found for ${node.kernelName}.`);
if (node2.gradient == null) {
throw new Error(`Cannot compute gradient: gradient function not found for ${node2.kernelName}.`);
}
const inputGradients = node.gradient(dys);
for (const inputName in node.inputs) {
const inputGradients = node2.gradient(dys);
for (const inputName in node2.inputs) {
if (!(inputName in inputGradients)) {
throw new Error(`Cannot backprop through input ${inputName}. Available gradients found: ${Object.keys(inputGradients)}.`);
}
const dx = tidy2(() => inputGradients[inputName]());
if (dx.dtype !== "float32") {
throw new Error(`Error in gradient for op ${node.kernelName}. The gradient of input ${inputName} must have 'float32' dtype, but has '${dx.dtype}'`);
throw new Error(`Error in gradient for op ${node2.kernelName}. The gradient of input ${inputName} must have 'float32' dtype, but has '${dx.dtype}'`);
}
const x = node.inputs[inputName];
const x = node2.inputs[inputName];
if (!arraysEqual(dx.shape, x.shape)) {
throw new Error(`Error in gradient for op ${node.kernelName}. The gradient of input '${inputName}' has shape '${dx.shape}', which does not match the shape of the input '${x.shape}'`);
throw new Error(`Error in gradient for op ${node2.kernelName}. The gradient of input '${inputName}' has shape '${dx.shape}', which does not match the shape of the input '${x.shape}'`);
}
if (tensorAccumulatedGradientMap[x.id] == null) {
tensorAccumulatedGradientMap[x.id] = dx;
@ -2981,8 +2981,8 @@ class Engine {
backpropagateGradients(accumulatedGradientMap, filteredTape, (f2) => this.tidy(f2), add);
const grads2 = xs.map((x) => accumulatedGradientMap[x.id]);
if (this.state.gradientDepth === 0) {
this.state.activeTape.forEach((node) => {
for (const tensor17 of node.saved) {
this.state.activeTape.forEach((node2) => {
for (const tensor17 of node2.saved) {
tensor17.dispose();
}
});
@ -24258,10 +24258,12 @@ function resizeResults(results, dimensions) {
}
// build/package.json
var version2 = "0.4.6";
var version2 = "0.5.1";
// build/src/index.js
const version3 = {faceapi: version2, tfjs_core: version, env: ENV.getFlags()};
const node = typeof process !== "undefined" ? process.version : false;
const browser = typeof navigator !== "undefined" ? navigator.userAgent : false;
const version3 = {faceapi: version2, node, browser, tfjs: version, backend: getBackend()};
export {
AgeGenderNet,
BoundingBox,

File diff suppressed because one or more lines are too long

6
dist/face-api.js vendored
View File

@ -807,7 +807,9 @@ var faceapi = (() => {
validateConfig: () => validateConfig,
version: () => version3
});
const version3 = {faceapi: version2, tfjs_core: version, env: ENV.getFlags()};
const node = typeof process !== "undefined" ? process.version : false;
const browser = typeof navigator !== "undefined" ? navigator.userAgent : false;
const version3 = {faceapi: version2, node, browser, tfjs: version, backend: getBackend()};
});
// node_modules/@tensorflow/tfjs-core/dist/environment.js
@ -24387,7 +24389,7 @@ Manifest JSON has weights with names: ${allManifestWeightNames.join(", ")}.`);
}
// build/package.json
var version2 = "0.4.6";
var version2 = "0.5.1";
return require_src();
})();
//# sourceMappingURL=face-api.js.map

File diff suppressed because one or more lines are too long

18
dist/face-api.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -123,7 +123,8 @@
await faceapi.tf.setBackend('webgl');
await faceapi.tf.enableProdMode();
await faceapi.tf.ENV.set('DEBUG', false);
log(`TensorFlow/JS Version: ${faceapi.tf.version_core} Backend ${faceapi.tf.getBackend()}`);
// check version
log(`Version: ${str(faceapi.version)}`);
// load face-api models
log('Loading FaceAPI models');
@ -136,8 +137,7 @@
const optionsTinyFace = new faceapi.TinyFaceDetectorOptions({ inputSize: imgSize, scoreThreshold: minScore });
const optionsSSDMobileNet = new faceapi.SsdMobilenetv1Options({ minConfidence: minScore, maxResults });
// check tf state
log(`TF Flags: ${str(faceapi.tf.ENV.flags)}`);
// check tf engine state
const engine = await faceapi.tf.engine();
log(`TF Engine State: ${str(engine.state)}`);

View File

@ -1,3 +1,6 @@
// const os = require('os');
// const process = require('process');
import * as tf from '@tensorflow/tfjs-core';
import * as draw from './draw';
import * as utils from './utils';
@ -21,4 +24,6 @@ export * from './NeuralNetwork';
export * from './resizeResults';
import * as pkg from '../package.json';
export const version = { faceapi: pkg.version, tfjs_core: tf.version_core, env: tf.ENV.getFlags() };
const node = typeof process !== 'undefined' ? process.version : false
const browser = typeof navigator !== 'undefined' ? navigator.userAgent : false
export const version = { faceapi: pkg.version, node, browser, tfjs: tf.version_core, backend: tf.getBackend() };