switch to commonjs and es2018 for compatibility

pull/13/head
Vladimir Mandic 2020-08-19 20:05:34 -04:00
parent 8032ef4171
commit 7d43d3fc4c
303 changed files with 7524 additions and 5374 deletions

View File

@ -1,8 +1,11 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
import { getModelUris } from './common/getModelUris'; Object.defineProperty(exports, "__esModule", { value: true });
import { loadWeightMap } from './dom'; exports.NeuralNetwork = void 0;
import { env } from './env'; const tf = require("@tensorflow/tfjs-core");
export class NeuralNetwork { const getModelUris_1 = require("./common/getModelUris");
const dom_1 = require("./dom");
const env_1 = require("./env");
class NeuralNetwork {
constructor(_name) { constructor(_name) {
this._name = _name; this._name = _name;
this._params = undefined; this._params = undefined;
@ -69,15 +72,15 @@ export class NeuralNetwork {
if (uri && typeof uri !== 'string') { if (uri && typeof uri !== 'string') {
throw new Error(`${this._name}.loadFromUri - expected model uri`); throw new Error(`${this._name}.loadFromUri - expected model uri`);
} }
const weightMap = await loadWeightMap(uri, this.getDefaultModelName()); const weightMap = await dom_1.loadWeightMap(uri, this.getDefaultModelName());
this.loadFromWeightMap(weightMap); this.loadFromWeightMap(weightMap);
} }
async loadFromDisk(filePath) { async loadFromDisk(filePath) {
if (filePath && typeof filePath !== 'string') { if (filePath && typeof filePath !== 'string') {
throw new Error(`${this._name}.loadFromDisk - expected model file path`); throw new Error(`${this._name}.loadFromDisk - expected model file path`);
} }
const { readFile } = env.getEnv(); const { readFile } = env_1.env.getEnv();
const { manifestUri, modelBaseUri } = getModelUris(filePath, this.getDefaultModelName()); const { manifestUri, modelBaseUri } = getModelUris_1.getModelUris(filePath, this.getDefaultModelName());
const fetchWeightsFromDisk = (filePaths) => Promise.all(filePaths.map(filePath => readFile(filePath).then(buf => buf.buffer))); const fetchWeightsFromDisk = (filePaths) => Promise.all(filePaths.map(filePath => readFile(filePath).then(buf => buf.buffer)));
const loadWeights = tf.io.weightsLoaderFactory(fetchWeightsFromDisk); const loadWeights = tf.io.weightsLoaderFactory(fetchWeightsFromDisk);
const manifest = JSON.parse((await readFile(manifestUri)).toString()); const manifest = JSON.parse((await readFile(manifestUri)).toString());
@ -111,4 +114,5 @@ export class NeuralNetwork {
return { obj, objProp }; return { obj, objProp };
} }
} }
exports.NeuralNetwork = NeuralNetwork;
//# sourceMappingURL=NeuralNetwork.js.map //# sourceMappingURL=NeuralNetwork.js.map

View File

@ -1 +1 @@
{"version":3,"file":"NeuralNetwork.js","sourceRoot":"","sources":["../src/NeuralNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,OAAgB,aAAa;IAKjC,YAAsB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAHzB,YAAO,GAA2B,SAAS,CAAA;QAC3C,mBAAc,GAAmB,EAAE,CAAA;IAEP,CAAC;IAEvC,IAAW,MAAM,KAA6B,OAAO,IAAI,CAAC,OAAO,CAAA,CAAC,CAAC;IACnE,IAAW,aAAa,KAAqB,OAAO,IAAI,CAAC,cAAc,CAAA,CAAC,CAAC;IACzE,IAAW,QAAQ,KAAc,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAEhD,gBAAgB,CAAC,SAAiB;QACvC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAA;QAC7D,OAAO,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,CAAC;IAEM,qBAAqB,CAAC,SAAiB,EAAE,MAAiB;QAC/D,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAA;QAC7D,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,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,OAAO,CAAC,EAAE,CAAA;QACrE,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QAE5B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;QAC/B,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE;YAC5D,MAAM,IAAI,KAAK,CAAC,8DAA8D,SAAS,EAAE,CAAC,CAAA;SAC3F;QAED,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAA;IACzB,CAAC;CAKF;AAvJD,sCAuJC"}

View File

@ -1,14 +1,17 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
import { fullyConnectedLayer } from '../common/fullyConnectedLayer'; Object.defineProperty(exports, "__esModule", { value: true });
import { seperateWeightMaps } from '../faceProcessor/util'; exports.AgeGenderNet = void 0;
import { TinyXception } from '../xception/TinyXception'; const tf = require("@tensorflow/tfjs-core");
import { extractParams } from './extractParams'; const fullyConnectedLayer_1 = require("../common/fullyConnectedLayer");
import { extractParamsFromWeigthMap } from './extractParamsFromWeigthMap'; const util_1 = require("../faceProcessor/util");
import { Gender } from './types'; const TinyXception_1 = require("../xception/TinyXception");
import { NeuralNetwork } from '../NeuralNetwork'; const extractParams_1 = require("./extractParams");
import { NetInput, toNetInput } from '../dom'; const extractParamsFromWeigthMap_1 = require("./extractParamsFromWeigthMap");
export class AgeGenderNet extends NeuralNetwork { const types_1 = require("./types");
constructor(faceFeatureExtractor = new TinyXception(2)) { const NeuralNetwork_1 = require("../NeuralNetwork");
const dom_1 = require("../dom");
class AgeGenderNet extends NeuralNetwork_1.NeuralNetwork {
constructor(faceFeatureExtractor = new TinyXception_1.TinyXception(2)) {
super('AgeGenderNet'); super('AgeGenderNet');
this._faceFeatureExtractor = faceFeatureExtractor; this._faceFeatureExtractor = faceFeatureExtractor;
} }
@ -21,12 +24,12 @@ export class AgeGenderNet extends NeuralNetwork {
throw new Error(`${this._name} - load model before inference`); throw new Error(`${this._name} - load model before inference`);
} }
return tf.tidy(() => { return tf.tidy(() => {
const bottleneckFeatures = input instanceof NetInput const bottleneckFeatures = input instanceof dom_1.NetInput
? this.faceFeatureExtractor.forwardInput(input) ? this.faceFeatureExtractor.forwardInput(input)
: input; : input;
const pooled = tf.avgPool(bottleneckFeatures, [7, 7], [2, 2], 'valid').as2D(bottleneckFeatures.shape[0], -1); const pooled = tf.avgPool(bottleneckFeatures, [7, 7], [2, 2], 'valid').as2D(bottleneckFeatures.shape[0], -1);
const age = fullyConnectedLayer(pooled, params.fc.age).as1D(); const age = fullyConnectedLayer_1.fullyConnectedLayer(pooled, params.fc.age).as1D();
const gender = fullyConnectedLayer(pooled, params.fc.gender); const gender = fullyConnectedLayer_1.fullyConnectedLayer(pooled, params.fc.gender);
return { age, gender }; return { age, gender };
}); });
} }
@ -37,10 +40,10 @@ export class AgeGenderNet extends NeuralNetwork {
}); });
} }
async forward(input) { async forward(input) {
return this.forwardInput(await toNetInput(input)); return this.forwardInput(await dom_1.toNetInput(input));
} }
async predictAgeAndGender(input) { async predictAgeAndGender(input) {
const netInput = await toNetInput(input); const netInput = await dom_1.toNetInput(input);
const out = await this.forwardInput(netInput); const out = await this.forwardInput(netInput);
const ages = tf.unstack(out.age); const ages = tf.unstack(out.age);
const genders = tf.unstack(out.gender); const genders = tf.unstack(out.gender);
@ -52,7 +55,7 @@ export class AgeGenderNet extends NeuralNetwork {
const age = (await ageTensor.data())[0]; const age = (await ageTensor.data())[0];
const probMale = (await genderTensor.data())[0]; const probMale = (await genderTensor.data())[0];
const isMale = probMale > 0.5; const isMale = probMale > 0.5;
const gender = isMale ? Gender.MALE : Gender.FEMALE; const gender = isMale ? types_1.Gender.MALE : types_1.Gender.FEMALE;
const genderProbability = isMale ? probMale : (1 - probMale); const genderProbability = isMale ? probMale : (1 - probMale);
ageTensor.dispose(); ageTensor.dispose();
genderTensor.dispose(); genderTensor.dispose();
@ -77,12 +80,12 @@ export class AgeGenderNet extends NeuralNetwork {
this._paramMappings = paramMappings; this._paramMappings = paramMappings;
} }
extractClassifierParams(weights) { extractClassifierParams(weights) {
return extractParams(weights); return extractParams_1.extractParams(weights);
} }
extractParamsFromWeigthMap(weightMap) { extractParamsFromWeigthMap(weightMap) {
const { featureExtractorMap, classifierMap } = seperateWeightMaps(weightMap); const { featureExtractorMap, classifierMap } = util_1.seperateWeightMaps(weightMap);
this.faceFeatureExtractor.loadFromWeightMap(featureExtractorMap); this.faceFeatureExtractor.loadFromWeightMap(featureExtractorMap);
return extractParamsFromWeigthMap(classifierMap); return extractParamsFromWeigthMap_1.extractParamsFromWeigthMap(classifierMap);
} }
extractParams(weights) { extractParams(weights) {
const classifierWeightSize = (512 * 1 + 1) + (512 * 2 + 2); const classifierWeightSize = (512 * 1 + 1) + (512 * 2 + 2);
@ -92,4 +95,5 @@ export class AgeGenderNet extends NeuralNetwork {
return this.extractClassifierParams(classifierWeights); return this.extractClassifierParams(classifierWeights);
} }
} }
exports.AgeGenderNet = AgeGenderNet;
//# sourceMappingURL=AgeGenderNet.js.map //# sourceMappingURL=AgeGenderNet.js.map

View File

@ -1 +1 @@
{"version":3,"file":"AgeGenderNet.js","sourceRoot":"","sources":["../../src/ageGenderNet/AgeGenderNet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAA0B,MAAM,EAAwB,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,aAAa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,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAA;QACvF,MAAM,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,oBAAoB,CAAC,CAAA;QAE9E,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAA;QACjE,OAAO,IAAI,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAA;IACxD,CAAC;CACF;AAlHD,oCAkHC"}

View File

@ -1,8 +1,11 @@
import { extractFCParamsFactory, extractWeightsFactory } from '../common'; "use strict";
export function extractParams(weights) { Object.defineProperty(exports, "__esModule", { value: true });
exports.extractParams = void 0;
const common_1 = require("../common");
function extractParams(weights) {
const paramMappings = []; const paramMappings = [];
const { extractWeights, getRemainingWeights } = extractWeightsFactory(weights); const { extractWeights, getRemainingWeights } = common_1.extractWeightsFactory(weights);
const extractFCParams = extractFCParamsFactory(extractWeights, paramMappings); const extractFCParams = common_1.extractFCParamsFactory(extractWeights, paramMappings);
const age = extractFCParams(512, 1, 'fc/age'); const age = extractFCParams(512, 1, 'fc/age');
const gender = extractFCParams(512, 2, 'fc/gender'); const gender = extractFCParams(512, 2, 'fc/gender');
if (getRemainingWeights().length !== 0) { if (getRemainingWeights().length !== 0) {
@ -13,4 +16,5 @@ export function extractParams(weights) {
params: { fc: { age, gender } } params: { fc: { age, gender } }
}; };
} }
exports.extractParams = extractParams;
//# sourceMappingURL=extractParams.js.map //# sourceMappingURL=extractParams.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractParams.js","sourceRoot":"","sources":["../../src/ageGenderNet/extractParams.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAgB,MAAM,WAAW,CAAC;AAGxF,MAAM,UAAU,aAAa,CAAC,OAAqB;IAEjD,MAAM,aAAa,GAAmB,EAAE,CAAA;IAExC,MAAM,EACJ,cAAc,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,GAAG,EAAE,MAAM,EAAE,EAAE;KAChC,CAAA;AACH,CAAC;AAtBD,sCAsBC"}

View File

@ -1,7 +1,10 @@
import { disposeUnusedWeightTensors, extractWeightEntryFactory } from '../common'; "use strict";
export function extractParamsFromWeigthMap(weightMap) { Object.defineProperty(exports, "__esModule", { value: true });
exports.extractParamsFromWeigthMap = void 0;
const common_1 = require("../common");
function extractParamsFromWeigthMap(weightMap) {
const paramMappings = []; const paramMappings = [];
const extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings); const extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
function extractFcParams(prefix) { function extractFcParams(prefix) {
const weights = extractWeightEntry(`${prefix}/weights`, 2); const weights = extractWeightEntry(`${prefix}/weights`, 2);
const bias = extractWeightEntry(`${prefix}/bias`, 1); const bias = extractWeightEntry(`${prefix}/bias`, 1);
@ -13,7 +16,8 @@ export function extractParamsFromWeigthMap(weightMap) {
gender: extractFcParams('fc/gender') gender: extractFcParams('fc/gender')
} }
}; };
disposeUnusedWeightTensors(weightMap, paramMappings); common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params, paramMappings }; return { params, paramMappings };
} }
exports.extractParamsFromWeigthMap = extractParamsFromWeigthMap;
//# sourceMappingURL=extractParamsFromWeigthMap.js.map //# sourceMappingURL=extractParamsFromWeigthMap.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractParamsFromWeigthMap.js","sourceRoot":"","sources":["../../src/ageGenderNet/extractParamsFromWeigthMap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAA0B,MAAM,WAAW,CAAC;AAG1G,MAAM,UAAU,0BAA0B,CACxC,SAA4B;IAG5B,MAAM,aAAa,GAAmB,EAAE,CAAA;IAExC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE9E,SAAS,eAAe,CAAC,MAAc;QACrC,MAAM,OAAO,GAAG,kBAAkB,CAAc,GAAG,MAAM,UAAU,EAAE,CAAC,CAAC,CAAA;QACvE,MAAM,IAAI,GAAG,kBAAkB,CAAc,GAAG,MAAM,OAAO,EAAE,CAAC,CAAC,CAAA;QACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC;IAED,MAAM,MAAM,GAAG;QACb,EAAE,EAAE;YACF,GAAG,EAAE,eAAe,CAAC,QAAQ,CAAC;YAC9B,MAAM,EAAE,eAAe,CAAC,WAAW,CAAC;SACrC;KACF,CAAA;IAED,0BAA0B,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAEpD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAA;AAClC,CAAC"} {"version":3,"file":"extractParamsFromWeigthMap.js","sourceRoot":"","sources":["../../src/ageGenderNet/extractParamsFromWeigthMap.ts"],"names":[],"mappings":";;;AAEA,sCAA0G;AAG1G,SAAgB,0BAA0B,CACxC,SAA4B;IAG5B,MAAM,aAAa,GAAmB,EAAE,CAAA;IAExC,MAAM,kBAAkB,GAAG,kCAAyB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE9E,SAAS,eAAe,CAAC,MAAc;QACrC,MAAM,OAAO,GAAG,kBAAkB,CAAc,GAAG,MAAM,UAAU,EAAE,CAAC,CAAC,CAAA;QACvE,MAAM,IAAI,GAAG,kBAAkB,CAAc,GAAG,MAAM,OAAO,EAAE,CAAC,CAAC,CAAA;QACjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC;IAED,MAAM,MAAM,GAAG;QACb,EAAE,EAAE;YACF,GAAG,EAAE,eAAe,CAAC,QAAQ,CAAC;YAC9B,MAAM,EAAE,eAAe,CAAC,WAAW,CAAC;SACrC;KACF,CAAA;IAED,mCAA0B,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAEpD,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,CAAA;AAClC,CAAC;AAxBD,gEAwBC"}

View File

@ -1,3 +1,6 @@
export * from './AgeGenderNet'; "use strict";
export * from './types'; Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./AgeGenderNet"), exports);
tslib_1.__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ageGenderNet/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"} {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ageGenderNet/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,kDAAwB"}

View File

@ -1,6 +1,9 @@
export var Gender; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Gender = void 0;
var Gender;
(function (Gender) { (function (Gender) {
Gender["FEMALE"] = "female"; Gender["FEMALE"] = "female";
Gender["MALE"] = "male"; Gender["MALE"] = "male";
})(Gender || (Gender = {})); })(Gender = exports.Gender || (exports.Gender = {}));
//# sourceMappingURL=types.js.map //# sourceMappingURL=types.js.map

View File

@ -1 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ageGenderNet/types.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,KAAN,MAAM,QAGjB"} {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ageGenderNet/types.ts"],"names":[],"mappings":";;;AAUA,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,GAAN,cAAM,KAAN,cAAM,QAGjB"}

View File

@ -1,7 +1,11 @@
import { Box } from './Box'; "use strict";
export class BoundingBox extends Box { Object.defineProperty(exports, "__esModule", { value: true });
exports.BoundingBox = void 0;
const Box_1 = require("./Box");
class BoundingBox extends Box_1.Box {
constructor(left, top, right, bottom, allowNegativeDimensions = false) { constructor(left, top, right, bottom, allowNegativeDimensions = false) {
super({ left, top, right, bottom }, allowNegativeDimensions); super({ left, top, right, bottom }, allowNegativeDimensions);
} }
} }
exports.BoundingBox = BoundingBox;
//# sourceMappingURL=BoundingBox.js.map //# sourceMappingURL=BoundingBox.js.map

View File

@ -1 +1 @@
{"version":3,"file":"BoundingBox.js","sourceRoot":"","sources":["../../src/classes/BoundingBox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAS5B,MAAM,OAAO,WAAY,SAAQ,GAAgB;IAC/C,YAAY,IAAY,EAAE,GAAW,EAAE,KAAa,EAAE,MAAc,EAAE,0BAAmC,KAAK;QAC5G,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAA;IAC9D,CAAC;CACF"} {"version":3,"file":"BoundingBox.js","sourceRoot":"","sources":["../../src/classes/BoundingBox.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAS5B,MAAa,WAAY,SAAQ,SAAgB;IAC/C,YAAY,IAAY,EAAE,GAAW,EAAE,KAAa,EAAE,MAAc,EAAE,0BAAmC,KAAK;QAC5G,KAAK,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAA;IAC9D,CAAC;CACF;AAJD,kCAIC"}

View File

@ -1,10 +1,13 @@
import { isDimensions, isValidNumber } from '../utils'; "use strict";
import { Point } from './Point'; Object.defineProperty(exports, "__esModule", { value: true });
export class Box { exports.Box = void 0;
const utils_1 = require("../utils");
const Point_1 = require("./Point");
class Box {
constructor(_box, allowNegativeDimensions = true) { constructor(_box, allowNegativeDimensions = true) {
const box = (_box || {}); const box = (_box || {});
const isBbox = [box.left, box.top, box.right, box.bottom].every(isValidNumber); const isBbox = [box.left, box.top, box.right, box.bottom].every(utils_1.isValidNumber);
const isRect = [box.x, box.y, box.width, box.height].every(isValidNumber); const isRect = [box.x, box.y, box.width, box.height].every(utils_1.isValidNumber);
if (!isRect && !isBbox) { if (!isRect && !isBbox) {
throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(box)}`); throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(box)}`);
} }
@ -18,7 +21,7 @@ export class Box {
this._height = height; this._height = height;
} }
static isRect(rect) { static isRect(rect) {
return !!rect && [rect.x, rect.y, rect.width, rect.height].every(isValidNumber); return !!rect && [rect.x, rect.y, rect.width, rect.height].every(utils_1.isValidNumber);
} }
static assertIsValidBox(box, callee, allowNegativeDimensions = false) { static assertIsValidBox(box, callee, allowNegativeDimensions = false) {
if (!Box.isRect(box)) { if (!Box.isRect(box)) {
@ -37,10 +40,10 @@ export class Box {
get right() { return this.x + this.width; } get right() { return this.x + this.width; }
get bottom() { return this.y + this.height; } get bottom() { return this.y + this.height; }
get area() { return this.width * this.height; } get area() { return this.width * this.height; }
get topLeft() { return new Point(this.left, this.top); } get topLeft() { return new Point_1.Point(this.left, this.top); }
get topRight() { return new Point(this.right, this.top); } get topRight() { return new Point_1.Point(this.right, this.top); }
get bottomLeft() { return new Point(this.left, this.bottom); } get bottomLeft() { return new Point_1.Point(this.left, this.bottom); }
get bottomRight() { return new Point(this.right, this.bottom); } get bottomRight() { return new Point_1.Point(this.right, this.bottom); }
round() { round() {
const [x, y, width, height] = [this.x, this.y, this.width, this.height] const [x, y, width, height] = [this.x, this.y, this.width, this.height]
.map(val => Math.round(val)); .map(val => Math.round(val));
@ -65,8 +68,8 @@ export class Box {
return new Box({ x, y, width, height }); return new Box({ x, y, width, height });
} }
rescale(s) { rescale(s) {
const scaleX = isDimensions(s) ? s.width : s; const scaleX = utils_1.isDimensions(s) ? s.width : s;
const scaleY = isDimensions(s) ? s.height : s; const scaleY = utils_1.isDimensions(s) ? s.height : s;
return new Box({ return new Box({
x: this.x * scaleX, x: this.x * scaleX,
y: this.y * scaleY, y: this.y * scaleY,
@ -137,4 +140,5 @@ export class Box {
}).toSquare().round(); }).toSquare().round();
} }
} }
exports.Box = Box;
//# sourceMappingURL=Box.js.map //# sourceMappingURL=Box.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,10 @@
import { isValidNumber } from '../utils'; "use strict";
export class Dimensions { Object.defineProperty(exports, "__esModule", { value: true });
exports.Dimensions = void 0;
const utils_1 = require("../utils");
class Dimensions {
constructor(width, height) { constructor(width, height) {
if (!isValidNumber(width) || !isValidNumber(height)) { if (!utils_1.isValidNumber(width) || !utils_1.isValidNumber(height)) {
throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({ width, height })}`); throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({ width, height })}`);
} }
this._width = width; this._width = width;
@ -13,4 +16,5 @@ export class Dimensions {
return new Dimensions(1 / this.width, 1 / this.height); return new Dimensions(1 / this.width, 1 / this.height);
} }
} }
exports.Dimensions = Dimensions;
//# sourceMappingURL=Dimensions.js.map //# sourceMappingURL=Dimensions.js.map

View File

@ -1 +1 @@
{"version":3,"file":"Dimensions.js","sourceRoot":"","sources":["../../src/classes/Dimensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOzC,MAAM,OAAO,UAAU;IAKrB,YAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE;YACnD,MAAM,IAAI,KAAK,CAAC,wFAAwF,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;SAC7I;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,OAAO,CAAA,CAAC,CAAC;IAE5C,OAAO;QACZ,OAAO,IAAI,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;CACF"} {"version":3,"file":"Dimensions.js","sourceRoot":"","sources":["../../src/classes/Dimensions.ts"],"names":[],"mappings":";;;AAAA,oCAAyC;AAOzC,MAAa,UAAU;IAKrB,YAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,qBAAa,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAa,CAAC,MAAM,CAAC,EAAE;YACnD,MAAM,IAAI,KAAK,CAAC,wFAAwF,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;SAC7I;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,OAAO,CAAA,CAAC,CAAC;IAE5C,OAAO;QACZ,OAAO,IAAI,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;CACF;AApBD,gCAoBC"}

View File

@ -1,5 +1,8 @@
import { ObjectDetection } from './ObjectDetection'; "use strict";
export class FaceDetection extends ObjectDetection { Object.defineProperty(exports, "__esModule", { value: true });
exports.FaceDetection = void 0;
const ObjectDetection_1 = require("./ObjectDetection");
class FaceDetection extends ObjectDetection_1.ObjectDetection {
constructor(score, relativeBox, imageDims) { constructor(score, relativeBox, imageDims) {
super(score, score, '', relativeBox, imageDims); super(score, score, '', relativeBox, imageDims);
} }
@ -8,4 +11,5 @@ export class FaceDetection extends ObjectDetection {
return new FaceDetection(score, relativeBox, imageDims); return new FaceDetection(score, relativeBox, imageDims);
} }
} }
exports.FaceDetection = FaceDetection;
//# sourceMappingURL=FaceDetection.js.map //# sourceMappingURL=FaceDetection.js.map

View File

@ -1 +1 @@
{"version":3,"file":"FaceDetection.js","sourceRoot":"","sources":["../../src/classes/FaceDetection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQpD,MAAM,OAAO,aAAc,SAAQ,eAAe;IAChD,YACE,KAAa,EACb,WAAiB,EACjB,SAAsB;QAEtB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;IACjD,CAAC;IAEM,OAAO,CAAC,KAAa,EAAE,MAAc;QAC1C,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QACtE,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;IACzD,CAAC;CACF"} {"version":3,"file":"FaceDetection.js","sourceRoot":"","sources":["../../src/classes/FaceDetection.ts"],"names":[],"mappings":";;;AAEA,uDAAoD;AAQpD,MAAa,aAAc,SAAQ,iCAAe;IAChD,YACE,KAAa,EACb,WAAiB,EACjB,SAAsB;QAEtB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;IACjD,CAAC;IAEM,OAAO,CAAC,KAAa,EAAE,MAAc;QAC1C,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QACtE,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;IACzD,CAAC;CACF;AAbD,sCAaC"}

View File

@ -1,33 +1,36 @@
import { minBbox } from '../ops'; "use strict";
import { getCenterPoint } from '../utils'; Object.defineProperty(exports, "__esModule", { value: true });
import { Box } from './Box'; exports.FaceLandmarks = void 0;
import { Dimensions } from './Dimensions'; const ops_1 = require("../ops");
import { FaceDetection } from './FaceDetection'; const utils_1 = require("../utils");
import { Point } from './Point'; const Box_1 = require("./Box");
import { Rect } from './Rect'; const Dimensions_1 = require("./Dimensions");
const FaceDetection_1 = require("./FaceDetection");
const Point_1 = require("./Point");
const Rect_1 = require("./Rect");
// face alignment constants // face alignment constants
const relX = 0.5; const relX = 0.5;
const relY = 0.43; const relY = 0.43;
const relScale = 0.45; const relScale = 0.45;
export class FaceLandmarks { class FaceLandmarks {
constructor(relativeFaceLandmarkPositions, imgDims, shift = new Point(0, 0)) { constructor(relativeFaceLandmarkPositions, imgDims, shift = new Point_1.Point(0, 0)) {
const { width, height } = imgDims; const { width, height } = imgDims;
this._imgDims = new Dimensions(width, height); this._imgDims = new Dimensions_1.Dimensions(width, height);
this._shift = shift; this._shift = shift;
this._positions = relativeFaceLandmarkPositions.map(pt => pt.mul(new Point(width, height)).add(shift)); this._positions = relativeFaceLandmarkPositions.map(pt => pt.mul(new Point_1.Point(width, height)).add(shift));
} }
get shift() { return new Point(this._shift.x, this._shift.y); } get shift() { return new Point_1.Point(this._shift.x, this._shift.y); }
get imageWidth() { return this._imgDims.width; } get imageWidth() { return this._imgDims.width; }
get imageHeight() { return this._imgDims.height; } get imageHeight() { return this._imgDims.height; }
get positions() { return this._positions; } get positions() { return this._positions; }
get relativePositions() { get relativePositions() {
return this._positions.map(pt => pt.sub(this._shift).div(new Point(this.imageWidth, this.imageHeight))); return this._positions.map(pt => pt.sub(this._shift).div(new Point_1.Point(this.imageWidth, this.imageHeight)));
} }
forSize(width, height) { forSize(width, height) {
return new this.constructor(this.relativePositions, { width, height }); return new this.constructor(this.relativePositions, { width, height });
} }
shiftBy(x, y) { shiftBy(x, y) {
return new this.constructor(this.relativePositions, this._imgDims, new Point(x, y)); return new this.constructor(this.relativePositions, this._imgDims, new Point_1.Point(x, y));
} }
shiftByPoint(pt) { shiftByPoint(pt) {
return this.shiftBy(pt.x, pt.y); return this.shiftBy(pt.x, pt.y);
@ -45,9 +48,9 @@ export class FaceLandmarks {
*/ */
align(detection, options = {}) { align(detection, options = {}) {
if (detection) { if (detection) {
const box = detection instanceof FaceDetection const box = detection instanceof FaceDetection_1.FaceDetection
? detection.box.floor() ? detection.box.floor()
: new Box(detection); : new Box_1.Box(detection);
return this.shiftBy(box.x, box.y).align(null, options); return this.shiftBy(box.x, box.y).align(null, options);
} }
const { useDlibAlignment, minBoxPadding } = Object.assign({}, { useDlibAlignment: false, minBoxPadding: 0.2 }, options); const { useDlibAlignment, minBoxPadding } = Object.assign({}, { useDlibAlignment: false, minBoxPadding: 0.2 }, options);
@ -62,18 +65,19 @@ export class FaceLandmarks {
const distToMouth = (pt) => mouthCenter.sub(pt).magnitude(); const distToMouth = (pt) => mouthCenter.sub(pt).magnitude();
const eyeToMouthDist = (distToMouth(leftEyeCenter) + distToMouth(rightEyeCenter)) / 2; const eyeToMouthDist = (distToMouth(leftEyeCenter) + distToMouth(rightEyeCenter)) / 2;
const size = Math.floor(eyeToMouthDist / relScale); const size = Math.floor(eyeToMouthDist / relScale);
const refPoint = getCenterPoint(centers); const refPoint = utils_1.getCenterPoint(centers);
// TODO: pad in case rectangle is out of image bounds // TODO: pad in case rectangle is out of image bounds
const x = Math.floor(Math.max(0, refPoint.x - (relX * size))); const x = Math.floor(Math.max(0, refPoint.x - (relX * size)));
const y = Math.floor(Math.max(0, refPoint.y - (relY * size))); const y = Math.floor(Math.max(0, refPoint.y - (relY * size)));
return new Rect(x, y, Math.min(size, this.imageWidth + x), Math.min(size, this.imageHeight + y)); return new Rect_1.Rect(x, y, Math.min(size, this.imageWidth + x), Math.min(size, this.imageHeight + y));
} }
alignMinBbox(padding) { alignMinBbox(padding) {
const box = minBbox(this.positions); const box = ops_1.minBbox(this.positions);
return box.pad(box.width * padding, box.height * padding); return box.pad(box.width * padding, box.height * padding);
} }
getRefPointsForAlignment() { getRefPointsForAlignment() {
throw new Error('getRefPointsForAlignment not implemented by base class'); throw new Error('getRefPointsForAlignment not implemented by base class');
} }
} }
exports.FaceLandmarks = FaceLandmarks;
//# sourceMappingURL=FaceLandmarks.js.map //# sourceMappingURL=FaceLandmarks.js.map

View File

@ -1 +1 @@
{"version":3,"file":"FaceLandmarks.js","sourceRoot":"","sources":["../../src/classes/FaceLandmarks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAS,IAAI,EAAE,MAAM,QAAQ,CAAC;AAErC,2BAA2B;AAC3B,MAAM,IAAI,GAAG,GAAG,CAAA;AAChB,MAAM,IAAI,GAAG,IAAI,CAAA;AACjB,MAAM,QAAQ,GAAG,IAAI,CAAA;AAOrB,MAAM,OAAO,aAAa;IAKxB,YACE,6BAAsC,EACtC,OAAoB,EACpB,QAAe,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QAE9B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC7C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,UAAU,GAAG,6BAA6B,CAAC,GAAG,CACj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,CAAA;QAClE,MAAM,cAAc,GAAG,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAA;QAErF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,QAAQ,CAAC,CAAA;QAElD,MAAM,QAAQ,GAAG,sBAAc,CAAC,OAAO,CAAC,CAAA;QACxC,qDAAqD;QACrD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QAC7D,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QAE7D,OAAO,IAAI,WAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,CAAA;IAClG,CAAC;IAEO,YAAY,CAAC,OAAe;QAClC,MAAM,GAAG,GAAG,aAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACnC,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,EAAE,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,CAAA;IAC3D,CAAC;IAES,wBAAwB;QAChC,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;IAC3E,CAAC;CACF;AAzGD,sCAyGC"}

View File

@ -1,13 +1,17 @@
import { getCenterPoint } from '../utils'; "use strict";
import { FaceLandmarks } from './FaceLandmarks'; Object.defineProperty(exports, "__esModule", { value: true });
export class FaceLandmarks5 extends FaceLandmarks { exports.FaceLandmarks5 = void 0;
const utils_1 = require("../utils");
const FaceLandmarks_1 = require("./FaceLandmarks");
class FaceLandmarks5 extends FaceLandmarks_1.FaceLandmarks {
getRefPointsForAlignment() { getRefPointsForAlignment() {
const pts = this.positions; const pts = this.positions;
return [ return [
pts[0], pts[0],
pts[1], pts[1],
getCenterPoint([pts[3], pts[4]]) utils_1.getCenterPoint([pts[3], pts[4]])
]; ];
} }
} }
exports.FaceLandmarks5 = FaceLandmarks5;
//# sourceMappingURL=FaceLandmarks5.js.map //# sourceMappingURL=FaceLandmarks5.js.map

View File

@ -1 +1 @@
{"version":3,"file":"FaceLandmarks5.js","sourceRoot":"","sources":["../../src/classes/FaceLandmarks5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,MAAM,OAAO,cAAe,SAAQ,aAAa;IAErC,wBAAwB;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAA;QAC1B,OAAO;YACL,GAAG,CAAC,CAAC,CAAC;YACN,GAAG,CAAC,CAAC,CAAC;YACN,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACjC,CAAA;IACH,CAAC;CACF"} {"version":3,"file":"FaceLandmarks5.js","sourceRoot":"","sources":["../../src/classes/FaceLandmarks5.ts"],"names":[],"mappings":";;;AAAA,oCAA0C;AAC1C,mDAAgD;AAIhD,MAAa,cAAe,SAAQ,6BAAa;IAErC,wBAAwB;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAA;QAC1B,OAAO;YACL,GAAG,CAAC,CAAC,CAAC;YACN,GAAG,CAAC,CAAC,CAAC;YACN,sBAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACjC,CAAA;IACH,CAAC;CACF;AAVD,wCAUC"}

View File

@ -1,6 +1,9 @@
import { getCenterPoint } from '../utils'; "use strict";
import { FaceLandmarks } from './FaceLandmarks'; Object.defineProperty(exports, "__esModule", { value: true });
export class FaceLandmarks68 extends FaceLandmarks { exports.FaceLandmarks68 = void 0;
const utils_1 = require("../utils");
const FaceLandmarks_1 = require("./FaceLandmarks");
class FaceLandmarks68 extends FaceLandmarks_1.FaceLandmarks {
getJawOutline() { getJawOutline() {
return this.positions.slice(0, 17); return this.positions.slice(0, 17);
} }
@ -27,7 +30,8 @@ export class FaceLandmarks68 extends FaceLandmarks {
this.getLeftEye(), this.getLeftEye(),
this.getRightEye(), this.getRightEye(),
this.getMouth() this.getMouth()
].map(getCenterPoint); ].map(utils_1.getCenterPoint);
} }
} }
exports.FaceLandmarks68 = FaceLandmarks68;
//# sourceMappingURL=FaceLandmarks68.js.map //# sourceMappingURL=FaceLandmarks68.js.map

View File

@ -1 +1 @@
{"version":3,"file":"FaceLandmarks68.js","sourceRoot":"","sources":["../../src/classes/FaceLandmarks68.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,MAAM,OAAO,eAAgB,SAAQ,aAAa;IACzC,aAAa;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACpC,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,eAAe;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAA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EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAES,wBAAwB;QAChC,OAAO;YACL,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,QAAQ,EAAE;SAChB,CAAC,GAAG,CAAC,sBAAc,CAAC,CAAA;IACvB,CAAC;CACF;AApCD,0CAoCC"}

View File

@ -1,5 +1,8 @@
import { round } from '../utils'; "use strict";
export class FaceMatch { Object.defineProperty(exports, "__esModule", { value: true });
exports.FaceMatch = void 0;
const utils_1 = require("../utils");
class FaceMatch {
constructor(label, distance) { constructor(label, distance) {
this._label = label; this._label = label;
this._distance = distance; this._distance = distance;
@ -7,7 +10,8 @@ export class FaceMatch {
get label() { return this._label; } get label() { return this._label; }
get distance() { return this._distance; } get distance() { return this._distance; }
toString(withDistance = true) { toString(withDistance = true) {
return `${this.label}${withDistance ? ` (${round(this.distance)})` : ''}`; return `${this.label}${withDistance ? ` (${utils_1.round(this.distance)})` : ''}`;
} }
} }
exports.FaceMatch = FaceMatch;
//# sourceMappingURL=FaceMatch.js.map //# sourceMappingURL=FaceMatch.js.map

View File

@ -1 +1 @@
{"version":3,"file":"FaceMatch.js","sourceRoot":"","sources":["../../src/classes/FaceMatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAOjC,MAAM,OAAO,SAAS;IAIpB,YAAY,KAAa,EAAE,QAAgB;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC3B,CAAC;IAED,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,QAAQ,KAAa,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IAEhD,QAAQ,CAAC,eAAwB,IAAI;QAC1C,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAC3E,CAAC;CACF"} {"version":3,"file":"FaceMatch.js","sourceRoot":"","sources":["../../src/classes/FaceMatch.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAOjC,MAAa,SAAS;IAIpB,YAAY,KAAa,EAAE,QAAgB;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC3B,CAAC;IAED,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,QAAQ,KAAa,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;IAEhD,QAAQ,CAAC,eAAwB,IAAI;QAC1C,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,KAAK,aAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAC3E,CAAC;CACF;AAfD,8BAeC"}

View File

@ -1,16 +1,20 @@
import { isValidNumber } from '../utils'; "use strict";
import { Box } from './Box'; Object.defineProperty(exports, "__esModule", { value: true });
export class LabeledBox extends Box { exports.LabeledBox = void 0;
const utils_1 = require("../utils");
const Box_1 = require("./Box");
class LabeledBox extends Box_1.Box {
constructor(box, label) { constructor(box, label) {
super(box); super(box);
this._label = label; this._label = label;
} }
static assertIsValidLabeledBox(box, callee) { static assertIsValidLabeledBox(box, callee) {
Box.assertIsValidBox(box, callee); Box_1.Box.assertIsValidBox(box, callee);
if (!isValidNumber(box.label)) { if (!utils_1.isValidNumber(box.label)) {
throw new Error(`${callee} - expected property label (${box.label}) to be a number`); throw new Error(`${callee} - expected property label (${box.label}) to be a number`);
} }
} }
get label() { return this._label; } get label() { return this._label; }
} }
exports.LabeledBox = LabeledBox;
//# sourceMappingURL=LabeledBox.js.map //# sourceMappingURL=LabeledBox.js.map

View File

@ -1 +1 @@
{"version":3,"file":"LabeledBox.js","sourceRoot":"","sources":["../../src/classes/LabeledBox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,MAAM,OAAO,UAAW,SAAQ,GAAe;IAY7C,YAAY,GAA+B,EAAE,KAAa;QACxD,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAbM,MAAM,CAAC,uBAAuB,CAAC,GAAQ,EAAE,MAAc;QAC5D,GAAG,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAEjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,+BAA+B,GAAG,CAAC,KAAK,kBAAkB,CAAC,CAAA;SACrF;IACH,CAAC;IASD,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;CAElD"} {"version":3,"file":"LabeledBox.js","sourceRoot":"","sources":["../../src/classes/LabeledBox.ts"],"names":[],"mappings":";;;AAAA,oCAAyC;AAEzC,+BAA4B;AAG5B,MAAa,UAAW,SAAQ,SAAe;IAY7C,YAAY,GAA+B,EAAE,KAAa;QACxD,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAbM,MAAM,CAAC,uBAAuB,CAAC,GAAQ,EAAE,MAAc;QAC5D,SAAG,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAEjC,IAAI,CAAC,qBAAa,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,+BAA+B,GAAG,CAAC,KAAK,kBAAkB,CAAC,CAAA;SACrF;IACH,CAAC;IASD,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;CAElD;AAnBD,gCAmBC"}

View File

@ -1,4 +1,7 @@
export class LabeledFaceDescriptors { "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LabeledFaceDescriptors = void 0;
class LabeledFaceDescriptors {
constructor(label, descriptors) { constructor(label, descriptors) {
if (!(typeof label === 'string')) { if (!(typeof label === 'string')) {
throw new Error('LabeledFaceDescriptors - constructor expected label to be a string'); throw new Error('LabeledFaceDescriptors - constructor expected label to be a string');
@ -24,4 +27,5 @@ export class LabeledFaceDescriptors {
return new LabeledFaceDescriptors(json.label, descriptors); return new LabeledFaceDescriptors(json.label, descriptors);
} }
} }
exports.LabeledFaceDescriptors = LabeledFaceDescriptors;
//# sourceMappingURL=LabeledFaceDescriptors.js.map //# sourceMappingURL=LabeledFaceDescriptors.js.map

View File

@ -1 +1 @@
{"version":3,"file":"LabeledFaceDescriptors.js","sourceRoot":"","sources":["../../src/classes/LabeledFaceDescriptors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,sBAAsB;IAIjC,YAAY,KAAa,EAAE,WAA2B;QACpD,IAAI,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAA;SACtF;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,YAAY,YAAY,CAAC,CAAC,EAAE;YAC5F,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAA;SAC5G;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI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;IACjC,CAAC;IAED,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,WAAW,KAAqB,OAAO,IAAI,CAAC,YAAY,CAAA,CAAC,CAAC;IAE9D,MAAM;QACX,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACxD,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAC,IAAS;QAC9B,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE;YAClD,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,sBAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC;CAEF;AAlCD,wDAkCC"}

View File

@ -1,12 +1,15 @@
import { Box } from './Box'; "use strict";
import { Dimensions } from './Dimensions'; Object.defineProperty(exports, "__esModule", { value: true });
export class ObjectDetection { exports.ObjectDetection = void 0;
const Box_1 = require("./Box");
const Dimensions_1 = require("./Dimensions");
class ObjectDetection {
constructor(score, classScore, className, relativeBox, imageDims) { constructor(score, classScore, className, relativeBox, imageDims) {
this._imageDims = new Dimensions(imageDims.width, imageDims.height); this._imageDims = new Dimensions_1.Dimensions(imageDims.width, imageDims.height);
this._score = score; this._score = score;
this._classScore = classScore; this._classScore = classScore;
this._className = className; this._className = className;
this._box = new Box(relativeBox).rescale(this._imageDims); this._box = new Box_1.Box(relativeBox).rescale(this._imageDims);
} }
get score() { return this._score; } get score() { return this._score; }
get classScore() { return this._classScore; } get classScore() { return this._classScore; }
@ -15,9 +18,10 @@ export class ObjectDetection {
get imageDims() { return this._imageDims; } get imageDims() { return this._imageDims; }
get imageWidth() { return this.imageDims.width; } get imageWidth() { return this.imageDims.width; }
get imageHeight() { return this.imageDims.height; } get imageHeight() { return this.imageDims.height; }
get relativeBox() { return new Box(this._box).rescale(this.imageDims.reverse()); } get relativeBox() { return new Box_1.Box(this._box).rescale(this.imageDims.reverse()); }
forSize(width, height) { forSize(width, height) {
return new ObjectDetection(this.score, this.classScore, this.className, this.relativeBox, { width, height }); return new ObjectDetection(this.score, this.classScore, this.className, this.relativeBox, { width, height });
} }
} }
exports.ObjectDetection = ObjectDetection;
//# sourceMappingURL=ObjectDetection.js.map //# sourceMappingURL=ObjectDetection.js.map

View File

@ -1 +1 @@
{"version":3,"file":"ObjectDetection.js","sourceRoot":"","sources":["../../src/classes/ObjectDetection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AAGvD,MAAM,OAAO,eAAe;IAO1B,YACE,KAAa,EACb,UAAkB,EAClB,SAAiB,EACjB,WAAkB,EAClB,SAAsB;QAEtB,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;QACnE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAC3D,CAAC;IAED,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAA,CAAC,CAAC;IAC3D,IAAW,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,CAAA,CAAC,CAAC;IACzD,IAAW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O,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAA,CAAC,CAAC;IAC3D,IAAW,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,CAAA,CAAC,CAAC;IACzD,IAAW,GAAG,KAAU,OAAO,IAAI,CAAC,IAAI,CAAA,CAAC,CAAC;IAC1C,IAAW,SAAS,KAAiB,OAAO,IAAI,CAAC,UAAU,CAAA,CAAC,CAAC;IAC7D,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAA,CAAC,CAAC;IAC/D,IAAW,WAAW,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAA,CAAC,CAAC;IACjE,IAAW,WAAW,KAAU,OAAO,IAAI,SAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA,CAAC,CAAC;IAEtF,OAAO,CAAC,KAAa,EAAE,MAAc;QAC1C,OAAO,IAAI,eAAe,CACxB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,WAAW,EAChB,EAAE,KAAK,EAAE,MAAM,EAAC,CACjB,CAAA;IACH,CAAC;CACF;AAvCD,0CAuCC"}

View File

@ -1,4 +1,7 @@
export class Point { "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Point = void 0;
class Point {
constructor(x, y) { constructor(x, y) {
this._x = x; this._x = x;
this._y = y; this._y = y;
@ -27,4 +30,5 @@ export class Point {
return new Point(Math.floor(this.x), Math.floor(this.y)); return new Point(Math.floor(this.x), Math.floor(this.y));
} }
} }
exports.Point = Point;
//# sourceMappingURL=Point.js.map //# sourceMappingURL=Point.js.map

View File

@ -1 +1 @@
{"version":3,"file":"Point.js","sourceRoot":"","sources":["../../src/classes/Point.ts"],"names":[],"mappings":"AAKA,MAAM,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,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC;IAEM,GAAG;QACR,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IACtD,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC7D,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1D,CAAC;CACF;AAvCD,sBAuCC"}

View File

@ -1,19 +1,23 @@
import { isValidProbablitiy } from '../utils'; "use strict";
import { LabeledBox } from './LabeledBox'; Object.defineProperty(exports, "__esModule", { value: true });
export class PredictedBox extends LabeledBox { exports.PredictedBox = void 0;
const utils_1 = require("../utils");
const LabeledBox_1 = require("./LabeledBox");
class PredictedBox extends LabeledBox_1.LabeledBox {
constructor(box, label, score, classScore) { constructor(box, label, score, classScore) {
super(box, label); super(box, label);
this._score = score; this._score = score;
this._classScore = classScore; this._classScore = classScore;
} }
static assertIsValidPredictedBox(box, callee) { static assertIsValidPredictedBox(box, callee) {
LabeledBox.assertIsValidLabeledBox(box, callee); LabeledBox_1.LabeledBox.assertIsValidLabeledBox(box, callee);
if (!isValidProbablitiy(box.score) if (!utils_1.isValidProbablitiy(box.score)
|| !isValidProbablitiy(box.classScore)) { || !utils_1.isValidProbablitiy(box.classScore)) {
throw new Error(`${callee} - expected properties score (${box.score}) and (${box.classScore}) to be a number between [0, 1]`); throw new Error(`${callee} - expected properties score (${box.score}) and (${box.classScore}) to be a number between [0, 1]`);
} }
} }
get score() { return this._score; } get score() { return this._score; }
get classScore() { return this._classScore; } get classScore() { return this._classScore; }
} }
exports.PredictedBox = PredictedBox;
//# sourceMappingURL=PredictedBox.js.map //# sourceMappingURL=PredictedBox.js.map

View File

@ -1 +1 @@
{"version":3,"file":"PredictedBox.js","sourceRoot":"","sources":["../../src/classes/PredictedBox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,MAAM,OAAO,YAAa,SAAQ,UAAU;IAgB1C,YAAY,GAA+B,EAAE,KAAa,EAAE,KAAa,EAAE,UAAkB;QAC3F,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;IAC/B,CAAC;IAlBM,MAAM,CAAC,yBAAyB,CAAC,GAAQ,EAAE,MAAc;QAC9D,UAAU,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAE/C,IACE,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;eAC3B,CAAC,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EACtC;YACA,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,iCAAiC,GAAG,CAAC,KAAK,UAAU,GAAG,CAAC,UAAU,iCAAiC,CAAC,CAAA;SAC9H;IACH,CAAC;IAWD,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAA,CAAC,CAAC;CAE5D"} {"version":3,"file":"PredictedBox.js","sourceRoot":"","sources":["../../src/classes/PredictedBox.ts"],"names":[],"mappings":";;;AAAA,oCAA8C;AAE9C,6CAA0C;AAG1C,MAAa,YAAa,SAAQ,uBAAU;IAgB1C,YAAY,GAA+B,EAAE,KAAa,EAAE,KAAa,EAAE,UAAkB;QAC3F,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACjB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;IAC/B,CAAC;IAlBM,MAAM,CAAC,yBAAyB,CAAC,GAAQ,EAAE,MAAc;QAC9D,uBAAU,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAE/C,IACE,CAAC,0BAAkB,CAAC,GAAG,CAAC,KAAK,CAAC;eAC3B,CAAC,0BAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,EACtC;YACA,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,iCAAiC,GAAG,CAAC,KAAK,UAAU,GAAG,CAAC,UAAU,iCAAiC,CAAC,CAAA;SAC9H;IACH,CAAC;IAWD,IAAW,KAAK,KAAa,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IACjD,IAAW,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAA,CAAC,CAAC;CAE5D;AAzBD,oCAyBC"}

View File

@ -1,7 +1,11 @@
import { Box } from './Box'; "use strict";
export class Rect extends Box { Object.defineProperty(exports, "__esModule", { value: true });
exports.Rect = void 0;
const Box_1 = require("./Box");
class Rect extends Box_1.Box {
constructor(x, y, width, height, allowNegativeDimensions = false) { constructor(x, y, width, height, allowNegativeDimensions = false) {
super({ x, y, width, height }, allowNegativeDimensions); super({ x, y, width, height }, allowNegativeDimensions);
} }
} }
exports.Rect = Rect;
//# sourceMappingURL=Rect.js.map //# sourceMappingURL=Rect.js.map

View File

@ -1 +1 @@
{"version":3,"file":"Rect.js","sourceRoot":"","sources":["../../src/classes/Rect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAS5B,MAAM,OAAO,IAAK,SAAQ,GAAS;IACjC,YAAY,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,MAAc,EAAE,0BAAmC,KAAK;QACvG,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAA;IACzD,CAAC;CACF"} {"version":3,"file":"Rect.js","sourceRoot":"","sources":["../../src/classes/Rect.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAS5B,MAAa,IAAK,SAAQ,SAAS;IACjC,YAAY,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,MAAc,EAAE,0BAAmC,KAAK;QACvG,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,uBAAuB,CAAC,CAAA;IACzD,CAAC;CACF;AAJD,oBAIC"}

View File

@ -1,15 +1,18 @@
export * from './BoundingBox'; "use strict";
export * from './Box'; Object.defineProperty(exports, "__esModule", { value: true });
export * from './Dimensions'; const tslib_1 = require("tslib");
export * from './FaceDetection'; tslib_1.__exportStar(require("./BoundingBox"), exports);
export * from './FaceLandmarks'; tslib_1.__exportStar(require("./Box"), exports);
export * from './FaceLandmarks5'; tslib_1.__exportStar(require("./Dimensions"), exports);
export * from './FaceLandmarks68'; tslib_1.__exportStar(require("./FaceDetection"), exports);
export * from './FaceMatch'; tslib_1.__exportStar(require("./FaceLandmarks"), exports);
export * from './LabeledBox'; tslib_1.__exportStar(require("./FaceLandmarks5"), exports);
export * from './LabeledFaceDescriptors'; tslib_1.__exportStar(require("./FaceLandmarks68"), exports);
export * from './ObjectDetection'; tslib_1.__exportStar(require("./FaceMatch"), exports);
export * from './Point'; tslib_1.__exportStar(require("./LabeledBox"), exports);
export * from './PredictedBox'; tslib_1.__exportStar(require("./LabeledFaceDescriptors"), exports);
export * from './Rect'; tslib_1.__exportStar(require("./ObjectDetection"), exports);
tslib_1.__exportStar(require("./Point"), exports);
tslib_1.__exportStar(require("./PredictedBox"), exports);
tslib_1.__exportStar(require("./Rect"), exports);
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,OAAO,CAAA;AACrB,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA"} {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,gDAAqB;AACrB,uDAA4B;AAC5B,0DAAgC;AAChC,0DAAgC;AAChC,2DAAiC;AACjC,4DAAkC;AAClC,sDAA4B;AAC5B,uDAA4B;AAC5B,mEAAyC;AACzC,4DAAiC;AACjC,kDAAuB;AACvB,yDAA8B;AAC9B,iDAAsB"}

View File

@ -1,8 +1,12 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
export function convLayer(x, params, padding = 'same', withRelu = false) { Object.defineProperty(exports, "__esModule", { value: true });
exports.convLayer = void 0;
const tf = require("@tensorflow/tfjs-core");
function convLayer(x, params, padding = 'same', withRelu = false) {
return tf.tidy(() => { return tf.tidy(() => {
const out = tf.add(tf.conv2d(x, params.filters, [1, 1], padding), params.bias); const out = tf.add(tf.conv2d(x, params.filters, [1, 1], padding), params.bias);
return withRelu ? tf.relu(out) : out; return withRelu ? tf.relu(out) : out;
}); });
} }
exports.convLayer = convLayer;
//# sourceMappingURL=convLayer.js.map //# sourceMappingURL=convLayer.js.map

View File

@ -1 +1 @@
{"version":3,"file":"convLayer.js","sourceRoot":"","sources":["../../src/common/convLayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI5C,MAAM,UAAU,SAAS,CACvB,CAAc,EACd,MAAkB,EAClB,UAA4B,MAAM,EAClC,WAAoB,KAAK;IAEzB,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAClB,MAAM,GAAG,GAAG,EAAE,CAAC,GAAG,CAChB,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,MAAM,CAAC,IAAI,CACG,CAAA;QAEhB,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACtC,CAAC,CAAC,CAAA;AACJ,CAAC"} {"version":3,"file":"convLayer.js","sourceRoot":"","sources":["../../src/common/convLayer.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAI5C,SAAgB,SAAS,CACvB,CAAc,EACd,MAAkB,EAClB,UAA4B,MAAM,EAClC,WAAoB,KAAK;IAEzB,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAClB,MAAM,GAAG,GAAG,EAAE,CAAC,GAAG,CAChB,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7C,MAAM,CAAC,IAAI,CACG,CAAA;QAEhB,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACtC,CAAC,CAAC,CAAA;AACJ,CAAC;AAdD,8BAcC"}

View File

@ -1,9 +1,13 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
export function depthwiseSeparableConv(x, params, stride) { Object.defineProperty(exports, "__esModule", { value: true });
exports.depthwiseSeparableConv = void 0;
const tf = require("@tensorflow/tfjs-core");
function depthwiseSeparableConv(x, params, stride) {
return tf.tidy(() => { return tf.tidy(() => {
let out = tf.separableConv2d(x, params.depthwise_filter, params.pointwise_filter, stride, 'same'); let out = tf.separableConv2d(x, params.depthwise_filter, params.pointwise_filter, stride, 'same');
out = tf.add(out, params.bias); out = tf.add(out, params.bias);
return out; return out;
}); });
} }
exports.depthwiseSeparableConv = depthwiseSeparableConv;
//# sourceMappingURL=depthwiseSeparableConv.js.map //# sourceMappingURL=depthwiseSeparableConv.js.map

View File

@ -1 +1 @@
{"version":3,"file":"depthwiseSeparableConv.js","sourceRoot":"","sources":["../../src/common/depthwiseSeparableConv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI5C,MAAM,UAAU,sBAAsB,CACpC,CAAc,EACd,MAA2B,EAC3B,MAAwB;IAExB,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAClB,IAAI,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;QACjG,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC"} {"version":3,"file":"depthwiseSeparableConv.js","sourceRoot":"","sources":["../../src/common/depthwiseSeparableConv.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAI5C,SAAgB,sBAAsB,CACpC,CAAc,EACd,MAA2B,EAC3B,MAAwB;IAExB,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAClB,IAAI,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;QACjG,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC;AAVD,wDAUC"}

View File

@ -1,8 +1,12 @@
export function disposeUnusedWeightTensors(weightMap, paramMappings) { "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.disposeUnusedWeightTensors = void 0;
function disposeUnusedWeightTensors(weightMap, paramMappings) {
Object.keys(weightMap).forEach(path => { Object.keys(weightMap).forEach(path => {
if (!paramMappings.some(pm => pm.originalPath === path)) { if (!paramMappings.some(pm => pm.originalPath === path)) {
weightMap[path].dispose(); weightMap[path].dispose();
} }
}); });
} }
exports.disposeUnusedWeightTensors = disposeUnusedWeightTensors;
//# sourceMappingURL=disposeUnusedWeightTensors.js.map //# sourceMappingURL=disposeUnusedWeightTensors.js.map

View File

@ -1 +1 @@
{"version":3,"file":"disposeUnusedWeightTensors.js","sourceRoot":"","sources":["../../src/common/disposeUnusedWeightTensors.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,0BAA0B,CAAC,SAAc,EAAE,aAA6B;IACtF,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,KAAK,IAAI,CAAC,EAAE;YACvD,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;SAC1B;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"} {"version":3,"file":"disposeUnusedWeightTensors.js","sourceRoot":"","sources":["../../src/common/disposeUnusedWeightTensors.ts"],"names":[],"mappings":";;;AAEA,SAAgB,0BAA0B,CAAC,SAAc,EAAE,aAA6B;IACtF,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,KAAK,IAAI,CAAC,EAAE;YACvD,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;SAC1B;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAND,gEAMC"}

View File

@ -1,5 +1,8 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
export function extractConvParamsFactory(extractWeights, paramMappings) { Object.defineProperty(exports, "__esModule", { value: true });
exports.extractConvParamsFactory = void 0;
const tf = require("@tensorflow/tfjs-core");
function extractConvParamsFactory(extractWeights, paramMappings) {
return function (channelsIn, channelsOut, filterSize, mappedPrefix) { return function (channelsIn, channelsOut, filterSize, mappedPrefix) {
const filters = tf.tensor4d(extractWeights(channelsIn * channelsOut * filterSize * filterSize), [filterSize, filterSize, channelsIn, channelsOut]); const filters = tf.tensor4d(extractWeights(channelsIn * channelsOut * filterSize * filterSize), [filterSize, filterSize, channelsIn, channelsOut]);
const bias = tf.tensor1d(extractWeights(channelsOut)); const bias = tf.tensor1d(extractWeights(channelsOut));
@ -7,4 +10,5 @@ export function extractConvParamsFactory(extractWeights, paramMappings) {
return { filters, bias }; return { filters, bias };
}; };
} }
exports.extractConvParamsFactory = extractConvParamsFactory;
//# sourceMappingURL=extractConvParamsFactory.js.map //# sourceMappingURL=extractConvParamsFactory.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractConvParamsFactory.js","sourceRoot":"","sources":["../../src/common/extractConvParamsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI5C,MAAM,UAAU,wBAAwB,CACtC,cAAsC,EACtC,aAA6B;IAG7B,OAAO,UACL,UAAkB,EAClB,WAAmB,EACnB,UAAkB,EAClB,YAAoB;QAGpB,MAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,CACzB,cAAc,CAAC,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC,EAClE,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,CAClD,CAAA;QACD,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;QAErD,aAAa,CAAC,IAAI,CAChB,EAAE,SAAS,EAAE,GAAG,YAAY,UAAU,EAAE,EACxC,EAAE,SAAS,EAAE,GAAG,YAAY,OAAO,EAAE,CACtC,CAAA;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC,CAAA;AAEH,CAAC"} {"version":3,"file":"extractConvParamsFactory.js","sourceRoot":"","sources":["../../src/common/extractConvParamsFactory.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAI5C,SAAgB,wBAAwB,CACtC,cAAsC,EACtC,aAA6B;IAG7B,OAAO,UACL,UAAkB,EAClB,WAAmB,EACnB,UAAkB,EAClB,YAAoB;QAGpB,MAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,CACzB,cAAc,CAAC,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC,EAClE,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,CAClD,CAAA;QACD,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;QAErD,aAAa,CAAC,IAAI,CAChB,EAAE,SAAS,EAAE,GAAG,YAAY,UAAU,EAAE,EACxC,EAAE,SAAS,EAAE,GAAG,YAAY,OAAO,EAAE,CACtC,CAAA;QAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC,CAAA;AAEH,CAAC;AA1BD,4DA0BC"}

View File

@ -1,5 +1,8 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
export function extractFCParamsFactory(extractWeights, paramMappings) { Object.defineProperty(exports, "__esModule", { value: true });
exports.extractFCParamsFactory = void 0;
const tf = require("@tensorflow/tfjs-core");
function extractFCParamsFactory(extractWeights, paramMappings) {
return function (channelsIn, channelsOut, mappedPrefix) { return function (channelsIn, channelsOut, mappedPrefix) {
const fc_weights = tf.tensor2d(extractWeights(channelsIn * channelsOut), [channelsIn, channelsOut]); const fc_weights = tf.tensor2d(extractWeights(channelsIn * channelsOut), [channelsIn, channelsOut]);
const fc_bias = tf.tensor1d(extractWeights(channelsOut)); const fc_bias = tf.tensor1d(extractWeights(channelsOut));
@ -10,4 +13,5 @@ export function extractFCParamsFactory(extractWeights, paramMappings) {
}; };
}; };
} }
exports.extractFCParamsFactory = extractFCParamsFactory;
//# sourceMappingURL=extractFCParamsFactory.js.map //# sourceMappingURL=extractFCParamsFactory.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractFCParamsFactory.js","sourceRoot":"","sources":["../../src/common/extractFCParamsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,UAAU,sBAAsB,CACpC,cAAsC,EACtC,aAA6B;IAG7B,OAAO,UACL,UAAkB,EAClB,WAAmB,EACnB,YAAoB;QAGpB,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,GAAG,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAA;QACnG,MAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;QAExD,aAAa,CAAC,IAAI,CAChB,EAAE,SAAS,EAAE,GAAG,YAAY,UAAU,EAAE,EACxC,EAAE,SAAS,EAAE,GAAG,YAAY,OAAO,EAAE,CACtC,CAAA;QAED,OAAO;YACL,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,OAAO;SACd,CAAA;IACH,CAAC,CAAA;AAEH,CAAC"} {"version":3,"file":"extractFCParamsFactory.js","sourceRoot":"","sources":["../../src/common/extractFCParamsFactory.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAK5C,SAAgB,sBAAsB,CACpC,cAAsC,EACtC,aAA6B;IAG7B,OAAO,UACL,UAAkB,EAClB,WAAmB,EACnB,YAAoB;QAGpB,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,GAAG,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAA;QACnG,MAAM,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;QAExD,aAAa,CAAC,IAAI,CAChB,EAAE,SAAS,EAAE,GAAG,YAAY,UAAU,EAAE,EACxC,EAAE,SAAS,EAAE,GAAG,YAAY,OAAO,EAAE,CACtC,CAAA;QAED,OAAO;YACL,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,OAAO;SACd,CAAA;IACH,CAAC,CAAA;AAEH,CAAC;AAzBD,wDAyBC"}

View File

@ -1,20 +1,25 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
import { SeparableConvParams } from './types'; Object.defineProperty(exports, "__esModule", { value: true });
export function extractSeparableConvParamsFactory(extractWeights, paramMappings) { exports.loadSeparableConvParamsFactory = exports.extractSeparableConvParamsFactory = void 0;
const tf = require("@tensorflow/tfjs-core");
const types_1 = require("./types");
function extractSeparableConvParamsFactory(extractWeights, paramMappings) {
return function (channelsIn, channelsOut, mappedPrefix) { return function (channelsIn, channelsOut, mappedPrefix) {
const depthwise_filter = tf.tensor4d(extractWeights(3 * 3 * channelsIn), [3, 3, channelsIn, 1]); const depthwise_filter = tf.tensor4d(extractWeights(3 * 3 * channelsIn), [3, 3, channelsIn, 1]);
const pointwise_filter = tf.tensor4d(extractWeights(channelsIn * channelsOut), [1, 1, channelsIn, channelsOut]); const pointwise_filter = tf.tensor4d(extractWeights(channelsIn * channelsOut), [1, 1, channelsIn, channelsOut]);
const bias = tf.tensor1d(extractWeights(channelsOut)); const bias = tf.tensor1d(extractWeights(channelsOut));
paramMappings.push({ paramPath: `${mappedPrefix}/depthwise_filter` }, { paramPath: `${mappedPrefix}/pointwise_filter` }, { paramPath: `${mappedPrefix}/bias` }); paramMappings.push({ paramPath: `${mappedPrefix}/depthwise_filter` }, { paramPath: `${mappedPrefix}/pointwise_filter` }, { paramPath: `${mappedPrefix}/bias` });
return new SeparableConvParams(depthwise_filter, pointwise_filter, bias); return new types_1.SeparableConvParams(depthwise_filter, pointwise_filter, bias);
}; };
} }
export function loadSeparableConvParamsFactory(extractWeightEntry) { exports.extractSeparableConvParamsFactory = extractSeparableConvParamsFactory;
function loadSeparableConvParamsFactory(extractWeightEntry) {
return function (prefix) { return function (prefix) {
const depthwise_filter = extractWeightEntry(`${prefix}/depthwise_filter`, 4); const depthwise_filter = extractWeightEntry(`${prefix}/depthwise_filter`, 4);
const pointwise_filter = extractWeightEntry(`${prefix}/pointwise_filter`, 4); const pointwise_filter = extractWeightEntry(`${prefix}/pointwise_filter`, 4);
const bias = extractWeightEntry(`${prefix}/bias`, 1); const bias = extractWeightEntry(`${prefix}/bias`, 1);
return new SeparableConvParams(depthwise_filter, pointwise_filter, bias); return new types_1.SeparableConvParams(depthwise_filter, pointwise_filter, bias);
}; };
} }
exports.loadSeparableConvParamsFactory = loadSeparableConvParamsFactory;
//# sourceMappingURL=extractSeparableConvParamsFactory.js.map //# sourceMappingURL=extractSeparableConvParamsFactory.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractSeparableConvParamsFactory.js","sourceRoot":"","sources":["../../src/common/extractSeparableConvParamsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAwC,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEpF,MAAM,UAAU,iCAAiC,CAC/C,cAAsC,EACtC,aAA6B;IAG7B,OAAO,UAAS,UAAkB,EAAE,WAAmB,EAAE,YAAoB;QAC3E,MAAM,gBAAgB,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAA;QAC/F,MAAM,gBAAgB,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAA;QAC/G,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAA;QAErD,aAAa,CAAC,IAAI,CAChB,EAAE,SAAS,EAAE,GAAG,YAAY,mBAAmB,EAAE,EACjD,EAAE,SAAS,EAAE,GAAG,YAAY,mBAAmB,EAAE,EACjD,EAAE,SAAS,EAAE,GAAG,YAAY,OAAO,EAAE,CACtC,CAAA;QAED,OAAO,IAAI,mBAAmB,CAC5B,gBAAgB,EAChB,gBAAgB,EAChB,IAAI,CACL,CAAA;IACH,CAAC,CAAA;AAEH,CAAC;AAED,MAAM,UAAU,8BAA8B,CAC5C,kBAAqE;IAGrE,OAAO,UAAU,MAAc;QAC7B,MAAM,gBAAgB,GAAG,kBAAkB,CAAc,GAAG,MAAM,mBAAmB,EAAE,CAAC,CAAC,CAAA;QACzF,MAAM,gBAAgB,GAAG,kBAAkB,CAAc,GAAG,MAAM,mBAAmB,EAAE,CAAC,CAAC,CAAA;QACzF,MAAM,IAAI,GAAG,kBAAkB,CAAc,GAAG,MAAM,OAAO,EAAE,CAAC,CAAC,CAAA;QAEjE,OAAO,IAAI,mBAAmB,CAC5B,gBAAgB,EAChB,gBAAgB,EAChB,IAAI,CACL,CAAA;IACH,CAAC,CAAA;AAEH,CAAC"} {"version":3,"file":"extractSeparableConvParamsFactory.js","sourceRoot":"","sources":["../../src/common/extractSeparableConvParamsFactory.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAE5C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AAA;IACH,CAAC,CAAA;AAEH,CAAC;AAhBD,wEAgBC"}

View File

@ -1,12 +1,16 @@
import { isTensor } from '../utils'; "use strict";
export function extractWeightEntryFactory(weightMap, paramMappings) { Object.defineProperty(exports, "__esModule", { value: true });
exports.extractWeightEntryFactory = void 0;
const utils_1 = require("../utils");
function extractWeightEntryFactory(weightMap, paramMappings) {
return function (originalPath, paramRank, mappedPath) { return function (originalPath, paramRank, mappedPath) {
const tensor = weightMap[originalPath]; const tensor = weightMap[originalPath];
if (!isTensor(tensor, paramRank)) { if (!utils_1.isTensor(tensor, paramRank)) {
throw new Error(`expected weightMap[${originalPath}] to be a Tensor${paramRank}D, instead have ${tensor}`); throw new Error(`expected weightMap[${originalPath}] to be a Tensor${paramRank}D, instead have ${tensor}`);
} }
paramMappings.push({ originalPath, paramPath: mappedPath || originalPath }); paramMappings.push({ originalPath, paramPath: mappedPath || originalPath });
return tensor; return tensor;
}; };
} }
exports.extractWeightEntryFactory = extractWeightEntryFactory;
//# sourceMappingURL=extractWeightEntryFactory.js.map //# sourceMappingURL=extractWeightEntryFactory.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractWeightEntryFactory.js","sourceRoot":"","sources":["../../src/common/extractWeightEntryFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,MAAM,UAAU,yBAAyB,CAAC,SAAc,EAAE,aAA6B;IAErF,OAAO,UAAa,YAAoB,EAAE,SAAiB,EAAE,UAAmB;QAC9E,MAAM,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;QAEtC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,YAAY,mBAAmB,SAAS,mBAAmB,MAAM,EAAE,CAAC,CAAA;SAC3G;QAED,aAAa,CAAC,IAAI,CAChB,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,IAAI,YAAY,EAAE,CACxD,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AAEH,CAAC"} {"version":3,"file":"extractWeightEntryFactory.js","sourceRoot":"","sources":["../../src/common/extractWeightEntryFactory.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AAGpC,SAAgB,yBAAyB,CAAC,SAAc,EAAE,aAA6B;IAErF,OAAO,UAAa,YAAoB,EAAE,SAAiB,EAAE,UAAmB;QAC9E,MAAM,MAAM,GAAG,SAAS,CAAC,YAAY,CAAC,CAAA;QAEtC,IAAI,CAAC,gBAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,YAAY,mBAAmB,SAAS,mBAAmB,MAAM,EAAE,CAAC,CAAA;SAC3G;QAED,aAAa,CAAC,IAAI,CAChB,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,IAAI,YAAY,EAAE,CACxD,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AAEH,CAAC;AAhBD,8DAgBC"}

View File

@ -1,4 +1,7 @@
export function extractWeightsFactory(weights) { "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractWeightsFactory = void 0;
function extractWeightsFactory(weights) {
let remainingWeights = weights; let remainingWeights = weights;
function extractWeights(numWeights) { function extractWeights(numWeights) {
const ret = remainingWeights.slice(0, numWeights); const ret = remainingWeights.slice(0, numWeights);
@ -13,4 +16,5 @@ export function extractWeightsFactory(weights) {
getRemainingWeights getRemainingWeights
}; };
} }
exports.extractWeightsFactory = extractWeightsFactory;
//# sourceMappingURL=extractWeightsFactory.js.map //# sourceMappingURL=extractWeightsFactory.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractWeightsFactory.js","sourceRoot":"","sources":["../../src/common/extractWeightsFactory.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,qBAAqB,CAAC,OAAqB;IACzD,IAAI,gBAAgB,GAAG,OAAO,CAAA;IAE9B,SAAS,cAAc,CAAC,UAAkB;QACxC,MAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;QACjD,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACrD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,SAAS,mBAAmB;QAC1B,OAAO,gBAAgB,CAAA;IACzB,CAAC;IAED,OAAO;QACL,cAAc;QACd,mBAAmB;KACpB,CAAA;AACH,CAAC"} {"version":3,"file":"extractWeightsFactory.js","sourceRoot":"","sources":["../../src/common/extractWeightsFactory.ts"],"names":[],"mappings":";;;AAAA,SAAgB,qBAAqB,CAAC,OAAqB;IACzD,IAAI,gBAAgB,GAAG,OAAO,CAAA;IAE9B,SAAS,cAAc,CAAC,UAAkB;QACxC,MAAM,GAAG,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;QACjD,gBAAgB,GAAG,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACrD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,SAAS,mBAAmB;QAC1B,OAAO,gBAAgB,CAAA;IACzB,CAAC;IAED,OAAO;QACL,cAAc;QACd,mBAAmB;KACpB,CAAA;AACH,CAAC;AAjBD,sDAiBC"}

View File

@ -1,5 +1,9 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
export function fullyConnectedLayer(x, params) { Object.defineProperty(exports, "__esModule", { value: true });
exports.fullyConnectedLayer = void 0;
const tf = require("@tensorflow/tfjs-core");
function fullyConnectedLayer(x, params) {
return tf.tidy(() => tf.add(tf.matMul(x, params.weights), params.bias)); return tf.tidy(() => tf.add(tf.matMul(x, params.weights), params.bias));
} }
exports.fullyConnectedLayer = fullyConnectedLayer;
//# sourceMappingURL=fullyConnectedLayer.js.map //# sourceMappingURL=fullyConnectedLayer.js.map

View File

@ -1 +1 @@
{"version":3,"file":"fullyConnectedLayer.js","sourceRoot":"","sources":["../../src/common/fullyConnectedLayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI5C,MAAM,UAAU,mBAAmB,CACjC,CAAc,EACd,MAAgB;IAEhB,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAClB,EAAE,CAAC,GAAG,CACJ,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,EAC5B,MAAM,CAAC,IAAI,CACZ,CACF,CAAA;AACH,CAAC"} {"version":3,"file":"fullyConnectedLayer.js","sourceRoot":"","sources":["../../src/common/fullyConnectedLayer.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAI5C,SAAgB,mBAAmB,CACjC,CAAc,EACd,MAAgB;IAEhB,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAClB,EAAE,CAAC,GAAG,CACJ,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,EAC5B,MAAM,CAAC,IAAI,CACZ,CACF,CAAA;AACH,CAAC;AAVD,kDAUC"}

View File

@ -1,4 +1,7 @@
export function getModelUris(uri, defaultModelName) { "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getModelUris = void 0;
function getModelUris(uri, defaultModelName) {
const defaultManifestFilename = `${defaultModelName}-weights_manifest.json`; const defaultManifestFilename = `${defaultModelName}-weights_manifest.json`;
if (!uri) { if (!uri) {
return { return {
@ -25,4 +28,5 @@ export function getModelUris(uri, defaultModelName) {
manifestUri: modelBaseUri === '/' ? `/${manifestFile}` : `${modelBaseUri}/${manifestFile}` manifestUri: modelBaseUri === '/' ? `/${manifestFile}` : `${modelBaseUri}/${manifestFile}`
}; };
} }
exports.getModelUris = getModelUris;
//# sourceMappingURL=getModelUris.js.map //# sourceMappingURL=getModelUris.js.map

View File

@ -1 +1 @@
{"version":3,"file":"getModelUris.js","sourceRoot":"","sources":["../../src/common/getModelUris.ts"],"names":[],"mappings":"AAA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AC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC1G,YAAY,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAA;IAEtE,OAAO;QACL,YAAY;QACZ,WAAW,EAAE,YAAY,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,GAAG,YAAY,IAAI,YAAY,EAAE;KAC3F,CAAA;AACH,CAAC;AAhCD,oCAgCC"}

View File

@ -1,11 +1,14 @@
export * from './convLayer'; "use strict";
export * from './depthwiseSeparableConv'; Object.defineProperty(exports, "__esModule", { value: true });
export * from './disposeUnusedWeightTensors'; const tslib_1 = require("tslib");
export * from './extractConvParamsFactory'; tslib_1.__exportStar(require("./convLayer"), exports);
export * from './extractFCParamsFactory'; tslib_1.__exportStar(require("./depthwiseSeparableConv"), exports);
export * from './extractSeparableConvParamsFactory'; tslib_1.__exportStar(require("./disposeUnusedWeightTensors"), exports);
export * from './extractWeightEntryFactory'; tslib_1.__exportStar(require("./extractConvParamsFactory"), exports);
export * from './extractWeightsFactory'; tslib_1.__exportStar(require("./extractFCParamsFactory"), exports);
export * from './getModelUris'; tslib_1.__exportStar(require("./extractSeparableConvParamsFactory"), exports);
export * from './types'; tslib_1.__exportStar(require("./extractWeightEntryFactory"), exports);
tslib_1.__exportStar(require("./extractWeightsFactory"), exports);
tslib_1.__exportStar(require("./getModelUris"), exports);
tslib_1.__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,qCAAqC,CAAA;AACnD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,SAAS,CAAA"} {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;AAAA,sDAA2B;AAC3B,mEAAwC;AACxC,uEAA4C;AAC5C,qEAA0C;AAC1C,mEAAwC;AACxC,8EAAmD;AACnD,sEAA2C;AAC3C,kEAAuC;AACvC,yDAA8B;AAC9B,kDAAuB"}

View File

@ -1,8 +1,12 @@
export function loadConvParamsFactory(extractWeightEntry) { "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadConvParamsFactory = void 0;
function loadConvParamsFactory(extractWeightEntry) {
return function (prefix) { return function (prefix) {
const filters = extractWeightEntry(`${prefix}/filters`, 4); const filters = extractWeightEntry(`${prefix}/filters`, 4);
const bias = extractWeightEntry(`${prefix}/bias`, 1); const bias = extractWeightEntry(`${prefix}/bias`, 1);
return { filters, bias }; return { filters, bias };
}; };
} }
exports.loadConvParamsFactory = loadConvParamsFactory;
//# sourceMappingURL=loadConvParamsFactory.js.map //# sourceMappingURL=loadConvParamsFactory.js.map

View File

@ -1 +1 @@
{"version":3,"file":"loadConvParamsFactory.js","sourceRoot":"","sources":["../../src/common/loadConvParamsFactory.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,qBAAqB,CAAC,kBAAqE;IACzG,OAAO,UAAS,MAAc;QAC5B,MAAM,OAAO,GAAG,kBAAkB,CAAc,GAAG,MAAM,UAAU,EAAE,CAAC,CAAC,CAAA;QACvE,MAAM,IAAI,GAAG,kBAAkB,CAAc,GAAG,MAAM,OAAO,EAAE,CAAC,CAAC,CAAA;QAEjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC,CAAA;AACH,CAAC"} {"version":3,"file":"loadConvParamsFactory.js","sourceRoot":"","sources":["../../src/common/loadConvParamsFactory.ts"],"names":[],"mappings":";;;AAIA,SAAgB,qBAAqB,CAAC,kBAAqE;IACzG,OAAO,UAAS,MAAc;QAC5B,MAAM,OAAO,GAAG,kBAAkB,CAAc,GAAG,MAAM,UAAU,EAAE,CAAC,CAAC,CAAA;QACvE,MAAM,IAAI,GAAG,kBAAkB,CAAc,GAAG,MAAM,OAAO,EAAE,CAAC,CAAC,CAAA;QAEjE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IAC1B,CAAC,CAAA;AACH,CAAC;AAPD,sDAOC"}

View File

@ -1,8 +1,12 @@
export class SeparableConvParams { "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeparableConvParams = void 0;
class SeparableConvParams {
constructor(depthwise_filter, pointwise_filter, bias) { constructor(depthwise_filter, pointwise_filter, bias) {
this.depthwise_filter = depthwise_filter; this.depthwise_filter = depthwise_filter;
this.pointwise_filter = pointwise_filter; this.pointwise_filter = pointwise_filter;
this.bias = bias; this.bias = bias;
} }
} }
exports.SeparableConvParams = SeparableConvParams;
//# sourceMappingURL=types.js.map //# sourceMappingURL=types.js.map

View File

@ -1 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AAmBA,MAAM,OAAO,mBAAmB;IAC9B,YACS,gBAA6B,EAC7B,gBAA6B,EAC7B,IAAiB;QAFjB,qBAAgB,GAAhB,gBAAgB,CAAa;QAC7B,qBAAgB,GAAhB,gBAAgB,CAAa;QAC7B,SAAI,GAAJ,IAAI,CAAa;IACvB,CAAC;CACL"} {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":";;;AAmBA,MAAa,mBAAmB;IAC9B,YACS,gBAA6B,EAC7B,gBAA6B,EAC7B,IAAiB;QAFjB,qBAAgB,GAAhB,gBAAgB,CAAa;QAC7B,qBAAgB,GAAhB,gBAAgB,CAAa;QAC7B,SAAI,GAAJ,IAAI,CAAa;IACvB,CAAC;CACL;AAND,kDAMC"}

View File

@ -1,10 +1,13 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
import { env } from '../env'; Object.defineProperty(exports, "__esModule", { value: true });
import { padToSquare } from '../ops/padToSquare'; exports.NetInput = void 0;
import { computeReshapedDimensions, isTensor3D, isTensor4D, range } from '../utils'; const tf = require("@tensorflow/tfjs-core");
import { createCanvasFromMedia } from './createCanvas'; const env_1 = require("../env");
import { imageToSquare } from './imageToSquare'; const padToSquare_1 = require("../ops/padToSquare");
export class NetInput { const utils_1 = require("../utils");
const createCanvas_1 = require("./createCanvas");
const imageToSquare_1 = require("./imageToSquare");
class NetInput {
constructor(inputs, treatAsBatchInput = false) { constructor(inputs, treatAsBatchInput = false) {
this._imageTensors = []; this._imageTensors = [];
this._canvases = []; this._canvases = [];
@ -16,12 +19,12 @@ export class NetInput {
this._treatAsBatchInput = treatAsBatchInput; this._treatAsBatchInput = treatAsBatchInput;
this._batchSize = inputs.length; this._batchSize = inputs.length;
inputs.forEach((input, idx) => { inputs.forEach((input, idx) => {
if (isTensor3D(input)) { if (utils_1.isTensor3D(input)) {
this._imageTensors[idx] = input; this._imageTensors[idx] = input;
this._inputDimensions[idx] = input.shape; this._inputDimensions[idx] = input.shape;
return; return;
} }
if (isTensor4D(input)) { if (utils_1.isTensor4D(input)) {
const batchSize = input.shape[0]; const batchSize = input.shape[0];
if (batchSize !== 1) { if (batchSize !== 1) {
throw new Error(`NetInput - tf.Tensor4D with batchSize ${batchSize} passed, but not supported in input array`); throw new Error(`NetInput - tf.Tensor4D with batchSize ${batchSize} passed, but not supported in input array`);
@ -30,7 +33,7 @@ export class NetInput {
this._inputDimensions[idx] = input.shape.slice(1); this._inputDimensions[idx] = input.shape.slice(1);
return; return;
} }
const canvas = input instanceof env.getEnv().Canvas ? input : createCanvasFromMedia(input); const canvas = input instanceof env_1.env.getEnv().Canvas ? input : createCanvas_1.createCanvasFromMedia(input);
this._canvases[idx] = canvas; this._canvases[idx] = canvas;
this._inputDimensions[idx] = [canvas.height, canvas.width, 3]; this._inputDimensions[idx] = [canvas.height, canvas.width, 3];
}); });
@ -54,7 +57,7 @@ export class NetInput {
return this._inputSize; return this._inputSize;
} }
get reshapedInputDimensions() { get reshapedInputDimensions() {
return range(this.batchSize, 0, 1).map((_, batchIdx) => this.getReshapedInputDimensions(batchIdx)); return utils_1.range(this.batchSize, 0, 1).map((_, batchIdx) => this.getReshapedInputDimensions(batchIdx));
} }
getInput(batchIdx) { getInput(batchIdx) {
return this.canvases[batchIdx] || this.imageTensors[batchIdx]; return this.canvases[batchIdx] || this.imageTensors[batchIdx];
@ -74,7 +77,7 @@ export class NetInput {
} }
const width = this.getInputWidth(batchIdx); const width = this.getInputWidth(batchIdx);
const height = this.getInputHeight(batchIdx); const height = this.getInputHeight(batchIdx);
return computeReshapedDimensions({ width, height }, this.inputSize); return utils_1.computeReshapedDimensions({ width, height }, this.inputSize);
} }
/** /**
* Create a batch tensor from all input canvases and tensors * Create a batch tensor from all input canvases and tensors
@ -88,20 +91,20 @@ export class NetInput {
toBatchTensor(inputSize, isCenterInputs = true) { toBatchTensor(inputSize, isCenterInputs = true) {
this._inputSize = inputSize; this._inputSize = inputSize;
return tf.tidy(() => { return tf.tidy(() => {
const inputTensors = range(this.batchSize, 0, 1).map(batchIdx => { const inputTensors = utils_1.range(this.batchSize, 0, 1).map(batchIdx => {
const input = this.getInput(batchIdx); const input = this.getInput(batchIdx);
if (input instanceof tf.Tensor) { if (input instanceof tf.Tensor) {
// @ts-ignore: error TS2344: Type 'Rank.R4' does not satisfy the constraint 'Tensor<Rank>'. // @ts-ignore: error TS2344: Type 'Rank.R4' does not satisfy the constraint 'Tensor<Rank>'.
let imgTensor = isTensor4D(input) ? input : input.expandDims(); let imgTensor = utils_1.isTensor4D(input) ? input : input.expandDims();
// @ts-ignore: error TS2344: Type 'Rank.R4' does not satisfy the constraint 'Tensor<Rank>'. // @ts-ignore: error TS2344: Type 'Rank.R4' does not satisfy the constraint 'Tensor<Rank>'.
imgTensor = padToSquare(imgTensor, isCenterInputs); imgTensor = padToSquare_1.padToSquare(imgTensor, isCenterInputs);
if (imgTensor.shape[1] !== inputSize || imgTensor.shape[2] !== inputSize) { if (imgTensor.shape[1] !== inputSize || imgTensor.shape[2] !== inputSize) {
imgTensor = tf.image.resizeBilinear(imgTensor, [inputSize, inputSize]); imgTensor = tf.image.resizeBilinear(imgTensor, [inputSize, inputSize]);
} }
return imgTensor.as3D(inputSize, inputSize, 3); return imgTensor.as3D(inputSize, inputSize, 3);
} }
if (input instanceof env.getEnv().Canvas) { if (input instanceof env_1.env.getEnv().Canvas) {
return tf.browser.fromPixels(imageToSquare(input, inputSize, isCenterInputs)); return tf.browser.fromPixels(imageToSquare_1.imageToSquare(input, inputSize, isCenterInputs));
} }
throw new Error(`toBatchTensor - at batchIdx ${batchIdx}, expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have ${input}`); throw new Error(`toBatchTensor - at batchIdx ${batchIdx}, expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have ${input}`);
}); });
@ -110,4 +113,5 @@ export class NetInput {
}); });
} }
} }
exports.NetInput = NetInput;
//# sourceMappingURL=NetInput.js.map //# sourceMappingURL=NetInput.js.map

View File

@ -1 +1 @@
{"version":3,"file":"NetInput.js","sourceRoot":"","sources":["../../src/dom/NetInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAG5C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,aAAa,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AE,CAAC,MAAM,EAAE;oBACxC,OAAO,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,6BAAa,CAAC,KAAK,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAA;iBAC9E;gBAED,MAAM,IAAI,KAAK,CAAC,+BAA+B,QAAQ,6FAA6F,KAAK,EAAE,CAAC,CAAA;YAC9J,CAAC,CAAC,CAAA;YAEF,MAAM,WAAW,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;YAE9G,OAAO,WAAW,CAAA;QACpB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF;AAhJD,4BAgJC"}

View File

@ -1,8 +1,11 @@
import { env } from '../env'; "use strict";
import { isMediaLoaded } from './isMediaLoaded'; Object.defineProperty(exports, "__esModule", { value: true });
export function awaitMediaLoaded(media) { exports.awaitMediaLoaded = void 0;
const env_1 = require("../env");
const isMediaLoaded_1 = require("./isMediaLoaded");
function awaitMediaLoaded(media) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (media instanceof env.getEnv().Canvas || isMediaLoaded(media)) { if (media instanceof env_1.env.getEnv().Canvas || isMediaLoaded_1.isMediaLoaded(media)) {
return resolve(); return resolve();
} }
function onLoad(e) { function onLoad(e) {
@ -23,4 +26,5 @@ export function awaitMediaLoaded(media) {
media.addEventListener('error', onError); media.addEventListener('error', onError);
}); });
} }
exports.awaitMediaLoaded = awaitMediaLoaded;
//# sourceMappingURL=awaitMediaLoaded.js.map //# sourceMappingURL=awaitMediaLoaded.js.map

View File

@ -1 +1 @@
{"version":3,"file":"awaitMediaLoaded.js","sourceRoot":"","sources":["../../src/dom/awaitMediaLoaded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,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AE,EAAE;QACrC,IAAI,KAAK,YAAY,SAAG,CAAC,MAAM,EAAE,CAAC,MAAM,IAAI,6BAAa,CAAC,KAAK,CAAC,EAAE;YAChE,OAAO,OAAO,EAAE,CAAA;SACjB;QAED,SAAS,MAAM,CAAC,CAAQ;YACtB,IAAI,CAAC,CAAC,CAAC,aAAa;gBAAE,OAAM;YAC5B,CAAC,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YACnD,CAAC,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YACrD,OAAO,CAAC,CAAC,CAAC,CAAA;QACZ,CAAC;QAED,SAAS,OAAO,CAAC,CAAQ;YACvB,IAAI,CAAC,CAAC,CAAC,aAAa;gBAAE,OAAM;YAC5B,CAAC,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YACnD,CAAC,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YACrD,MAAM,CAAC,CAAC,CAAC,CAAA;QACX,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACtC,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;AACJ,CAAC;AAxBD,4CAwBC"}

View File

@ -1,5 +1,8 @@
import { env } from '../env'; "use strict";
export function bufferToImage(buf) { Object.defineProperty(exports, "__esModule", { value: true });
exports.bufferToImage = void 0;
const env_1 = require("../env");
function bufferToImage(buf) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!(buf instanceof Blob)) { if (!(buf instanceof Blob)) {
return reject('bufferToImage - expected buf to be of type: Blob'); return reject('bufferToImage - expected buf to be of type: Blob');
@ -9,7 +12,7 @@ export function bufferToImage(buf) {
if (typeof reader.result !== 'string') { if (typeof reader.result !== 'string') {
return reject('bufferToImage - expected reader.result to be a string, in onload'); return reject('bufferToImage - expected reader.result to be a string, in onload');
} }
const img = env.getEnv().createImageElement(); const img = env_1.env.getEnv().createImageElement();
img.onload = () => resolve(img); img.onload = () => resolve(img);
img.onerror = reject; img.onerror = reject;
img.src = reader.result; img.src = reader.result;
@ -18,4 +21,5 @@ export function bufferToImage(buf) {
reader.readAsDataURL(buf); reader.readAsDataURL(buf);
}); });
} }
exports.bufferToImage = bufferToImage;
//# sourceMappingURL=bufferToImage.js.map //# sourceMappingURL=bufferToImage.js.map

View File

@ -1 +1 @@
{"version":3,"file":"bufferToImage.js","sourceRoot":"","sources":["../../src/dom/bufferToImage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,UAAU,aAAa,CAAC,GAAS;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,CAAC,GAAG,YAAY,IAAI,CAAC,EAAE;YAC1B,OAAO,MAAM,CAAC,kDAAkD,CAAC,CAAA;SAClE;QAED,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAA;QAC/B,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACnB,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;gBACrC,OAAO,MAAM,CAAC,kEAAkE,CAAC,CAAA;aAClF;YAED,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,kBAAkB,EAAE,CAAA;YAC7C,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAC/B,GAAG,CAAC,OAAO,GAAG,MAAM,CAAA;YACpB,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAA;QACzB,CAAC,CAAA;QACD,MAAM,CAAC,OAAO,GAAG,MAAM,CAAA;QACvB,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC"} {"version":3,"file":"bufferToImage.js","sourceRoot":"","sources":["../../src/dom/bufferToImage.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAE7B,SAAgB,aAAa,CAAC,GAAS;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,CAAC,CAAC,GAAG,YAAY,IAAI,CAAC,EAAE;YAC1B,OAAO,MAAM,CAAC,kDAAkD,CAAC,CAAA;SAClE;QAED,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAA;QAC/B,MAAM,CAAC,MAAM,GAAG,GAAG,EAAE;YACnB,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE;gBACrC,OAAO,MAAM,CAAC,kEAAkE,CAAC,CAAA;aAClF;YAED,MAAM,GAAG,GAAG,SAAG,CAAC,MAAM,EAAE,CAAC,kBAAkB,EAAE,CAAA;YAC7C,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAC/B,GAAG,CAAC,OAAO,GAAG,MAAM,CAAA;YACpB,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAA;QACzB,CAAC,CAAA;QACD,MAAM,CAAC,OAAO,GAAG,MAAM,CAAA;QACvB,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC;AApBD,sCAoBC"}

View File

@ -1,27 +1,32 @@
import { env } from '../env'; "use strict";
import { getContext2dOrThrow } from './getContext2dOrThrow'; Object.defineProperty(exports, "__esModule", { value: true });
import { getMediaDimensions } from './getMediaDimensions'; exports.createCanvasFromMedia = exports.createCanvas = void 0;
import { isMediaLoaded } from './isMediaLoaded'; const env_1 = require("../env");
export function createCanvas({ width, height }) { const getContext2dOrThrow_1 = require("./getContext2dOrThrow");
const { createCanvasElement } = env.getEnv(); const getMediaDimensions_1 = require("./getMediaDimensions");
const isMediaLoaded_1 = require("./isMediaLoaded");
function createCanvas({ width, height }) {
const { createCanvasElement } = env_1.env.getEnv();
const canvas = createCanvasElement(); const canvas = createCanvasElement();
canvas.width = width; canvas.width = width;
canvas.height = height; canvas.height = height;
return canvas; return canvas;
} }
export function createCanvasFromMedia(media, dims) { exports.createCanvas = createCanvas;
const { ImageData } = env.getEnv(); function createCanvasFromMedia(media, dims) {
if (!(media instanceof ImageData) && !isMediaLoaded(media)) { const { ImageData } = env_1.env.getEnv();
if (!(media instanceof ImageData) && !isMediaLoaded_1.isMediaLoaded(media)) {
throw new Error('createCanvasFromMedia - media has not finished loading yet'); throw new Error('createCanvasFromMedia - media has not finished loading yet');
} }
const { width, height } = dims || getMediaDimensions(media); const { width, height } = dims || getMediaDimensions_1.getMediaDimensions(media);
const canvas = createCanvas({ width, height }); const canvas = createCanvas({ width, height });
if (media instanceof ImageData) { if (media instanceof ImageData) {
getContext2dOrThrow(canvas).putImageData(media, 0, 0); getContext2dOrThrow_1.getContext2dOrThrow(canvas).putImageData(media, 0, 0);
} }
else { else {
getContext2dOrThrow(canvas).drawImage(media, 0, 0, width, height); getContext2dOrThrow_1.getContext2dOrThrow(canvas).drawImage(media, 0, 0, width, height);
} }
return canvas; return canvas;
} }
exports.createCanvasFromMedia = createCanvasFromMedia;
//# sourceMappingURL=createCanvas.js.map //# sourceMappingURL=createCanvas.js.map

View File

@ -1 +1 @@
{"version":3,"file":"createCanvas.js","sourceRoot":"","sources":["../../src/dom/createCanvas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,YAAY,CAAC,EAAE,KAAK,EAA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AM,EAAE,CAAA;IAC5C,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAA;IACpC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,OAAO,MAAM,CAAA;AACf,CAAC;AAPD,oCAOC;AAED,SAAgB,qBAAqB,CAAC,KAAsD,EAAE,IAAkB;IAE9G,MAAM,EAAE,SAAS,EAAE,GAAG,SAAG,CAAC,MAAM,EAAE,CAAA;IAElC,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,IAAI,CAAC,6BAAa,CAAC,KAAK,CAAC,EAAE;QAC1D,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAA;KAC9E;IAED,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,IAAI,uCAAkB,CAAC,KAAK,CAAC,CAAA;IAC3D,MAAM,MAAM,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAE9C,IAAI,KAAK,YAAY,SAAS,EAAE;QAC9B,yCAAmB,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;KACtD;SAAM;QACL,yCAAmB,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;KAClE;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAjBD,sDAiBC"}

View File

@ -1,6 +1,9 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
import { FaceDetection } from '../classes/FaceDetection'; Object.defineProperty(exports, "__esModule", { value: true });
import { isTensor3D, isTensor4D } from '../utils'; exports.extractFaceTensors = void 0;
const tf = require("@tensorflow/tfjs-core");
const FaceDetection_1 = require("../classes/FaceDetection");
const utils_1 = require("../utils");
/** /**
* Extracts the tensors of the image regions containing the detected faces. * Extracts the tensors of the image regions containing the detected faces.
* Useful if you want to compute the face descriptors for the face images. * Useful if you want to compute the face descriptors for the face images.
@ -11,16 +14,16 @@ import { isTensor3D, isTensor4D } from '../utils';
* @param detections The face detection results or face bounding boxes for that image. * @param detections The face detection results or face bounding boxes for that image.
* @returns Tensors of the corresponding image region for each detected face. * @returns Tensors of the corresponding image region for each detected face.
*/ */
export async function extractFaceTensors(imageTensor, detections) { async function extractFaceTensors(imageTensor, detections) {
if (!isTensor3D(imageTensor) && !isTensor4D(imageTensor)) { if (!utils_1.isTensor3D(imageTensor) && !utils_1.isTensor4D(imageTensor)) {
throw new Error('extractFaceTensors - expected image tensor to be 3D or 4D'); throw new Error('extractFaceTensors - expected image tensor to be 3D or 4D');
} }
if (isTensor4D(imageTensor) && imageTensor.shape[0] > 1) { if (utils_1.isTensor4D(imageTensor) && imageTensor.shape[0] > 1) {
throw new Error('extractFaceTensors - batchSize > 1 not supported'); throw new Error('extractFaceTensors - batchSize > 1 not supported');
} }
return tf.tidy(() => { return tf.tidy(() => {
const [imgHeight, imgWidth, numChannels] = imageTensor.shape.slice(isTensor4D(imageTensor) ? 1 : 0); const [imgHeight, imgWidth, numChannels] = imageTensor.shape.slice(utils_1.isTensor4D(imageTensor) ? 1 : 0);
const boxes = detections.map(det => det instanceof FaceDetection const boxes = detections.map(det => det instanceof FaceDetection_1.FaceDetection
? det.forSize(imgWidth, imgHeight).box ? det.forSize(imgWidth, imgHeight).box
: det) : det)
.map(box => box.clipAtImageBorders(imgWidth, imgHeight)); .map(box => box.clipAtImageBorders(imgWidth, imgHeight));
@ -28,4 +31,5 @@ export async function extractFaceTensors(imageTensor, detections) {
return faceTensors; return faceTensors;
}); });
} }
exports.extractFaceTensors = extractFaceTensors;
//# sourceMappingURL=extractFaceTensors.js.map //# sourceMappingURL=extractFaceTensors.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractFaceTensors.js","sourceRoot":"","sources":["../../src/dom/extractFaceTensors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,E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CAAA;QAE1D,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CACxD,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CACxG,CAAA;QAED,OAAO,WAAW,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC;AA7BD,gDA6BC"}

View File

@ -1,9 +1,12 @@
import { FaceDetection } from '../classes/FaceDetection'; "use strict";
import { env } from '../env'; Object.defineProperty(exports, "__esModule", { value: true });
import { createCanvas } from './createCanvas'; exports.extractFaces = void 0;
import { getContext2dOrThrow } from './getContext2dOrThrow'; const FaceDetection_1 = require("../classes/FaceDetection");
import { imageTensorToCanvas } from './imageTensorToCanvas'; const env_1 = require("../env");
import { toNetInput } from './toNetInput'; const createCanvas_1 = require("./createCanvas");
const getContext2dOrThrow_1 = require("./getContext2dOrThrow");
const imageTensorToCanvas_1 = require("./imageTensorToCanvas");
const toNetInput_1 = require("./toNetInput");
/** /**
* Extracts the image regions containing the detected faces. * Extracts the image regions containing the detected faces.
* *
@ -11,29 +14,30 @@ import { toNetInput } from './toNetInput';
* @param detections The face detection results or face bounding boxes for that image. * @param detections The face detection results or face bounding boxes for that image.
* @returns The Canvases of the corresponding image region for each detected face. * @returns The Canvases of the corresponding image region for each detected face.
*/ */
export async function extractFaces(input, detections) { async function extractFaces(input, detections) {
const { Canvas } = env.getEnv(); const { Canvas } = env_1.env.getEnv();
let canvas = input; let canvas = input;
if (!(input instanceof Canvas)) { if (!(input instanceof Canvas)) {
const netInput = await toNetInput(input); const netInput = await toNetInput_1.toNetInput(input);
if (netInput.batchSize > 1) { if (netInput.batchSize > 1) {
throw new Error('extractFaces - batchSize > 1 not supported'); throw new Error('extractFaces - batchSize > 1 not supported');
} }
const tensorOrCanvas = netInput.getInput(0); const tensorOrCanvas = netInput.getInput(0);
canvas = tensorOrCanvas instanceof Canvas canvas = tensorOrCanvas instanceof Canvas
? tensorOrCanvas ? tensorOrCanvas
: await imageTensorToCanvas(tensorOrCanvas); : await imageTensorToCanvas_1.imageTensorToCanvas(tensorOrCanvas);
} }
const ctx = getContext2dOrThrow(canvas); const ctx = getContext2dOrThrow_1.getContext2dOrThrow(canvas);
const boxes = detections.map(det => det instanceof FaceDetection const boxes = detections.map(det => det instanceof FaceDetection_1.FaceDetection
? det.forSize(canvas.width, canvas.height).box.floor() ? det.forSize(canvas.width, canvas.height).box.floor()
: det) : det)
.map(box => box.clipAtImageBorders(canvas.width, canvas.height)); .map(box => box.clipAtImageBorders(canvas.width, canvas.height));
return boxes.map(({ x, y, width, height }) => { return boxes.map(({ x, y, width, height }) => {
const faceImg = createCanvas({ width, height }); const faceImg = createCanvas_1.createCanvas({ width, height });
getContext2dOrThrow(faceImg) getContext2dOrThrow_1.getContext2dOrThrow(faceImg)
.putImageData(ctx.getImageData(x, y, width, height), 0, 0); .putImageData(ctx.getImageData(x, y, width, height), 0, 0);
return faceImg; return faceImg;
}); });
} }
exports.extractFaces = extractFaces;
//# sourceMappingURL=extractFaces.js.map //# sourceMappingURL=extractFaces.js.map

View File

@ -1 +1 @@
{"version":3,"file":"extractFaces.js","sourceRoot":"","sources":["../../src/dom/extractFaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE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AAG,CAAC,KAAK,EAAE;QACtD,CAAC,CAAC,GAAG,CACR;SACE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAElE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,2BAAY,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;QAC/C,yCAAmB,CAAC,OAAO,CAAC;aACzB,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;QAC5D,OAAO,OAAO,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC;AApCD,oCAoCC"}

View File

@ -1,11 +1,15 @@
import { bufferToImage } from './bufferToImage'; "use strict";
import { fetchOrThrow } from './fetchOrThrow'; Object.defineProperty(exports, "__esModule", { value: true });
export async function fetchImage(uri) { exports.fetchImage = void 0;
const res = await fetchOrThrow(uri); const bufferToImage_1 = require("./bufferToImage");
const fetchOrThrow_1 = require("./fetchOrThrow");
async function fetchImage(uri) {
const res = await fetchOrThrow_1.fetchOrThrow(uri);
const blob = await (res).blob(); const blob = await (res).blob();
if (!blob.type.startsWith('image/')) { if (!blob.type.startsWith('image/')) {
throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${blob.type}, for url: ${res.url}`); throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${blob.type}, for url: ${res.url}`);
} }
return bufferToImage(blob); return bufferToImage_1.bufferToImage(blob);
} }
exports.fetchImage = fetchImage;
//# sourceMappingURL=fetchImage.js.map //# sourceMappingURL=fetchImage.js.map

View File

@ -1 +1 @@
{"version":3,"file":"fetchImage.js","sourceRoot":"","sources":["../../src/dom/fetchImage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IAE/B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,wEAAwE,IAAI,CAAC,IAAI,cAAc,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;KAC1H;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC"} {"version":3,"file":"fetchImage.js","sourceRoot":"","sources":["../../src/dom/fetchImage.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,iDAA8C;AAEvC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,MAAM,GAAG,GAAG,MAAM,2BAAY,CAAC,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IAE/B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,wEAAwE,IAAI,CAAC,IAAI,cAAc,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;KAC1H;IACD,OAAO,6BAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AARD,gCAQC"}

View File

@ -1,5 +1,9 @@
import { fetchOrThrow } from './fetchOrThrow'; "use strict";
export async function fetchJson(uri) { Object.defineProperty(exports, "__esModule", { value: true });
return (await fetchOrThrow(uri)).json(); exports.fetchJson = void 0;
const fetchOrThrow_1 = require("./fetchOrThrow");
async function fetchJson(uri) {
return (await fetchOrThrow_1.fetchOrThrow(uri)).json();
} }
exports.fetchJson = fetchJson;
//# sourceMappingURL=fetchJson.js.map //# sourceMappingURL=fetchJson.js.map

View File

@ -1 +1 @@
{"version":3,"file":"fetchJson.js","sourceRoot":"","sources":["../../src/dom/fetchJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAI,GAAW;IAC5C,OAAO,CAAC,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AACzC,CAAC"} {"version":3,"file":"fetchJson.js","sourceRoot":"","sources":["../../src/dom/fetchJson.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAEvC,KAAK,UAAU,SAAS,CAAI,GAAW;IAC5C,OAAO,CAAC,MAAM,2BAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AACzC,CAAC;AAFD,8BAEC"}

View File

@ -1,5 +1,9 @@
import { fetchOrThrow } from './fetchOrThrow'; "use strict";
export async function fetchNetWeights(uri) { Object.defineProperty(exports, "__esModule", { value: true });
return new Float32Array(await (await fetchOrThrow(uri)).arrayBuffer()); exports.fetchNetWeights = void 0;
const fetchOrThrow_1 = require("./fetchOrThrow");
async function fetchNetWeights(uri) {
return new Float32Array(await (await fetchOrThrow_1.fetchOrThrow(uri)).arrayBuffer());
} }
exports.fetchNetWeights = fetchNetWeights;
//# sourceMappingURL=fetchNetWeights.js.map //# sourceMappingURL=fetchNetWeights.js.map

View File

@ -1 +1 @@
{"version":3,"file":"fetchNetWeights.js","sourceRoot":"","sources":["../../src/dom/fetchNetWeights.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC/C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACxE,CAAC"} {"version":3,"file":"fetchNetWeights.js","sourceRoot":"","sources":["../../src/dom/fetchNetWeights.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAEvC,KAAK,UAAU,eAAe,CAAC,GAAW;IAC/C,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,MAAM,2BAAY,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACxE,CAAC;AAFD,0CAEC"}

View File

@ -1,10 +1,14 @@
import { env } from '../env'; "use strict";
export async function fetchOrThrow(url, init) { Object.defineProperty(exports, "__esModule", { value: true });
const fetch = env.getEnv().fetch; exports.fetchOrThrow = void 0;
const env_1 = require("../env");
async function fetchOrThrow(url, init) {
const fetch = env_1.env.getEnv().fetch;
const res = await fetch(url, init); const res = await fetch(url, init);
if (!(res.status < 400)) { if (!(res.status < 400)) {
throw new Error(`failed to fetch: (${res.status}) ${res.statusText}, from url: ${res.url}`); throw new Error(`failed to fetch: (${res.status}) ${res.statusText}, from url: ${res.url}`);
} }
return res; return res;
} }
exports.fetchOrThrow = fetchOrThrow;
//# sourceMappingURL=fetchOrThrow.js.map //# sourceMappingURL=fetchOrThrow.js.map

View File

@ -1 +1 @@
{"version":3,"file":"fetchOrThrow.js","sourceRoot":"","sources":["../../src/dom/fetchOrThrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAW,EACX,IAAkB;IAGlB,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAA;IAChC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,eAAe,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;KAC5F;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"} {"version":3,"file":"fetchOrThrow.js","sourceRoot":"","sources":["../../src/dom/fetchOrThrow.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAEtB,KAAK,UAAU,YAAY,CAChC,GAAW,EACX,IAAkB;IAGlB,MAAM,KAAK,GAAG,SAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAA;IAChC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAClC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,UAAU,eAAe,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;KAC5F;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAXD,oCAWC"}

View File

@ -1,11 +1,14 @@
import { env } from '../env'; "use strict";
import { resolveInput } from './resolveInput'; Object.defineProperty(exports, "__esModule", { value: true });
export function getContext2dOrThrow(canvasArg) { exports.getContext2dOrThrow = void 0;
const { Canvas, CanvasRenderingContext2D } = env.getEnv(); const env_1 = require("../env");
const resolveInput_1 = require("./resolveInput");
function getContext2dOrThrow(canvasArg) {
const { Canvas, CanvasRenderingContext2D } = env_1.env.getEnv();
if (canvasArg instanceof CanvasRenderingContext2D) { if (canvasArg instanceof CanvasRenderingContext2D) {
return canvasArg; return canvasArg;
} }
const canvas = resolveInput(canvasArg); const canvas = resolveInput_1.resolveInput(canvasArg);
if (!(canvas instanceof Canvas)) { if (!(canvas instanceof Canvas)) {
throw new Error('resolveContext2d - expected canvas to be of instance of Canvas'); throw new Error('resolveContext2d - expected canvas to be of instance of Canvas');
} }
@ -15,4 +18,5 @@ export function getContext2dOrThrow(canvasArg) {
} }
return ctx; return ctx;
} }
exports.getContext2dOrThrow = getContext2dOrThrow;
//# sourceMappingURL=getContext2dOrThrow.js.map //# sourceMappingURL=getContext2dOrThrow.js.map

View File

@ -1 +1 @@
{"version":3,"file":"getContext2dOrThrow.js","sourceRoot":"","sources":["../../src/dom/getContext2dOrThrow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,UAAU,mBAAmB,CAAC,SAAgE;IAElG,MAAM,EAAE,MAAM,EAAE,wBAAwB,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,CAAA;IAEzD,IAAI,SAAS,YAAY,wBAAwB,EAAE;QACjD,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAA;IAEtC,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;KAClF;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;KAChE;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"} {"version":3,"file":"getContext2dOrThrow.js","sourceRoot":"","sources":["../../src/dom/getContext2dOrThrow.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAC7B,iDAA8C;AAE9C,SAAgB,mBAAmB,CAAC,SAAgE;IAElG,MAAM,EAAE,MAAM,EAAE,wBAAwB,EAAE,GAAG,SAAG,CAAC,MAAM,EAAE,CAAA;IAEzD,IAAI,SAAS,YAAY,wBAAwB,EAAE;QACjD,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,MAAM,GAAG,2BAAY,CAAC,SAAS,CAAC,CAAA;IAEtC,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAA;KAClF;IAED,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACnC,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;KAChE;IAED,OAAO,GAAG,CAAA;AACZ,CAAC;AApBD,kDAoBC"}

View File

@ -1,13 +1,17 @@
import { Dimensions } from '../classes/Dimensions'; "use strict";
import { env } from '../env'; Object.defineProperty(exports, "__esModule", { value: true });
export function getMediaDimensions(input) { exports.getMediaDimensions = void 0;
const { Image, Video } = env.getEnv(); const Dimensions_1 = require("../classes/Dimensions");
const env_1 = require("../env");
function getMediaDimensions(input) {
const { Image, Video } = env_1.env.getEnv();
if (input instanceof Image) { if (input instanceof Image) {
return new Dimensions(input.naturalWidth, input.naturalHeight); return new Dimensions_1.Dimensions(input.naturalWidth, input.naturalHeight);
} }
if (input instanceof Video) { if (input instanceof Video) {
return new Dimensions(input.videoWidth, input.videoHeight); return new Dimensions_1.Dimensions(input.videoWidth, input.videoHeight);
} }
return new Dimensions(input.width, input.height); return new Dimensions_1.Dimensions(input.width, input.height);
} }
exports.getMediaDimensions = getMediaDimensions;
//# sourceMappingURL=getMediaDimensions.js.map //# sourceMappingURL=getMediaDimensions.js.map

View File

@ -1 +1 @@
{"version":3,"file":"getMediaDimensions.js","sourceRoot":"","sources":["../../src/dom/getMediaDimensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,UAAU,kBAAkB,CAAC,KAA4E;IAE7G,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,CAAA;IAErC,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;KAC/D;IACD,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;KAC3D;IACD,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;AAClD,CAAC"} {"version":3,"file":"getMediaDimensions.js","sourceRoot":"","sources":["../../src/dom/getMediaDimensions.ts"],"names":[],"mappings":";;;AAAA,sDAAgE;AAChE,gCAA6B;AAE7B,SAAgB,kBAAkB,CAAC,KAA4E;IAE7G,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAG,CAAC,MAAM,EAAE,CAAA;IAErC,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,IAAI,uBAAU,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;KAC/D;IACD,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,OAAO,IAAI,uBAAU,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;KAC3D;IACD,OAAO,IAAI,uBAAU,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;AAClD,CAAC;AAXD,gDAWC"}

View File

@ -1,12 +1,16 @@
import * as tf from '@tensorflow/tfjs-core'; "use strict";
import { env } from '../env'; Object.defineProperty(exports, "__esModule", { value: true });
import { isTensor4D } from '../utils'; exports.imageTensorToCanvas = void 0;
export async function imageTensorToCanvas(imgTensor, canvas) { const tf = require("@tensorflow/tfjs-core");
const targetCanvas = canvas || env.getEnv().createCanvasElement(); const env_1 = require("../env");
const [height, width, numChannels] = imgTensor.shape.slice(isTensor4D(imgTensor) ? 1 : 0); const utils_1 = require("../utils");
async function imageTensorToCanvas(imgTensor, canvas) {
const targetCanvas = canvas || env_1.env.getEnv().createCanvasElement();
const [height, width, numChannels] = imgTensor.shape.slice(utils_1.isTensor4D(imgTensor) ? 1 : 0);
const imgTensor3D = tf.tidy(() => imgTensor.as3D(height, width, numChannels).toInt()); const imgTensor3D = tf.tidy(() => imgTensor.as3D(height, width, numChannels).toInt());
await tf.browser.toPixels(imgTensor3D, targetCanvas); await tf.browser.toPixels(imgTensor3D, targetCanvas);
imgTensor3D.dispose(); imgTensor3D.dispose();
return targetCanvas; return targetCanvas;
} }
exports.imageTensorToCanvas = imageTensorToCanvas;
//# sourceMappingURL=imageTensorToCanvas.js.map //# sourceMappingURL=imageTensorToCanvas.js.map

View File

@ -1 +1 @@
{"version":3,"file":"imageTensorToCanvas.js","sourceRoot":"","sources":["../../src/dom/imageTensorToCanvas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAAoB,EACpB,MAA0B;IAG1B,MAAM,YAAY,GAAG,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,mBAAmB,EAAE,CAAA;IAEjE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACzF,MAAM,WAAW,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;IACrF,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAEpD,WAAW,CAAC,OAAO,EAAE,CAAA;IAErB,OAAO,YAAY,CAAA;AACrB,CAAC"} {"version":3,"file":"imageTensorToCanvas.js","sourceRoot":"","sources":["../../src/dom/imageTensorToCanvas.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAE5C,gCAA6B;AAC7B,oCAAsC;AAE/B,KAAK,UAAU,mBAAmB,CACvC,SAAoB,EACpB,MAA0B;IAG1B,MAAM,YAAY,GAAG,MAAM,IAAI,SAAG,CAAC,MAAM,EAAE,CAAC,mBAAmB,EAAE,CAAA;IAEjE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACzF,MAAM,WAAW,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,CAAA;IACrF,MAAM,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAEpD,WAAW,CAAC,OAAO,EAAE,CAAA;IAErB,OAAO,YAAY,CAAA;AACrB,CAAC;AAdD,kDAcC"}

View File

@ -1,22 +1,26 @@
import { env } from '../env'; "use strict";
import { createCanvas, createCanvasFromMedia } from './createCanvas'; Object.defineProperty(exports, "__esModule", { value: true });
import { getContext2dOrThrow } from './getContext2dOrThrow'; exports.imageToSquare = void 0;
import { getMediaDimensions } from './getMediaDimensions'; const env_1 = require("../env");
export function imageToSquare(input, inputSize, centerImage = false) { const createCanvas_1 = require("./createCanvas");
const { Image, Canvas } = env.getEnv(); const getContext2dOrThrow_1 = require("./getContext2dOrThrow");
const getMediaDimensions_1 = require("./getMediaDimensions");
function imageToSquare(input, inputSize, centerImage = false) {
const { Image, Canvas } = env_1.env.getEnv();
if (!(input instanceof Image || input instanceof Canvas)) { if (!(input instanceof Image || input instanceof Canvas)) {
throw new Error('imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement'); throw new Error('imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement');
} }
const dims = getMediaDimensions(input); const dims = getMediaDimensions_1.getMediaDimensions(input);
const scale = inputSize / Math.max(dims.height, dims.width); const scale = inputSize / Math.max(dims.height, dims.width);
const width = scale * dims.width; const width = scale * dims.width;
const height = scale * dims.height; const height = scale * dims.height;
const targetCanvas = createCanvas({ width: inputSize, height: inputSize }); const targetCanvas = createCanvas_1.createCanvas({ width: inputSize, height: inputSize });
const inputCanvas = input instanceof Canvas ? input : createCanvasFromMedia(input); const inputCanvas = input instanceof Canvas ? input : createCanvas_1.createCanvasFromMedia(input);
const offset = Math.abs(width - height) / 2; const offset = Math.abs(width - height) / 2;
const dx = centerImage && width < height ? offset : 0; const dx = centerImage && width < height ? offset : 0;
const dy = centerImage && height < width ? offset : 0; const dy = centerImage && height < width ? offset : 0;
getContext2dOrThrow(targetCanvas).drawImage(inputCanvas, dx, dy, width, height); getContext2dOrThrow_1.getContext2dOrThrow(targetCanvas).drawImage(inputCanvas, dx, dy, width, height);
return targetCanvas; return targetCanvas;
} }
exports.imageToSquare = imageToSquare;
//# sourceMappingURL=imageToSquare.js.map //# sourceMappingURL=imageToSquare.js.map

View File

@ -1 +1 @@
{"version":3,"file":"imageToSquare.js","sourceRoot":"","sources":["../../src/dom/imageToSquare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,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,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;IACrD,yCAAmB,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAE/E,OAAO,YAAY,CAAA;AACrB,CAAC;AAtBD,sCAsBC"}

View File

@ -1,22 +1,25 @@
export * from './awaitMediaLoaded'; "use strict";
export * from './bufferToImage'; Object.defineProperty(exports, "__esModule", { value: true });
export * from './createCanvas'; const tslib_1 = require("tslib");
export * from './extractFaces'; tslib_1.__exportStar(require("./awaitMediaLoaded"), exports);
export * from './extractFaceTensors'; tslib_1.__exportStar(require("./bufferToImage"), exports);
export * from './fetchImage'; tslib_1.__exportStar(require("./createCanvas"), exports);
export * from './fetchJson'; tslib_1.__exportStar(require("./extractFaces"), exports);
export * from './fetchNetWeights'; tslib_1.__exportStar(require("./extractFaceTensors"), exports);
export * from './fetchOrThrow'; tslib_1.__exportStar(require("./fetchImage"), exports);
export * from './getContext2dOrThrow'; tslib_1.__exportStar(require("./fetchJson"), exports);
export * from './getMediaDimensions'; tslib_1.__exportStar(require("./fetchNetWeights"), exports);
export * from './imageTensorToCanvas'; tslib_1.__exportStar(require("./fetchOrThrow"), exports);
export * from './imageToSquare'; tslib_1.__exportStar(require("./getContext2dOrThrow"), exports);
export * from './isMediaElement'; tslib_1.__exportStar(require("./getMediaDimensions"), exports);
export * from './isMediaLoaded'; tslib_1.__exportStar(require("./imageTensorToCanvas"), exports);
export * from './loadWeightMap'; tslib_1.__exportStar(require("./imageToSquare"), exports);
export * from './matchDimensions'; tslib_1.__exportStar(require("./isMediaElement"), exports);
export * from './NetInput'; tslib_1.__exportStar(require("./isMediaLoaded"), exports);
export * from './resolveInput'; tslib_1.__exportStar(require("./loadWeightMap"), exports);
export * from './toNetInput'; tslib_1.__exportStar(require("./matchDimensions"), exports);
export * from './types'; tslib_1.__exportStar(require("./NetInput"), exports);
tslib_1.__exportStar(require("./resolveInput"), exports);
tslib_1.__exportStar(require("./toNetInput"), exports);
tslib_1.__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map

View File

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA"} {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dom/index.ts"],"names":[],"mappings":";;;AAAA,6DAAkC;AAClC,0DAA+B;AAC/B,yDAA8B;AAC9B,yDAA8B;AAC9B,+DAAoC;AACpC,uDAA4B;AAC5B,sDAA2B;AAC3B,4DAAiC;AACjC,yDAA8B;AAC9B,gEAAqC;AACrC,+DAAoC;AACpC,gEAAqC;AACrC,0DAA+B;AAC/B,2DAAgC;AAChC,0DAA+B;AAC/B,0DAA+B;AAC/B,4DAAiC;AACjC,qDAA0B;AAC1B,yDAA8B;AAC9B,uDAA4B;AAC5B,kDAAuB"}

View File

@ -1,8 +1,12 @@
import { env } from '../env'; "use strict";
export function isMediaElement(input) { Object.defineProperty(exports, "__esModule", { value: true });
const { Image, Canvas, Video } = env.getEnv(); exports.isMediaElement = void 0;
const env_1 = require("../env");
function isMediaElement(input) {
const { Image, Canvas, Video } = env_1.env.getEnv();
return input instanceof Image return input instanceof Image
|| input instanceof Canvas || input instanceof Canvas
|| input instanceof Video; || input instanceof Video;
} }
exports.isMediaElement = isMediaElement;
//# sourceMappingURL=isMediaElement.js.map //# sourceMappingURL=isMediaElement.js.map

View File

@ -1 +1 @@
{"version":3,"file":"isMediaElement.js","sourceRoot":"","sources":["../../src/dom/isMediaElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,UAAU,cAAc,CAAC,KAAU;IAEvC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,CAAA;IAE7C,OAAO,KAAK,YAAY,KAAK;WACxB,KAAK,YAAY,MAAM;WACvB,KAAK,YAAY,KAAK,CAAA;AAC7B,CAAC"} {"version":3,"file":"isMediaElement.js","sourceRoot":"","sources":["../../src/dom/isMediaElement.ts"],"names":[],"mappings":";;;AAAA,gCAA6B;AAE7B,SAAgB,cAAc,CAAC,KAAU;IAEvC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,SAAG,CAAC,MAAM,EAAE,CAAA;IAE7C,OAAO,KAAK,YAAY,KAAK;WACxB,KAAK,YAAY,MAAM;WACvB,KAAK,YAAY,KAAK,CAAA;AAC7B,CAAC;AAPD,wCAOC"}

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