Commit d2ccd39f by vincent

remove build directory

parent fc8a27e1
......@@ -7,5 +7,4 @@ proto
weights_uncompressed
weights_unused
docs
out
build
\ No newline at end of file
out
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { TinyXception } from '../xception/TinyXception';
import { AgeAndGenderPrediction, NetOutput, NetParams } from './types';
export declare class AgeGenderNet extends NeuralNetwork<NetParams> {
private _faceFeatureExtractor;
constructor(faceFeatureExtractor?: TinyXception);
readonly faceFeatureExtractor: TinyXception;
runNet(input: NetInput | tf.Tensor4D): NetOutput;
forwardInput(input: NetInput | tf.Tensor4D): NetOutput;
forward(input: TNetInput): Promise<NetOutput>;
predictAgeAndGender(input: TNetInput): Promise<AgeAndGenderPrediction | AgeAndGenderPrediction[]>;
protected getDefaultModelName(): string;
dispose(throwOnRedispose?: boolean): void;
loadClassifierParams(weights: Float32Array): void;
extractClassifierParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
};
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
};
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var fullyConnectedLayer_1 = require("../common/fullyConnectedLayer");
var util_1 = require("../faceProcessor/util");
var TinyXception_1 = require("../xception/TinyXception");
var extractParams_1 = require("./extractParams");
var extractParamsFromWeigthMap_1 = require("./extractParamsFromWeigthMap");
var types_1 = require("./types");
var AgeGenderNet = /** @class */ (function (_super) {
tslib_1.__extends(AgeGenderNet, _super);
function AgeGenderNet(faceFeatureExtractor) {
if (faceFeatureExtractor === void 0) { faceFeatureExtractor = new TinyXception_1.TinyXception(2); }
var _this = _super.call(this, 'AgeGenderNet') || this;
_this._faceFeatureExtractor = faceFeatureExtractor;
return _this;
}
Object.defineProperty(AgeGenderNet.prototype, "faceFeatureExtractor", {
get: function () {
return this._faceFeatureExtractor;
},
enumerable: true,
configurable: true
});
AgeGenderNet.prototype.runNet = function (input) {
var _this = this;
var params = this.params;
if (!params) {
throw new Error(this._name + " - load model before inference");
}
return tf.tidy(function () {
var bottleneckFeatures = input instanceof tfjs_image_recognition_base_1.NetInput
? _this.faceFeatureExtractor.forwardInput(input)
: input;
var pooled = tf.avgPool(bottleneckFeatures, [7, 7], [2, 2], 'valid').as2D(bottleneckFeatures.shape[0], -1);
var age = fullyConnectedLayer_1.fullyConnectedLayer(pooled, params.fc.age).as1D();
var gender = fullyConnectedLayer_1.fullyConnectedLayer(pooled, params.fc.gender);
return { age: age, gender: gender };
});
};
AgeGenderNet.prototype.forwardInput = function (input) {
var _this = this;
return tf.tidy(function () {
var _a = _this.runNet(input), age = _a.age, gender = _a.gender;
return { age: age, gender: tf.softmax(gender) };
});
};
AgeGenderNet.prototype.forward = function (input) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
}
});
});
};
AgeGenderNet.prototype.predictAgeAndGender = function (input) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var netInput, out, ages, genders, ageAndGenderTensors, predictionsByBatch;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 1:
netInput = _a.sent();
return [4 /*yield*/, this.forwardInput(netInput)];
case 2:
out = _a.sent();
ages = tf.unstack(out.age);
genders = tf.unstack(out.gender);
ageAndGenderTensors = ages.map(function (ageTensor, i) { return ({
ageTensor: ageTensor,
genderTensor: genders[i]
}); });
return [4 /*yield*/, Promise.all(ageAndGenderTensors.map(function (_a) {
var ageTensor = _a.ageTensor, genderTensor = _a.genderTensor;
return tslib_1.__awaiter(_this, void 0, void 0, function () {
var age, probMale, isMale, gender, genderProbability;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, ageTensor.data()];
case 1:
age = (_b.sent())[0];
return [4 /*yield*/, genderTensor.data()];
case 2:
probMale = (_b.sent())[0];
isMale = probMale > 0.5;
gender = isMale ? types_1.Gender.MALE : types_1.Gender.FEMALE;
genderProbability = isMale ? probMale : (1 - probMale);
ageTensor.dispose();
genderTensor.dispose();
return [2 /*return*/, { age: age, gender: gender, genderProbability: genderProbability }];
}
});
});
}))];
case 3:
predictionsByBatch = _a.sent();
out.age.dispose();
out.gender.dispose();
return [2 /*return*/, netInput.isBatchInput
? predictionsByBatch
: predictionsByBatch[0]];
}
});
});
};
AgeGenderNet.prototype.getDefaultModelName = function () {
return 'age_gender_model';
};
AgeGenderNet.prototype.dispose = function (throwOnRedispose) {
if (throwOnRedispose === void 0) { throwOnRedispose = true; }
this.faceFeatureExtractor.dispose(throwOnRedispose);
_super.prototype.dispose.call(this, throwOnRedispose);
};
AgeGenderNet.prototype.loadClassifierParams = function (weights) {
var _a = this.extractClassifierParams(weights), params = _a.params, paramMappings = _a.paramMappings;
this._params = params;
this._paramMappings = paramMappings;
};
AgeGenderNet.prototype.extractClassifierParams = function (weights) {
return extractParams_1.extractParams(weights);
};
AgeGenderNet.prototype.extractParamsFromWeigthMap = function (weightMap) {
var _a = util_1.seperateWeightMaps(weightMap), featureExtractorMap = _a.featureExtractorMap, classifierMap = _a.classifierMap;
this.faceFeatureExtractor.loadFromWeightMap(featureExtractorMap);
return extractParamsFromWeigthMap_1.extractParamsFromWeigthMap(classifierMap);
};
AgeGenderNet.prototype.extractParams = function (weights) {
var classifierWeightSize = (512 * 1 + 1) + (512 * 2 + 2);
var featureExtractorWeights = weights.slice(0, weights.length - classifierWeightSize);
var classifierWeights = weights.slice(weights.length - classifierWeightSize);
this.faceFeatureExtractor.extractWeights(featureExtractorWeights);
return this.extractClassifierParams(classifierWeights);
};
return AgeGenderNet;
}(tfjs_image_recognition_base_1.NeuralNetwork));
exports.AgeGenderNet = AgeGenderNet;
//# sourceMappingURL=AgeGenderNet.js.map
\ No newline at end of file
{"version":3,"file":"AgeGenderNet.js","sourceRoot":"","sources":["../../../src/ageGenderNet/AgeGenderNet.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAC5C,2EAA6F;AAE7F,qEAAoE;AACpE,8CAA2D;AAC3D,yDAAwD;AACxD,iDAAgD;AAChD,2EAA0E;AAC1E,iCAA+E;AAE/E;IAAkC,wCAAwB;IAIxD,sBAAY,oBAAwD;QAAxD,qCAAA,EAAA,2BAAyC,2BAAY,CAAC,CAAC,CAAC;QAApE,YACE,kBAAM,cAAc,CAAC,SAEtB;QADC,KAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAA;;IACnD,CAAC;IAED,sBAAW,8CAAoB;aAA/B;YACE,OAAO,IAAI,CAAC,qBAAqB,CAAA;QACnC,CAAC;;;OAAA;IAEM,6BAAM,GAAb,UAAc,KAA6B;QAA3C,iBAkBC;QAhBS,IAAA,oBAAM,CAAS;QAEvB,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAI,IAAI,CAAC,KAAK,mCAAgC,CAAC,CAAA;SAC/D;QAED,OAAO,EAAE,CAAC,IAAI,CAAC;YACb,IAAM,kBAAkB,GAAG,KAAK,YAAY,sCAAQ;gBAClD,CAAC,CAAC,KAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,KAAK,CAAC;gBAC/C,CAAC,CAAC,KAAK,CAAA;YAET,IAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,C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;AAAD,CAAC,AAlHD,CAAkC,2CAAa,GAkH9C;AAlHY,oCAAY"}
\ No newline at end of file
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
function extractParams(weights) {
var paramMappings = [];
var _a = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractFCParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractFCParamsFactory(extractWeights, paramMappings);
var age = extractFCParams(512, 1, 'fc/age');
var gender = extractFCParams(512, 2, 'fc/gender');
if (getRemainingWeights().length !== 0) {
throw new Error("weights remaing after extract: " + getRemainingWeights().length);
}
return {
paramMappings: paramMappings,
params: { fc: { age: age, gender: gender } }
};
}
exports.extractParams = extractParams;
//# sourceMappingURL=extractParams.js.map
\ No newline at end of file
{"version":3,"file":"extractParams.js","sourceRoot":"","sources":["../../../src/ageGenderNet/extractParams.ts"],"names":[],"mappings":";;AAAA,2EAAuE;AAIvE,SAAgB,aAAa,CAAC,OAAqB;IAEjD,IAAM,aAAa,GAA4C,EAAE,CAAA;IAE3D,IAAA,0FAGqD,EAFzD,kCAAc,EACd,4CACyD,CAAA;IAE3D,IAAM,eAAe,GAAG,sDAAwB,CAAC,sBAAsB,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;IAEtG,IAAM,GAAG,GAAG,eAAe,CAAC,GAAG,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAA;IAC7C,IAAM,MAAM,GAAG,eAAe,CAAC,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,CAAA;IAEnD,IAAI,mBAAmB,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,oCAAkC,mBAAmB,EAAE,CAAC,MAAQ,CAAC,CAAA;KAClF;IAED,OAAO;QACL,aAAa,eAAA;QACb,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,KAAA,EAAE,MAAM,QAAA,EAAE,EAAE;KAChC,CAAA;AACH,CAAC;AAtBD,sCAsBC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
function extractParamsFromWeigthMap(weightMap) {
var paramMappings = [];
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
function extractFcParams(prefix) {
var weights = extractWeightEntry(prefix + "/weights", 2);
var bias = extractWeightEntry(prefix + "/bias", 1);
return { weights: weights, bias: bias };
}
var params = {
fc: {
age: extractFcParams('fc/age'),
gender: extractFcParams('fc/gender')
}
};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
exports.extractParamsFromWeigthMap = extractParamsFromWeigthMap;
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
\ No newline at end of file
{"version":3,"file":"extractParamsFromWeigthMap.js","sourceRoot":"","sources":["../../../src/ageGenderNet/extractParamsFromWeigthMap.ts"],"names":[],"mappings":";;AACA,2EAAuE;AAIvE,SAAgB,0BAA0B,CACxC,SAA4B;IAG5B,IAAM,aAAa,GAA4C,EAAE,CAAA;IAEjE,IAAM,kBAAkB,GAAG,sDAAwB,CAAC,yBAAyB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAEvG,SAAS,eAAe,CAAC,MAAc;QACrC,IAAM,OAAO,GAAG,kBAAkB,CAAiB,MAAM,aAAU,EAAE,CAAC,CAAC,CAAA;QACvE,IAAM,IAAI,GAAG,kBAAkB,CAAiB,MAAM,UAAO,EAAE,CAAC,CAAC,CAAA;QACjE,OAAO,EAAE,OAAO,SAAA,EAAE,IAAI,MAAA,EAAE,CAAA;IAC1B,CAAC;IAED,IAAM,MAAM,GAAG;QACb,EAAE,EAAE;YACF,GAAG,EAAE,eAAe,CAAC,QAAQ,CAAC;YAC9B,MAAM,EAAE,eAAe,CAAC,WAAW,CAAC;SACrC;KACF,CAAA;IAED,sDAAwB,CAAC,0BAA0B,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE7E,OAAO,EAAE,MAAM,QAAA,EAAE,aAAa,eAAA,EAAE,CAAA;AAClC,CAAC;AAxBD,gEAwBC"}
\ No newline at end of file
export * from './AgeGenderNet';
export * from './types';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./AgeGenderNet"), exports);
tslib_1.__exportStar(require("./types"), exports);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ageGenderNet/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B;AAC/B,kDAAwB"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare type AgeAndGenderPrediction = {
age: number;
gender: Gender;
genderProbability: number;
};
export declare enum Gender {
FEMALE = "female",
MALE = "male"
}
export declare type NetOutput = {
age: tf.Tensor1D;
gender: tf.Tensor2D;
};
export declare type NetParams = {
fc: {
age: TfjsImageRecognitionBase.FCParams;
gender: TfjsImageRecognitionBase.FCParams;
};
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Gender;
(function (Gender) {
Gender["FEMALE"] = "female";
Gender["MALE"] = "male";
})(Gender = exports.Gender || (exports.Gender = {}));
//# sourceMappingURL=types.js.map
\ No newline at end of file
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ageGenderNet/types.ts"],"names":[],"mappings":";;AASA,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,2BAAiB,CAAA;IACjB,uBAAa,CAAA;AACf,CAAC,EAHW,MAAM,GAAN,cAAM,KAAN,cAAM,QAGjB"}
\ No newline at end of file
import { Box, IDimensions, ObjectDetection, Rect } from 'tfjs-image-recognition-base';
export interface IFaceDetecion {
score: number;
box: Box;
}
export declare class FaceDetection extends ObjectDetection implements IFaceDetecion {
constructor(score: number, relativeBox: Rect, imageDims: IDimensions);
forSize(width: number, height: number): FaceDetection;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceDetection = /** @class */ (function (_super) {
tslib_1.__extends(FaceDetection, _super);
function FaceDetection(score, relativeBox, imageDims) {
return _super.call(this, score, score, '', relativeBox, imageDims) || this;
}
FaceDetection.prototype.forSize = function (width, height) {
var _a = _super.prototype.forSize.call(this, width, height), score = _a.score, relativeBox = _a.relativeBox, imageDims = _a.imageDims;
return new FaceDetection(score, relativeBox, imageDims);
};
return FaceDetection;
}(tfjs_image_recognition_base_1.ObjectDetection));
exports.FaceDetection = FaceDetection;
//# sourceMappingURL=FaceDetection.js.map
\ No newline at end of file
{"version":3,"file":"FaceDetection.js","sourceRoot":"","sources":["../../../src/classes/FaceDetection.ts"],"names":[],"mappings":";;;AAAA,2EAAsF;AAOtF;IAAmC,yCAAe;IAChD,uBACE,KAAa,EACb,WAAiB,EACjB,SAAsB;eAEtB,kBAAM,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,SAAS,CAAC;IACjD,CAAC;IAEM,+BAAO,GAAd,UAAe,KAAa,EAAE,MAAc;QACpC,IAAA,uDAAgE,EAA9D,gBAAK,EAAE,4BAAW,EAAE,wBAA0C,CAAA;QACtE,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,CAAC,CAAA;IACzD,CAAC;IACH,oBAAC;AAAD,CAAC,AAbD,CAAmC,6CAAe,GAajD;AAbY,sCAAa"}
\ No newline at end of file
import { Box, Dimensions, IBoundingBox, IDimensions, IRect, Point } from 'tfjs-image-recognition-base';
import { FaceDetection } from './FaceDetection';
export interface IFaceLandmarks {
positions: Point[];
shift: Point;
}
export declare class FaceLandmarks implements IFaceLandmarks {
protected _shift: Point;
protected _positions: Point[];
protected _imgDims: Dimensions;
constructor(relativeFaceLandmarkPositions: Point[], imgDims: IDimensions, shift?: Point);
readonly shift: Point;
readonly imageWidth: number;
readonly imageHeight: number;
readonly positions: Point[];
readonly relativePositions: Point[];
forSize<T extends FaceLandmarks>(width: number, height: number): T;
shiftBy<T extends FaceLandmarks>(x: number, y: number): T;
shiftByPoint<T extends FaceLandmarks>(pt: Point): T;
/**
* Aligns the face landmarks after face detection from the relative positions of the faces
* bounding box, or it's current shift. This function should be used to align the face images
* after face detection has been performed, before they are passed to the face recognition net.
* This will make the computed face descriptor more accurate.
*
* @param detection (optional) The bounding box of the face or the face detection result. If
* no argument was passed the position of the face landmarks are assumed to be relative to
* it's current shift.
* @returns The bounding box of the aligned face.
*/
align(detection?: FaceDetection | IRect | IBoundingBox | null, options?: {
useDlibAlignment?: boolean;
minBoxPadding?: number;
}): Box;
private alignDlib;
private alignMinBbox;
protected getRefPointsForAlignment(): Point[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var minBbox_1 = require("../minBbox");
var FaceDetection_1 = require("./FaceDetection");
// face alignment constants
var relX = 0.5;
var relY = 0.43;
var relScale = 0.45;
var FaceLandmarks = /** @class */ (function () {
function FaceLandmarks(relativeFaceLandmarkPositions, imgDims, shift) {
if (shift === void 0) { shift = new tfjs_image_recognition_base_1.Point(0, 0); }
var width = imgDims.width, height = imgDims.height;
this._imgDims = new tfjs_image_recognition_base_1.Dimensions(width, height);
this._shift = shift;
this._positions = relativeFaceLandmarkPositions.map(function (pt) { return pt.mul(new tfjs_image_recognition_base_1.Point(width, height)).add(shift); });
}
Object.defineProperty(FaceLandmarks.prototype, "shift", {
get: function () { return new tfjs_image_recognition_base_1.Point(this._shift.x, this._shift.y); },
enumerable: true,
configurable: true
});
Object.defineProperty(FaceLandmarks.prototype, "imageWidth", {
get: function () { return this._imgDims.width; },
enumerable: true,
configurable: true
});
Object.defineProperty(FaceLandmarks.prototype, "imageHeight", {
get: function () { return this._imgDims.height; },
enumerable: true,
configurable: true
});
Object.defineProperty(FaceLandmarks.prototype, "positions", {
get: function () { return this._positions; },
enumerable: true,
configurable: true
});
Object.defineProperty(FaceLandmarks.prototype, "relativePositions", {
get: function () {
var _this = this;
return this._positions.map(function (pt) { return pt.sub(_this._shift).div(new tfjs_image_recognition_base_1.Point(_this.imageWidth, _this.imageHeight)); });
},
enumerable: true,
configurable: true
});
FaceLandmarks.prototype.forSize = function (width, height) {
return new this.constructor(this.relativePositions, { width: width, height: height });
};
FaceLandmarks.prototype.shiftBy = function (x, y) {
return new this.constructor(this.relativePositions, this._imgDims, new tfjs_image_recognition_base_1.Point(x, y));
};
FaceLandmarks.prototype.shiftByPoint = function (pt) {
return this.shiftBy(pt.x, pt.y);
};
/**
* Aligns the face landmarks after face detection from the relative positions of the faces
* bounding box, or it's current shift. This function should be used to align the face images
* after face detection has been performed, before they are passed to the face recognition net.
* This will make the computed face descriptor more accurate.
*
* @param detection (optional) The bounding box of the face or the face detection result. If
* no argument was passed the position of the face landmarks are assumed to be relative to
* it's current shift.
* @returns The bounding box of the aligned face.
*/
FaceLandmarks.prototype.align = function (detection, options) {
if (options === void 0) { options = {}; }
if (detection) {
var box = detection instanceof FaceDetection_1.FaceDetection
? detection.box.floor()
: new tfjs_image_recognition_base_1.Box(detection);
return this.shiftBy(box.x, box.y).align(null, options);
}
var _a = Object.assign({}, { useDlibAlignment: false, minBoxPadding: 0.2 }, options), useDlibAlignment = _a.useDlibAlignment, minBoxPadding = _a.minBoxPadding;
if (useDlibAlignment) {
return this.alignDlib();
}
return this.alignMinBbox(minBoxPadding);
};
FaceLandmarks.prototype.alignDlib = function () {
var centers = this.getRefPointsForAlignment();
var leftEyeCenter = centers[0], rightEyeCenter = centers[1], mouthCenter = centers[2];
var distToMouth = function (pt) { return mouthCenter.sub(pt).magnitude(); };
var eyeToMouthDist = (distToMouth(leftEyeCenter) + distToMouth(rightEyeCenter)) / 2;
var size = Math.floor(eyeToMouthDist / relScale);
var refPoint = tfjs_image_recognition_base_1.getCenterPoint(centers);
// TODO: pad in case rectangle is out of image bounds
var x = Math.floor(Math.max(0, refPoint.x - (relX * size)));
var y = Math.floor(Math.max(0, refPoint.y - (relY * size)));
return new tfjs_image_recognition_base_1.Rect(x, y, Math.min(size, this.imageWidth + x), Math.min(size, this.imageHeight + y));
};
FaceLandmarks.prototype.alignMinBbox = function (padding) {
var box = minBbox_1.minBbox(this.positions);
return box.pad(box.width * padding, box.height * padding);
};
FaceLandmarks.prototype.getRefPointsForAlignment = function () {
throw new Error('getRefPointsForAlignment not implemented by base class');
};
return FaceLandmarks;
}());
exports.FaceLandmarks = FaceLandmarks;
//# sourceMappingURL=FaceLandmarks.js.map
\ No newline at end of file
{"version":3,"file":"FaceLandmarks.js","sourceRoot":"","sources":["../../../src/classes/FaceLandmarks.ts"],"names":[],"mappings":";;AAAA,2EAA6H;AAE7H,sCAAqC;AACrC,iDAAgD;AAEhD,2BAA2B;AAC3B,IAAM,IAAI,GAAG,GAAG,CAAA;AAChB,IAAM,IAAI,GAAG,IAAI,CAAA;AACjB,IAAM,QAAQ,GAAG,IAAI,CAAA;AAOrB;IAKE,uBACE,6BAAsC,EACtC,OAAoB,EACpB,KAA8B;QAA9B,sBAAA,EAAA,YAAmB,mCAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QAEtB,IAAA,qBAAK,EAAE,uBAAM,CAAY;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,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AW,CAAC,aAAa,CAAC,GAAG,WAAW,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAA;QAErF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,QAAQ,CAAC,CAAA;QAElD,IAAM,QAAQ,GAAG,4CAAc,CAAC,OAAO,CAAC,CAAA;QACxC,qDAAqD;QACrD,IAAM,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,IAAM,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,kCAAI,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,oCAAY,GAApB,UAAqB,OAAe;QAClC,IAAM,GAAG,GAAG,iBAAO,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,gDAAwB,GAAlC;QACE,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;IAC3E,CAAC;IACH,oBAAC;AAAD,CAAC,AAzGD,IAyGC;AAzGY,sCAAa"}
\ No newline at end of file
import { Point } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from './FaceLandmarks';
export declare class FaceLandmarks5 extends FaceLandmarks {
protected getRefPointsForAlignment(): Point[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceLandmarks_1 = require("./FaceLandmarks");
var FaceLandmarks5 = /** @class */ (function (_super) {
tslib_1.__extends(FaceLandmarks5, _super);
function FaceLandmarks5() {
return _super !== null && _super.apply(this, arguments) || this;
}
FaceLandmarks5.prototype.getRefPointsForAlignment = function () {
var pts = this.positions;
return [
pts[0],
pts[1],
tfjs_image_recognition_base_1.getCenterPoint([pts[3], pts[4]])
];
};
return FaceLandmarks5;
}(FaceLandmarks_1.FaceLandmarks));
exports.FaceLandmarks5 = FaceLandmarks5;
//# sourceMappingURL=FaceLandmarks5.js.map
\ No newline at end of file
{"version":3,"file":"FaceLandmarks5.js","sourceRoot":"","sources":["../../../src/classes/FaceLandmarks5.ts"],"names":[],"mappings":";;;AAAA,2EAAoE;AAEpE,iDAAgD;AAEhD;IAAoC,0CAAa;IAAjD;;IAUA,CAAC;IARW,iDAAwB,GAAlC;QACE,IAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAA;QAC1B,OAAO;YACL,GAAG,CAAC,CAAC,CAAC;YACN,GAAG,CAAC,CAAC,CAAC;YACN,4CAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACjC,CAAA;IACH,CAAC;IACH,qBAAC;AAAD,CAAC,AAVD,CAAoC,6BAAa,GAUhD;AAVY,wCAAc"}
\ No newline at end of file
import { Point } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from '../classes/FaceLandmarks';
export declare class FaceLandmarks68 extends FaceLandmarks {
getJawOutline(): Point[];
getLeftEyeBrow(): Point[];
getRightEyeBrow(): Point[];
getNose(): Point[];
getLeftEye(): Point[];
getRightEye(): Point[];
getMouth(): Point[];
protected getRefPointsForAlignment(): Point[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceLandmarks_1 = require("../classes/FaceLandmarks");
var FaceLandmarks68 = /** @class */ (function (_super) {
tslib_1.__extends(FaceLandmarks68, _super);
function FaceLandmarks68() {
return _super !== null && _super.apply(this, arguments) || this;
}
FaceLandmarks68.prototype.getJawOutline = function () {
return this.positions.slice(0, 17);
};
FaceLandmarks68.prototype.getLeftEyeBrow = function () {
return this.positions.slice(17, 22);
};
FaceLandmarks68.prototype.getRightEyeBrow = function () {
return this.positions.slice(22, 27);
};
FaceLandmarks68.prototype.getNose = function () {
return this.positions.slice(27, 36);
};
FaceLandmarks68.prototype.getLeftEye = function () {
return this.positions.slice(36, 42);
};
FaceLandmarks68.prototype.getRightEye = function () {
return this.positions.slice(42, 48);
};
FaceLandmarks68.prototype.getMouth = function () {
return this.positions.slice(48, 68);
};
FaceLandmarks68.prototype.getRefPointsForAlignment = function () {
return [
this.getLeftEye(),
this.getRightEye(),
this.getMouth()
].map(tfjs_image_recognition_base_1.getCenterPoint);
};
return FaceLandmarks68;
}(FaceLandmarks_1.FaceLandmarks));
exports.FaceLandmarks68 = FaceLandmarks68;
//# sourceMappingURL=FaceLandmarks68.js.map
\ No newline at end of file
{"version":3,"file":"FaceLandmarks68.js","sourceRoot":"","sources":["../../../src/classes/FaceLandmarks68.ts"],"names":[],"mappings":";;;AAAA,2EAAoE;AAEpE,0DAAyD;AAEzD;IAAqC,2CAAa;IAAlD;;IAoCA,CAAC;IAnCQ,uCAAa,GAApB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACpC,CAAC;IAEM,wCAAc,GAArB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,yCAAe,GAAtB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,iCAAO,GAAd;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,oCAAU,GAAjB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,qCAAW,GAAlB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,kCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAES,kDAAwB,GAAlC;QACE,OAAO;YACL,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,WAAW,EAAE;YAClB,IAAI,CAAC,QAAQ,EAAE;SAChB,CAAC,GAAG,CAAC,4CAAc,CAAC,CAAA;IACvB,CAAC;IACH,sBAAC;AAAD,CAAC,AApCD,CAAqC,6BAAa,GAoCjD;AApCY,0CAAe"}
\ No newline at end of file
export interface IFaceMatch {
label: string;
distance: number;
}
export declare class FaceMatch implements IFaceMatch {
private _label;
private _distance;
constructor(label: string, distance: number);
readonly label: string;
readonly distance: number;
toString(withDistance?: boolean): string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceMatch = /** @class */ (function () {
function FaceMatch(label, distance) {
this._label = label;
this._distance = distance;
}
Object.defineProperty(FaceMatch.prototype, "label", {
get: function () { return this._label; },
enumerable: true,
configurable: true
});
Object.defineProperty(FaceMatch.prototype, "distance", {
get: function () { return this._distance; },
enumerable: true,
configurable: true
});
FaceMatch.prototype.toString = function (withDistance) {
if (withDistance === void 0) { withDistance = true; }
return "" + this.label + (withDistance ? " (" + tfjs_image_recognition_base_1.round(this.distance) + ")" : '');
};
return FaceMatch;
}());
exports.FaceMatch = FaceMatch;
//# sourceMappingURL=FaceMatch.js.map
\ No newline at end of file
{"version":3,"file":"FaceMatch.js","sourceRoot":"","sources":["../../../src/classes/FaceMatch.ts"],"names":[],"mappings":";;AAAA,2EAAoD;AAOpD;IAIE,mBAAY,KAAa,EAAE,QAAgB;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;IAC3B,CAAC;IAED,sBAAW,4BAAK;aAAhB,cAA6B,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;;;OAAA;IACjD,sBAAW,+BAAQ;aAAnB,cAAgC,OAAO,IAAI,CAAC,SAAS,CAAA,CAAC,CAAC;;;OAAA;IAEhD,4BAAQ,GAAf,UAAgB,YAA4B;QAA5B,6BAAA,EAAA,mBAA4B;QAC1C,OAAO,KAAG,IAAI,CAAC,KAAK,IAAG,YAAY,CAAC,CAAC,CAAC,OAAK,mCAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAA;IAC3E,CAAC;IACH,gBAAC;AAAD,CAAC,AAfD,IAeC;AAfY,8BAAS"}
\ No newline at end of file
export declare class LabeledFaceDescriptors {
private _label;
private _descriptors;
constructor(label: string, descriptors: Float32Array[]);
readonly label: string;
readonly descriptors: Float32Array[];
toJSON(): any;
static fromJSON(json: any): LabeledFaceDescriptors;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LabeledFaceDescriptors = /** @class */ (function () {
function LabeledFaceDescriptors(label, descriptors) {
if (!(typeof label === 'string')) {
throw new Error('LabeledFaceDescriptors - constructor expected label to be a string');
}
if (!Array.isArray(descriptors) || descriptors.some(function (desc) { return !(desc instanceof Float32Array); })) {
throw new Error('LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array');
}
this._label = label;
this._descriptors = descriptors;
}
Object.defineProperty(LabeledFaceDescriptors.prototype, "label", {
get: function () { return this._label; },
enumerable: true,
configurable: true
});
Object.defineProperty(LabeledFaceDescriptors.prototype, "descriptors", {
get: function () { return this._descriptors; },
enumerable: true,
configurable: true
});
LabeledFaceDescriptors.prototype.toJSON = function () {
return {
label: this.label,
descriptors: this.descriptors.map(function (d) { return Array.from(d); })
};
};
LabeledFaceDescriptors.fromJSON = function (json) {
var descriptors = json.descriptors.map(function (d) {
return new Float32Array(d);
});
return new LabeledFaceDescriptors(json.label, descriptors);
};
return LabeledFaceDescriptors;
}());
exports.LabeledFaceDescriptors = LabeledFaceDescriptors;
//# sourceMappingURL=LabeledFaceDescriptors.js.map
\ No newline at end of file
{"version":3,"file":"LabeledFaceDescriptors.js","sourceRoot":"","sources":["../../../src/classes/LabeledFaceDescriptors.ts"],"names":[],"mappings":";;AAAA;IAIE,gCAAY,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,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,IAAI,YAAY,YAAY,CAAC,EAA/B,CAA+B,CAAC,EAAE;YAC5F,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAA;SAC5G;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;QACnB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAA;IACjC,CAAC;IAED,sBAAW,yCAAK;aAAhB,cAA6B,OAAO,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;;;OAAA;IACjD,sBAAW,+CAAW;aAAtB,cAA2C,OAAO,IAAI,CAAC,YAAY,CAAA,CAAC,CAAC;;;OAAA;IAE9D,uCAAM,GAAb;QACE,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAb,CAAa,CAAC;SACxD,CAAC;IACJ,CAAC;IAEa,+BAAQ,GAAtB,UAAuB,IAAS;QAC9B,IAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAC,CAAM;YAC9C,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;IAEH,6BAAC;AAAD,CAAC,AAlCD,IAkCC;AAlCY,wDAAsB"}
\ No newline at end of file
export * from './FaceDetection';
export * from './FaceLandmarks';
export * from './FaceLandmarks5';
export * from './FaceLandmarks68';
export * from './FaceMatch';
export * from './LabeledFaceDescriptors';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./FaceDetection"), exports);
tslib_1.__exportStar(require("./FaceLandmarks"), exports);
tslib_1.__exportStar(require("./FaceLandmarks5"), exports);
tslib_1.__exportStar(require("./FaceLandmarks68"), exports);
tslib_1.__exportStar(require("./FaceMatch"), exports);
tslib_1.__exportStar(require("./LabeledFaceDescriptors"), exports);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/classes/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,0DAAgC;AAChC,2DAAiC;AACjC,4DAAkC;AAClC,sDAA4B;AAC5B,mEAAyC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function depthwiseSeparableConv(x: tf.Tensor4D, params: TfjsImageRecognitionBase.SeparableConvParams, stride: [number, number]): tf.Tensor4D;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
function depthwiseSeparableConv(x, params, stride) {
return tf.tidy(function () {
var out = tf.separableConv2d(x, params.depthwise_filter, params.pointwise_filter, stride, 'same');
out = tf.add(out, params.bias);
return out;
});
}
exports.depthwiseSeparableConv = depthwiseSeparableConv;
//# sourceMappingURL=depthwiseSeparableConv.js.map
\ No newline at end of file
{"version":3,"file":"depthwiseSeparableConv.js","sourceRoot":"","sources":["../../../src/common/depthwiseSeparableConv.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAG5C,SAAgB,sBAAsB,CACpC,CAAc,EACd,MAAoD,EACpD,MAAwB;IAExB,OAAO,EAAE,CAAC,IAAI,CAAC;QACb,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"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function fullyConnectedLayer(x: tf.Tensor2D, params: TfjsImageRecognitionBase.FCParams): tf.Tensor2D;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
function fullyConnectedLayer(x, params) {
return tf.tidy(function () {
return tf.add(tf.matMul(x, params.weights), params.bias);
});
}
exports.fullyConnectedLayer = fullyConnectedLayer;
//# sourceMappingURL=fullyConnectedLayer.js.map
\ No newline at end of file
{"version":3,"file":"fullyConnectedLayer.js","sourceRoot":"","sources":["../../../src/common/fullyConnectedLayer.ts"],"names":[],"mappings":";;AAAA,0CAA4C;AAG5C,SAAgB,mBAAmB,CACjC,CAAc,EACd,MAAyC;IAEzC,OAAO,EAAE,CAAC,IAAI,CAAC;QACb,OAAA,EAAE,CAAC,GAAG,CACJ,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,EAC5B,MAAM,CAAC,IAAI,CACZ;IAHD,CAGC,CACF,CAAA;AACH,CAAC;AAVD,kDAUC"}
\ No newline at end of file
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function loadConvParamsFactory(extractWeightEntry: <T>(originalPath: string, paramRank: number) => T): (prefix: string) => TfjsImageRecognitionBase.ConvParams;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function loadConvParamsFactory(extractWeightEntry) {
return function (prefix) {
var filters = extractWeightEntry(prefix + "/filters", 4);
var bias = extractWeightEntry(prefix + "/bias", 1);
return { filters: filters, bias: bias };
};
}
exports.loadConvParamsFactory = loadConvParamsFactory;
//# sourceMappingURL=loadConvParamsFactory.js.map
\ No newline at end of file
{"version":3,"file":"loadConvParamsFactory.js","sourceRoot":"","sources":["../../../src/common/loadConvParamsFactory.ts"],"names":[],"mappings":";;AAGA,SAAgB,qBAAqB,CAAC,kBAAqE;IACzG,OAAO,UAAS,MAAc;QAC5B,IAAM,OAAO,GAAG,kBAAkB,CAAiB,MAAM,aAAU,EAAE,CAAC,CAAC,CAAA;QACvE,IAAM,IAAI,GAAG,kBAAkB,CAAiB,MAAM,UAAO,EAAE,CAAC,CAAC,CAAA;QAEjE,OAAO,EAAE,OAAO,SAAA,EAAE,IAAI,MAAA,EAAE,CAAA;IAC1B,CAAC,CAAA;AACH,CAAC;AAPD,sDAOC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { Rect } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
/**
* Extracts the tensors of the image regions containing the detected faces.
* Useful if you want to compute the face descriptors for the face images.
* Using this method is faster then extracting a canvas for each face and
* converting them to tensors individually.
*
* @param imageTensor The image tensor that face detection has been performed on.
* @param detections The face detection results or face bounding boxes for that image.
* @returns Tensors of the corresponding image region for each detected face.
*/
export declare function extractFaceTensors(imageTensor: tf.Tensor3D | tf.Tensor4D, detections: Array<FaceDetection | Rect>): Promise<tf.Tensor3D[]>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceDetection_1 = require("../classes/FaceDetection");
/**
* Extracts the tensors of the image regions containing the detected faces.
* Useful if you want to compute the face descriptors for the face images.
* Using this method is faster then extracting a canvas for each face and
* converting them to tensors individually.
*
* @param imageTensor The image tensor that face detection has been performed on.
* @param detections The face detection results or face bounding boxes for that image.
* @returns Tensors of the corresponding image region for each detected face.
*/
function extractFaceTensors(imageTensor, detections) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
if (!tfjs_image_recognition_base_1.isTensor3D(imageTensor) && !tfjs_image_recognition_base_1.isTensor4D(imageTensor)) {
throw new Error('extractFaceTensors - expected image tensor to be 3D or 4D');
}
if (tfjs_image_recognition_base_1.isTensor4D(imageTensor) && imageTensor.shape[0] > 1) {
throw new Error('extractFaceTensors - batchSize > 1 not supported');
}
return [2 /*return*/, tf.tidy(function () {
var _a = imageTensor.shape.slice(tfjs_image_recognition_base_1.isTensor4D(imageTensor) ? 1 : 0), imgHeight = _a[0], imgWidth = _a[1], numChannels = _a[2];
var boxes = detections.map(function (det) { return det instanceof FaceDetection_1.FaceDetection
? det.forSize(imgWidth, imgHeight).box
: det; })
.map(function (box) { return box.clipAtImageBorders(imgWidth, imgHeight); });
var faceTensors = boxes.map(function (_a) {
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
return tf.slice3d(imageTensor.as3D(imgHeight, imgWidth, numChannels), [y, x, 0], [height, width, numChannels]);
});
return faceTensors;
})];
});
});
}
exports.extractFaceTensors = extractFaceTensors;
//# sourceMappingURL=extractFaceTensors.js.map
\ No newline at end of file
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AK,EAAE,WAAW,CAAC,CAAC;oBAAvG,CAAuG,CACxG,CAAA;oBAED,OAAO,WAAW,CAAA;gBACpB,CAAC,CAAC,EAAA;;;CACH;AA7BD,gDA6BC"}
\ No newline at end of file
import { Rect, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
/**
* Extracts the image regions containing the detected faces.
*
* @param input The image that face detection has been performed on.
* @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.
*/
export declare function extractFaces(input: TNetInput, detections: Array<FaceDetection | Rect>): Promise<HTMLCanvasElement[]>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceDetection_1 = require("../classes/FaceDetection");
/**
* Extracts the image regions containing the detected faces.
*
* @param input The image that face detection has been performed on.
* @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.
*/
function extractFaces(input, detections) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var Canvas, canvas, netInput, tensorOrCanvas, _a, ctx, boxes;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
Canvas = tfjs_image_recognition_base_1.env.getEnv().Canvas;
canvas = input;
if (!!(input instanceof Canvas)) return [3 /*break*/, 5];
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 1:
netInput = _b.sent();
if (netInput.batchSize > 1) {
throw new Error('extractFaces - batchSize > 1 not supported');
}
tensorOrCanvas = netInput.getInput(0);
if (!(tensorOrCanvas instanceof Canvas)) return [3 /*break*/, 2];
_a = tensorOrCanvas;
return [3 /*break*/, 4];
case 2: return [4 /*yield*/, tfjs_image_recognition_base_1.imageTensorToCanvas(tensorOrCanvas)];
case 3:
_a = _b.sent();
_b.label = 4;
case 4:
canvas = _a;
_b.label = 5;
case 5:
ctx = tfjs_image_recognition_base_1.getContext2dOrThrow(canvas);
boxes = detections.map(function (det) { return det instanceof FaceDetection_1.FaceDetection
? det.forSize(canvas.width, canvas.height).box.floor()
: det; })
.map(function (box) { return box.clipAtImageBorders(canvas.width, canvas.height); });
return [2 /*return*/, boxes.map(function (_a) {
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
var faceImg = tfjs_image_recognition_base_1.createCanvas({ width: width, height: height });
tfjs_image_recognition_base_1.getContext2dOrThrow(faceImg)
.putImageData(ctx.getImageData(x, y, width, height), 0, 0);
return faceImg;
})];
}
});
});
}
exports.extractFaces = extractFaces;
//# sourceMappingURL=extractFaces.js.map
\ No newline at end of file
{"version":3,"file":"extractFaces.js","sourceRoot":"","sources":["../../../src/dom/extractFaces.ts"],"names":[],"mappings":";;;AAAA,2EAQqC;AAErC,0DAAyD;AAEzD;;;;;;GAMG;AACH,SAAsB,YAAY,CAChC,KAAgB,EAChB,UAAuC;;;;;;oBAG/B,MAAM,GAAK,iCAAG,CAAC,MAAM,EAAE,OAAjB,CAAiB;oBAE3B,MAAM,GAAG,KAA0B,CAAA;yBAEnC,CAAC,CAAC,KAAK,YAAY,MAAM,CAAC,EAA1B,wBAA0B;oBACX,qBAAM,wCAAU,CAAC,KAAK,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;oBAExC,IAAI,QAAQ,CAAC,SAAS,GAAG,CAAC,EAAE;wBAC1B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;qBAC9D;oBAEK,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;yBAClC,CAAA,cAAc,YAAY,MAAM,CAAA,EAAhC,wBAAgC;oBACrC,KAAA,cAAc,CAAA;;wBACd,qBAAM,iDAAmB,CAAC,cAAc,CAAC,EAAA;;oBAAzC,KAAA,SAAyC,CAAA;;;oBAF7C,MAAM,KAEuC,CAAA;;;oBAGzC,GAAG,GAAG,iDAAmB,CAAC,MAAM,CAAC,CAAA;oBACjC,KAAK,GAAG,UAAU,CAAC,GAAG,CAC1B,UAAA,GAAG,IAAI,OAAA,GAAG,YAAY,6BAAa;wBACjC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE;wBACtD,CAAC,CAAC,GAAG,EAFA,CAEA,CACR;yBACE,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAnD,CAAmD,CAAC,CAAA;oBAElE,sBAAO,KAAK,CAAC,GAAG,CAAC,UAAC,EAAuB;gCAArB,QAAC,EAAE,QAAC,EAAE,gBAAK,EAAE,kBAAM;4BACrC,IAAM,OAAO,GAAG,0CAAY,CAAC,EAAE,KAAK,OAAA,EAAE,MAAM,QAAA,EAAE,CAAC,CAAA;4BAC/C,iDAAmB,CAAC,OAAO,CAAC;iCACzB,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;4BAC5D,OAAO,OAAO,CAAA;wBAChB,CAAC,CAAC,EAAA;;;;CACH;AApCD,oCAoCC"}
\ No newline at end of file
export * from './extractFaces';
export * from './extractFaceTensors';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./extractFaces"), exports);
tslib_1.__exportStar(require("./extractFaceTensors"), exports);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dom/index.ts"],"names":[],"mappings":";;;AAAA,yDAA8B;AAC9B,+DAAoC"}
\ No newline at end of file
import { FaceLandmarks } from '../classes/FaceLandmarks';
import { WithFaceDetection } from '../factories/WithFaceDetection';
import { WithFaceLandmarks } from '../factories/WithFaceLandmarks';
export interface IDrawFaceLandmarksOptions {
drawLines?: boolean;
drawPoints?: boolean;
lineWidth?: number;
pointSize?: number;
lineColor?: string;
pointColor?: string;
}
export declare class DrawFaceLandmarksOptions {
drawLines: boolean;
drawPoints: boolean;
lineWidth: number;
pointSize: number;
lineColor: string;
pointColor: string;
constructor(options?: IDrawFaceLandmarksOptions);
}
export declare class DrawFaceLandmarks {
faceLandmarks: FaceLandmarks;
options: DrawFaceLandmarksOptions;
constructor(faceLandmarks: FaceLandmarks, options?: IDrawFaceLandmarksOptions);
draw(canvasArg: string | HTMLCanvasElement | CanvasRenderingContext2D): void;
}
export declare type DrawFaceLandmarksInput = FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>>;
export declare function drawFaceLandmarks(canvasArg: string | HTMLCanvasElement, faceLandmarks: DrawFaceLandmarksInput | Array<DrawFaceLandmarksInput>): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceLandmarks_1 = require("../classes/FaceLandmarks");
var FaceLandmarks68_1 = require("../classes/FaceLandmarks68");
var WithFaceLandmarks_1 = require("../factories/WithFaceLandmarks");
var drawContour_1 = require("./drawContour");
var DrawFaceLandmarksOptions = /** @class */ (function () {
function DrawFaceLandmarksOptions(options) {
if (options === void 0) { options = {}; }
var _a = options.drawLines, drawLines = _a === void 0 ? true : _a, _b = options.drawPoints, drawPoints = _b === void 0 ? true : _b, lineWidth = options.lineWidth, lineColor = options.lineColor, pointSize = options.pointSize, pointColor = options.pointColor;
this.drawLines = drawLines;
this.drawPoints = drawPoints;
this.lineWidth = lineWidth || 1;
this.pointSize = pointSize || 2;
this.lineColor = lineColor || 'rgba(0, 255, 255, 1)';
this.pointColor = pointColor || 'rgba(255, 0, 255, 1)';
}
return DrawFaceLandmarksOptions;
}());
exports.DrawFaceLandmarksOptions = DrawFaceLandmarksOptions;
var DrawFaceLandmarks = /** @class */ (function () {
function DrawFaceLandmarks(faceLandmarks, options) {
if (options === void 0) { options = {}; }
this.faceLandmarks = faceLandmarks;
this.options = new DrawFaceLandmarksOptions(options);
}
DrawFaceLandmarks.prototype.draw = function (canvasArg) {
var ctx = tfjs_image_recognition_base_1.getContext2dOrThrow(canvasArg);
var _a = this.options, drawLines = _a.drawLines, drawPoints = _a.drawPoints, lineWidth = _a.lineWidth, lineColor = _a.lineColor, pointSize = _a.pointSize, pointColor = _a.pointColor;
if (drawLines && this.faceLandmarks instanceof FaceLandmarks68_1.FaceLandmarks68) {
ctx.strokeStyle = lineColor;
ctx.lineWidth = lineWidth;
drawContour_1.drawContour(ctx, this.faceLandmarks.getJawOutline());
drawContour_1.drawContour(ctx, this.faceLandmarks.getLeftEyeBrow());
drawContour_1.drawContour(ctx, this.faceLandmarks.getRightEyeBrow());
drawContour_1.drawContour(ctx, this.faceLandmarks.getNose());
drawContour_1.drawContour(ctx, this.faceLandmarks.getLeftEye(), true);
drawContour_1.drawContour(ctx, this.faceLandmarks.getRightEye(), true);
drawContour_1.drawContour(ctx, this.faceLandmarks.getMouth(), true);
}
if (drawPoints) {
ctx.strokeStyle = pointColor;
ctx.fillStyle = pointColor;
var drawPoint = function (pt) {
ctx.beginPath();
ctx.arc(pt.x, pt.y, pointSize, 0, 2 * Math.PI);
ctx.fill();
};
this.faceLandmarks.positions.forEach(drawPoint);
}
};
return DrawFaceLandmarks;
}());
exports.DrawFaceLandmarks = DrawFaceLandmarks;
function drawFaceLandmarks(canvasArg, faceLandmarks) {
var faceLandmarksArray = Array.isArray(faceLandmarks) ? faceLandmarks : [faceLandmarks];
faceLandmarksArray.forEach(function (f) {
var landmarks = f instanceof FaceLandmarks_1.FaceLandmarks
? f
: (WithFaceLandmarks_1.isWithFaceLandmarks(f) ? f.landmarks : undefined);
if (!landmarks) {
throw new Error('drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof');
}
new DrawFaceLandmarks(landmarks).draw(canvasArg);
});
}
exports.drawFaceLandmarks = drawFaceLandmarks;
//# sourceMappingURL=DrawFaceLandmar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IAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAA;IACzF,kBAAkB,CAAC,OAAO,CAAC,UAAA,CAAC;QAC1B,IAAM,SAAS,GAAG,CAAC,YAAY,6BAAa;YAC1C,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC,uCAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QACtD,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,8HAA8H,CAAC,CAAA;SAChJ;QAED,IAAI,iBAAiB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC;AAfD,8CAeC"}
\ No newline at end of file
import { Point } from 'tfjs-image-recognition-base';
export declare function drawContour(ctx: CanvasRenderingContext2D, points: Point[], isClosed?: boolean): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function drawContour(ctx, points, isClosed) {
if (isClosed === void 0) { isClosed = false; }
ctx.beginPath();
points.slice(1).forEach(function (_a, prevIdx) {
var x = _a.x, y = _a.y;
var from = points[prevIdx];
ctx.moveTo(from.x, from.y);
ctx.lineTo(x, y);
});
if (isClosed) {
var from = points[points.length - 1];
var to = points[0];
if (!from || !to) {
return;
}
ctx.moveTo(from.x, from.y);
ctx.lineTo(to.x, to.y);
}
ctx.stroke();
}
exports.drawContour = drawContour;
//# sourceMappingURL=drawContour.js.map
\ No newline at end of file
{"version":3,"file":"drawContour.js","sourceRoot":"","sources":["../../../src/draw/drawContour.ts"],"names":[],"mappings":";;AAEA,SAAgB,WAAW,CACzB,GAA6B,EAC7B,MAAe,EACf,QAAyB;IAAzB,yBAAA,EAAA,gBAAyB;IAEzB,GAAG,CAAC,SAAS,EAAE,CAAA;IAEf,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAC,EAAQ,EAAE,OAAO;YAAf,QAAC,EAAE,QAAC;QAC7B,IAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;QAC5B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;QAC1B,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAClB,CAAC,CAAC,CAAA;IAEF,IAAI,QAAQ,EAAE;QACZ,IAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACtC,IAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;QACpB,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE;YAChB,OAAM;SACP;QAED,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;QAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;KACvB;IAED,GAAG,CAAC,MAAM,EAAE,CAAA;AACd,CAAC;AAzBD,kCAyBC"}
\ No newline at end of file
import { IBoundingBox, IRect } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { WithFaceDetection } from '../factories/WithFaceDetection';
export declare type TDrawDetectionsInput = IRect | IBoundingBox | FaceDetection | WithFaceDetection<{}>;
export declare function drawDetections(canvasArg: string | HTMLCanvasElement, detections: TDrawDetectionsInput | Array<TDrawDetectionsInput>): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceDetection_1 = require("../classes/FaceDetection");
var WithFaceDetection_1 = require("../factories/WithFaceDetection");
function drawDetections(canvasArg, detections) {
var detectionsArray = Array.isArray(detections) ? detections : [detections];
detectionsArray.forEach(function (det) {
var score = det instanceof FaceDetection_1.FaceDetection
? det.score
: (WithFaceDetection_1.isWithFaceDetection(det) ? det.detection.score : undefined);
var box = det instanceof FaceDetection_1.FaceDetection
? det.box
: (WithFaceDetection_1.isWithFaceDetection(det) ? det.detection.box : new tfjs_image_recognition_base_1.Box(det));
var label = score ? "" + tfjs_image_recognition_base_1.round(score) : undefined;
new tfjs_image_recognition_base_1.draw.DrawBox(box, { label: label }).draw(canvasArg);
});
}
exports.drawDetections = drawDetections;
//# sourceMappingURL=drawDetections.js.map
\ No newline at end of file
{"version":3,"file":"drawDetections.js","sourceRoot":"","sources":["../../../src/draw/drawDetections.ts"],"names":[],"mappings":";;AAAA,2EAAoF;AAEpF,0DAAyD;AACzD,oEAAwF;AAIxF,SAAgB,cAAc,CAC5B,SAAqC,EACrC,UAA8D;IAE9D,IAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IAE7E,eAAe,CAAC,OAAO,CAAC,UAAA,GAAG;QACzB,IAAM,KAAK,GAAG,GAAG,YAAY,6BAAa;YACxC,CAAC,CAAC,GAAG,CAAC,KAAK;YACX,CAAC,CAAC,CAAC,uCAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAEhE,IAAM,GAAG,GAAG,GAAG,YAAY,6BAAa;YACtC,CAAC,CAAC,GAAG,CAAC,GAAG;YACT,CAAC,CAAC,CAAC,uCAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,iCAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAEjE,IAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,KAAG,mCAAK,CAAC,KAAK,CAAG,CAAC,CAAC,CAAC,SAAS,CAAA;QACnD,IAAI,kCAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;AACJ,CAAC;AAlBD,wCAkBC"}
\ No newline at end of file
import { IPoint } from 'tfjs-image-recognition-base';
import { FaceExpressions } from '../faceExpressionNet';
import { WithFaceExpressions } from '../factories/WithFaceExpressions';
export declare type DrawFaceExpressionsInput = FaceExpressions | WithFaceExpressions<{}>;
export declare function drawFaceExpressions(canvasArg: string | HTMLCanvasElement, faceExpressions: DrawFaceExpressionsInput | Array<DrawFaceExpressionsInput>, minConfidence?: number, textFieldAnchor?: IPoint): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var faceExpressionNet_1 = require("../faceExpressionNet");
var WithFaceDetection_1 = require("../factories/WithFaceDetection");
var WithFaceExpressions_1 = require("../factories/WithFaceExpressions");
function drawFaceExpressions(canvasArg, faceExpressions, minConfidence, textFieldAnchor) {
if (minConfidence === void 0) { minConfidence = 0.1; }
var faceExpressionsArray = Array.isArray(faceExpressions) ? faceExpressions : [faceExpressions];
faceExpressionsArray.forEach(function (e) {
var expr = e instanceof faceExpressionNet_1.FaceExpressions
? e
: (WithFaceExpressions_1.isWithFaceExpressions(e) ? e.expressions : undefined);
if (!expr) {
throw new Error('drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof');
}
var sorted = expr.asSortedArray();
var resultsToDisplay = sorted.filter(function (expr) { return expr.probability > minConfidence; });
var anchor = WithFaceDetection_1.isWithFaceDetection(e)
? e.detection.box.bottomLeft
: (textFieldAnchor || new tfjs_image_recognition_base_1.Point(0, 0));
var drawTextField = new tfjs_image_recognition_base_1.draw.DrawTextField(resultsToDisplay.map(function (expr) { return expr.expression + " (" + tfjs_image_recognition_base_1.round(expr.probability) + ")"; }), anchor);
drawTextField.draw(canvasArg);
});
}
exports.drawFaceExpressions = drawFaceExpressions;
//# sourceMappingURL=drawFaceExpressions.js.map
\ No newline at end of file
{"version":3,"file":"drawFaceExpressions.js","sourceRoot":"","sources":["../../../src/draw/drawFaceExpressions.ts"],"names":[],"mappings":";;AAAA,2EAAyE;AAEzE,0DAAuD;AACvD,oEAAqE;AACrE,wEAA8F;AAI9F,SAAgB,mBAAmB,CACjC,SAAqC,EACrC,eAA2E,EAC3E,aAAmB,EACnB,eAAwB;IADxB,8BAAA,EAAA,mBAAmB;IAGnB,IAAM,oBAAoB,GAAG,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAA;IAEjG,oBAAoB,CAAC,OAAO,CAAC,UAAA,CAAC;QAC5B,IAAM,IAAI,GAAG,CAAC,YAAY,mCAAe;YACvC,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC,2CAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAC1D,IAAI,CAAC,IAAI,EAAE;YACT,MAAM,IAAI,KAAK,CAAC,iHAAiH,CAAC,CAAA;SACnI;QAED,IAAM,MAAM,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACnC,IAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,WAAW,GAAG,aAAa,EAAhC,CAAgC,CAAC,CAAA;QAEhF,IAAM,MAAM,GAAG,uCAAmB,CAAC,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU;YAC5B,CAAC,CAAC,CAAC,eAAe,IAAI,IAAI,mCAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAExC,IAAM,aAAa,GAAG,IAAI,kCAAI,CAAC,aAAa,CAC1C,gBAAgB,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAG,IAAI,CAAC,UAAU,UAAK,mCAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAG,EAAjD,CAAiD,CAAC,EAC/E,MAAM,CACP,CAAA;QACD,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;AACJ,CAAC;AA7BD,kDA6BC"}
\ No newline at end of file
export * from './drawContour';
export * from './drawDetections';
export * from './drawFaceExpressions';
export * from './DrawFaceLandmarks';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./drawContour"), exports);
tslib_1.__exportStar(require("./drawDetections"), exports);
tslib_1.__exportStar(require("./drawFaceExpressions"), exports);
tslib_1.__exportStar(require("./DrawFaceLandmarks"), exports);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/draw/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,2DAAgC;AAChC,gEAAqC;AACrC,8DAAmC"}
\ No newline at end of file
export declare function euclideanDistance(arr1: number[] | Float32Array, arr2: number[] | Float32Array): number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function euclideanDistance(arr1, arr2) {
if (arr1.length !== arr2.length)
throw new Error('euclideanDistance: arr1.length !== arr2.length');
var desc1 = Array.from(arr1);
var desc2 = Array.from(arr2);
return Math.sqrt(desc1
.map(function (val, i) { return val - desc2[i]; })
.reduce(function (res, diff) { return res + Math.pow(diff, 2); }, 0));
}
exports.euclideanDistance = euclideanDistance;
//# sourceMappingURL=euclideanDistance.js.map
\ No newline at end of file
{"version":3,"file":"euclideanDistance.js","sourceRoot":"","sources":["../../src/euclideanDistance.ts"],"names":[],"mappings":";;AAAA,SAAgB,iBAAiB,CAAC,IAA6B,EAAE,IAA6B;IAC5F,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAC7B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;IAEnE,IAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,IAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAE9B,OAAO,IAAI,CAAC,IAAI,CACd,KAAK;SACF,GAAG,CAAC,UAAC,GAAG,EAAE,CAAC,IAAK,OAAA,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAd,CAAc,CAAC;SAC/B,MAAM,CAAC,UAAC,GAAG,EAAE,IAAI,IAAK,OAAA,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,EAAvB,CAAuB,EAAE,CAAC,CAAC,CACrD,CAAA;AACH,CAAC;AAZD,8CAYC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, TNetInput } from 'tfjs-image-recognition-base';
import { FaceFeatureExtractor } from '../faceFeatureExtractor/FaceFeatureExtractor';
import { FaceFeatureExtractorParams } from '../faceFeatureExtractor/types';
import { FaceProcessor } from '../faceProcessor/FaceProcessor';
import { FaceExpressions } from './FaceExpressions';
export declare class FaceExpressionNet extends FaceProcessor<FaceFeatureExtractorParams> {
constructor(faceFeatureExtractor?: FaceFeatureExtractor);
forwardInput(input: NetInput | tf.Tensor4D): tf.Tensor2D;
forward(input: TNetInput): Promise<tf.Tensor2D>;
predictExpressions(input: TNetInput): Promise<FaceExpressions | FaceExpressions[]>;
protected getDefaultModelName(): string;
protected getClassifierChannelsIn(): number;
protected getClassifierChannelsOut(): number;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceFeatureExtractor_1 = require("../faceFeatureExtractor/FaceFeatureExtractor");
var FaceProcessor_1 = require("../faceProcessor/FaceProcessor");
var FaceExpressions_1 = require("./FaceExpressions");
var FaceExpressionNet = /** @class */ (function (_super) {
tslib_1.__extends(FaceExpressionNet, _super);
function FaceExpressionNet(faceFeatureExtractor) {
if (faceFeatureExtractor === void 0) { faceFeatureExtractor = new FaceFeatureExtractor_1.FaceFeatureExtractor(); }
return _super.call(this, 'FaceExpressionNet', faceFeatureExtractor) || this;
}
FaceExpressionNet.prototype.forwardInput = function (input) {
var _this = this;
return tf.tidy(function () { return tf.softmax(_this.runNet(input)); });
};
FaceExpressionNet.prototype.forward = function (input) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
}
});
});
};
FaceExpressionNet.prototype.predictExpressions = function (input) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var netInput, out, probabilitesByBatch, predictionsByBatch;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 1:
netInput = _a.sent();
return [4 /*yield*/, this.forwardInput(netInput)];
case 2:
out = _a.sent();
return [4 /*yield*/, Promise.all(tf.unstack(out).map(function (t) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var data;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, t.data()];
case 1:
data = _a.sent();
t.dispose();
return [2 /*return*/, data];
}
});
}); }))];
case 3:
probabilitesByBatch = _a.sent();
out.dispose();
predictionsByBatch = probabilitesByBatch
.map(function (probabilites) { return new FaceExpressions_1.FaceExpressions(probabilites); });
return [2 /*return*/, netInput.isBatchInput
? predictionsByBatch
: predictionsByBatch[0]];
}
});
});
};
FaceExpressionNet.prototype.getDefaultModelName = function () {
return 'face_expression_model';
};
FaceExpressionNet.prototype.getClassifierChannelsIn = function () {
return 256;
};
FaceExpressionNet.prototype.getClassifierChannelsOut = function () {
return 7;
};
return FaceExpressionNet;
}(FaceProcessor_1.FaceProcessor));
exports.FaceExpressionNet = FaceExpressionNet;
//# sourceMappingURL=FaceExpressionNet.js.map
\ No newline at end of file
{"version":3,"file":"FaceExpressionNet.js","sourceRoot":"","sources":["../../../src/faceExpressionNet/FaceExpressionNet.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAC5C,2EAA8E;AAE9E,qFAAoF;AAEpF,gEAA+D;AAC/D,qDAAoD;AAEpD;IAAuC,6CAAyC;IAE9E,2BAAY,oBAAuE;QAAvE,qCAAA,EAAA,2BAAiD,2CAAoB,EAAE;eACjF,kBAAM,mBAAmB,EAAE,oBAAoB,CAAC;IAClD,CAAC;IAEM,wCAAY,GAAnB,UAAoB,KAA6B;QAAjD,iBAEC;QADC,OAAO,EAAE,CAAC,IAAI,CAAC,cAAM,OAAA,EAAE,CAAC,OAAO,CAAC,KAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAA9B,CAA8B,CAAC,CAAA;IACtD,CAAC;IAEY,mCAAO,GAApB,UAAqB,KAAgB;;;;;;wBAC5B,KAAA,IAAI,CAAC,YAAY,CAAA;wBAAC,qBAAM,wCAAU,CAAC,KAAK,CAAC,EAAA;4BAAhD,sBAAO,SAAA,IAAI,GAAc,SAAuB,EAAC,EAAA;;;;KAClD;IAEY,8CAAkB,GAA/B,UAAgC,KAAgB;;;;;;4BAC7B,qBAAM,wCAAU,CAAC,KAAK,CAAC,EAAA;;wBAAlC,QAAQ,GAAG,SAAuB;wBAC5B,qBAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAA;;wBAAvC,GAAG,GAAG,SAAiC;wBACjB,qBAAM,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAM,CAAC;;;;gDAC1D,qBAAM,CAAC,CAAC,IAAI,EAAE,EAAA;;4CAArB,IAAI,GAAG,SAAc;4CAC3B,CAAC,CAAC,OAAO,EAAE,CAAA;4CACX,sBAAO,IAAI,EAAA;;;iCACZ,CAAC,CAAC,EAAA;;wBAJG,mBAAmB,GAAG,SAIzB;wBACH,GAAG,CAAC,OAAO,EAAE,CAAA;wBAEP,kBAAkB,GAAG,mBAAmB;6BAC3C,GAAG,CAAC,UAAA,YAAY,IAAI,OAAA,IAAI,iCAAe,CAAC,YAA4B,CAAC,EAAjD,CAAiD,CAAC,CAAA;wBAEzE,sBAAO,QAAQ,CAAC,YAAY;gCAC1B,CAAC,CAAC,kBAAkB;gCACpB,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAA;;;;KAC1B;IAES,+CAAmB,GAA7B;QACE,OAAO,uBAAuB,CAAA;IAChC,CAAC;IAES,mDAAuB,GAAjC;QACE,OAAO,GAAG,CAAA;IACZ,CAAC;IAES,oDAAwB,GAAlC;QACE,OAAO,CAAC,CAAA;IACV,CAAC;IACH,wBAAC;AAAD,CAAC,AA3CD,CAAuC,6BAAa,GA2CnD;AA3CY,8CAAiB"}
\ No newline at end of file
export declare const FACE_EXPRESSION_LABELS: string[];
export declare class FaceExpressions {
neutral: number;
happy: number;
sad: number;
angry: number;
fearful: number;
disgusted: number;
surprised: number;
constructor(probabilities: number[] | Float32Array);
asSortedArray(): {
expression: string;
probability: number;
}[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FACE_EXPRESSION_LABELS = ['neutral', 'happy', 'sad', 'angry', 'fearful', 'disgusted', 'surprised'];
var FaceExpressions = /** @class */ (function () {
function FaceExpressions(probabilities) {
var _this = this;
if (probabilities.length !== 7) {
throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: " + probabilities.length);
}
exports.FACE_EXPRESSION_LABELS.forEach(function (expression, idx) {
_this[expression] = probabilities[idx];
});
}
FaceExpressions.prototype.asSortedArray = function () {
var _this = this;
return exports.FACE_EXPRESSION_LABELS
.map(function (expression) { return ({ expression: expression, probability: _this[expression] }); })
.sort(function (e0, e1) { return e1.probability - e0.probability; });
};
return FaceExpressions;
}());
exports.FaceExpressions = FaceExpressions;
//# sourceMappingURL=FaceExpressions.js.map
\ No newline at end of file
{"version":3,"file":"FaceExpressions.js","sourceRoot":"","sources":["../../../src/faceExpressionNet/FaceExpressions.ts"],"names":[],"mappings":";;AAAa,QAAA,sBAAsB,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAA;AAE/G;IASE,yBAAY,aAAsC;QAAlD,iBAQC;QAPC,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,KAAK,CAAC,gFAA8E,aAAa,CAAC,MAAQ,CAAC,CAAA;SACtH;QAED,8BAAsB,CAAC,OAAO,CAAC,UAAC,UAAU,EAAE,GAAG;YAC7C,KAAI,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;QACvC,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,uCAAa,GAAb;QAAA,iBAIC;QAHC,OAAO,8BAAsB;aAC1B,GAAG,CAAC,UAAA,UAAU,IAAI,OAAA,CAAC,EAAE,UAAU,YAAA,EAAE,WAAW,EAAE,KAAI,CAAC,UAAU,CAAW,EAAE,CAAC,EAAzD,CAAyD,CAAC;aAC5E,IAAI,CAAC,UAAC,EAAE,EAAE,EAAE,IAAK,OAAA,EAAE,CAAC,WAAW,GAAG,EAAE,CAAC,WAAW,EAA/B,CAA+B,CAAC,CAAA;IACtD,CAAC;IACH,sBAAC;AAAD,CAAC,AAxBD,IAwBC;AAxBY,0CAAe"}
\ No newline at end of file
export * from './FaceExpressionNet';
export * from './FaceExpressions';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./FaceExpressionNet"), exports);
tslib_1.__exportStar(require("./FaceExpressions"), exports);
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/faceExpressionNet/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,4DAAkC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { FaceFeatureExtractorParams, IFaceFeatureExtractor } from './types';
export declare class FaceFeatureExtractor extends NeuralNetwork<FaceFeatureExtractorParams> implements IFaceFeatureExtractor<FaceFeatureExtractorParams> {
constructor();
forwardInput(input: NetInput): tf.Tensor4D;
forward(input: TNetInput): Promise<tf.Tensor4D>;
protected getDefaultModelName(): string;
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: FaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: FaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
};
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var denseBlock_1 = require("./denseBlock");
var extractParams_1 = require("./extractParams");
var extractParamsFromWeigthMap_1 = require("./extractParamsFromWeigthMap");
var FaceFeatureExtractor = /** @class */ (function (_super) {
tslib_1.__extends(FaceFeatureExtractor, _super);
function FaceFeatureExtractor() {
return _super.call(this, 'FaceFeatureExtractor') || this;
}
FaceFeatureExtractor.prototype.forwardInput = function (input) {
var params = this.params;
if (!params) {
throw new Error('FaceFeatureExtractor - load model before inference');
}
return tf.tidy(function () {
var batchTensor = input.toBatchTensor(112, true);
var meanRgb = [122.782, 117.001, 104.298];
var normalized = tfjs_image_recognition_base_1.normalize(batchTensor, meanRgb).div(tf.scalar(255));
var out = denseBlock_1.denseBlock4(normalized, params.dense0, true);
out = denseBlock_1.denseBlock4(out, params.dense1);
out = denseBlock_1.denseBlock4(out, params.dense2);
out = denseBlock_1.denseBlock4(out, params.dense3);
out = tf.avgPool(out, [7, 7], [2, 2], 'valid');
return out;
});
};
FaceFeatureExtractor.prototype.forward = function (input) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
}
});
});
};
FaceFeatureExtractor.prototype.getDefaultModelName = function () {
return 'face_feature_extractor_model';
};
FaceFeatureExtractor.prototype.extractParamsFromWeigthMap = function (weightMap) {
return extractParamsFromWeigthMap_1.extractParamsFromWeigthMap(weightMap);
};
FaceFeatureExtractor.prototype.extractParams = function (weights) {
return extractParams_1.extractParams(weights);
};
return FaceFeatureExtractor;
}(tfjs_image_recognition_base_1.NeuralNetwork));
exports.FaceFeatureExtractor = FaceFeatureExtractor;
//# sourceMappingURL=FaceFeatureExtractor.js.map
\ No newline at end of file
{"version":3,"file":"FaceFeatureExtractor.js","sourceRoot":"","sources":["../../../src/faceFeatureExtractor/FaceFeatureExtractor.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAC5C,2EAAwG;AAExG,2CAA2C;AAC3C,iDAAgD;AAChD,2EAA0E;AAG1E;IAA0C,gDAAyC;IAEjF;eACE,kBAAM,sBAAsB,CAAC;IAC/B,CAAC;IAEM,2CAAY,GAAnB,UAAoB,KAAe;QAEzB,IAAA,oBAAM,CAAS;QAEvB,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;SACtE;QAED,OAAO,EAAE,CAAC,IAAI,CAAC;YACb,IAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YAClD,IAAM,OAAO,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;YAC3C,IAAM,UAAU,GAAG,uCAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAgB,CAAA;YAErF,IAAI,GAAG,GAAG,wBAAW,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YACtD,GAAG,GAAG,wBAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YACrC,GAAG,GAAG,wBAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YACrC,GAAG,GAAG,wBAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YACrC,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;YAE9C,OAAO,GAAG,CAAA;QACZ,CAAC,CAAC,CAAA;IACJ,CAAC;IAEY,sCAAO,GAApB,UAAqB,KAAgB;;;;;;wBAC5B,KAAA,IAAI,CAAC,YAAY,CAAA;wBAAC,qBAAM,wCAAU,CAAC,KAAK,CAAC,EAAA;4BAAhD,sBAAO,SAAA,IAAI,GAAc,SAAuB,EAAC,EAAA;;;;KAClD;IAES,kDAAmB,GAA7B;QACE,OAAO,8BAA8B,CAAA;IACvC,CAAC;IAES,yDAA0B,GAApC,UAAqC,SAA4B;QAC/D,OAAO,uDAA0B,CAAC,SAAS,CAAC,CAAA;IAC9C,CAAC;IAES,4CAAa,GAAvB,UAAwB,OAAqB;QAC3C,OAAO,6BAAa,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IACH,2BAAC;AAAD,CAAC,AA5CD,CAA0C,2CAAa,GA4CtD;AA5CY,oDAAoB"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { IFaceFeatureExtractor, TinyFaceFeatureExtractorParams } from './types';
export declare class TinyFaceFeatureExtractor extends NeuralNetwork<TinyFaceFeatureExtractorParams> implements IFaceFeatureExtractor<TinyFaceFeatureExtractorParams> {
constructor();
forwardInput(input: NetInput): tf.Tensor4D;
forward(input: TNetInput): Promise<tf.Tensor4D>;
protected getDefaultModelName(): string;
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: TinyFaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: TinyFaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
};
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var denseBlock_1 = require("./denseBlock");
var extractParamsFromWeigthMapTiny_1 = require("./extractParamsFromWeigthMapTiny");
var extractParamsTiny_1 = require("./extractParamsTiny");
var TinyFaceFeatureExtractor = /** @class */ (function (_super) {
tslib_1.__extends(TinyFaceFeatureExtractor, _super);
function TinyFaceFeatureExtractor() {
return _super.call(this, 'TinyFaceFeatureExtractor') || this;
}
TinyFaceFeatureExtractor.prototype.forwardInput = function (input) {
var params = this.params;
if (!params) {
throw new Error('TinyFaceFeatureExtractor - load model before inference');
}
return tf.tidy(function () {
var batchTensor = input.toBatchTensor(112, true);
var meanRgb = [122.782, 117.001, 104.298];
var normalized = tfjs_image_recognition_base_1.normalize(batchTensor, meanRgb).div(tf.scalar(255));
var out = denseBlock_1.denseBlock3(normalized, params.dense0, true);
out = denseBlock_1.denseBlock3(out, params.dense1);
out = denseBlock_1.denseBlock3(out, params.dense2);
out = tf.avgPool(out, [14, 14], [2, 2], 'valid');
return out;
});
};
TinyFaceFeatureExtractor.prototype.forward = function (input) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];
}
});
});
};
TinyFaceFeatureExtractor.prototype.getDefaultModelName = function () {
return 'face_feature_extractor_tiny_model';
};
TinyFaceFeatureExtractor.prototype.extractParamsFromWeigthMap = function (weightMap) {
return extractParamsFromWeigthMapTiny_1.extractParamsFromWeigthMapTiny(weightMap);
};
TinyFaceFeatureExtractor.prototype.extractParams = function (weights) {
return extractParamsTiny_1.extractParamsTiny(weights);
};
return TinyFaceFeatureExtractor;
}(tfjs_image_recognition_base_1.NeuralNetwork));
exports.TinyFaceFeatureExtractor = TinyFaceFeatureExtractor;
//# sourceMappingURL=TinyFaceFeatureExtractor.js.map
\ No newline at end of file
{"version":3,"file":"TinyFaceFeatureExtractor.js","sourceRoot":"","sources":["../../../src/faceFeatureExtractor/TinyFaceFeatureExtractor.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAC5C,2EAAwG;AAExG,2CAA2C;AAC3C,mFAAkF;AAClF,yDAAwD;AAGxD;IAA8C,oDAA6C;IAEzF;eACE,kBAAM,0BAA0B,CAAC;IACnC,CAAC;IAEM,+CAAY,GAAnB,UAAoB,KAAe;QAEzB,IAAA,oBAAM,CAAS;QAEvB,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;SAC1E;QAED,OAAO,EAAE,CAAC,IAAI,CAAC;YACb,IAAM,WAAW,GAAG,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YAClD,IAAM,OAAO,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;YAC3C,IAAM,UAAU,GAAG,uCAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAgB,CAAA;YAErF,IAAI,GAAG,GAAG,wBAAW,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YACtD,GAAG,GAAG,wBAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YACrC,GAAG,GAAG,wBAAW,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YACrC,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;YAEhD,OAAO,GAAG,CAAA;QACZ,CAAC,CAAC,CAAA;IACJ,CAAC;IAEY,0CAAO,GAApB,UAAqB,KAAgB;;;;;;wBAC5B,KAAA,IAAI,CAAC,YAAY,CAAA;wBAAC,qBAAM,wCAAU,CAAC,KAAK,CAAC,EAAA;4BAAhD,sBAAO,SAAA,IAAI,GAAc,SAAuB,EAAC,EAAA;;;;KAClD;IAES,sDAAmB,GAA7B;QACE,OAAO,mCAAmC,CAAA;IAC5C,CAAC;IAES,6DAA0B,GAApC,UAAqC,SAA4B;QAC/D,OAAO,+DAA8B,CAAC,SAAS,CAAC,CAAA;IAClD,CAAC;IAES,gDAAa,GAAvB,UAAwB,OAAqB;QAC3C,OAAO,qCAAiB,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;IACH,+BAAC;AAAD,CAAC,AA3CD,CAA8C,2CAAa,GA2C1D;AA3CY,4DAAwB"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { DenseBlock3Params, DenseBlock4Params } from './types';
export declare function denseBlock3(x: tf.Tensor4D, denseBlockParams: DenseBlock3Params, isFirstLayer?: boolean): tf.Tensor4D;
export declare function denseBlock4(x: tf.Tensor4D, denseBlockParams: DenseBlock4Params, isFirstLayer?: boolean, isScaleDown?: boolean): tf.Tensor4D;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var depthwiseSeparableConv_1 = require("../common/depthwiseSeparableConv");
function denseBlock3(x, denseBlockParams, isFirstLayer) {
if (isFirstLayer === void 0) { isFirstLayer = false; }
return tf.tidy(function () {
var out1 = tf.relu(isFirstLayer
? tf.add(tf.conv2d(x, denseBlockParams.conv0.filters, [2, 2], 'same'), denseBlockParams.conv0.bias)
: depthwiseSeparableConv_1.depthwiseSeparableConv(x, denseBlockParams.conv0, [2, 2]));
var out2 = depthwiseSeparableConv_1.depthwiseSeparableConv(out1, denseBlockParams.conv1, [1, 1]);
var in3 = tf.relu(tf.add(out1, out2));
var out3 = depthwiseSeparableConv_1.depthwiseSeparableConv(in3, denseBlockParams.conv2, [1, 1]);
return tf.relu(tf.add(out1, tf.add(out2, out3)));
});
}
exports.denseBlock3 = denseBlock3;
function denseBlock4(x, denseBlockParams, isFirstLayer, isScaleDown) {
if (isFirstLayer === void 0) { isFirstLayer = false; }
if (isScaleDown === void 0) { isScaleDown = true; }
return tf.tidy(function () {
var out1 = tf.relu(isFirstLayer
? tf.add(tf.conv2d(x, denseBlockParams.conv0.filters, isScaleDown ? [2, 2] : [1, 1], 'same'), denseBlockParams.conv0.bias)
: depthwiseSeparableConv_1.depthwiseSeparableConv(x, denseBlockParams.conv0, isScaleDown ? [2, 2] : [1, 1]));
var out2 = depthwiseSeparableConv_1.depthwiseSeparableConv(out1, denseBlockParams.conv1, [1, 1]);
var in3 = tf.relu(tf.add(out1, out2));
var out3 = depthwiseSeparableConv_1.depthwiseSeparableConv(in3, denseBlockParams.conv2, [1, 1]);
var in4 = tf.relu(tf.add(out1, tf.add(out2, out3)));
var out4 = depthwiseSeparableConv_1.depthwiseSeparableConv(in4, denseBlockParams.conv3, [1, 1]);
return tf.relu(tf.add(out1, tf.add(out2, tf.add(out3, out4))));
});
}
exports.denseBlock4 = denseBlock4;
//# sourceMappingURL=denseBlock.js.map
\ No newline at end of file
{"version":3,"file":"denseBlock.js","sourceRoot":"","sources":["../../../src/faceFeatureExt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AC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAgB,CAAA;IAC/E,CAAC,CAAC,CAAA;AACJ,CAAC;AAzBD,kCAyBC"}
\ No newline at end of file
import { FaceFeatureExtractorParams } from './types';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function extractParams(weights: Float32Array): {
params: FaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var extractorsFactory_1 = require("./extractorsFactory");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
function extractParams(weights) {
var paramMappings = [];
var _a = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractDenseBlock4Params = extractorsFactory_1.extractorsFactory(extractWeights, paramMappings).extractDenseBlock4Params;
var dense0 = extractDenseBlock4Params(3, 32, 'dense0', true);
var dense1 = extractDenseBlock4Params(32, 64, 'dense1');
var dense2 = extractDenseBlock4Params(64, 128, 'dense2');
var dense3 = extractDenseBlock4Params(128, 256, 'dense3');
if (getRemainingWeights().length !== 0) {
throw new Error("weights remaing after extract: " + getRemainingWeights().length);
}
return {
paramMappings: paramMappings,
params: { dense0: dense0, dense1: dense1, dense2: dense2, dense3: dense3 }
};
}
exports.extractParams = extractParams;
//# sourceMappingURL=extractParams.js.map
\ No newline at end of file
{"version":3,"file":"extractParams.js","sourceRoot":"","sources":["../../../src/faceFeatureExtractor/extractParams.ts"],"names":[],"mappings":";;AACA,yDAAwD;AAExD,2EAAuE;AAEvE,SAAgB,aAAa,CAAC,OAAqB;IAEjD,IAAM,aAAa,GAA4C,EAAE,CAAA;IAE3D,IAAA,0FAGqD,EAFzD,kCAAc,EACd,4CACyD,CAAA;IAGzD,IAAA,wHAAwB,CAC0B;IAEpD,IAAM,MAAM,GAAG,wBAAwB,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;IAC9D,IAAM,MAAM,GAAG,wBAAwB,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;IACzD,IAAM,MAAM,GAAG,wBAAwB,CAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC1D,IAAM,MAAM,GAAG,wBAAwB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;IAE3D,IAAI,mBAAmB,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,oCAAkC,mBAAmB,EAAE,CAAC,MAAQ,CAAC,CAAA;KAClF;IAED,OAAO;QACL,aAAa,eAAA;QACb,MAAM,EAAE,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAE,MAAM,QAAA,EAAE;KAC3C,CAAA;AACH,CAAC;AA1BD,sCA0BC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FaceFeatureExtractorParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: FaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var loadParamsFactory_1 = require("./loadParamsFactory");
function extractParamsFromWeigthMap(weightMap) {
var paramMappings = [];
var extractDenseBlock4Params = loadParamsFactory_1.loadParamsFactory(weightMap, paramMappings).extractDenseBlock4Params;
var params = {
dense0: extractDenseBlock4Params('dense0', true),
dense1: extractDenseBlock4Params('dense1'),
dense2: extractDenseBlock4Params('dense2'),
dense3: extractDenseBlock4Params('dense3')
};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
exports.extractParamsFromWeigthMap = extractParamsFromWeigthMap;
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
\ No newline at end of file
{"version":3,"file":"extractParamsFromWeigthMap.js","sourceRoot":"","sources":["../../../src/faceFeatureExtractor/extractParamsFromWeigthMap.ts"],"names":[],"mappings":";;AACA,2EAAuE;AAEvE,yDAAwD;AAGxD,SAAgB,0BAA0B,CACxC,SAA4B;IAG5B,IAAM,aAAa,GAA4C,EAAE,CAAA;IAG/D,IAAA,mHAAwB,CACqB;IAE/C,IAAM,MAAM,GAAG;QACb,MAAM,EAAE,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChD,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC;QAC1C,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC;QAC1C,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC;KAC3C,CAAA;IAED,sDAAwB,CAAC,0BAA0B,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE7E,OAAO,EAAE,MAAM,QAAA,EAAE,aAAa,eAAA,EAAE,CAAA;AAClC,CAAC;AApBD,gEAoBC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { TinyFaceFeatureExtractorParams } from './types';
export declare function extractParamsFromWeigthMapTiny(weightMap: tf.NamedTensorMap): {
params: TinyFaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var loadParamsFactory_1 = require("./loadParamsFactory");
function extractParamsFromWeigthMapTiny(weightMap) {
var paramMappings = [];
var extractDenseBlock3Params = loadParamsFactory_1.loadParamsFactory(weightMap, paramMappings).extractDenseBlock3Params;
var params = {
dense0: extractDenseBlock3Params('dense0', true),
dense1: extractDenseBlock3Params('dense1'),
dense2: extractDenseBlock3Params('dense2')
};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
exports.extractParamsFromWeigthMapTiny = extractParamsFromWeigthMapTiny;
//# sourceMappingURL=extractParamsFromWeigthMapTiny.js.map
\ No newline at end of file
{"version":3,"file":"extractParamsFromWeigthMapTiny.js","sourceRoot":"","sources":["../../../src/faceFeatureExtractor/extractParamsFromWeigthMapTiny.ts"],"names":[],"mappings":";;AACA,2EAAuE;AAEvE,yDAAwD;AAGxD,SAAgB,8BAA8B,CAC5C,SAA4B;IAG5B,IAAM,aAAa,GAA4C,EAAE,CAAA;IAG/D,IAAA,mHAAwB,CACqB;IAE/C,IAAM,MAAM,GAAG;QACb,MAAM,EAAE,wBAAwB,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChD,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC;QAC1C,MAAM,EAAE,wBAAwB,CAAC,QAAQ,CAAC;KAC3C,CAAA;IAED,sDAAwB,CAAC,0BAA0B,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAE7E,OAAO,EAAE,MAAM,QAAA,EAAE,aAAa,eAAA,EAAE,CAAA;AAClC,CAAC;AAnBD,wEAmBC"}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment