Socket
Socket
Sign inDemoInstall

face-api.js

Package Overview
Dependencies
307
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.21.0 to 0.22.0

build/commonjs/classes/BoundingBox.d.ts

11

build/commonjs/ageGenderNet/AgeGenderNet.d.ts
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';
import { NeuralNetwork } from '../NeuralNetwork';
import { NetInput, TNetInput } from '../dom';
export declare class AgeGenderNet extends NeuralNetwork<NetParams> {
private _faceFeatureExtractor;
constructor(faceFeatureExtractor?: TinyXception);
readonly faceFeatureExtractor: TinyXception;
get faceFeatureExtractor(): TinyXception;
runNet(input: NetInput | tf.Tensor4D): NetOutput;

@@ -18,12 +19,12 @@ forwardInput(input: NetInput | tf.Tensor4D): NetOutput;

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,3 +5,2 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var fullyConnectedLayer_1 = require("../common/fullyConnectedLayer");

@@ -13,2 +12,4 @@ var util_1 = require("../faceProcessor/util");

var types_1 = require("./types");
var NeuralNetwork_1 = require("../NeuralNetwork");
var dom_1 = require("../dom");
var AgeGenderNet = /** @class */ (function (_super) {

@@ -36,3 +37,3 @@ tslib_1.__extends(AgeGenderNet, _super);

return tf.tidy(function () {
var bottleneckFeatures = input instanceof tfjs_image_recognition_base_1.NetInput
var bottleneckFeatures = input instanceof dom_1.NetInput
? _this.faceFeatureExtractor.forwardInput(input)

@@ -60,3 +61,3 @@ : input;

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -73,3 +74,3 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 0: return [4 /*yield*/, dom_1.toNetInput(input)];
case 1:

@@ -148,4 +149,4 @@ netInput = _a.sent();

return AgeGenderNet;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.AgeGenderNet = AgeGenderNet;
//# sourceMappingURL=AgeGenderNet.js.map

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
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 _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractFCParams = common_1.extractFCParamsFactory(extractWeights, paramMappings);
var age = extractFCParams(512, 1, 'fc/age');

@@ -9,0 +9,0 @@ var gender = extractFCParams(512, 2, 'fc/gender');

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
function extractParamsFromWeigthMap(weightMap) {
var paramMappings = [];
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
function extractFcParams(prefix) {

@@ -18,3 +18,3 @@ var weights = extractWeightEntry(prefix + "/weights", 2);

};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };

@@ -21,0 +21,0 @@ }

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FCParams } from '../common';
export declare type AgeAndGenderPrediction = {

@@ -18,5 +18,5 @@ age: number;

fc: {
age: TfjsImageRecognitionBase.FCParams;
gender: TfjsImageRecognitionBase.FCParams;
age: FCParams;
gender: FCParams;
};
};

@@ -1,2 +0,5 @@

import { Box, IDimensions, ObjectDetection, Rect } from 'tfjs-image-recognition-base';
import { Box } from './Box';
import { IDimensions } from './Dimensions';
import { ObjectDetection } from './ObjectDetection';
import { Rect } from './Rect';
export interface IFaceDetecion {

@@ -3,0 +6,0 @@ score: number;

"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 ObjectDetection_1 = require("./ObjectDetection");
var FaceDetection = /** @class */ (function (_super) {

@@ -15,4 +15,4 @@ tslib_1.__extends(FaceDetection, _super);

return FaceDetection;
}(tfjs_image_recognition_base_1.ObjectDetection));
}(ObjectDetection_1.ObjectDetection));
exports.FaceDetection = FaceDetection;
//# sourceMappingURL=FaceDetection.js.map

@@ -1,3 +0,7 @@

import { Box, Dimensions, IBoundingBox, IDimensions, IRect, Point } from 'tfjs-image-recognition-base';
import { IBoundingBox } from './BoundingBox';
import { Box } from './Box';
import { Dimensions, IDimensions } from './Dimensions';
import { FaceDetection } from './FaceDetection';
import { Point } from './Point';
import { IRect } from './Rect';
export interface IFaceLandmarks {

@@ -12,7 +16,7 @@ positions: Point[];

constructor(relativeFaceLandmarkPositions: Point[], imgDims: IDimensions, shift?: Point);
readonly shift: Point;
readonly imageWidth: number;
readonly imageHeight: number;
readonly positions: Point[];
readonly relativePositions: Point[];
get shift(): Point;
get imageWidth(): number;
get imageHeight(): number;
get positions(): Point[];
get relativePositions(): Point[];
forSize<T extends FaceLandmarks>(width: number, height: number): T;

@@ -19,0 +23,0 @@ shiftBy<T extends FaceLandmarks>(x: number, y: number): T;

"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 ops_1 = require("../ops");
var utils_1 = require("../utils");
var Box_1 = require("./Box");
var Dimensions_1 = require("./Dimensions");
var FaceDetection_1 = require("./FaceDetection");
var Point_1 = require("./Point");
var Rect_1 = require("./Rect");
// face alignment constants

@@ -12,10 +16,10 @@ var relX = 0.5;

function FaceLandmarks(relativeFaceLandmarkPositions, imgDims, shift) {
if (shift === void 0) { shift = new tfjs_image_recognition_base_1.Point(0, 0); }
if (shift === void 0) { shift = new Point_1.Point(0, 0); }
var width = imgDims.width, height = imgDims.height;
this._imgDims = new tfjs_image_recognition_base_1.Dimensions(width, height);
this._imgDims = new Dimensions_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); });
this._positions = relativeFaceLandmarkPositions.map(function (pt) { return pt.mul(new Point_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); },
get: function () { return new Point_1.Point(this._shift.x, this._shift.y); },
enumerable: true,

@@ -42,3 +46,3 @@ configurable: true

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)); });
return this._positions.map(function (pt) { return pt.sub(_this._shift).div(new Point_1.Point(_this.imageWidth, _this.imageHeight)); });
},

@@ -52,3 +56,3 @@ enumerable: true,

FaceLandmarks.prototype.shiftBy = function (x, y) {
return new this.constructor(this.relativePositions, this._imgDims, new tfjs_image_recognition_base_1.Point(x, y));
return new this.constructor(this.relativePositions, this._imgDims, new Point_1.Point(x, y));
};

@@ -74,3 +78,3 @@ FaceLandmarks.prototype.shiftByPoint = function (pt) {

? detection.box.floor()
: new tfjs_image_recognition_base_1.Box(detection);
: new Box_1.Box(detection);
return this.shiftBy(box.x, box.y).align(null, options);

@@ -90,10 +94,10 @@ }

var size = Math.floor(eyeToMouthDist / relScale);
var refPoint = tfjs_image_recognition_base_1.getCenterPoint(centers);
var refPoint = utils_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));
return new Rect_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);
var box = ops_1.minBbox(this.positions);
return box.pad(box.width * padding, box.height * padding);

@@ -100,0 +104,0 @@ };

@@ -1,5 +0,5 @@

import { Point } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from './FaceLandmarks';
import { Point } from './Point';
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 utils_1 = require("../utils");
var FaceLandmarks_1 = require("./FaceLandmarks");

@@ -16,3 +16,3 @@ var FaceLandmarks5 = /** @class */ (function (_super) {

pts[1],
tfjs_image_recognition_base_1.getCenterPoint([pts[3], pts[4]])
utils_1.getCenterPoint([pts[3], pts[4]])
];

@@ -19,0 +19,0 @@ };

@@ -1,3 +0,3 @@

import { Point } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from '../classes/FaceLandmarks';
import { FaceLandmarks } from './FaceLandmarks';
import { Point } from './Point';
export declare class FaceLandmarks68 extends FaceLandmarks {

@@ -4,0 +4,0 @@ getJawOutline(): 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 utils_1 = require("../utils");
var FaceLandmarks_1 = require("./FaceLandmarks");
var FaceLandmarks68 = /** @class */ (function (_super) {

@@ -37,3 +37,3 @@ tslib_1.__extends(FaceLandmarks68, _super);

this.getMouth()
].map(tfjs_image_recognition_base_1.getCenterPoint);
].map(utils_1.getCenterPoint);
};

@@ -40,0 +40,0 @@ return FaceLandmarks68;

@@ -9,5 +9,5 @@ export interface IFaceMatch {

constructor(label: string, distance: number);
readonly label: string;
readonly distance: number;
get label(): string;
get 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 utils_1 = require("../utils");
var FaceMatch = /** @class */ (function () {

@@ -21,3 +21,3 @@ function FaceMatch(label, distance) {

if (withDistance === void 0) { withDistance = true; }
return "" + this.label + (withDistance ? " (" + tfjs_image_recognition_base_1.round(this.distance) + ")" : '');
return "" + this.label + (withDistance ? " (" + utils_1.round(this.distance) + ")" : '');
};

@@ -24,0 +24,0 @@ return FaceMatch;

@@ -0,1 +1,4 @@

export * from './BoundingBox';
export * from './Box';
export * from './Dimensions';
export * from './FaceDetection';

@@ -6,2 +9,7 @@ export * from './FaceLandmarks';

export * from './FaceMatch';
export * from './LabeledBox';
export * from './LabeledFaceDescriptors';
export * from './ObjectDetection';
export * from './Point';
export * from './PredictedBox';
export * from './Rect';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
tslib_1.__exportStar(require("./BoundingBox"), exports);
tslib_1.__exportStar(require("./Box"), exports);
tslib_1.__exportStar(require("./Dimensions"), exports);
tslib_1.__exportStar(require("./FaceDetection"), exports);

@@ -9,3 +12,8 @@ tslib_1.__exportStar(require("./FaceLandmarks"), exports);

tslib_1.__exportStar(require("./FaceMatch"), exports);
tslib_1.__exportStar(require("./LabeledBox"), exports);
tslib_1.__exportStar(require("./LabeledFaceDescriptors"), exports);
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

@@ -5,6 +5,6 @@ export declare class LabeledFaceDescriptors {

constructor(label: string, descriptors: Float32Array[]);
readonly label: string;
readonly descriptors: Float32Array[];
get label(): string;
get descriptors(): Float32Array[];
toJSON(): any;
static fromJSON(json: any): LabeledFaceDescriptors;
}
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;
import { SeparableConvParams } from './types';
export declare function depthwiseSeparableConv(x: tf.Tensor4D, params: SeparableConvParams, stride: [number, number]): tf.Tensor4D;
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;
import { FCParams } from './types';
export declare function fullyConnectedLayer(x: tf.Tensor2D, params: FCParams): tf.Tensor2D;

@@ -1,2 +0,2 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function loadConvParamsFactory(extractWeightEntry: <T>(originalPath: string, paramRank: number) => T): (prefix: string) => TfjsImageRecognitionBase.ConvParams;
import { ConvParams } from './types';
export declare function loadConvParamsFactory(extractWeightEntry: <T>(originalPath: string, paramRank: number) => T): (prefix: string) => ConvParams;

@@ -1,3 +0,4 @@

import { Rect, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { Rect } from '../classes/Rect';
import { TNetInput } from './types';
/**

@@ -4,0 +5,0 @@ * Extracts the image regions containing the detected faces.

"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");
var env_1 = require("../env");
var createCanvas_1 = require("./createCanvas");
var getContext2dOrThrow_1 = require("./getContext2dOrThrow");
var imageTensorToCanvas_1 = require("./imageTensorToCanvas");
var toNetInput_1 = require("./toNetInput");
/**

@@ -19,6 +23,6 @@ * Extracts the image regions containing the detected faces.

case 0:
Canvas = tfjs_image_recognition_base_1.env.getEnv().Canvas;
Canvas = env_1.env.getEnv().Canvas;
canvas = input;
if (!!(input instanceof Canvas)) return [3 /*break*/, 5];
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, toNetInput_1.toNetInput(input)];
case 1:

@@ -33,3 +37,3 @@ netInput = _b.sent();

return [3 /*break*/, 4];
case 2: return [4 /*yield*/, tfjs_image_recognition_base_1.imageTensorToCanvas(tensorOrCanvas)];
case 2: return [4 /*yield*/, imageTensorToCanvas_1.imageTensorToCanvas(tensorOrCanvas)];
case 3:

@@ -42,3 +46,3 @@ _a = _b.sent();

case 5:
ctx = tfjs_image_recognition_base_1.getContext2dOrThrow(canvas);
ctx = getContext2dOrThrow_1.getContext2dOrThrow(canvas);
boxes = detections.map(function (det) { return det instanceof FaceDetection_1.FaceDetection

@@ -50,4 +54,4 @@ ? det.forSize(canvas.width, canvas.height).box.floor()

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)
var faceImg = createCanvas_1.createCanvas({ width: width, height: height });
getContext2dOrThrow_1.getContext2dOrThrow(faceImg)
.putImageData(ctx.getImageData(x, y, width, height), 0, 0);

@@ -54,0 +58,0 @@ return faceImg;

import * as tf from '@tensorflow/tfjs-core';
import { Rect } from 'tfjs-image-recognition-base';
import { Rect } from '../classes';
import { FaceDetection } from '../classes/FaceDetection';

@@ -4,0 +4,0 @@ /**

@@ -5,4 +5,4 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var FaceDetection_1 = require("../classes/FaceDetection");
var utils_1 = require("../utils");
/**

@@ -21,10 +21,10 @@ * Extracts the tensors of the image regions containing the detected faces.

return tslib_1.__generator(this, function (_a) {
if (!tfjs_image_recognition_base_1.isTensor3D(imageTensor) && !tfjs_image_recognition_base_1.isTensor4D(imageTensor)) {
if (!utils_1.isTensor3D(imageTensor) && !utils_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) {
if (utils_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 _a = imageTensor.shape.slice(utils_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

@@ -31,0 +31,0 @@ ? det.forSize(imgWidth, imgHeight).box

@@ -0,2 +1,21 @@

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

@@ -1,2 +0,2 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export declare function drawContour(ctx: CanvasRenderingContext2D, points: Point[], isClosed?: boolean): void;

@@ -1,2 +0,2 @@

import { IBoundingBox, IRect } from 'tfjs-image-recognition-base';
import { IBoundingBox, IRect } from '../classes';
import { FaceDetection } from '../classes/FaceDetection';

@@ -3,0 +3,0 @@ import { WithFaceDetection } from '../factories/WithFaceDetection';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
var FaceDetection_1 = require("../classes/FaceDetection");
var WithFaceDetection_1 = require("../factories/WithFaceDetection");
var utils_1 = require("../utils");
var DrawBox_1 = require("./DrawBox");
function drawDetections(canvasArg, detections) {

@@ -14,5 +16,5 @@ var detectionsArray = Array.isArray(detections) ? detections : [detections];

? 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);
: (WithFaceDetection_1.isWithFaceDetection(det) ? det.detection.box : new classes_1.Box(det));
var label = score ? "" + utils_1.round(score) : undefined;
new DrawBox_1.DrawBox(box, { label: label }).draw(canvasArg);
});

@@ -19,0 +21,0 @@ }

@@ -1,2 +0,2 @@

import { IPoint } from 'tfjs-image-recognition-base';
import { IPoint } from '../classes';
import { FaceExpressions } from '../faceExpressionNet';

@@ -3,0 +3,0 @@ import { WithFaceExpressions } from '../factories/WithFaceExpressions';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
var faceExpressionNet_1 = require("../faceExpressionNet");
var WithFaceDetection_1 = require("../factories/WithFaceDetection");
var WithFaceExpressions_1 = require("../factories/WithFaceExpressions");
var utils_1 = require("../utils");
var DrawTextField_1 = require("./DrawTextField");
function drawFaceExpressions(canvasArg, faceExpressions, minConfidence, textFieldAnchor) {

@@ -21,4 +23,4 @@ if (minConfidence === void 0) { minConfidence = 0.1; }

? 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);
: (textFieldAnchor || new classes_1.Point(0, 0));
var drawTextField = new DrawTextField_1.DrawTextField(resultsToDisplay.map(function (expr) { return expr.expression + " (" + utils_1.round(expr.probability) + ")"; }), anchor);
drawTextField.draw(canvasArg);

@@ -25,0 +27,0 @@ });

"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 getContext2dOrThrow_1 = require("../dom/getContext2dOrThrow");
var WithFaceLandmarks_1 = require("../factories/WithFaceLandmarks");

@@ -29,3 +29,3 @@ var drawContour_1 = require("./drawContour");

DrawFaceLandmarks.prototype.draw = function (canvasArg) {
var ctx = tfjs_image_recognition_base_1.getContext2dOrThrow(canvasArg);
var ctx = getContext2dOrThrow_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;

@@ -32,0 +32,0 @@ if (drawLines && this.faceLandmarks instanceof FaceLandmarks68_1.FaceLandmarks68) {

export * from './drawContour';
export * from './drawDetections';
export * from './drawFaceExpressions';
export * from './DrawBox';
export * from './DrawFaceLandmarks';
export * from './DrawTextField';

@@ -7,3 +7,5 @@ "use strict";

tslib_1.__exportStar(require("./drawFaceExpressions"), exports);
tslib_1.__exportStar(require("./DrawBox"), exports);
tslib_1.__exportStar(require("./DrawFaceLandmarks"), exports);
tslib_1.__exportStar(require("./DrawTextField"), exports);
//# sourceMappingURL=index.js.map
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { FaceFeatureExtractor } from '../faceFeatureExtractor/FaceFeatureExtractor';

@@ -4,0 +4,0 @@ import { FaceFeatureExtractorParams } from '../faceFeatureExtractor/types';

@@ -5,3 +5,3 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var dom_1 = require("../dom");
var FaceFeatureExtractor_1 = require("../faceFeatureExtractor/FaceFeatureExtractor");

@@ -27,3 +27,3 @@ var FaceProcessor_1 = require("../faceProcessor/FaceProcessor");

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -40,3 +40,3 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 0: return [4 /*yield*/, dom_1.toNetInput(input)];
case 1:

@@ -43,0 +43,0 @@ netInput = _a.sent();

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ExtractWeightsFunction, ParamMapping } from '../common';
import { DenseBlock3Params, DenseBlock4Params } from './types';
export declare function extractorsFactory(extractWeights: TfjsImageRecognitionBase.ExtractWeightsFunction, paramMappings: TfjsImageRecognitionBase.ParamMapping[]): {
export declare function extractorsFactory(extractWeights: ExtractWeightsFunction, paramMappings: ParamMapping[]): {
extractDenseBlock3Params: (channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer?: boolean) => DenseBlock3Params;
extractDenseBlock4Params: (channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer?: boolean) => DenseBlock4Params;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
function extractorsFactory(extractWeights, paramMappings) {
var extractConvParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractSeparableConvParamsFactory(extractWeights, paramMappings);
var extractConvParams = common_1.extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = common_1.extractSeparableConvParamsFactory(extractWeights, paramMappings);
function extractDenseBlock3Params(channelsIn, channelsOut, mappedPrefix, isFirstLayer) {

@@ -8,0 +8,0 @@ if (isFirstLayer === void 0) { isFirstLayer = false; }

@@ -0,6 +1,6 @@

import { ParamMapping } from '../common';
import { FaceFeatureExtractorParams } from './types';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function extractParams(weights: Float32Array): {
params: FaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../common");
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 _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractDenseBlock4Params = extractorsFactory_1.extractorsFactory(extractWeights, paramMappings).extractDenseBlock4Params;

@@ -9,0 +9,0 @@ var dense0 = extractDenseBlock4Params(3, 32, 'dense0', true);

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { FaceFeatureExtractorParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: FaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var loadParamsFactory_1 = require("./loadParamsFactory");

@@ -14,3 +14,3 @@ function extractParamsFromWeigthMap(weightMap) {

};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };

@@ -17,0 +17,0 @@ }

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { TinyFaceFeatureExtractorParams } from './types';
export declare function extractParamsFromWeigthMapTiny(weightMap: tf.NamedTensorMap): {
params: TinyFaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var loadParamsFactory_1 = require("./loadParamsFactory");

@@ -13,3 +13,3 @@ function extractParamsFromWeigthMapTiny(weightMap) {

};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };

@@ -16,0 +16,0 @@ }

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { TinyFaceFeatureExtractorParams } from './types';
export declare function extractParamsTiny(weights: Float32Array): {
params: TinyFaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var extractorsFactory_1 = require("./extractorsFactory");
function extractParamsTiny(weights) {
var paramMappings = [];
var _a = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractDenseBlock3Params = extractorsFactory_1.extractorsFactory(extractWeights, paramMappings).extractDenseBlock3Params;

@@ -9,0 +9,0 @@ var dense0 = extractDenseBlock3Params(3, 32, 'dense0', true);

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { FaceFeatureExtractorParams, IFaceFeatureExtractor } from './types';

@@ -11,8 +12,8 @@ export declare class FaceFeatureExtractor extends NeuralNetwork<FaceFeatureExtractorParams> implements IFaceFeatureExtractor<FaceFeatureExtractorParams> {

params: FaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: FaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,3 +5,5 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var dom_1 = require("../dom");
var NeuralNetwork_1 = require("../NeuralNetwork");
var ops_1 = require("../ops");
var denseBlock_1 = require("./denseBlock");

@@ -23,3 +25,3 @@ var extractParams_1 = require("./extractParams");

var meanRgb = [122.782, 117.001, 104.298];
var normalized = tfjs_image_recognition_base_1.normalize(batchTensor, meanRgb).div(tf.scalar(255));
var normalized = ops_1.normalize(batchTensor, meanRgb).div(tf.scalar(255));
var out = denseBlock_1.denseBlock4(normalized, params.dense0, true);

@@ -40,3 +42,3 @@ out = denseBlock_1.denseBlock4(out, params.dense1);

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -57,4 +59,4 @@ }

return FaceFeatureExtractor;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.FaceFeatureExtractor = FaceFeatureExtractor;
//# sourceMappingURL=FaceFeatureExtractor.js.map

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { DenseBlock3Params, DenseBlock4Params } from './types';
export declare function loadParamsFactory(weightMap: any, paramMappings: TfjsImageRecognitionBase.ParamMapping[]): {
export declare function loadParamsFactory(weightMap: any, paramMappings: ParamMapping[]): {
extractDenseBlock3Params: (prefix: string, isFirstLayer?: boolean) => DenseBlock3Params;
extractDenseBlock4Params: (prefix: string, isFirstLayer?: boolean) => DenseBlock4Params;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var loadConvParamsFactory_1 = require("../common/loadConvParamsFactory");
function loadParamsFactory(weightMap, paramMappings) {
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
var extractConvParams = loadConvParamsFactory_1.loadConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.loadSeparableConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = common_1.loadSeparableConvParamsFactory(extractWeightEntry);
function extractDenseBlock3Params(prefix, isFirstLayer) {

@@ -10,0 +10,0 @@ if (isFirstLayer === void 0) { isFirstLayer = false; }

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { IFaceFeatureExtractor, TinyFaceFeatureExtractorParams } from './types';

@@ -11,8 +12,8 @@ export declare class TinyFaceFeatureExtractor extends NeuralNetwork<TinyFaceFeatureExtractorParams> implements IFaceFeatureExtractor<TinyFaceFeatureExtractorParams> {

params: TinyFaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: TinyFaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,3 +5,5 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var dom_1 = require("../dom");
var NeuralNetwork_1 = require("../NeuralNetwork");
var ops_1 = require("../ops");
var denseBlock_1 = require("./denseBlock");

@@ -23,3 +25,3 @@ var extractParamsFromWeigthMapTiny_1 = require("./extractParamsFromWeigthMapTiny");

var meanRgb = [122.782, 117.001, 104.298];
var normalized = tfjs_image_recognition_base_1.normalize(batchTensor, meanRgb).div(tf.scalar(255));
var normalized = ops_1.normalize(batchTensor, meanRgb).div(tf.scalar(255));
var out = denseBlock_1.denseBlock3(normalized, params.dense0, true);

@@ -39,3 +41,3 @@ out = denseBlock_1.denseBlock3(out, params.dense1);

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -56,4 +58,4 @@ }

return TinyFaceFeatureExtractor;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.TinyFaceFeatureExtractor = TinyFaceFeatureExtractor;
//# sourceMappingURL=TinyFaceFeatureExtractor.js.map
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput, TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '..';
import { ConvParams, SeparableConvParams } from '../common';
import { NeuralNetwork } from '../NeuralNetwork';
export declare type ConvWithBatchNormParams = BatchNormParams & {

@@ -17,8 +19,8 @@ filter: tf.Tensor4D;

export declare type DenseBlock3Params = {
conv0: TfjsImageRecognitionBase.SeparableConvParams | TfjsImageRecognitionBase.ConvParams;
conv1: TfjsImageRecognitionBase.SeparableConvParams;
conv2: TfjsImageRecognitionBase.SeparableConvParams;
conv0: SeparableConvParams | ConvParams;
conv1: SeparableConvParams;
conv2: SeparableConvParams;
};
export declare type DenseBlock4Params = DenseBlock3Params & {
conv3: TfjsImageRecognitionBase.SeparableConvParams;
conv3: SeparableConvParams;
};

@@ -25,0 +27,0 @@ export declare type TinyFaceFeatureExtractorParams = {

import * as tf from '@tensorflow/tfjs-core';
import { IDimensions, NetInput, TNetInput } from 'tfjs-image-recognition-base';
import { IDimensions } from '../classes';
import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { NetInput, TNetInput } from '../dom';
import { FaceFeatureExtractorParams, TinyFaceFeatureExtractorParams } from '../faceFeatureExtractor/types';

@@ -5,0 +6,0 @@ import { FaceProcessor } from '../faceProcessor/FaceProcessor';

@@ -5,5 +5,7 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
var FaceLandmarks68_1 = require("../classes/FaceLandmarks68");
var dom_1 = require("../dom");
var FaceProcessor_1 = require("../faceProcessor/FaceProcessor");
var utils_1 = require("../utils");
var FaceLandmark68NetBase = /** @class */ (function (_super) {

@@ -65,3 +67,3 @@ tslib_1.__extends(FaceLandmark68NetBase, _super);

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -78,3 +80,3 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 0: return [4 /*yield*/, dom_1.toNetInput(input)];
case 1:

@@ -92,5 +94,5 @@ netInput = _a.sent();

landmarksArray = _b.apply(_a, [_c.sent()]);
xCoords = landmarksArray.filter(function (_, i) { return tfjs_image_recognition_base_1.isEven(i); });
yCoords = landmarksArray.filter(function (_, i) { return !tfjs_image_recognition_base_1.isEven(i); });
return [2 /*return*/, new FaceLandmarks68_1.FaceLandmarks68(Array(68).fill(0).map(function (_, i) { return new tfjs_image_recognition_base_1.Point(xCoords[i], yCoords[i]); }), {
xCoords = landmarksArray.filter(function (_, i) { return utils_1.isEven(i); });
yCoords = landmarksArray.filter(function (_, i) { return !utils_1.isEven(i); });
return [2 /*return*/, new FaceLandmarks68_1.FaceLandmarks68(Array(68).fill(0).map(function (_, i) { return new classes_1.Point(xCoords[i], yCoords[i]); }), {
height: netInput.getInputHeight(batchIdx),

@@ -97,0 +99,0 @@ width: netInput.getInputWidth(batchIdx),

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array, channelsIn: number, channelsOut: number): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
function extractParams(weights, channelsIn, channelsOut) {
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 _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractFCParams = common_1.extractFCParamsFactory(extractWeights, paramMappings);
var fc = extractFCParams(channelsIn, channelsOut, 'fc');

@@ -9,0 +9,0 @@ if (getRemainingWeights().length !== 0) {

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
function extractParamsFromWeigthMap(weightMap) {
var paramMappings = [];
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
function extractFcParams(prefix) {

@@ -15,3 +15,3 @@ var weights = extractWeightEntry(prefix + "/weights", 2);

};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };

@@ -18,0 +18,0 @@ }

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork } from 'tfjs-image-recognition-base';
import { NetInput } from '../dom';
import { FaceFeatureExtractorParams, IFaceFeatureExtractor, TinyFaceFeatureExtractorParams } from '../faceFeatureExtractor/types';
import { NeuralNetwork } from '../NeuralNetwork';
import { NetParams } from './types';

@@ -8,3 +9,3 @@ export declare abstract class FaceProcessor<TExtractorParams extends FaceFeatureExtractorParams | TinyFaceFeatureExtractorParams> extends NeuralNetwork<NetParams> {

constructor(_name: string, faceFeatureExtractor: IFaceFeatureExtractor<TExtractorParams>);
readonly faceFeatureExtractor: IFaceFeatureExtractor<TExtractorParams>;
get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>;
protected abstract getDefaultModelName(): string;

@@ -18,12 +19,12 @@ protected abstract getClassifierChannelsIn(): number;

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,4 +5,5 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var fullyConnectedLayer_1 = require("../common/fullyConnectedLayer");
var dom_1 = require("../dom");
var NeuralNetwork_1 = require("../NeuralNetwork");
var extractParams_1 = require("./extractParams");

@@ -32,3 +33,3 @@ var extractParamsFromWeigthMap_1 = require("./extractParamsFromWeigthMap");

return tf.tidy(function () {
var bottleneckFeatures = input instanceof tfjs_image_recognition_base_1.NetInput
var bottleneckFeatures = input instanceof dom_1.NetInput
? _this.faceFeatureExtractor.forwardInput(input)

@@ -67,4 +68,4 @@ : input;

return FaceProcessor;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.FaceProcessor = FaceProcessor;
//# sourceMappingURL=FaceProcessor.js.map

@@ -1,4 +0,4 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FCParams } from '../common';
export declare type NetParams = {
fc: TfjsImageRecognitionBase.FCParams;
fc: FCParams;
};
import * as tf from '@tensorflow/tfjs-core';
import { ConvLayerParams } from './types';
export declare function conv(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor<tf.Rank.R4>;
export declare function convNoRelu(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor<tf.Rank.R4>;
export declare function convDown(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor<tf.Rank.R4>;
export declare function conv(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor4D;
export declare function convNoRelu(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor4D;
export declare function convDown(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor4D;

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var utils_1 = require("../utils");
function extractorsFactory(extractWeights, paramMappings) {

@@ -9,3 +10,3 @@ function extractFilterValues(numFilterValues, numFilters, filterSize) {

var depth = weights.length / (numFilters * filterSize * filterSize);
if (tfjs_image_recognition_base_1.isFloat(depth)) {
if (utils_1.isFloat(depth)) {
throw new Error("depth has to be an integer: " + depth + ", weights.length: " + weights.length + ", numFilters: " + numFilters + ", filterSize: " + filterSize);

@@ -47,3 +48,3 @@ }

function extractParams(weights) {
var _a = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var paramMappings = [];

@@ -50,0 +51,0 @@ var _b = extractorsFactory(extractWeights, paramMappings), extractConvLayerParams = _b.extractConvLayerParams, extractResidualLayerParams = _b.extractResidualLayerParams;

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var utils_1 = require("../utils");
function extractorsFactory(weightMap, paramMappings) {
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
function extractScaleLayerParams(prefix) {

@@ -48,3 +49,3 @@ var weights = extractWeightEntry(prefix + "/scale/weights", 1);

paramMappings.push({ originalPath: 'fc', paramPath: 'fc' });
if (!tfjs_image_recognition_base_1.isTensor2D(fc)) {
if (!utils_1.isTensor2D(fc)) {
throw new Error("expected weightMap[fc] to be a Tensor2D, instead have " + fc);

@@ -70,3 +71,3 @@ }

};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };

@@ -73,0 +74,0 @@ }

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { NetParams } from './types';

@@ -12,8 +13,8 @@ export declare class FaceRecognitionNet extends NeuralNetwork<NetParams> {

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,3 +5,5 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var dom_1 = require("../dom");
var NeuralNetwork_1 = require("../NeuralNetwork");
var ops_1 = require("../ops");
var convLayer_1 = require("./convLayer");

@@ -24,3 +26,3 @@ var extractParams_1 = require("./extractParams");

var meanRgb = [122.782, 117.001, 104.298];
var normalized = tfjs_image_recognition_base_1.normalize(batchTensor, meanRgb).div(tf.scalar(256));
var normalized = ops_1.normalize(batchTensor, meanRgb).div(tf.scalar(256));
var out = convLayer_1.convDown(normalized, params.conv32_down);

@@ -54,3 +56,3 @@ out = tf.maxPool(out, 3, 2, 'valid');

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -67,3 +69,3 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
case 0: return [4 /*yield*/, dom_1.toNetInput(input)];
case 1:

@@ -93,4 +95,4 @@ netInput = _a.sent();

return FaceRecognitionNet;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.FaceRecognitionNet = FaceRecognitionNet;
//# sourceMappingURL=FaceRecognitionNet.js.map
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ConvParams } from '../common';
export declare type ScaleLayerParams = {

@@ -12,3 +12,3 @@ weights: tf.Tensor1D;

export declare type ConvLayerParams = {
conv: TfjsImageRecognitionBase.ConvParams;
conv: ConvParams;
scale: ScaleLayerParams;

@@ -15,0 +15,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var types_1 = require("../ageGenderNet/types");
var utils_1 = require("../utils");
function isWithGender(obj) {
return (obj['gender'] === types_1.Gender.MALE || obj['gender'] === types_1.Gender.FEMALE)
&& tfjs_image_recognition_base_1.isValidProbablitiy(obj['genderProbability']);
&& utils_1.isValidProbablitiy(obj['genderProbability']);
}

@@ -9,0 +9,0 @@ exports.isWithGender = isWithGender;

@@ -1,7 +0,8 @@

import { TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithFaceDescriptor, WithFaceDetection, WithFaceLandmarks } from '../factories';
import { IMtcnnOptions } from '../mtcnn/MtcnnOptions';
import { ITinyYolov2Options } from '../tinyYolov2';
export declare function allFacesSsdMobilenetv1(input: TNetInput, minConfidence?: number): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare function allFacesTinyYolov2(input: TNetInput, forwardParams?: TfjsImageRecognitionBase.ITinyYolov2Options): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare function allFacesTinyYolov2(input: TNetInput, forwardParams?: ITinyYolov2Options): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare function allFacesMtcnn(input: TNetInput, forwardParams?: IMtcnnOptions): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare const allFaces: typeof allFacesSsdMobilenetv1;
"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 MtcnnOptions_1 = require("../mtcnn/MtcnnOptions");
var ssdMobilenetv1_1 = require("../ssdMobilenetv1");
var tinyYolov2_1 = require("../tinyYolov2");
var detectFaces_1 = require("./detectFaces");

@@ -13,5 +13,7 @@ // export allFaces API for backward compatibility

switch (_a.label) {
case 0: return [4 /*yield*/, detectFaces_1.detectAllFaces(input, new ssdMobilenetv1_1.SsdMobilenetv1Options(minConfidence ? { minConfidence: minConfidence } : {}))
.withFaceLandmarks()
.withFaceDescriptors()];
case 0:
console.warn('allFacesSsdMobilenetv1 is deprecated and will be removed soon, use the high level api instead');
return [4 /*yield*/, detectFaces_1.detectAllFaces(input, new ssdMobilenetv1_1.SsdMobilenetv1Options(minConfidence ? { minConfidence: minConfidence } : {}))
.withFaceLandmarks()
.withFaceDescriptors()];
case 1: return [2 /*return*/, _a.sent()];

@@ -28,5 +30,7 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, detectFaces_1.detectAllFaces(input, new tfjs_image_recognition_base_1.TfjsImageRecognitionBase.TinyYolov2Options(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 0:
console.warn('allFacesTinyYolov2 is deprecated and will be removed soon, use the high level api instead');
return [4 /*yield*/, detectFaces_1.detectAllFaces(input, new tinyYolov2_1.TinyYolov2Options(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 1: return [2 /*return*/, _a.sent()];

@@ -43,5 +47,7 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, detectFaces_1.detectAllFaces(input, new MtcnnOptions_1.MtcnnOptions(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 0:
console.warn('allFacesMtcnn is deprecated and will be removed soon, use the high level api instead');
return [4 /*yield*/, detectFaces_1.detectAllFaces(input, new MtcnnOptions_1.MtcnnOptions(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 1: return [2 /*return*/, _a.sent()];

@@ -48,0 +54,0 @@ }

@@ -1,2 +0,2 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithFaceDescriptor } from '../factories/WithFaceDescriptor';

@@ -3,0 +3,0 @@ import { WithFaceDetection } from '../factories/WithFaceDetection';

@@ -1,3 +0,3 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { TNetInput } from '../dom';
import { FaceLandmark68Net } from '../faceLandmarkNet/FaceLandmark68Net';

@@ -16,3 +16,3 @@ import { FaceLandmark68TinyNet } from '../faceLandmarkNet/FaceLandmark68TinyNet';

constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, useTinyLandmarkNet: boolean);
protected readonly landmarkNet: FaceLandmark68Net | FaceLandmark68TinyNet;
protected get landmarkNet(): FaceLandmark68Net | FaceLandmark68TinyNet;
}

@@ -19,0 +19,0 @@ export declare class DetectAllFaceLandmarksTask<TSource extends WithFaceDetection<{}>> extends DetectFaceLandmarksTaskBase<WithFaceLandmarks<TSource>[], TSource[]> {

@@ -1,2 +0,2 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { DetectAllFacesTask, DetectSingleFaceTask } from './DetectFacesTasks';

@@ -3,0 +3,0 @@ import { FaceDetectionOptions } from './types';

@@ -1,3 +0,3 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { TNetInput } from '../dom';
import { ComposableTask } from './ComposableTask';

@@ -4,0 +4,0 @@ import { DetectAllFaceLandmarksTask, DetectSingleFaceLandmarksTask } from './DetectFaceLandmarksTasks';

"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 WithFaceDetection_1 = require("../factories/WithFaceDetection");

@@ -9,2 +8,3 @@ var MtcnnOptions_1 = require("../mtcnn/MtcnnOptions");

var TinyFaceDetectorOptions_1 = require("../tinyFaceDetector/TinyFaceDetectorOptions");
var tinyYolov2_1 = require("../tinyYolov2");
var ComposableTask_1 = require("./ComposableTask");

@@ -48,3 +48,3 @@ var DetectFaceLandmarksTasks_1 = require("./DetectFaceLandmarksTasks");

? function (input) { return nets_1.nets.ssdMobilenetv1.locateFaces(input, options); }
: (options instanceof tfjs_image_recognition_base_1.TfjsImageRecognitionBase.TinyYolov2Options
: (options instanceof tinyYolov2_1.TinyYolov2Options
? function (input) { return nets_1.nets.tinyYolov2.locateFaces(input, options); }

@@ -51,0 +51,0 @@ : null));

import * as tf from '@tensorflow/tfjs-core';
import { TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { TNetInput } from '../dom';
import { WithFaceDetection } from '../factories/WithFaceDetection';

@@ -5,0 +5,0 @@ import { WithFaceLandmarks } from '../factories/WithFaceLandmarks';

@@ -8,4 +8,4 @@ import { FaceMatch } from '../classes/FaceMatch';

constructor(inputs: LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>, distanceThreshold?: number);
readonly labeledDescriptors: LabeledFaceDescriptors[];
readonly distanceThreshold: number;
get labeledDescriptors(): LabeledFaceDescriptors[];
get distanceThreshold(): number;
computeMeanDistance(queryDescriptor: Float32Array, descriptors: Float32Array[]): number;

@@ -12,0 +12,0 @@ matchDescriptor(queryDescriptor: Float32Array): FaceMatch;

@@ -1,2 +0,1 @@

import { TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { AgeGenderNet } from '../ageGenderNet/AgeGenderNet';

@@ -7,2 +6,3 @@ import { AgeAndGenderPrediction } from '../ageGenderNet/types';

import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { TNetInput } from '../dom';
import { FaceExpressionNet } from '../faceExpressionNet/FaceExpressionNet';

@@ -20,3 +20,3 @@ import { FaceExpressions } from '../faceExpressionNet/FaceExpressions';

import { TinyFaceDetectorOptions } from '../tinyFaceDetector/TinyFaceDetectorOptions';
import { TinyYolov2 } from '../tinyYolov2';
import { ITinyYolov2Options, TinyYolov2 } from '../tinyYolov2';
export declare const nets: {

@@ -56,3 +56,3 @@ ssdMobilenetv1: SsdMobilenetv1;

*/
export declare const tinyYolov2: (input: TNetInput, options: TfjsImageRecognitionBase.ITinyYolov2Options) => Promise<FaceDetection[]>;
export declare const tinyYolov2: (input: TNetInput, options: ITinyYolov2Options) => Promise<FaceDetection[]>;
/**

@@ -59,0 +59,0 @@ * Attempts to detect all faces in an image and the 5 point face landmarks

import * as tf from '@tensorflow/tfjs-core';
import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithAge } from '../factories/WithAge';

@@ -13,4 +13,4 @@ import { WithFaceDetection } from '../factories/WithFaceDetection';

protected input: TNetInput;
protected extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}

@@ -17,0 +17,0 @@ export declare class PredictAllAgeAndGenderTask<TSource extends WithFaceDetection<{}>> extends PredictAgeAndGenderTaskBase<WithAge<WithGender<TSource>>[], TSource[]> {

import * as tf from '@tensorflow/tfjs-core';
import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithFaceDetection } from '../factories/WithFaceDetection';

@@ -12,4 +12,4 @@ import { WithFaceExpressions } from '../factories/WithFaceExpressions';

protected input: TNetInput;
protected extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}

@@ -16,0 +16,0 @@ export declare class PredictAllFaceExpressionsTask<TSource extends WithFaceDetection<{}>> extends PredictFaceExpressionsTaskBase<WithFaceExpressions<TSource>[], TSource[]> {

@@ -1,7 +0,8 @@

import { TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { TNetInput } from '../dom';
import { MtcnnOptions } from '../mtcnn/MtcnnOptions';
import { SsdMobilenetv1Options } from '../ssdMobilenetv1/SsdMobilenetv1Options';
import { TinyFaceDetectorOptions } from '../tinyFaceDetector/TinyFaceDetectorOptions';
export declare type FaceDetectionOptions = TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TfjsImageRecognitionBase.TinyYolov2Options;
import { TinyYolov2Options } from '../tinyYolov2';
export declare type FaceDetectionOptions = TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options;
export declare type FaceDetectionFunction = (input: TNetInput) => Promise<FaceDetection[]>;
import * as tf from '@tensorflow/tfjs-core';
import { draw as drawBase } from 'tfjs-image-recognition-base';
import * as drawExtended from './draw';
export { tf };
export * from 'tfjs-image-recognition-base';
import * as draw from './draw';
import * as utils from './utils';
export { draw, utils, tf };
export * from './ageGenderNet/index';
declare const draw: {
drawContour(ctx: CanvasRenderingContext2D, points: import("tfjs-image-recognition-base").Point[], isClosed?: boolean): void;
drawDetections(canvasArg: string | HTMLCanvasElement, detections: import("./classes").FaceDetection | import("tfjs-image-recognition-base").IRect | {
detection: import("./classes").FaceDetection;
} | import("tfjs-image-recognition-base").IBoundingBox | drawExtended.TDrawDetectionsInput[]): void;
drawFaceExpressions(canvasArg: string | HTMLCanvasElement, faceExpressions: import("./faceExpressionNet").FaceExpressions | {
expressions: import("./faceExpressionNet").FaceExpressions;
} | drawExtended.DrawFaceExpressionsInput[], minConfidence?: number, textFieldAnchor?: import("tfjs-image-recognition-base").IPoint | undefined): void;
drawFaceLandmarks(canvasArg: string | HTMLCanvasElement, faceLandmarks: import("./classes").FaceLandmarks | import("./factories").WithFaceLandmarks<{
detection: import("./classes").FaceDetection;
}, import("./classes").FaceLandmarks68> | drawExtended.DrawFaceLandmarksInput[]): void;
DrawFaceLandmarksOptions: typeof drawExtended.DrawFaceLandmarksOptions;
DrawFaceLandmarks: typeof drawExtended.DrawFaceLandmarks;
DrawBoxOptions: typeof drawBase.DrawBoxOptions;
DrawBox: typeof drawBase.DrawBox;
AnchorPosition: typeof drawBase.AnchorPosition;
DrawTextFieldOptions: typeof drawBase.DrawTextFieldOptions;
DrawTextField: typeof drawBase.DrawTextField;
};
export { draw };
export * from './classes/index';
export * from './dom/index';
export * from './env/index';
export * from './faceExpressionNet/index';

@@ -35,2 +15,3 @@ export * from './faceLandmarkNet/index';

export * from './mtcnn/index';
export * from './ops/index';
export * from './ssdMobilenetv1/index';

@@ -40,2 +21,3 @@ export * from './tinyFaceDetector/index';

export * from './euclideanDistance';
export * from './NeuralNetwork';
export * from './resizeResults';

@@ -6,10 +6,10 @@ "use strict";

exports.tf = tf;
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var drawExtended = require("./draw");
tslib_1.__exportStar(require("tfjs-image-recognition-base"), exports);
var draw = require("./draw");
exports.draw = draw;
var utils = require("./utils");
exports.utils = utils;
tslib_1.__exportStar(require("./ageGenderNet/index"), exports);
var draw = tslib_1.__assign(tslib_1.__assign({}, tfjs_image_recognition_base_1.draw), drawExtended);
exports.draw = draw;
tslib_1.__exportStar(require("./classes/index"), exports);
tslib_1.__exportStar(require("./dom/index"), exports);
tslib_1.__exportStar(require("./env/index"), exports);
tslib_1.__exportStar(require("./faceExpressionNet/index"), exports);

@@ -21,2 +21,3 @@ tslib_1.__exportStar(require("./faceLandmarkNet/index"), exports);

tslib_1.__exportStar(require("./mtcnn/index"), exports);
tslib_1.__exportStar(require("./ops/index"), exports);
tslib_1.__exportStar(require("./ssdMobilenetv1/index"), exports);

@@ -26,3 +27,4 @@ tslib_1.__exportStar(require("./tinyFaceDetector/index"), exports);

tslib_1.__exportStar(require("./euclideanDistance"), exports);
tslib_1.__exportStar(require("./NeuralNetwork"), exports);
tslib_1.__exportStar(require("./resizeResults"), exports);
//# sourceMappingURL=index.js.map
import * as tf from '@tensorflow/tfjs-core';
import { Box, IDimensions } from 'tfjs-image-recognition-base';
import { Box, IDimensions } from '../classes';
export declare function extractImagePatches(img: HTMLCanvasElement, boxes: Box[], { width, height }: IDimensions): Promise<tf.Tensor4D[]>;

@@ -5,3 +5,4 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var dom_1 = require("../dom");
var env_1 = require("../env");
var normalize_1 = require("./normalize");

@@ -16,3 +17,3 @@ function extractImagePatches(img, boxes, _a) {

case 0:
imgCtx = tfjs_image_recognition_base_1.getContext2dOrThrow(img);
imgCtx = dom_1.getContext2dOrThrow(img);
return [4 /*yield*/, Promise.all(boxes.map(function (box) { return tslib_1.__awaiter(_this, void 0, void 0, function () {

@@ -25,3 +26,3 @@ var _a, y, ey, x, ex, fromX, fromY, imgData;

imgData = imgCtx.getImageData(fromX, fromY, (ex - fromX), (ey - fromY));
return [2 /*return*/, tfjs_image_recognition_base_1.env.isNodejs() ? tfjs_image_recognition_base_1.createCanvasFromMedia(imgData) : createImageBitmap(imgData)];
return [2 /*return*/, env_1.env.isNodejs() ? dom_1.createCanvasFromMedia(imgData) : createImageBitmap(imgData)];
});

@@ -33,4 +34,4 @@ }); }))];

bitmaps.forEach(function (bmp) {
var patch = tfjs_image_recognition_base_1.createCanvas({ width: width, height: height });
var patchCtx = tfjs_image_recognition_base_1.getContext2dOrThrow(patch);
var patch = dom_1.createCanvas({ width: width, height: height });
var patchCtx = dom_1.getContext2dOrThrow(patch);
patchCtx.drawImage(bmp, 0, 0, width, height);

@@ -37,0 +38,0 @@ var data = patchCtx.getImageData(0, 0, width, height).data;

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -5,6 +5,6 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
function extractorsFactory(extractWeights, paramMappings) {
var extractConvParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractConvParamsFactory(extractWeights, paramMappings);
var extractFCParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractFCParamsFactory(extractWeights, paramMappings);
var extractConvParams = common_1.extractConvParamsFactory(extractWeights, paramMappings);
var extractFCParams = common_1.extractFCParamsFactory(extractWeights, paramMappings);
function extractPReluParams(size, paramPath) {

@@ -57,3 +57,3 @@ var alpha = tf.tensor1d(extractWeights(size));

function extractParams(weights) {
var _a = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var paramMappings = [];

@@ -60,0 +60,0 @@ var _b = extractorsFactory(extractWeights, paramMappings), extractPNetParams = _b.extractPNetParams, extractRNetParams = _b.extractRNetParams, extractONetParams = _b.extractONetParams;

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"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 common_1 = require("../common");
function extractorsFactory(weightMap, paramMappings) {
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
function extractConvParams(prefix) {

@@ -66,3 +66,3 @@ var filters = extractWeightEntry(prefix + "/weights", 4, prefix + "/filters");

var onet = extractONetParams();
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: { pnet: pnet, rnet: rnet, onet: onet }, paramMappings: paramMappings };

@@ -69,0 +69,0 @@ }

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { IMtcnnOptions } from './MtcnnOptions';

@@ -7,2 +8,4 @@ import { MtcnnResult, NetParams } from './types';

constructor();
load(weightsOrUrl: Float32Array | string | undefined): Promise<void>;
loadFromDisk(filePath: string | undefined): Promise<void>;
forwardInput(input: NetInput, forwardParams?: IMtcnnOptions): Promise<{

@@ -20,8 +23,8 @@ results: MtcnnResult[];

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,6 +5,8 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
var FaceDetection_1 = require("../classes/FaceDetection");
var FaceLandmarks5_1 = require("../classes/FaceLandmarks5");
var dom_1 = require("../dom");
var factories_1 = require("../factories");
var NeuralNetwork_1 = require("../NeuralNetwork");
var bgrToRgbTensor_1 = require("./bgrToRgbTensor");

@@ -25,2 +27,18 @@ var config_1 = require("./config");

}
Mtcnn.prototype.load = function (weightsOrUrl) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
console.warn('mtcnn is deprecated and will be removed soon');
return [2 /*return*/, _super.prototype.load.call(this, weightsOrUrl)];
});
});
};
Mtcnn.prototype.loadFromDisk = function (filePath) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
console.warn('mtcnn is deprecated and will be removed soon');
return [2 /*return*/, _super.prototype.loadFromDisk.call(this, filePath)];
});
});
};
Mtcnn.prototype.forwardInput = function (input, forwardParams) {

@@ -87,6 +105,6 @@ if (forwardParams === void 0) { forwardParams = {}; }

stats.total_stage3 = Date.now() - ts;
results = out3.boxes.map(function (box, idx) { return factories_1.extendWithFaceLandmarks(factories_1.extendWithFaceDetection({}, new FaceDetection_1.FaceDetection(out3.scores[idx], new tfjs_image_recognition_base_1.Rect(box.left / width, box.top / height, box.width / width, box.height / height), {
results = out3.boxes.map(function (box, idx) { return factories_1.extendWithFaceLandmarks(factories_1.extendWithFaceDetection({}, new FaceDetection_1.FaceDetection(out3.scores[idx], new classes_1.Rect(box.left / width, box.top / height, box.width / width, box.height / height), {
height: height,
width: width
})), new FaceLandmarks5_1.FaceLandmarks5(out3.points[idx].map(function (pt) { return pt.sub(new tfjs_image_recognition_base_1.Point(box.left, box.top)).div(new tfjs_image_recognition_base_1.Point(box.width, box.height)); }), { width: box.width, height: box.height })); });
})), new FaceLandmarks5_1.FaceLandmarks5(out3.points[idx].map(function (pt) { return pt.sub(new classes_1.Point(box.left, box.top)).div(new classes_1.Point(box.width, box.height)); }), { width: box.width, height: box.height })); });
return [2 /*return*/, onReturn({ results: results, stats: stats })];

@@ -105,3 +123,3 @@ }

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [4 /*yield*/, _a.apply(this, [_b.sent(),

@@ -122,3 +140,3 @@ forwardParams])];

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent(),

@@ -140,4 +158,4 @@ forwardParams])];

return Mtcnn;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.Mtcnn = Mtcnn;
//# sourceMappingURL=Mtcnn.js.map

@@ -1,4 +0,4 @@

import { Box } from 'tfjs-image-recognition-base';
import { Box } from '../classes';
export declare class MtcnnBox extends Box<MtcnnBox> {
constructor(left: number, top: number, right: number, bottom: number);
}
"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 classes_1 = require("../classes");
var MtcnnBox = /** @class */ (function (_super) {

@@ -11,4 +11,4 @@ tslib_1.__extends(MtcnnBox, _super);

return MtcnnBox;
}(tfjs_image_recognition_base_1.Box));
}(classes_1.Box));
exports.MtcnnBox = MtcnnBox;
//# sourceMappingURL=MtcnnBox.js.map

@@ -16,7 +16,7 @@ export interface IMtcnnOptions {

constructor({ minFaceSize, scaleFactor, maxNumScales, scoreThresholds, scaleSteps }?: IMtcnnOptions);
readonly minFaceSize: number;
readonly scaleFactor: number;
readonly maxNumScales: number;
readonly scoreThresholds: number[];
readonly scaleSteps: number[] | undefined;
get minFaceSize(): number;
get scaleFactor(): number;
get maxNumScales(): number;
get scoreThresholds(): number[];
get scaleSteps(): number[] | undefined;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var fullyConnectedLayer_1 = require("../common/fullyConnectedLayer");

@@ -12,3 +12,3 @@ var prelu_1 = require("./prelu");

out = tf.maxPool(out, [2, 2], [2, 2], 'same');
out = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(out, params.conv4, 'valid');
out = common_1.convLayer(out, params.conv4, 'valid');
out = prelu_1.prelu(out, params.prelu4_alpha);

@@ -15,0 +15,0 @@ var vectorized = tf.reshape(out, [out.shape[0], params.fc1.weights.shape[0]]);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var sharedLayers_1 = require("./sharedLayers");

@@ -9,6 +9,6 @@ function PNet(x, params) {

var out = sharedLayers_1.sharedLayer(x, params, true);
var conv = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(out, params.conv4_1, 'valid');
var conv = common_1.convLayer(out, params.conv4_1, 'valid');
var max = tf.expandDims(tf.max(conv, 3), 3);
var prob = tf.softmax(tf.sub(conv, max), 3);
var regions = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(out, params.conv4_2, 'valid');
var regions = common_1.convLayer(out, params.conv4_2, 'valid');
return { prob: prob, regions: regions };

@@ -15,0 +15,0 @@ });

import * as tf from '@tensorflow/tfjs-core';
import { SharedParams } from './types';
export declare function sharedLayer(x: tf.Tensor4D, params: SharedParams, isPnet?: boolean): tf.Tensor<tf.Rank.R4>;
export declare function sharedLayer(x: tf.Tensor4D, params: SharedParams, isPnet?: boolean): tf.Tensor4D;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var prelu_1 = require("./prelu");

@@ -9,9 +9,9 @@ function sharedLayer(x, params, isPnet) {

return tf.tidy(function () {
var out = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(x, params.conv1, 'valid');
var out = common_1.convLayer(x, params.conv1, 'valid');
out = prelu_1.prelu(out, params.prelu1_alpha);
out = tf.maxPool(out, isPnet ? [2, 2] : [3, 3], [2, 2], 'same');
out = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(out, params.conv2, 'valid');
out = common_1.convLayer(out, params.conv2, 'valid');
out = prelu_1.prelu(out, params.prelu2_alpha);
out = isPnet ? out : tf.maxPool(out, [3, 3], [2, 2], 'valid');
out = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(out, params.conv3, 'valid');
out = common_1.convLayer(out, params.conv3, 'valid');
out = prelu_1.prelu(out, params.prelu3_alpha);

@@ -18,0 +18,0 @@ return out;

import * as tf from '@tensorflow/tfjs-core';
import { BoundingBox } from 'tfjs-image-recognition-base';
import { BoundingBox } from '../classes';
import { PNetParams } from './types';

@@ -4,0 +4,0 @@ export declare function stage1(imgTensor: tf.Tensor4D, scales: number[], scoreThreshold: number, params: PNetParams, stats: any): {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
var ops_1 = require("../ops");
var config_1 = require("./config");

@@ -25,3 +26,3 @@ var getSizesForScale_1 = require("./getSizesForScale");

if (scoresData[y][x] >= scoreThreshold) {
indices.push(new tfjs_image_recognition_base_1.Point(x, y));
indices.push(new classes_1.Point(x, y));
}

@@ -31,3 +32,3 @@ }

var boundingBoxes = indices.map(function (idx) {
var cell = new tfjs_image_recognition_base_1.BoundingBox(Math.round((idx.y * config_1.CELL_STRIDE + 1) / scale), Math.round((idx.x * config_1.CELL_STRIDE + 1) / scale), Math.round((idx.y * config_1.CELL_STRIDE + config_1.CELL_SIZE) / scale), Math.round((idx.x * config_1.CELL_STRIDE + config_1.CELL_SIZE) / scale));
var cell = new classes_1.BoundingBox(Math.round((idx.y * config_1.CELL_STRIDE + 1) / scale), Math.round((idx.x * config_1.CELL_STRIDE + 1) / scale), Math.round((idx.y * config_1.CELL_STRIDE + config_1.CELL_SIZE) / scale), Math.round((idx.x * config_1.CELL_STRIDE + config_1.CELL_SIZE) / scale));
var score = scoresData[idx.y][idx.x];

@@ -71,3 +72,3 @@ var regionsData = regionsTensor.arraySync();

var ts = Date.now();
var indices = tfjs_image_recognition_base_1.nonMaxSuppression(boundingBoxes.map(function (bbox) { return bbox.cell; }), boundingBoxes.map(function (bbox) { return bbox.score; }), 0.5);
var indices = ops_1.nonMaxSuppression(boundingBoxes.map(function (bbox) { return bbox.cell; }), boundingBoxes.map(function (bbox) { return bbox.score; }), 0.5);
statsForScale.nms = Date.now() - ts;

@@ -83,3 +84,3 @@ statsForScale.numBoxes = indices.length;

var ts = Date.now();
var indices = tfjs_image_recognition_base_1.nonMaxSuppression(allBoxes.map(function (bbox) { return bbox.cell; }), allBoxes.map(function (bbox) { return bbox.score; }), 0.7);
var indices = ops_1.nonMaxSuppression(allBoxes.map(function (bbox) { return bbox.cell; }), allBoxes.map(function (bbox) { return bbox.score; }), 0.7);
stats.stage1_nms = Date.now() - ts;

@@ -91,3 +92,3 @@ finalScores = indices.map(function (idx) { return allBoxes[idx].score; });

var cell = _a.cell, region = _a.region;
return new tfjs_image_recognition_base_1.BoundingBox(cell.left + (region.left * cell.width), cell.top + (region.top * cell.height), cell.right + (region.right * cell.width), cell.bottom + (region.bottom * cell.height)).toSquare().round();
return new classes_1.BoundingBox(cell.left + (region.left * cell.width), cell.top + (region.top * cell.height), cell.right + (region.right * cell.width), cell.bottom + (region.bottom * cell.height)).toSquare().round();
});

@@ -94,0 +95,0 @@ }

@@ -1,2 +0,2 @@

import { Box } from 'tfjs-image-recognition-base';
import { Box } from '../classes';
import { RNetParams } from './types';

@@ -3,0 +3,0 @@ export declare function stage2(img: HTMLCanvasElement, inputBoxes: Box[], scoreThreshold: number, params: RNetParams, stats: any): Promise<{

@@ -5,3 +5,3 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var ops_1 = require("../ops");
var extractImagePatches_1 = require("./extractImagePatches");

@@ -49,3 +49,3 @@ var MtcnnBox_1 = require("./MtcnnBox");

ts = Date.now();
indicesNms = tfjs_image_recognition_base_1.nonMaxSuppression(filteredBoxes, filteredScores, 0.7);
indicesNms = ops_1.nonMaxSuppression(filteredBoxes, filteredScores, 0.7);
stats.stage2_nms = Date.now() - ts;

@@ -52,0 +52,0 @@ regions_1 = indicesNms.map(function (idx) {

@@ -1,2 +0,2 @@

import { BoundingBox, Box, Point } from 'tfjs-image-recognition-base';
import { BoundingBox, Box, Point } from '../classes';
import { ONetParams } from './types';

@@ -3,0 +3,0 @@ export declare function stage3(img: HTMLCanvasElement, inputBoxes: BoundingBox[], scoreThreshold: number, params: ONetParams, stats: any): Promise<{

@@ -5,3 +5,4 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
var ops_1 = require("../ops");
var extractImagePatches_1 = require("./extractImagePatches");

@@ -55,3 +56,3 @@ var MtcnnBox_1 = require("./MtcnnBox");

ts = Date.now();
indicesNms = tfjs_image_recognition_base_1.nonMaxSuppression(filteredBoxes, filteredScores, 0.7, false);
indicesNms = ops_1.nonMaxSuppression(filteredBoxes, filteredScores, 0.7, false);
stats.stage3_nms = Date.now() - ts;

@@ -63,3 +64,3 @@ finalBoxes = indicesNms.map(function (idx) { return filteredBoxes[idx]; });

var pointsData = onetOuts[idx].points.arraySync();
return new tfjs_image_recognition_base_1.Point(((pointsData[0][ptIdx] * (finalBoxes[i].width + 1)) + finalBoxes[i].left), ((pointsData[0][ptIdx + 5] * (finalBoxes[i].height + 1)) + finalBoxes[i].top));
return new classes_1.Point(((pointsData[0][ptIdx] * (finalBoxes[i].width + 1)) + finalBoxes[i].left), ((pointsData[0][ptIdx + 5] * (finalBoxes[i].height + 1)) + finalBoxes[i].top));
});

@@ -66,0 +67,0 @@ });

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FaceLandmarks5 } from '../classes/FaceLandmarks5';
import { ConvParams, FCParams } from '../common';
import { WithFaceDetection, WithFaceLandmarks } from '../factories';
export declare type SharedParams = {
conv1: TfjsImageRecognitionBase.ConvParams;
conv1: ConvParams;
prelu1_alpha: tf.Tensor1D;
conv2: TfjsImageRecognitionBase.ConvParams;
conv2: ConvParams;
prelu2_alpha: tf.Tensor1D;
conv3: TfjsImageRecognitionBase.ConvParams;
conv3: ConvParams;
prelu3_alpha: tf.Tensor1D;
};
export declare type PNetParams = SharedParams & {
conv4_1: TfjsImageRecognitionBase.ConvParams;
conv4_2: TfjsImageRecognitionBase.ConvParams;
conv4_1: ConvParams;
conv4_2: ConvParams;
};
export declare type RNetParams = SharedParams & {
fc1: TfjsImageRecognitionBase.FCParams;
fc1: FCParams;
prelu4_alpha: tf.Tensor1D;
fc2_1: TfjsImageRecognitionBase.FCParams;
fc2_2: TfjsImageRecognitionBase.FCParams;
fc2_1: FCParams;
fc2_2: FCParams;
};
export declare type ONetParams = SharedParams & {
conv4: TfjsImageRecognitionBase.ConvParams;
conv4: ConvParams;
prelu4_alpha: tf.Tensor1D;
fc1: TfjsImageRecognitionBase.FCParams;
fc1: FCParams;
prelu5_alpha: tf.Tensor1D;
fc2_1: TfjsImageRecognitionBase.FCParams;
fc2_2: TfjsImageRecognitionBase.FCParams;
fc2_3: TfjsImageRecognitionBase.FCParams;
fc2_1: FCParams;
fc2_2: FCParams;
fc2_3: FCParams;
};

@@ -32,0 +32,0 @@ export declare type NetParams = {

@@ -1,2 +0,2 @@

import { IDimensions } from 'tfjs-image-recognition-base';
import { IDimensions } from './classes';
export declare function resizeResults<T>(results: T, dimensions: IDimensions): T;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("./classes");
var FaceDetection_1 = require("./classes/FaceDetection");

@@ -9,3 +9,3 @@ var FaceLandmarks_1 = require("./classes/FaceLandmarks");

function resizeResults(results, dimensions) {
var _a = new tfjs_image_recognition_base_1.Dimensions(dimensions.width, dimensions.height), width = _a.width, height = _a.height;
var _a = new classes_1.Dimensions(dimensions.width, dimensions.height), width = _a.width, height = _a.height;
if (width <= 0 || height <= 0) {

@@ -12,0 +12,0 @@ throw new Error("resizeResults - invalid dimensions: " + JSON.stringify({ width: width, height: height }));

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
function boxPredictionLayer(x, params) {
return tf.tidy(function () {
var batchSize = x.shape[0];
var boxPredictionEncoding = tf.reshape(tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(x, params.box_encoding_predictor), [batchSize, -1, 1, 4]);
var classPrediction = tf.reshape(tfjs_image_recognition_base_1.TfjsImageRecognitionBase.convLayer(x, params.class_predictor), [batchSize, -1, 3]);
var boxPredictionEncoding = tf.reshape(common_1.convLayer(x, params.box_encoding_predictor), [batchSize, -1, 1, 4]);
var classPrediction = tf.reshape(common_1.convLayer(x, params.class_predictor), [batchSize, -1, 3]);
return {

@@ -11,0 +11,0 @@ boxPredictionEncoding: boxPredictionEncoding,

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
function extractorsFactory(extractWeights, paramMappings) {

@@ -140,3 +140,3 @@ function extractDepthwiseConvParams(numChannels, mappedPrefix) {

var paramMappings = [];
var _a = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _b = extractorsFactory(extractWeights, paramMappings), extractMobilenetV1Params = _b.extractMobilenetV1Params, extractPredictionLayerParams = _b.extractPredictionLayerParams;

@@ -143,0 +143,0 @@ var mobilenetv1 = extractMobilenetV1Params();

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var utils_1 = require("../utils");
function extractorsFactory(weightMap, paramMappings) {
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
function extractPointwiseConvParams(prefix, idx, mappedPrefix) {

@@ -88,3 +89,3 @@ var filters = extractWeightEntry(prefix + "/Conv2d_" + idx + "_pointwise/weights", 4, mappedPrefix + "/filters");

paramMappings.push({ originalPath: 'Output/extra_dim', paramPath: 'output_layer/extra_dim' });
if (!tfjs_image_recognition_base_1.isTensor3D(extra_dim)) {
if (!utils_1.isTensor3D(extra_dim)) {
throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have " + extra_dim);

@@ -99,3 +100,3 @@ }

};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };

@@ -102,0 +103,0 @@ }

import * as tf from '@tensorflow/tfjs-core';
import { MobileNetV1 } from './types';
export declare function mobileNetV1(x: tf.Tensor4D, params: MobileNetV1.Params): {
out: tf.Tensor<tf.Rank.R4>;
out: tf.Tensor4D;
conv11: any;
};
import * as tf from '@tensorflow/tfjs-core';
import { OutputLayerParams } from './types';
export declare function outputLayer(boxPredictions: tf.Tensor4D, classPredictions: tf.Tensor4D, params: OutputLayerParams): {
boxes: tf.Tensor<tf.Rank.R2>[];
scores: tf.Tensor<tf.Rank.R1>[];
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
};
import * as tf from '@tensorflow/tfjs-core';
import { PointwiseConvParams } from './types';
export declare function pointwiseConvLayer(x: tf.Tensor4D, params: PointwiseConvParams, strides: [number, number]): tf.Tensor<tf.Rank.R4>;
export declare function pointwiseConvLayer(x: tf.Tensor4D, params: PointwiseConvParams, strides: [number, number]): tf.Tensor4D;
import * as tf from '@tensorflow/tfjs-core';
import { PredictionLayerParams } from './types';
export declare function predictionLayer(x: tf.Tensor4D, conv11: tf.Tensor4D, params: PredictionLayerParams): {
boxPredictions: tf.Tensor<tf.Rank.R4>;
classPredictions: tf.Tensor<tf.Rank.R4>;
boxPredictions: tf.Tensor4D;
classPredictions: tf.Tensor4D;
};
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { ISsdMobilenetv1Options } from './SsdMobilenetv1Options';

@@ -9,8 +10,8 @@ import { NetParams } from './types';

forwardInput(input: NetInput): {
boxes: tf.Tensor<tf.Rank.R2>[];
scores: tf.Tensor<tf.Rank.R1>[];
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
};
forward(input: TNetInput): Promise<{
boxes: tf.Tensor<tf.Rank.R2>[];
scores: tf.Tensor<tf.Rank.R1>[];
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
}>;

@@ -21,8 +22,8 @@ locateFaces(input: TNetInput, options?: ISsdMobilenetv1Options): Promise<FaceDetection[]>;

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,4 +5,6 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
var FaceDetection_1 = require("../classes/FaceDetection");
var dom_1 = require("../dom");
var NeuralNetwork_1 = require("../NeuralNetwork");
var extractParams_1 = require("./extractParams");

@@ -40,3 +42,3 @@ var extractParamsFromWeigthMap_1 = require("./extractParamsFromWeigthMap");

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -55,3 +57,3 @@ }

_a = new SsdMobilenetv1Options_1.SsdMobilenetv1Options(options), maxResults = _a.maxResults, minConfidence = _a.minConfidence;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1:

@@ -87,3 +89,3 @@ netInput = _e.sent();

].map(function (val) { return val * padX; }), left = _b[0], right = _b[1];
return new FaceDetection_1.FaceDetection(scoresData[idx], new tfjs_image_recognition_base_1.Rect(left, top, right - left, bottom - top), {
return new FaceDetection_1.FaceDetection(scoresData[idx], new classes_1.Rect(left, top, right - left, bottom - top), {
height: netInput.getInputHeight(0),

@@ -110,4 +112,4 @@ width: netInput.getInputWidth(0)

return SsdMobilenetv1;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.SsdMobilenetv1 = SsdMobilenetv1;
//# sourceMappingURL=SsdMobilenetv1.js.map

@@ -10,4 +10,4 @@ export interface ISsdMobilenetv1Options {

constructor({ minConfidence, maxResults }?: ISsdMobilenetv1Options);
readonly minConfidence: number;
readonly maxResults: number;
get minConfidence(): number;
get maxResults(): number;
}
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ConvParams } from '../common';
export declare type PointwiseConvParams = {

@@ -37,4 +37,4 @@ filters: tf.Tensor4D;

export declare type BoxPredictionParams = {
box_encoding_predictor: TfjsImageRecognitionBase.ConvParams;
class_predictor: TfjsImageRecognitionBase.ConvParams;
box_encoding_predictor: ConvParams;
class_predictor: ConvParams;
};

@@ -41,0 +41,0 @@ export declare type PredictionLayerParams = {

@@ -1,4 +0,4 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export declare const IOU_THRESHOLD = 0.4;
export declare const BOX_ANCHORS: Point[];
export declare const MEAN_RGB: [number, number, number];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
exports.IOU_THRESHOLD = 0.4;
exports.BOX_ANCHORS = [
new tfjs_image_recognition_base_1.Point(1.603231, 2.094468),
new tfjs_image_recognition_base_1.Point(6.041143, 7.080126),
new tfjs_image_recognition_base_1.Point(2.882459, 3.518061),
new tfjs_image_recognition_base_1.Point(4.266906, 5.178857),
new tfjs_image_recognition_base_1.Point(9.041765, 10.66308)
new classes_1.Point(1.603231, 2.094468),
new classes_1.Point(6.041143, 7.080126),
new classes_1.Point(2.882459, 3.518061),
new classes_1.Point(4.266906, 5.178857),
new classes_1.Point(9.041765, 10.66308)
];
exports.MEAN_RGB = [117.001, 114.697, 97.404];
//# sourceMappingURL=const.js.map
import * as tf from '@tensorflow/tfjs-core';
import { Point, TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes';
export declare class TinyFaceDetector extends TfjsImageRecognitionBase.TinyYolov2 {
import { FaceDetection, Point } from '../classes';
import { ParamMapping } from '../common';
import { TNetInput } from '../dom';
import { ITinyYolov2Options } from '../tinyYolov2';
import { TinyYolov2Base } from '../tinyYolov2/TinyYolov2Base';
import { TinyYolov2NetParams } from '../tinyYolov2/types';
export declare class TinyFaceDetector extends TinyYolov2Base {
constructor();
readonly anchors: Point[];
locateFaces(input: TNetInput, forwardParams: TfjsImageRecognitionBase.ITinyYolov2Options): Promise<FaceDetection[]>;
get anchors(): Point[];
locateFaces(input: TNetInput, forwardParams: ITinyYolov2Options): Promise<FaceDetection[]>;
protected getDefaultModelName(): string;
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: TfjsImageRecognitionBase.TinyYolov2NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
params: TinyYolov2NetParams;
paramMappings: ParamMapping[];
};
}
"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 classes_1 = require("../classes");
var TinyYolov2Base_1 = require("../tinyYolov2/TinyYolov2Base");
var const_1 = require("./const");

@@ -50,4 +50,4 @@ var TinyFaceDetector = /** @class */ (function (_super) {

return TinyFaceDetector;
}(tfjs_image_recognition_base_1.TfjsImageRecognitionBase.TinyYolov2));
}(TinyYolov2Base_1.TinyYolov2Base));
exports.TinyFaceDetector = TinyFaceDetector;
//# sourceMappingURL=TinyFaceDetector.js.map

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export interface ITinyFaceDetectorOptions extends TfjsImageRecognitionBase.ITinyYolov2Options {
import { ITinyYolov2Options, TinyYolov2Options } from '../tinyYolov2';
export interface ITinyFaceDetectorOptions extends ITinyYolov2Options {
}
export declare class TinyFaceDetectorOptions extends TfjsImageRecognitionBase.TinyYolov2Options {
export declare class TinyFaceDetectorOptions extends TinyYolov2Options {
protected _name: string;
}
"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 tinyYolov2_1 = require("../tinyYolov2");
var TinyFaceDetectorOptions = /** @class */ (function (_super) {

@@ -13,4 +13,4 @@ tslib_1.__extends(TinyFaceDetectorOptions, _super);

return TinyFaceDetectorOptions;
}(tfjs_image_recognition_base_1.TfjsImageRecognitionBase.TinyYolov2Options));
}(tinyYolov2_1.TinyYolov2Options));
exports.TinyFaceDetectorOptions = TinyFaceDetectorOptions;
//# sourceMappingURL=TinyFaceDetectorOptions.js.map

@@ -1,2 +0,2 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export declare const IOU_THRESHOLD = 0.4;

@@ -3,0 +3,0 @@ export declare const BOX_ANCHORS: Point[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var classes_1 = require("../classes");
exports.IOU_THRESHOLD = 0.4;
exports.BOX_ANCHORS = [
new tfjs_image_recognition_base_1.Point(0.738768, 0.874946),
new tfjs_image_recognition_base_1.Point(2.42204, 2.65704),
new tfjs_image_recognition_base_1.Point(4.30971, 7.04493),
new tfjs_image_recognition_base_1.Point(10.246, 4.59428),
new tfjs_image_recognition_base_1.Point(12.6868, 11.8741)
new classes_1.Point(0.738768, 0.874946),
new classes_1.Point(2.42204, 2.65704),
new classes_1.Point(4.30971, 7.04493),
new classes_1.Point(10.246, 4.59428),
new classes_1.Point(12.6868, 11.8741)
];
exports.BOX_ANCHORS_SEPARABLE = [
new tfjs_image_recognition_base_1.Point(1.603231, 2.094468),
new tfjs_image_recognition_base_1.Point(6.041143, 7.080126),
new tfjs_image_recognition_base_1.Point(2.882459, 3.518061),
new tfjs_image_recognition_base_1.Point(4.266906, 5.178857),
new tfjs_image_recognition_base_1.Point(9.041765, 10.66308)
new classes_1.Point(1.603231, 2.094468),
new classes_1.Point(6.041143, 7.080126),
new classes_1.Point(2.882459, 3.518061),
new classes_1.Point(4.266906, 5.178857),
new classes_1.Point(9.041765, 10.66308)
];

@@ -19,0 +19,0 @@ exports.MEAN_RGB_SEPARABLE = [117.001, 114.697, 97.404];

import { TinyYolov2 } from './TinyYolov2';
export * from './TinyYolov2Options';
export * from './config';
export * from './types';
export { TinyYolov2 };
export declare function createTinyYolov2(weights: Float32Array, withSeparableConvs?: boolean): TinyYolov2;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var TinyYolov2_1 = require("./TinyYolov2");
exports.TinyYolov2 = TinyYolov2_1.TinyYolov2;
tslib_1.__exportStar(require("./TinyYolov2Options"), exports);
tslib_1.__exportStar(require("./config"), exports);
function createTinyYolov2(weights, withSeparableConvs) {

@@ -6,0 +9,0 @@ if (withSeparableConvs === void 0) { withSeparableConvs = true; }

import * as tf from '@tensorflow/tfjs-core';
import { Point, TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes';
export declare class TinyYolov2 extends TfjsImageRecognitionBase.TinyYolov2 {
import { FaceDetection, Point } from '../classes';
import { ParamMapping } from '../common/types';
import { TNetInput } from '../dom/types';
import { TinyYolov2Base } from './TinyYolov2Base';
import { ITinyYolov2Options } from './TinyYolov2Options';
import { TinyYolov2NetParams } from './types';
export declare class TinyYolov2 extends TinyYolov2Base {
constructor(withSeparableConvs?: boolean);
readonly withSeparableConvs: boolean;
readonly anchors: Point[];
locateFaces(input: TNetInput, forwardParams: TfjsImageRecognitionBase.ITinyYolov2Options): Promise<FaceDetection[]>;
get withSeparableConvs(): boolean;
get anchors(): Point[];
locateFaces(input: TNetInput, forwardParams: ITinyYolov2Options): Promise<FaceDetection[]>;
protected getDefaultModelName(): string;
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: TfjsImageRecognitionBase.TinyYolov2NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
params: TinyYolov2NetParams;
paramMappings: ParamMapping[];
};
}
"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 classes_1 = require("../classes");
var const_1 = require("./const");
var TinyYolov2Base_1 = require("./TinyYolov2Base");
var TinyYolov2 = /** @class */ (function (_super) {

@@ -62,4 +62,4 @@ tslib_1.__extends(TinyYolov2, _super);

return TinyYolov2;
}(tfjs_image_recognition_base_1.TfjsImageRecognitionBase.TinyYolov2));
}(TinyYolov2Base_1.TinyYolov2Base));
exports.TinyYolov2 = TinyYolov2;
//# sourceMappingURL=TinyYolov2.js.map

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common/types';
import { TinyXceptionParams } from './types';
export declare function extractParams(weights: Float32Array, numMainBlocks: number): {
params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var utils_1 = require("../utils");
function extractorsFactory(extractWeights, paramMappings) {
var extractConvParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractSeparableConvParamsFactory(extractWeights, paramMappings);
var extractConvParams = common_1.extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = common_1.extractSeparableConvParamsFactory(extractWeights, paramMappings);
function extractReductionBlockParams(channelsIn, channelsOut, mappedPrefix) {

@@ -28,3 +29,3 @@ var separable_conv0 = extractSeparableConvParams(channelsIn, channelsOut, mappedPrefix + "/separable_conv0");

var paramMappings = [];
var _a = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = common_1.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _b = extractorsFactory(extractWeights, paramMappings), extractConvParams = _b.extractConvParams, extractSeparableConvParams = _b.extractSeparableConvParams, extractReductionBlockParams = _b.extractReductionBlockParams, extractMainBlockParams = _b.extractMainBlockParams;

@@ -40,3 +41,3 @@ var entry_flow_conv_in = extractConvParams(3, 32, 3, 'entry_flow/conv_in');

var middle_flow = {};
tfjs_image_recognition_base_1.range(numMainBlocks, 0, 1).forEach(function (idx) {
utils_1.range(numMainBlocks, 0, 1).forEach(function (idx) {
middle_flow["main_block_" + idx] = extractMainBlockParams(128, "middle_flow/main_block_" + idx);

@@ -43,0 +44,0 @@ });

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { TinyXceptionParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap, numMainBlocks: number): {
params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var common_1 = require("../common");
var loadConvParamsFactory_1 = require("../common/loadConvParamsFactory");
var utils_1 = require("../utils");
function loadParamsFactory(weightMap, paramMappings) {
var extractWeightEntry = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = common_1.extractWeightEntryFactory(weightMap, paramMappings);
var extractConvParams = loadConvParamsFactory_1.loadConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = tfjs_image_recognition_base_1.TfjsImageRecognitionBase.loadSeparableConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = common_1.loadSeparableConvParamsFactory(extractWeightEntry);
function extractReductionBlockParams(mappedPrefix) {

@@ -40,3 +41,3 @@ var separable_conv0 = extractSeparableConvParams(mappedPrefix + "/separable_conv0");

var middle_flow = {};
tfjs_image_recognition_base_1.range(numMainBlocks, 0, 1).forEach(function (idx) {
utils_1.range(numMainBlocks, 0, 1).forEach(function (idx) {
middle_flow["main_block_" + idx] = extractMainBlockParams("middle_flow/main_block_" + idx);

@@ -50,3 +51,3 @@ });

};
tfjs_image_recognition_base_1.TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
common_1.disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: { entry_flow: entry_flow, middle_flow: middle_flow, exit_flow: exit_flow }, paramMappings: paramMappings };

@@ -53,0 +54,0 @@ }

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { TinyXceptionParams } from './types';

@@ -12,8 +13,8 @@ export declare class TinyXception extends NeuralNetwork<TinyXceptionParams> {

params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}

@@ -5,4 +5,7 @@ "use strict";

var tf = require("@tensorflow/tfjs-core");
var tfjs_image_recognition_base_1 = require("tfjs-image-recognition-base");
var depthwiseSeparableConv_1 = require("../common/depthwiseSeparableConv");
var common_1 = require("../common");
var dom_1 = require("../dom");
var NeuralNetwork_1 = require("../NeuralNetwork");
var ops_1 = require("../ops");
var utils_1 = require("../utils");
var extractParams_1 = require("./extractParams");

@@ -16,4 +19,4 @@ var extractParamsFromWeigthMap_1 = require("./extractParamsFromWeigthMap");

var out = isActivateInput ? tf.relu(x) : x;
out = depthwiseSeparableConv_1.depthwiseSeparableConv(out, params.separable_conv0, [1, 1]);
out = depthwiseSeparableConv_1.depthwiseSeparableConv(tf.relu(out), params.separable_conv1, [1, 1]);
out = common_1.depthwiseSeparableConv(out, params.separable_conv0, [1, 1]);
out = common_1.depthwiseSeparableConv(tf.relu(out), params.separable_conv1, [1, 1]);
out = tf.maxPool(out, [3, 3], [2, 2], 'same');

@@ -24,5 +27,5 @@ out = tf.add(out, conv(x, params.expansion_conv, [2, 2]));

function mainBlock(x, params) {
var out = depthwiseSeparableConv_1.depthwiseSeparableConv(tf.relu(x), params.separable_conv0, [1, 1]);
out = depthwiseSeparableConv_1.depthwiseSeparableConv(tf.relu(out), params.separable_conv1, [1, 1]);
out = depthwiseSeparableConv_1.depthwiseSeparableConv(tf.relu(out), params.separable_conv2, [1, 1]);
var out = common_1.depthwiseSeparableConv(tf.relu(x), params.separable_conv0, [1, 1]);
out = common_1.depthwiseSeparableConv(tf.relu(out), params.separable_conv1, [1, 1]);
out = common_1.depthwiseSeparableConv(tf.relu(out), params.separable_conv2, [1, 1]);
out = tf.add(out, x);

@@ -47,11 +50,11 @@ return out;

var meanRgb = [122.782, 117.001, 104.298];
var normalized = tfjs_image_recognition_base_1.normalize(batchTensor, meanRgb).div(tf.scalar(256));
var normalized = ops_1.normalize(batchTensor, meanRgb).div(tf.scalar(256));
var out = tf.relu(conv(normalized, params.entry_flow.conv_in, [2, 2]));
out = reductionBlock(out, params.entry_flow.reduction_block_0, false);
out = reductionBlock(out, params.entry_flow.reduction_block_1);
tfjs_image_recognition_base_1.range(_this._numMainBlocks, 0, 1).forEach(function (idx) {
utils_1.range(_this._numMainBlocks, 0, 1).forEach(function (idx) {
out = mainBlock(out, params.middle_flow["main_block_" + idx]);
});
out = reductionBlock(out, params.exit_flow.reduction_block);
out = tf.relu(depthwiseSeparableConv_1.depthwiseSeparableConv(out, params.exit_flow.separable_conv, [1, 1]));
out = tf.relu(common_1.depthwiseSeparableConv(out, params.exit_flow.separable_conv, [1, 1]));
return out;

@@ -67,3 +70,3 @@ });

_a = this.forwardInput;
return [4 /*yield*/, tfjs_image_recognition_base_1.toNetInput(input)];
return [4 /*yield*/, dom_1.toNetInput(input)];
case 1: return [2 /*return*/, _a.apply(this, [_b.sent()])];

@@ -84,4 +87,4 @@ }

return TinyXception;
}(tfjs_image_recognition_base_1.NeuralNetwork));
}(NeuralNetwork_1.NeuralNetwork));
exports.TinyXception = TinyXception;
//# sourceMappingURL=TinyXception.js.map

@@ -1,15 +0,15 @@

import { TfjsImageRecognitionBase } from "tfjs-image-recognition-base";
import { ConvParams, SeparableConvParams } from '../common';
export declare type ReductionBlockParams = {
separable_conv0: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv1: TfjsImageRecognitionBase.SeparableConvParams;
expansion_conv: TfjsImageRecognitionBase.ConvParams;
separable_conv0: SeparableConvParams;
separable_conv1: SeparableConvParams;
expansion_conv: ConvParams;
};
export declare type MainBlockParams = {
separable_conv0: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv1: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv2: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv0: SeparableConvParams;
separable_conv1: SeparableConvParams;
separable_conv2: SeparableConvParams;
};
export declare type TinyXceptionParams = {
entry_flow: {
conv_in: TfjsImageRecognitionBase.ConvParams;
conv_in: ConvParams;
reduction_block_0: ReductionBlockParams;

@@ -21,4 +21,4 @@ reduction_block_1: ReductionBlockParams;

reduction_block: ReductionBlockParams;
separable_conv: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv: SeparableConvParams;
};
};
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';
import { NeuralNetwork } from '../NeuralNetwork';
import { NetInput, TNetInput } from '../dom';
export declare class AgeGenderNet extends NeuralNetwork<NetParams> {
private _faceFeatureExtractor;
constructor(faceFeatureExtractor?: TinyXception);
readonly faceFeatureExtractor: TinyXception;
get faceFeatureExtractor(): TinyXception;
runNet(input: NetInput | tf.Tensor4D): NetOutput;

@@ -18,12 +19,12 @@ forwardInput(input: NetInput | tf.Tensor4D): NetOutput;

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, toNetInput } from 'tfjs-image-recognition-base';
import { fullyConnectedLayer } from '../common/fullyConnectedLayer';

@@ -10,2 +9,4 @@ import { seperateWeightMaps } from '../faceProcessor/util';

import { Gender } from './types';
import { NeuralNetwork } from '../NeuralNetwork';
import { NetInput, toNetInput } from '../dom';
var AgeGenderNet = /** @class */ (function (_super) {

@@ -12,0 +13,0 @@ __extends(AgeGenderNet, _super);

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractFCParamsFactory, extractWeightsFactory } from '../common';
export function extractParams(weights) {
var paramMappings = [];
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractFCParams = TfjsImageRecognitionBase.extractFCParamsFactory(extractWeights, paramMappings);
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractFCParams = extractFCParamsFactory(extractWeights, paramMappings);
var age = extractFCParams(512, 1, 'fc/age');

@@ -7,0 +7,0 @@ var gender = extractFCParams(512, 2, 'fc/gender');

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,5 +0,5 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors, extractWeightEntryFactory } from '../common';
export function extractParamsFromWeigthMap(weightMap) {
var paramMappings = [];
var extractWeightEntry = TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings);
function extractFcParams(prefix) {

@@ -16,5 +16,5 @@ var weights = extractWeightEntry(prefix + "/weights", 2);

};
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FCParams } from '../common';
export declare type AgeAndGenderPrediction = {

@@ -18,5 +18,5 @@ age: number;

fc: {
age: TfjsImageRecognitionBase.FCParams;
gender: TfjsImageRecognitionBase.FCParams;
age: FCParams;
gender: FCParams;
};
};

@@ -1,2 +0,5 @@

import { Box, IDimensions, ObjectDetection, Rect } from 'tfjs-image-recognition-base';
import { Box } from './Box';
import { IDimensions } from './Dimensions';
import { ObjectDetection } from './ObjectDetection';
import { Rect } from './Rect';
export interface IFaceDetecion {

@@ -3,0 +6,0 @@ score: number;

import { __extends } from "tslib";
import { ObjectDetection } from 'tfjs-image-recognition-base';
import { ObjectDetection } from './ObjectDetection';
var FaceDetection = /** @class */ (function (_super) {

@@ -4,0 +4,0 @@ __extends(FaceDetection, _super);

@@ -1,3 +0,7 @@

import { Box, Dimensions, IBoundingBox, IDimensions, IRect, Point } from 'tfjs-image-recognition-base';
import { IBoundingBox } from './BoundingBox';
import { Box } from './Box';
import { Dimensions, IDimensions } from './Dimensions';
import { FaceDetection } from './FaceDetection';
import { Point } from './Point';
import { IRect } from './Rect';
export interface IFaceLandmarks {

@@ -12,7 +16,7 @@ positions: Point[];

constructor(relativeFaceLandmarkPositions: Point[], imgDims: IDimensions, shift?: Point);
readonly shift: Point;
readonly imageWidth: number;
readonly imageHeight: number;
readonly positions: Point[];
readonly relativePositions: Point[];
get shift(): Point;
get imageWidth(): number;
get imageHeight(): number;
get positions(): Point[];
get relativePositions(): Point[];
forSize<T extends FaceLandmarks>(width: number, height: number): T;

@@ -19,0 +23,0 @@ shiftBy<T extends FaceLandmarks>(x: number, y: number): T;

@@ -1,4 +0,8 @@

import { Box, Dimensions, getCenterPoint, Point, Rect } from 'tfjs-image-recognition-base';
import { minBbox } from '../minBbox';
import { minBbox } from '../ops';
import { getCenterPoint } from '../utils';
import { Box } from './Box';
import { Dimensions } from './Dimensions';
import { FaceDetection } from './FaceDetection';
import { Point } from './Point';
import { Rect } from './Rect';
// face alignment constants

@@ -5,0 +9,0 @@ var relX = 0.5;

@@ -1,5 +0,5 @@

import { Point } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from './FaceLandmarks';
import { Point } from './Point';
export declare class FaceLandmarks5 extends FaceLandmarks {
protected getRefPointsForAlignment(): Point[];
}
import { __extends } from "tslib";
import { getCenterPoint } from 'tfjs-image-recognition-base';
import { getCenterPoint } from '../utils';
import { FaceLandmarks } from './FaceLandmarks';

@@ -4,0 +4,0 @@ var FaceLandmarks5 = /** @class */ (function (_super) {

@@ -1,3 +0,3 @@

import { Point } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from '../classes/FaceLandmarks';
import { FaceLandmarks } from './FaceLandmarks';
import { Point } from './Point';
export declare class FaceLandmarks68 extends FaceLandmarks {

@@ -4,0 +4,0 @@ getJawOutline(): Point[];

import { __extends } from "tslib";
import { getCenterPoint } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from '../classes/FaceLandmarks';
import { getCenterPoint } from '../utils';
import { FaceLandmarks } from './FaceLandmarks';
var FaceLandmarks68 = /** @class */ (function (_super) {

@@ -5,0 +5,0 @@ __extends(FaceLandmarks68, _super);

@@ -9,5 +9,5 @@ export interface IFaceMatch {

constructor(label: string, distance: number);
readonly label: string;
readonly distance: number;
get label(): string;
get distance(): number;
toString(withDistance?: boolean): string;
}

@@ -1,2 +0,2 @@

import { round } from 'tfjs-image-recognition-base';
import { round } from '../utils';
var FaceMatch = /** @class */ (function () {

@@ -3,0 +3,0 @@ function FaceMatch(label, distance) {

@@ -0,1 +1,4 @@

export * from './BoundingBox';
export * from './Box';
export * from './Dimensions';
export * from './FaceDetection';

@@ -6,2 +9,7 @@ export * from './FaceLandmarks';

export * from './FaceMatch';
export * from './LabeledBox';
export * from './LabeledFaceDescriptors';
export * from './ObjectDetection';
export * from './Point';
export * from './PredictedBox';
export * from './Rect';

@@ -0,1 +1,4 @@

export * from './BoundingBox';
export * from './Box';
export * from './Dimensions';
export * from './FaceDetection';

@@ -6,3 +9,8 @@ export * from './FaceLandmarks';

export * from './FaceMatch';
export * from './LabeledBox';
export * from './LabeledFaceDescriptors';
export * from './ObjectDetection';
export * from './Point';
export * from './PredictedBox';
export * from './Rect';
//# sourceMappingURL=index.js.map

@@ -5,6 +5,6 @@ export declare class LabeledFaceDescriptors {

constructor(label: string, descriptors: Float32Array[]);
readonly label: string;
readonly descriptors: Float32Array[];
get label(): string;
get descriptors(): Float32Array[];
toJSON(): any;
static fromJSON(json: any): LabeledFaceDescriptors;
}
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;
import { SeparableConvParams } from './types';
export declare function depthwiseSeparableConv(x: tf.Tensor4D, params: SeparableConvParams, stride: [number, number]): tf.Tensor4D;
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;
import { FCParams } from './types';
export declare function fullyConnectedLayer(x: tf.Tensor2D, params: FCParams): tf.Tensor2D;

@@ -1,2 +0,2 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function loadConvParamsFactory(extractWeightEntry: <T>(originalPath: string, paramRank: number) => T): (prefix: string) => TfjsImageRecognitionBase.ConvParams;
import { ConvParams } from './types';
export declare function loadConvParamsFactory(extractWeightEntry: <T>(originalPath: string, paramRank: number) => T): (prefix: string) => ConvParams;

@@ -1,3 +0,4 @@

import { Rect, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { Rect } from '../classes/Rect';
import { TNetInput } from './types';
/**

@@ -4,0 +5,0 @@ * Extracts the image regions containing the detected faces.

import { __awaiter, __generator } from "tslib";
import { createCanvas, env, getContext2dOrThrow, imageTensorToCanvas, toNetInput, } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { env } from '../env';
import { createCanvas } from './createCanvas';
import { getContext2dOrThrow } from './getContext2dOrThrow';
import { imageTensorToCanvas } from './imageTensorToCanvas';
import { toNetInput } from './toNetInput';
/**

@@ -5,0 +9,0 @@ * Extracts the image regions containing the detected faces.

import * as tf from '@tensorflow/tfjs-core';
import { Rect } from 'tfjs-image-recognition-base';
import { Rect } from '../classes';
import { FaceDetection } from '../classes/FaceDetection';

@@ -4,0 +4,0 @@ /**

import { __awaiter, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { isTensor4D, isTensor3D } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { isTensor3D, isTensor4D } from '../utils';
/**

@@ -6,0 +6,0 @@ * Extracts the tensors of the image regions containing the detected faces.

@@ -0,2 +1,21 @@

export * from './awaitMediaLoaded';
export * from './bufferToImage';
export * from './createCanvas';
export * from './extractFaces';
export * from './extractFaceTensors';
export * from './fetchImage';
export * from './fetchJson';
export * from './fetchNetWeights';
export * from './fetchOrThrow';
export * from './getContext2dOrThrow';
export * from './getMediaDimensions';
export * from './imageTensorToCanvas';
export * from './imageToSquare';
export * from './isMediaElement';
export * from './isMediaLoaded';
export * from './loadWeightMap';
export * from './matchDimensions';
export * from './NetInput';
export * from './resolveInput';
export * from './toNetInput';
export * from './types';

@@ -0,3 +1,21 @@

export * from './awaitMediaLoaded';
export * from './bufferToImage';
export * from './createCanvas';
export * from './extractFaces';
export * from './extractFaceTensors';
export * from './fetchImage';
export * from './fetchJson';
export * from './fetchNetWeights';
export * from './fetchOrThrow';
export * from './getContext2dOrThrow';
export * from './getMediaDimensions';
export * from './imageTensorToCanvas';
export * from './imageToSquare';
export * from './isMediaElement';
export * from './isMediaLoaded';
export * from './loadWeightMap';
export * from './matchDimensions';
export * from './NetInput';
export * from './resolveInput';
export * from './toNetInput';
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export declare function drawContour(ctx: CanvasRenderingContext2D, points: Point[], isClosed?: boolean): void;

@@ -1,2 +0,2 @@

import { IBoundingBox, IRect } from 'tfjs-image-recognition-base';
import { IBoundingBox, IRect } from '../classes';
import { FaceDetection } from '../classes/FaceDetection';

@@ -3,0 +3,0 @@ import { WithFaceDetection } from '../factories/WithFaceDetection';

@@ -1,4 +0,6 @@

import { Box, draw, round } from 'tfjs-image-recognition-base';
import { Box } from '../classes';
import { FaceDetection } from '../classes/FaceDetection';
import { isWithFaceDetection } from '../factories/WithFaceDetection';
import { round } from '../utils';
import { DrawBox } from './DrawBox';
export function drawDetections(canvasArg, detections) {

@@ -14,5 +16,5 @@ var detectionsArray = Array.isArray(detections) ? detections : [detections];

var label = score ? "" + round(score) : undefined;
new draw.DrawBox(box, { label: label }).draw(canvasArg);
new DrawBox(box, { label: label }).draw(canvasArg);
});
}
//# sourceMappingURL=drawDetections.js.map

@@ -1,2 +0,2 @@

import { IPoint } from 'tfjs-image-recognition-base';
import { IPoint } from '../classes';
import { FaceExpressions } from '../faceExpressionNet';

@@ -3,0 +3,0 @@ import { WithFaceExpressions } from '../factories/WithFaceExpressions';

@@ -1,5 +0,7 @@

import { draw, Point, round } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
import { FaceExpressions } from '../faceExpressionNet';
import { isWithFaceDetection } from '../factories/WithFaceDetection';
import { isWithFaceExpressions } from '../factories/WithFaceExpressions';
import { round } from '../utils';
import { DrawTextField } from './DrawTextField';
export function drawFaceExpressions(canvasArg, faceExpressions, minConfidence, textFieldAnchor) {

@@ -20,3 +22,3 @@ if (minConfidence === void 0) { minConfidence = 0.1; }

: (textFieldAnchor || new Point(0, 0));
var drawTextField = new draw.DrawTextField(resultsToDisplay.map(function (expr) { return expr.expression + " (" + round(expr.probability) + ")"; }), anchor);
var drawTextField = new DrawTextField(resultsToDisplay.map(function (expr) { return expr.expression + " (" + round(expr.probability) + ")"; }), anchor);
drawTextField.draw(canvasArg);

@@ -23,0 +25,0 @@ });

@@ -1,4 +0,4 @@

import { getContext2dOrThrow } from 'tfjs-image-recognition-base';
import { FaceLandmarks } from '../classes/FaceLandmarks';
import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { getContext2dOrThrow } from '../dom/getContext2dOrThrow';
import { isWithFaceLandmarks } from '../factories/WithFaceLandmarks';

@@ -5,0 +5,0 @@ import { drawContour } from './drawContour';

export * from './drawContour';
export * from './drawDetections';
export * from './drawFaceExpressions';
export * from './DrawBox';
export * from './DrawFaceLandmarks';
export * from './DrawTextField';
export * from './drawContour';
export * from './drawDetections';
export * from './drawFaceExpressions';
export * from './DrawBox';
export * from './DrawFaceLandmarks';
export * from './DrawTextField';
//# sourceMappingURL=index.js.map
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { FaceFeatureExtractor } from '../faceFeatureExtractor/FaceFeatureExtractor';

@@ -4,0 +4,0 @@ import { FaceFeatureExtractorParams } from '../faceFeatureExtractor/types';

import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { toNetInput } from 'tfjs-image-recognition-base';
import { toNetInput } from '../dom';
import { FaceFeatureExtractor } from '../faceFeatureExtractor/FaceFeatureExtractor';

@@ -5,0 +5,0 @@ import { FaceProcessor } from '../faceProcessor/FaceProcessor';

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ExtractWeightsFunction, ParamMapping } from '../common';
import { DenseBlock3Params, DenseBlock4Params } from './types';
export declare function extractorsFactory(extractWeights: TfjsImageRecognitionBase.ExtractWeightsFunction, paramMappings: TfjsImageRecognitionBase.ParamMapping[]): {
export declare function extractorsFactory(extractWeights: ExtractWeightsFunction, paramMappings: ParamMapping[]): {
extractDenseBlock3Params: (channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer?: boolean) => DenseBlock3Params;
extractDenseBlock4Params: (channelsIn: number, channelsOut: number, mappedPrefix: string, isFirstLayer?: boolean) => DenseBlock4Params;
};

@@ -1,5 +0,5 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractConvParamsFactory, extractSeparableConvParamsFactory, } from '../common';
export function extractorsFactory(extractWeights, paramMappings) {
var extractConvParams = TfjsImageRecognitionBase.extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = TfjsImageRecognitionBase.extractSeparableConvParamsFactory(extractWeights, paramMappings);
var extractConvParams = extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = extractSeparableConvParamsFactory(extractWeights, paramMappings);
function extractDenseBlock3Params(channelsIn, channelsOut, mappedPrefix, isFirstLayer) {

@@ -6,0 +6,0 @@ if (isFirstLayer === void 0) { isFirstLayer = false; }

@@ -0,6 +1,6 @@

import { ParamMapping } from '../common';
import { FaceFeatureExtractorParams } from './types';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export declare function extractParams(weights: Float32Array): {
params: FaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -0,6 +1,6 @@

import { extractWeightsFactory } from '../common';
import { extractorsFactory } from './extractorsFactory';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export function extractParams(weights) {
var paramMappings = [];
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractDenseBlock4Params = extractorsFactory(extractWeights, paramMappings).extractDenseBlock4Params;

@@ -7,0 +7,0 @@ var dense0 = extractDenseBlock4Params(3, 32, 'dense0', true);

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { FaceFeatureExtractorParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: FaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,2 +0,2 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors } from '../common';
import { loadParamsFactory } from './loadParamsFactory';

@@ -12,5 +12,5 @@ export function extractParamsFromWeigthMap(weightMap) {

};
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { TinyFaceFeatureExtractorParams } from './types';
export declare function extractParamsFromWeigthMapTiny(weightMap: tf.NamedTensorMap): {
params: TinyFaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,2 +0,2 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors } from '../common';
import { loadParamsFactory } from './loadParamsFactory';

@@ -11,5 +11,5 @@ export function extractParamsFromWeigthMapTiny(weightMap) {

};
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMapTiny.js.map

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { TinyFaceFeatureExtractorParams } from './types';
export declare function extractParamsTiny(weights: Float32Array): {
params: TinyFaceFeatureExtractorParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractWeightsFactory } from '../common';
import { extractorsFactory } from './extractorsFactory';
export function extractParamsTiny(weights) {
var paramMappings = [];
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractDenseBlock3Params = extractorsFactory(extractWeights, paramMappings).extractDenseBlock3Params;

@@ -7,0 +7,0 @@ var dense0 = extractDenseBlock3Params(3, 32, 'dense0', true);

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { FaceFeatureExtractorParams, IFaceFeatureExtractor } from './types';

@@ -11,8 +12,8 @@ export declare class FaceFeatureExtractor extends NeuralNetwork<FaceFeatureExtractorParams> implements IFaceFeatureExtractor<FaceFeatureExtractorParams> {

params: FaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: FaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NeuralNetwork, normalize, toNetInput } from 'tfjs-image-recognition-base';
import { toNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { normalize } from '../ops';
import { denseBlock4 } from './denseBlock';

@@ -5,0 +7,0 @@ import { extractParams } from './extractParams';

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { DenseBlock3Params, DenseBlock4Params } from './types';
export declare function loadParamsFactory(weightMap: any, paramMappings: TfjsImageRecognitionBase.ParamMapping[]): {
export declare function loadParamsFactory(weightMap: any, paramMappings: ParamMapping[]): {
extractDenseBlock3Params: (prefix: string, isFirstLayer?: boolean) => DenseBlock3Params;
extractDenseBlock4Params: (prefix: string, isFirstLayer?: boolean) => DenseBlock4Params;
};

@@ -1,7 +0,7 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractWeightEntryFactory, loadSeparableConvParamsFactory } from '../common';
import { loadConvParamsFactory } from '../common/loadConvParamsFactory';
export function loadParamsFactory(weightMap, paramMappings) {
var extractWeightEntry = TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings);
var extractConvParams = loadConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = TfjsImageRecognitionBase.loadSeparableConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = loadSeparableConvParamsFactory(extractWeightEntry);
function extractDenseBlock3Params(prefix, isFirstLayer) {

@@ -8,0 +8,0 @@ if (isFirstLayer === void 0) { isFirstLayer = false; }

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { IFaceFeatureExtractor, TinyFaceFeatureExtractorParams } from './types';

@@ -11,8 +12,8 @@ export declare class TinyFaceFeatureExtractor extends NeuralNetwork<TinyFaceFeatureExtractorParams> implements IFaceFeatureExtractor<TinyFaceFeatureExtractorParams> {

params: TinyFaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: TinyFaceFeatureExtractorParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NeuralNetwork, normalize, toNetInput } from 'tfjs-image-recognition-base';
import { toNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { normalize } from '../ops';
import { denseBlock3 } from './denseBlock';

@@ -5,0 +7,0 @@ import { extractParamsFromWeigthMapTiny } from './extractParamsFromWeigthMapTiny';

import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput, TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '..';
import { ConvParams, SeparableConvParams } from '../common';
import { NeuralNetwork } from '../NeuralNetwork';
export declare type ConvWithBatchNormParams = BatchNormParams & {

@@ -17,8 +19,8 @@ filter: tf.Tensor4D;

export declare type DenseBlock3Params = {
conv0: TfjsImageRecognitionBase.SeparableConvParams | TfjsImageRecognitionBase.ConvParams;
conv1: TfjsImageRecognitionBase.SeparableConvParams;
conv2: TfjsImageRecognitionBase.SeparableConvParams;
conv0: SeparableConvParams | ConvParams;
conv1: SeparableConvParams;
conv2: SeparableConvParams;
};
export declare type DenseBlock4Params = DenseBlock3Params & {
conv3: TfjsImageRecognitionBase.SeparableConvParams;
conv3: SeparableConvParams;
};

@@ -25,0 +27,0 @@ export declare type TinyFaceFeatureExtractorParams = {

import * as tf from '@tensorflow/tfjs-core';
import { IDimensions, NetInput, TNetInput } from 'tfjs-image-recognition-base';
import { IDimensions } from '../classes';
import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { NetInput, TNetInput } from '../dom';
import { FaceFeatureExtractorParams, TinyFaceFeatureExtractorParams } from '../faceFeatureExtractor/types';

@@ -5,0 +6,0 @@ import { FaceProcessor } from '../faceProcessor/FaceProcessor';

import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { isEven, Point, toNetInput } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { toNetInput } from '../dom';
import { FaceProcessor } from '../faceProcessor/FaceProcessor';
import { isEven } from '../utils';
var FaceLandmark68NetBase = /** @class */ (function (_super) {

@@ -7,0 +9,0 @@ __extends(FaceLandmark68NetBase, _super);

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array, channelsIn: number, channelsOut: number): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractFCParamsFactory, extractWeightsFactory } from '../common';
export function extractParams(weights, channelsIn, channelsOut) {
var paramMappings = [];
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractFCParams = TfjsImageRecognitionBase.extractFCParamsFactory(extractWeights, paramMappings);
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var extractFCParams = extractFCParamsFactory(extractWeights, paramMappings);
var fc = extractFCParams(channelsIn, channelsOut, 'fc');

@@ -7,0 +7,0 @@ if (getRemainingWeights().length !== 0) {

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,5 +0,5 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors, extractWeightEntryFactory } from '../common';
export function extractParamsFromWeigthMap(weightMap) {
var paramMappings = [];
var extractWeightEntry = TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings);
function extractFcParams(prefix) {

@@ -13,5 +13,5 @@ var weights = extractWeightEntry(prefix + "/weights", 2);

};
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork } from 'tfjs-image-recognition-base';
import { NetInput } from '../dom';
import { FaceFeatureExtractorParams, IFaceFeatureExtractor, TinyFaceFeatureExtractorParams } from '../faceFeatureExtractor/types';
import { NeuralNetwork } from '../NeuralNetwork';
import { NetParams } from './types';

@@ -8,3 +9,3 @@ export declare abstract class FaceProcessor<TExtractorParams extends FaceFeatureExtractorParams | TinyFaceFeatureExtractorParams> extends NeuralNetwork<NetParams> {

constructor(_name: string, faceFeatureExtractor: IFaceFeatureExtractor<TExtractorParams>);
readonly faceFeatureExtractor: IFaceFeatureExtractor<TExtractorParams>;
get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>;
protected abstract getDefaultModelName(): string;

@@ -18,12 +19,12 @@ protected abstract getClassifierChannelsIn(): number;

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __extends } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork } from 'tfjs-image-recognition-base';
import { fullyConnectedLayer } from '../common/fullyConnectedLayer';
import { NetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { extractParams } from './extractParams';

@@ -6,0 +7,0 @@ import { extractParamsFromWeigthMap } from './extractParamsFromWeigthMap';

@@ -1,4 +0,4 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FCParams } from '../common';
export declare type NetParams = {
fc: TfjsImageRecognitionBase.FCParams;
fc: FCParams;
};
import * as tf from '@tensorflow/tfjs-core';
import { ConvLayerParams } from './types';
export declare function conv(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor<tf.Rank.R4>;
export declare function convNoRelu(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor<tf.Rank.R4>;
export declare function convDown(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor<tf.Rank.R4>;
export declare function conv(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor4D;
export declare function convNoRelu(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor4D;
export declare function convDown(x: tf.Tensor4D, params: ConvLayerParams): tf.Tensor4D;

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
import * as tf from '@tensorflow/tfjs-core';
import { isFloat, TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractWeightsFactory } from '../common';
import { isFloat } from '../utils';
function extractorsFactory(extractWeights, paramMappings) {

@@ -44,3 +45,3 @@ function extractFilterValues(numFilterValues, numFilters, filterSize) {

export function extractParams(weights) {
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var paramMappings = [];

@@ -47,0 +48,0 @@ var _b = extractorsFactory(extractWeights, paramMappings), extractConvLayerParams = _b.extractConvLayerParams, extractResidualLayerParams = _b.extractResidualLayerParams;

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,4 +0,5 @@

import { isTensor2D, TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors, extractWeightEntryFactory } from '../common';
import { isTensor2D } from '../utils';
function extractorsFactory(weightMap, paramMappings) {
var extractWeightEntry = TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings);
function extractScaleLayerParams(prefix) {

@@ -67,5 +68,5 @@ var weights = extractWeightEntry(prefix + "/scale/weights", 1);

};
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { NetParams } from './types';

@@ -12,8 +13,8 @@ export declare class FaceRecognitionNet extends NeuralNetwork<NetParams> {

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NeuralNetwork, normalize, toNetInput } from 'tfjs-image-recognition-base';
import { toNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { normalize } from '../ops';
import { convDown } from './convLayer';

@@ -5,0 +7,0 @@ import { extractParams } from './extractParams';

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ConvParams } from '../common';
export declare type ScaleLayerParams = {

@@ -12,3 +12,3 @@ weights: tf.Tensor1D;

export declare type ConvLayerParams = {
conv: TfjsImageRecognitionBase.ConvParams;
conv: ConvParams;
scale: ScaleLayerParams;

@@ -15,0 +15,0 @@ };

@@ -1,3 +0,3 @@

import { isValidProbablitiy } from 'tfjs-image-recognition-base';
import { Gender } from '../ageGenderNet/types';
import { isValidProbablitiy } from '../utils';
export function isWithGender(obj) {

@@ -4,0 +4,0 @@ return (obj['gender'] === Gender.MALE || obj['gender'] === Gender.FEMALE)

@@ -1,7 +0,8 @@

import { TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithFaceDescriptor, WithFaceDetection, WithFaceLandmarks } from '../factories';
import { IMtcnnOptions } from '../mtcnn/MtcnnOptions';
import { ITinyYolov2Options } from '../tinyYolov2';
export declare function allFacesSsdMobilenetv1(input: TNetInput, minConfidence?: number): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare function allFacesTinyYolov2(input: TNetInput, forwardParams?: TfjsImageRecognitionBase.ITinyYolov2Options): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare function allFacesTinyYolov2(input: TNetInput, forwardParams?: ITinyYolov2Options): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare function allFacesMtcnn(input: TNetInput, forwardParams?: IMtcnnOptions): Promise<WithFaceDescriptor<WithFaceLandmarks<WithFaceDetection<{}>>>[]>;
export declare const allFaces: typeof allFacesSsdMobilenetv1;
import { __awaiter, __generator } from "tslib";
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { MtcnnOptions } from '../mtcnn/MtcnnOptions';
import { SsdMobilenetv1Options } from '../ssdMobilenetv1';
import { TinyYolov2Options } from '../tinyYolov2';
import { detectAllFaces } from './detectFaces';

@@ -11,5 +11,7 @@ // export allFaces API for backward compatibility

switch (_a.label) {
case 0: return [4 /*yield*/, detectAllFaces(input, new SsdMobilenetv1Options(minConfidence ? { minConfidence: minConfidence } : {}))
.withFaceLandmarks()
.withFaceDescriptors()];
case 0:
console.warn('allFacesSsdMobilenetv1 is deprecated and will be removed soon, use the high level api instead');
return [4 /*yield*/, detectAllFaces(input, new SsdMobilenetv1Options(minConfidence ? { minConfidence: minConfidence } : {}))
.withFaceLandmarks()
.withFaceDescriptors()];
case 1: return [2 /*return*/, _a.sent()];

@@ -25,5 +27,7 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, detectAllFaces(input, new TfjsImageRecognitionBase.TinyYolov2Options(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 0:
console.warn('allFacesTinyYolov2 is deprecated and will be removed soon, use the high level api instead');
return [4 /*yield*/, detectAllFaces(input, new TinyYolov2Options(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 1: return [2 /*return*/, _a.sent()];

@@ -39,5 +43,7 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, detectAllFaces(input, new MtcnnOptions(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 0:
console.warn('allFacesMtcnn is deprecated and will be removed soon, use the high level api instead');
return [4 /*yield*/, detectAllFaces(input, new MtcnnOptions(forwardParams))
.withFaceLandmarks()
.withFaceDescriptors()];
case 1: return [2 /*return*/, _a.sent()];

@@ -44,0 +50,0 @@ }

@@ -1,2 +0,2 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithFaceDescriptor } from '../factories/WithFaceDescriptor';

@@ -3,0 +3,0 @@ import { WithFaceDetection } from '../factories/WithFaceDetection';

@@ -1,3 +0,3 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { TNetInput } from '../dom';
import { FaceLandmark68Net } from '../faceLandmarkNet/FaceLandmark68Net';

@@ -16,3 +16,3 @@ import { FaceLandmark68TinyNet } from '../faceLandmarkNet/FaceLandmark68TinyNet';

constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, useTinyLandmarkNet: boolean);
protected readonly landmarkNet: FaceLandmark68Net | FaceLandmark68TinyNet;
protected get landmarkNet(): FaceLandmark68Net | FaceLandmark68TinyNet;
}

@@ -19,0 +19,0 @@ export declare class DetectAllFaceLandmarksTask<TSource extends WithFaceDetection<{}>> extends DetectFaceLandmarksTaskBase<WithFaceLandmarks<TSource>[], TSource[]> {

@@ -1,2 +0,2 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { DetectAllFacesTask, DetectSingleFaceTask } from './DetectFacesTasks';

@@ -3,0 +3,0 @@ import { FaceDetectionOptions } from './types';

@@ -1,3 +0,3 @@

import { TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { TNetInput } from '../dom';
import { ComposableTask } from './ComposableTask';

@@ -4,0 +4,0 @@ import { DetectAllFaceLandmarksTask, DetectSingleFaceLandmarksTask } from './DetectFaceLandmarksTasks';

import { __awaiter, __extends, __generator } from "tslib";
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extendWithFaceDetection } from '../factories/WithFaceDetection';

@@ -7,2 +6,3 @@ import { MtcnnOptions } from '../mtcnn/MtcnnOptions';

import { TinyFaceDetectorOptions } from '../tinyFaceDetector/TinyFaceDetectorOptions';
import { TinyYolov2Options } from '../tinyYolov2';
import { ComposableTask } from './ComposableTask';

@@ -46,3 +46,3 @@ import { DetectAllFaceLandmarksTask, DetectSingleFaceLandmarksTask } from './DetectFaceLandmarksTasks';

? function (input) { return nets.ssdMobilenetv1.locateFaces(input, options); }
: (options instanceof TfjsImageRecognitionBase.TinyYolov2Options
: (options instanceof TinyYolov2Options
? function (input) { return nets.tinyYolov2.locateFaces(input, options); }

@@ -49,0 +49,0 @@ : null));

import * as tf from '@tensorflow/tfjs-core';
import { TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { TNetInput } from '../dom';
import { WithFaceDetection } from '../factories/WithFaceDetection';

@@ -5,0 +5,0 @@ import { WithFaceLandmarks } from '../factories/WithFaceLandmarks';

@@ -8,4 +8,4 @@ import { FaceMatch } from '../classes/FaceMatch';

constructor(inputs: LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>, distanceThreshold?: number);
readonly labeledDescriptors: LabeledFaceDescriptors[];
readonly distanceThreshold: number;
get labeledDescriptors(): LabeledFaceDescriptors[];
get distanceThreshold(): number;
computeMeanDistance(queryDescriptor: Float32Array, descriptors: Float32Array[]): number;

@@ -12,0 +12,0 @@ matchDescriptor(queryDescriptor: Float32Array): FaceMatch;

@@ -1,2 +0,1 @@

import { TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { AgeGenderNet } from '../ageGenderNet/AgeGenderNet';

@@ -7,2 +6,3 @@ import { AgeAndGenderPrediction } from '../ageGenderNet/types';

import { FaceLandmarks68 } from '../classes/FaceLandmarks68';
import { TNetInput } from '../dom';
import { FaceExpressionNet } from '../faceExpressionNet/FaceExpressionNet';

@@ -20,3 +20,3 @@ import { FaceExpressions } from '../faceExpressionNet/FaceExpressions';

import { TinyFaceDetectorOptions } from '../tinyFaceDetector/TinyFaceDetectorOptions';
import { TinyYolov2 } from '../tinyYolov2';
import { ITinyYolov2Options, TinyYolov2 } from '../tinyYolov2';
export declare const nets: {

@@ -56,3 +56,3 @@ ssdMobilenetv1: SsdMobilenetv1;

*/
export declare const tinyYolov2: (input: TNetInput, options: TfjsImageRecognitionBase.ITinyYolov2Options) => Promise<FaceDetection[]>;
export declare const tinyYolov2: (input: TNetInput, options: ITinyYolov2Options) => Promise<FaceDetection[]>;
/**

@@ -59,0 +59,0 @@ * Attempts to detect all faces in an image and the 5 point face landmarks

import * as tf from '@tensorflow/tfjs-core';
import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithAge } from '../factories/WithAge';

@@ -13,4 +13,4 @@ import { WithFaceDetection } from '../factories/WithFaceDetection';

protected input: TNetInput;
protected extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}

@@ -17,0 +17,0 @@ export declare class PredictAllAgeAndGenderTask<TSource extends WithFaceDetection<{}>> extends PredictAgeAndGenderTaskBase<WithAge<WithGender<TSource>>[], TSource[]> {

import * as tf from '@tensorflow/tfjs-core';
import { TNetInput } from 'tfjs-image-recognition-base';
import { TNetInput } from '../dom';
import { WithFaceDetection } from '../factories/WithFaceDetection';

@@ -12,4 +12,4 @@ import { WithFaceExpressions } from '../factories/WithFaceExpressions';

protected input: TNetInput;
protected extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (HTMLCanvasElement | tf.Tensor<tf.Rank.R3>)[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}

@@ -16,0 +16,0 @@ export declare class PredictAllFaceExpressionsTask<TSource extends WithFaceDetection<{}>> extends PredictFaceExpressionsTaskBase<WithFaceExpressions<TSource>[], TSource[]> {

@@ -1,7 +0,8 @@

import { TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { TNetInput } from '../dom';
import { MtcnnOptions } from '../mtcnn/MtcnnOptions';
import { SsdMobilenetv1Options } from '../ssdMobilenetv1/SsdMobilenetv1Options';
import { TinyFaceDetectorOptions } from '../tinyFaceDetector/TinyFaceDetectorOptions';
export declare type FaceDetectionOptions = TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TfjsImageRecognitionBase.TinyYolov2Options;
import { TinyYolov2Options } from '../tinyYolov2';
export declare type FaceDetectionOptions = TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options;
export declare type FaceDetectionFunction = (input: TNetInput) => Promise<FaceDetection[]>;
import * as tf from '@tensorflow/tfjs-core';
import { draw as drawBase } from 'tfjs-image-recognition-base';
import * as drawExtended from './draw';
export { tf };
export * from 'tfjs-image-recognition-base';
import * as draw from './draw';
import * as utils from './utils';
export { draw, utils, tf };
export * from './ageGenderNet/index';
declare const draw: {
drawContour(ctx: CanvasRenderingContext2D, points: import("tfjs-image-recognition-base").Point[], isClosed?: boolean): void;
drawDetections(canvasArg: string | HTMLCanvasElement, detections: import("./classes").FaceDetection | import("tfjs-image-recognition-base").IRect | {
detection: import("./classes").FaceDetection;
} | import("tfjs-image-recognition-base").IBoundingBox | drawExtended.TDrawDetectionsInput[]): void;
drawFaceExpressions(canvasArg: string | HTMLCanvasElement, faceExpressions: import("./faceExpressionNet").FaceExpressions | {
expressions: import("./faceExpressionNet").FaceExpressions;
} | drawExtended.DrawFaceExpressionsInput[], minConfidence?: number, textFieldAnchor?: import("tfjs-image-recognition-base").IPoint | undefined): void;
drawFaceLandmarks(canvasArg: string | HTMLCanvasElement, faceLandmarks: import("./classes").FaceLandmarks | import("./factories").WithFaceLandmarks<{
detection: import("./classes").FaceDetection;
}, import("./classes").FaceLandmarks68> | drawExtended.DrawFaceLandmarksInput[]): void;
DrawFaceLandmarksOptions: typeof drawExtended.DrawFaceLandmarksOptions;
DrawFaceLandmarks: typeof drawExtended.DrawFaceLandmarks;
DrawBoxOptions: typeof drawBase.DrawBoxOptions;
DrawBox: typeof drawBase.DrawBox;
AnchorPosition: typeof drawBase.AnchorPosition;
DrawTextFieldOptions: typeof drawBase.DrawTextFieldOptions;
DrawTextField: typeof drawBase.DrawTextField;
};
export { draw };
export * from './classes/index';
export * from './dom/index';
export * from './env/index';
export * from './faceExpressionNet/index';

@@ -35,2 +15,3 @@ export * from './faceLandmarkNet/index';

export * from './mtcnn/index';
export * from './ops/index';
export * from './ssdMobilenetv1/index';

@@ -40,2 +21,3 @@ export * from './tinyFaceDetector/index';

export * from './euclideanDistance';
export * from './NeuralNetwork';
export * from './resizeResults';

@@ -1,12 +0,9 @@

import { __assign } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { draw as drawBase } from 'tfjs-image-recognition-base';
import * as drawExtended from './draw';
export { tf };
export * from 'tfjs-image-recognition-base';
import * as draw from './draw';
import * as utils from './utils';
export { draw, utils, tf };
export * from './ageGenderNet/index';
var draw = __assign(__assign({}, drawBase), drawExtended);
export { draw };
export * from './classes/index';
export * from './dom/index';
export * from './env/index';
export * from './faceExpressionNet/index';

@@ -18,2 +15,3 @@ export * from './faceLandmarkNet/index';

export * from './mtcnn/index';
export * from './ops/index';
export * from './ssdMobilenetv1/index';

@@ -23,3 +21,4 @@ export * from './tinyFaceDetector/index';

export * from './euclideanDistance';
export * from './NeuralNetwork';
export * from './resizeResults';
//# sourceMappingURL=index.js.map
import * as tf from '@tensorflow/tfjs-core';
import { Box, IDimensions } from 'tfjs-image-recognition-base';
import { Box, IDimensions } from '../classes';
export declare function extractImagePatches(img: HTMLCanvasElement, boxes: Box[], { width, height }: IDimensions): Promise<tf.Tensor4D[]>;
import { __awaiter, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { createCanvas, createCanvasFromMedia, env, getContext2dOrThrow, } from 'tfjs-image-recognition-base';
import { createCanvas, createCanvasFromMedia, getContext2dOrThrow } from '../dom';
import { env } from '../env';
import { normalize } from './normalize';

@@ -5,0 +6,0 @@ export function extractImagePatches(img, boxes, _a) {

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
import { __assign } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractConvParamsFactory, extractFCParamsFactory, extractWeightsFactory, } from '../common';
function extractorsFactory(extractWeights, paramMappings) {
var extractConvParams = TfjsImageRecognitionBase.extractConvParamsFactory(extractWeights, paramMappings);
var extractFCParams = TfjsImageRecognitionBase.extractFCParamsFactory(extractWeights, paramMappings);
var extractConvParams = extractConvParamsFactory(extractWeights, paramMappings);
var extractFCParams = extractFCParamsFactory(extractWeights, paramMappings);
function extractPReluParams(size, paramPath) {

@@ -54,3 +54,3 @@ var alpha = tf.tensor1d(extractWeights(size));

export function extractParams(weights) {
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var paramMappings = [];

@@ -57,0 +57,0 @@ var _b = extractorsFactory(extractWeights, paramMappings), extractPNetParams = _b.extractPNetParams, extractRNetParams = _b.extractRNetParams, extractONetParams = _b.extractONetParams;

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
import { __assign } from "tslib";
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors, extractWeightEntryFactory } from '../common';
function extractorsFactory(weightMap, paramMappings) {
var extractWeightEntry = TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings);
function extractConvParams(prefix) {

@@ -64,5 +64,5 @@ var filters = extractWeightEntry(prefix + "/weights", 4, prefix + "/filters");

var onet = extractONetParams();
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: { pnet: pnet, rnet: rnet, onet: onet }, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { IMtcnnOptions } from './MtcnnOptions';

@@ -7,2 +8,4 @@ import { MtcnnResult, NetParams } from './types';

constructor();
load(weightsOrUrl: Float32Array | string | undefined): Promise<void>;
loadFromDisk(filePath: string | undefined): Promise<void>;
forwardInput(input: NetInput, forwardParams?: IMtcnnOptions): Promise<{

@@ -20,8 +23,8 @@ results: MtcnnResult[];

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NeuralNetwork, Point, Rect, toNetInput } from 'tfjs-image-recognition-base';
import { Point, Rect } from '../classes';
import { FaceDetection } from '../classes/FaceDetection';
import { FaceLandmarks5 } from '../classes/FaceLandmarks5';
import { toNetInput } from '../dom';
import { extendWithFaceDetection, extendWithFaceLandmarks } from '../factories';
import { NeuralNetwork } from '../NeuralNetwork';
import { bgrToRgbTensor } from './bgrToRgbTensor';

@@ -22,2 +24,18 @@ import { CELL_SIZE } from './config';

}
Mtcnn.prototype.load = function (weightsOrUrl) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
console.warn('mtcnn is deprecated and will be removed soon');
return [2 /*return*/, _super.prototype.load.call(this, weightsOrUrl)];
});
});
};
Mtcnn.prototype.loadFromDisk = function (filePath) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
console.warn('mtcnn is deprecated and will be removed soon');
return [2 /*return*/, _super.prototype.loadFromDisk.call(this, filePath)];
});
});
};
Mtcnn.prototype.forwardInput = function (input, forwardParams) {

@@ -24,0 +42,0 @@ if (forwardParams === void 0) { forwardParams = {}; }

@@ -1,4 +0,4 @@

import { Box } from 'tfjs-image-recognition-base';
import { Box } from '../classes';
export declare class MtcnnBox extends Box<MtcnnBox> {
constructor(left: number, top: number, right: number, bottom: number);
}
import { __extends } from "tslib";
import { Box } from 'tfjs-image-recognition-base';
import { Box } from '../classes';
var MtcnnBox = /** @class */ (function (_super) {

@@ -4,0 +4,0 @@ __extends(MtcnnBox, _super);

@@ -16,7 +16,7 @@ export interface IMtcnnOptions {

constructor({ minFaceSize, scaleFactor, maxNumScales, scoreThresholds, scaleSteps }?: IMtcnnOptions);
readonly minFaceSize: number;
readonly scaleFactor: number;
readonly maxNumScales: number;
readonly scoreThresholds: number[];
readonly scaleSteps: number[] | undefined;
get minFaceSize(): number;
get scaleFactor(): number;
get maxNumScales(): number;
get scoreThresholds(): number[];
get scaleSteps(): number[] | undefined;
}
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { convLayer } from '../common';
import { fullyConnectedLayer } from '../common/fullyConnectedLayer';

@@ -10,3 +10,3 @@ import { prelu } from './prelu';

out = tf.maxPool(out, [2, 2], [2, 2], 'same');
out = TfjsImageRecognitionBase.convLayer(out, params.conv4, 'valid');
out = convLayer(out, params.conv4, 'valid');
out = prelu(out, params.prelu4_alpha);

@@ -13,0 +13,0 @@ var vectorized = tf.reshape(out, [out.shape[0], params.fc1.weights.shape[0]]);

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { convLayer } from '../common';
import { sharedLayer } from './sharedLayers';

@@ -7,6 +7,6 @@ export function PNet(x, params) {

var out = sharedLayer(x, params, true);
var conv = TfjsImageRecognitionBase.convLayer(out, params.conv4_1, 'valid');
var conv = convLayer(out, params.conv4_1, 'valid');
var max = tf.expandDims(tf.max(conv, 3), 3);
var prob = tf.softmax(tf.sub(conv, max), 3);
var regions = TfjsImageRecognitionBase.convLayer(out, params.conv4_2, 'valid');
var regions = convLayer(out, params.conv4_2, 'valid');
return { prob: prob, regions: regions };

@@ -13,0 +13,0 @@ });

import * as tf from '@tensorflow/tfjs-core';
import { SharedParams } from './types';
export declare function sharedLayer(x: tf.Tensor4D, params: SharedParams, isPnet?: boolean): tf.Tensor<tf.Rank.R4>;
export declare function sharedLayer(x: tf.Tensor4D, params: SharedParams, isPnet?: boolean): tf.Tensor4D;
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { convLayer } from '../common';
import { prelu } from './prelu';

@@ -7,9 +7,9 @@ export function sharedLayer(x, params, isPnet) {

return tf.tidy(function () {
var out = TfjsImageRecognitionBase.convLayer(x, params.conv1, 'valid');
var out = convLayer(x, params.conv1, 'valid');
out = prelu(out, params.prelu1_alpha);
out = tf.maxPool(out, isPnet ? [2, 2] : [3, 3], [2, 2], 'same');
out = TfjsImageRecognitionBase.convLayer(out, params.conv2, 'valid');
out = convLayer(out, params.conv2, 'valid');
out = prelu(out, params.prelu2_alpha);
out = isPnet ? out : tf.maxPool(out, [3, 3], [2, 2], 'valid');
out = TfjsImageRecognitionBase.convLayer(out, params.conv3, 'valid');
out = convLayer(out, params.conv3, 'valid');
out = prelu(out, params.prelu3_alpha);

@@ -16,0 +16,0 @@ return out;

import * as tf from '@tensorflow/tfjs-core';
import { BoundingBox } from 'tfjs-image-recognition-base';
import { BoundingBox } from '../classes';
import { PNetParams } from './types';

@@ -4,0 +4,0 @@ export declare function stage1(imgTensor: tf.Tensor4D, scales: number[], scoreThreshold: number, params: PNetParams, stats: any): {

import * as tf from '@tensorflow/tfjs-core';
import { BoundingBox, nonMaxSuppression, Point } from 'tfjs-image-recognition-base';
import { BoundingBox, Point } from '../classes';
import { nonMaxSuppression } from '../ops';
import { CELL_SIZE, CELL_STRIDE } from './config';

@@ -4,0 +5,0 @@ import { getSizesForScale } from './getSizesForScale';

@@ -1,2 +0,2 @@

import { Box } from 'tfjs-image-recognition-base';
import { Box } from '../classes';
import { RNetParams } from './types';

@@ -3,0 +3,0 @@ export declare function stage2(img: HTMLCanvasElement, inputBoxes: Box[], scoreThreshold: number, params: RNetParams, stats: any): Promise<{

import { __awaiter, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { nonMaxSuppression } from 'tfjs-image-recognition-base';
import { nonMaxSuppression } from '../ops';
import { extractImagePatches } from './extractImagePatches';

@@ -5,0 +5,0 @@ import { MtcnnBox } from './MtcnnBox';

@@ -1,2 +0,2 @@

import { BoundingBox, Box, Point } from 'tfjs-image-recognition-base';
import { BoundingBox, Box, Point } from '../classes';
import { ONetParams } from './types';

@@ -3,0 +3,0 @@ export declare function stage3(img: HTMLCanvasElement, inputBoxes: BoundingBox[], scoreThreshold: number, params: ONetParams, stats: any): Promise<{

import { __awaiter, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { nonMaxSuppression, Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
import { nonMaxSuppression } from '../ops';
import { extractImagePatches } from './extractImagePatches';

@@ -5,0 +6,0 @@ import { MtcnnBox } from './MtcnnBox';

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FaceLandmarks5 } from '../classes/FaceLandmarks5';
import { ConvParams, FCParams } from '../common';
import { WithFaceDetection, WithFaceLandmarks } from '../factories';
export declare type SharedParams = {
conv1: TfjsImageRecognitionBase.ConvParams;
conv1: ConvParams;
prelu1_alpha: tf.Tensor1D;
conv2: TfjsImageRecognitionBase.ConvParams;
conv2: ConvParams;
prelu2_alpha: tf.Tensor1D;
conv3: TfjsImageRecognitionBase.ConvParams;
conv3: ConvParams;
prelu3_alpha: tf.Tensor1D;
};
export declare type PNetParams = SharedParams & {
conv4_1: TfjsImageRecognitionBase.ConvParams;
conv4_2: TfjsImageRecognitionBase.ConvParams;
conv4_1: ConvParams;
conv4_2: ConvParams;
};
export declare type RNetParams = SharedParams & {
fc1: TfjsImageRecognitionBase.FCParams;
fc1: FCParams;
prelu4_alpha: tf.Tensor1D;
fc2_1: TfjsImageRecognitionBase.FCParams;
fc2_2: TfjsImageRecognitionBase.FCParams;
fc2_1: FCParams;
fc2_2: FCParams;
};
export declare type ONetParams = SharedParams & {
conv4: TfjsImageRecognitionBase.ConvParams;
conv4: ConvParams;
prelu4_alpha: tf.Tensor1D;
fc1: TfjsImageRecognitionBase.FCParams;
fc1: FCParams;
prelu5_alpha: tf.Tensor1D;
fc2_1: TfjsImageRecognitionBase.FCParams;
fc2_2: TfjsImageRecognitionBase.FCParams;
fc2_3: TfjsImageRecognitionBase.FCParams;
fc2_1: FCParams;
fc2_2: FCParams;
fc2_3: FCParams;
};

@@ -32,0 +32,0 @@ export declare type NetParams = {

@@ -1,2 +0,2 @@

import { IDimensions } from 'tfjs-image-recognition-base';
import { IDimensions } from './classes';
export declare function resizeResults<T>(results: T, dimensions: IDimensions): T;

@@ -1,2 +0,2 @@

import { Dimensions } from 'tfjs-image-recognition-base';
import { Dimensions } from './classes';
import { FaceDetection } from './classes/FaceDetection';

@@ -3,0 +3,0 @@ import { FaceLandmarks } from './classes/FaceLandmarks';

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { convLayer } from '../common';
export function boxPredictionLayer(x, params) {
return tf.tidy(function () {
var batchSize = x.shape[0];
var boxPredictionEncoding = tf.reshape(TfjsImageRecognitionBase.convLayer(x, params.box_encoding_predictor), [batchSize, -1, 1, 4]);
var classPrediction = tf.reshape(TfjsImageRecognitionBase.convLayer(x, params.class_predictor), [batchSize, -1, 3]);
var boxPredictionEncoding = tf.reshape(convLayer(x, params.box_encoding_predictor), [batchSize, -1, 1, 4]);
var classPrediction = tf.reshape(convLayer(x, params.class_predictor), [batchSize, -1, 3]);
return {

@@ -9,0 +9,0 @@ boxPredictionEncoding: boxPredictionEncoding,

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractWeightsFactory } from '../common';
function extractorsFactory(extractWeights, paramMappings) {

@@ -138,3 +138,3 @@ function extractDepthwiseConvParams(numChannels, mappedPrefix) {

var paramMappings = [];
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _b = extractorsFactory(extractWeights, paramMappings), extractMobilenetV1Params = _b.extractMobilenetV1Params, extractPredictionLayerParams = _b.extractPredictionLayerParams;

@@ -141,0 +141,0 @@ var mobilenetv1 = extractMobilenetV1Params();

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { NetParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,4 +0,5 @@

import { isTensor3D, TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors, extractWeightEntryFactory } from '../common';
import { isTensor3D } from '../utils';
function extractorsFactory(weightMap, paramMappings) {
var extractWeightEntry = TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings);
function extractPointwiseConvParams(prefix, idx, mappedPrefix) {

@@ -96,5 +97,5 @@ var filters = extractWeightEntry(prefix + "/Conv2d_" + idx + "_pointwise/weights", 4, mappedPrefix + "/filters");

};
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: params, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
import * as tf from '@tensorflow/tfjs-core';
import { MobileNetV1 } from './types';
export declare function mobileNetV1(x: tf.Tensor4D, params: MobileNetV1.Params): {
out: tf.Tensor<tf.Rank.R4>;
out: tf.Tensor4D;
conv11: any;
};
import * as tf from '@tensorflow/tfjs-core';
import { OutputLayerParams } from './types';
export declare function outputLayer(boxPredictions: tf.Tensor4D, classPredictions: tf.Tensor4D, params: OutputLayerParams): {
boxes: tf.Tensor<tf.Rank.R2>[];
scores: tf.Tensor<tf.Rank.R1>[];
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
};
import * as tf from '@tensorflow/tfjs-core';
import { PointwiseConvParams } from './types';
export declare function pointwiseConvLayer(x: tf.Tensor4D, params: PointwiseConvParams, strides: [number, number]): tf.Tensor<tf.Rank.R4>;
export declare function pointwiseConvLayer(x: tf.Tensor4D, params: PointwiseConvParams, strides: [number, number]): tf.Tensor4D;
import * as tf from '@tensorflow/tfjs-core';
import { PredictionLayerParams } from './types';
export declare function predictionLayer(x: tf.Tensor4D, conv11: tf.Tensor4D, params: PredictionLayerParams): {
boxPredictions: tf.Tensor<tf.Rank.R4>;
classPredictions: tf.Tensor<tf.Rank.R4>;
boxPredictions: tf.Tensor4D;
classPredictions: tf.Tensor4D;
};
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes/FaceDetection';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { ISsdMobilenetv1Options } from './SsdMobilenetv1Options';

@@ -9,8 +10,8 @@ import { NetParams } from './types';

forwardInput(input: NetInput): {
boxes: tf.Tensor<tf.Rank.R2>[];
scores: tf.Tensor<tf.Rank.R1>[];
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
};
forward(input: TNetInput): Promise<{
boxes: tf.Tensor<tf.Rank.R2>[];
scores: tf.Tensor<tf.Rank.R1>[];
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
}>;

@@ -21,8 +22,8 @@ locateFaces(input: TNetInput, options?: ISsdMobilenetv1Options): Promise<FaceDetection[]>;

params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: NetParams;
paramMappings: import("tfjs-image-recognition-base/build/commonjs/common").ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NeuralNetwork, Rect, toNetInput } from 'tfjs-image-recognition-base';
import { Rect } from '../classes';
import { FaceDetection } from '../classes/FaceDetection';
import { toNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { extractParams } from './extractParams';

@@ -6,0 +8,0 @@ import { extractParamsFromWeigthMap } from './extractParamsFromWeigthMap';

@@ -10,4 +10,4 @@ export interface ISsdMobilenetv1Options {

constructor({ minConfidence, maxResults }?: ISsdMobilenetv1Options);
readonly minConfidence: number;
readonly maxResults: number;
get minConfidence(): number;
get maxResults(): number;
}
import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ConvParams } from '../common';
export declare type PointwiseConvParams = {

@@ -37,4 +37,4 @@ filters: tf.Tensor4D;

export declare type BoxPredictionParams = {
box_encoding_predictor: TfjsImageRecognitionBase.ConvParams;
class_predictor: TfjsImageRecognitionBase.ConvParams;
box_encoding_predictor: ConvParams;
class_predictor: ConvParams;
};

@@ -41,0 +41,0 @@ export declare type PredictionLayerParams = {

@@ -1,4 +0,4 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export declare const IOU_THRESHOLD = 0.4;
export declare const BOX_ANCHORS: Point[];
export declare const MEAN_RGB: [number, number, number];

@@ -1,2 +0,2 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export var IOU_THRESHOLD = 0.4;

@@ -3,0 +3,0 @@ export var BOX_ANCHORS = [

import * as tf from '@tensorflow/tfjs-core';
import { Point, TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes';
export declare class TinyFaceDetector extends TfjsImageRecognitionBase.TinyYolov2 {
import { FaceDetection, Point } from '../classes';
import { ParamMapping } from '../common';
import { TNetInput } from '../dom';
import { ITinyYolov2Options } from '../tinyYolov2';
import { TinyYolov2Base } from '../tinyYolov2/TinyYolov2Base';
import { TinyYolov2NetParams } from '../tinyYolov2/types';
export declare class TinyFaceDetector extends TinyYolov2Base {
constructor();
readonly anchors: Point[];
locateFaces(input: TNetInput, forwardParams: TfjsImageRecognitionBase.ITinyYolov2Options): Promise<FaceDetection[]>;
get anchors(): Point[];
locateFaces(input: TNetInput, forwardParams: ITinyYolov2Options): Promise<FaceDetection[]>;
protected getDefaultModelName(): string;
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: TfjsImageRecognitionBase.TinyYolov2NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
params: TinyYolov2NetParams;
paramMappings: ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes';
import { TinyYolov2Base } from '../tinyYolov2/TinyYolov2Base';
import { BOX_ANCHORS, IOU_THRESHOLD, MEAN_RGB } from './const';

@@ -48,4 +48,4 @@ var TinyFaceDetector = /** @class */ (function (_super) {

return TinyFaceDetector;
}(TfjsImageRecognitionBase.TinyYolov2));
}(TinyYolov2Base));
export { TinyFaceDetector };
//# sourceMappingURL=TinyFaceDetector.js.map

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
export interface ITinyFaceDetectorOptions extends TfjsImageRecognitionBase.ITinyYolov2Options {
import { ITinyYolov2Options, TinyYolov2Options } from '../tinyYolov2';
export interface ITinyFaceDetectorOptions extends ITinyYolov2Options {
}
export declare class TinyFaceDetectorOptions extends TfjsImageRecognitionBase.TinyYolov2Options {
export declare class TinyFaceDetectorOptions extends TinyYolov2Options {
protected _name: string;
}
import { __extends } from "tslib";
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { TinyYolov2Options } from '../tinyYolov2';
var TinyFaceDetectorOptions = /** @class */ (function (_super) {

@@ -11,4 +11,4 @@ __extends(TinyFaceDetectorOptions, _super);

return TinyFaceDetectorOptions;
}(TfjsImageRecognitionBase.TinyYolov2Options));
}(TinyYolov2Options));
export { TinyFaceDetectorOptions };
//# sourceMappingURL=TinyFaceDetectorOptions.js.map

@@ -1,2 +0,2 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export declare const IOU_THRESHOLD = 0.4;

@@ -3,0 +3,0 @@ export declare const BOX_ANCHORS: Point[];

@@ -1,2 +0,2 @@

import { Point } from 'tfjs-image-recognition-base';
import { Point } from '../classes';
export var IOU_THRESHOLD = 0.4;

@@ -3,0 +3,0 @@ export var BOX_ANCHORS = [

import { TinyYolov2 } from './TinyYolov2';
export * from './TinyYolov2Options';
export * from './config';
export * from './types';
export { TinyYolov2 };
export declare function createTinyYolov2(weights: Float32Array, withSeparableConvs?: boolean): TinyYolov2;
import { TinyYolov2 } from './TinyYolov2';
export * from './TinyYolov2Options';
export * from './config';
export { TinyYolov2 };

@@ -3,0 +5,0 @@ export function createTinyYolov2(weights, withSeparableConvs) {

import * as tf from '@tensorflow/tfjs-core';
import { Point, TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes';
export declare class TinyYolov2 extends TfjsImageRecognitionBase.TinyYolov2 {
import { FaceDetection, Point } from '../classes';
import { ParamMapping } from '../common/types';
import { TNetInput } from '../dom/types';
import { TinyYolov2Base } from './TinyYolov2Base';
import { ITinyYolov2Options } from './TinyYolov2Options';
import { TinyYolov2NetParams } from './types';
export declare class TinyYolov2 extends TinyYolov2Base {
constructor(withSeparableConvs?: boolean);
readonly withSeparableConvs: boolean;
readonly anchors: Point[];
locateFaces(input: TNetInput, forwardParams: TfjsImageRecognitionBase.ITinyYolov2Options): Promise<FaceDetection[]>;
get withSeparableConvs(): boolean;
get anchors(): Point[];
locateFaces(input: TNetInput, forwardParams: ITinyYolov2Options): Promise<FaceDetection[]>;
protected getDefaultModelName(): string;
protected extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap): {
params: TfjsImageRecognitionBase.TinyYolov2NetParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
params: TinyYolov2NetParams;
paramMappings: ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { FaceDetection } from '../classes';
import { BOX_ANCHORS, BOX_ANCHORS_SEPARABLE, DEFAULT_MODEL_NAME, DEFAULT_MODEL_NAME_SEPARABLE_CONV, IOU_THRESHOLD, MEAN_RGB_SEPARABLE, } from './const';
import { TinyYolov2Base } from './TinyYolov2Base';
var TinyYolov2 = /** @class */ (function (_super) {

@@ -60,4 +60,4 @@ __extends(TinyYolov2, _super);

return TinyYolov2;
}(TfjsImageRecognitionBase.TinyYolov2));
}(TinyYolov2Base));
export { TinyYolov2 };
//# sourceMappingURL=TinyYolov2.js.map

@@ -1,6 +0,6 @@

import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common/types';
import { TinyXceptionParams } from './types';
export declare function extractParams(weights: Float32Array, numMainBlocks: number): {
params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,5 +0,6 @@

import { range, TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { extractConvParamsFactory, extractSeparableConvParamsFactory, extractWeightsFactory } from '../common';
import { range } from '../utils';
function extractorsFactory(extractWeights, paramMappings) {
var extractConvParams = TfjsImageRecognitionBase.extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = TfjsImageRecognitionBase.extractSeparableConvParamsFactory(extractWeights, paramMappings);
var extractConvParams = extractConvParamsFactory(extractWeights, paramMappings);
var extractSeparableConvParams = extractSeparableConvParamsFactory(extractWeights, paramMappings);
function extractReductionBlockParams(channelsIn, channelsOut, mappedPrefix) {

@@ -26,3 +27,3 @@ var separable_conv0 = extractSeparableConvParams(channelsIn, channelsOut, mappedPrefix + "/separable_conv0");

var paramMappings = [];
var _a = TfjsImageRecognitionBase.extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _a = extractWeightsFactory(weights), extractWeights = _a.extractWeights, getRemainingWeights = _a.getRemainingWeights;
var _b = extractorsFactory(extractWeights, paramMappings), extractConvParams = _b.extractConvParams, extractSeparableConvParams = _b.extractSeparableConvParams, extractReductionBlockParams = _b.extractReductionBlockParams, extractMainBlockParams = _b.extractMainBlockParams;

@@ -29,0 +30,0 @@ var entry_flow_conv_in = extractConvParams(3, 32, 3, 'entry_flow/conv_in');

import * as tf from '@tensorflow/tfjs-core';
import { TfjsImageRecognitionBase } from 'tfjs-image-recognition-base';
import { ParamMapping } from '../common';
import { TinyXceptionParams } from './types';
export declare function extractParamsFromWeigthMap(weightMap: tf.NamedTensorMap, numMainBlocks: number): {
params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: ParamMapping[];
};

@@ -1,7 +0,8 @@

import { TfjsImageRecognitionBase, range } from 'tfjs-image-recognition-base';
import { disposeUnusedWeightTensors, extractWeightEntryFactory, loadSeparableConvParamsFactory, } from '../common';
import { loadConvParamsFactory } from '../common/loadConvParamsFactory';
import { range } from '../utils';
function loadParamsFactory(weightMap, paramMappings) {
var extractWeightEntry = TfjsImageRecognitionBase.extractWeightEntryFactory(weightMap, paramMappings);
var extractWeightEntry = extractWeightEntryFactory(weightMap, paramMappings);
var extractConvParams = loadConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = TfjsImageRecognitionBase.loadSeparableConvParamsFactory(extractWeightEntry);
var extractSeparableConvParams = loadSeparableConvParamsFactory(extractWeightEntry);
function extractReductionBlockParams(mappedPrefix) {

@@ -47,5 +48,5 @@ var separable_conv0 = extractSeparableConvParams(mappedPrefix + "/separable_conv0");

};
TfjsImageRecognitionBase.disposeUnusedWeightTensors(weightMap, paramMappings);
disposeUnusedWeightTensors(weightMap, paramMappings);
return { params: { entry_flow: entry_flow, middle_flow: middle_flow, exit_flow: exit_flow }, paramMappings: paramMappings };
}
//# sourceMappingURL=extractParamsFromWeigthMap.js.map
import * as tf from '@tensorflow/tfjs-core';
import { NetInput, NeuralNetwork, TfjsImageRecognitionBase, TNetInput } from 'tfjs-image-recognition-base';
import { NetInput, TNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { TinyXceptionParams } from './types';

@@ -12,8 +13,8 @@ export declare class TinyXception extends NeuralNetwork<TinyXceptionParams> {

params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
protected extractParams(weights: Float32Array): {
params: TinyXceptionParams;
paramMappings: TfjsImageRecognitionBase.ParamMapping[];
paramMappings: import("../common").ParamMapping[];
};
}
import { __awaiter, __extends, __generator } from "tslib";
import * as tf from '@tensorflow/tfjs-core';
import { NeuralNetwork, normalize, range, toNetInput, } from 'tfjs-image-recognition-base';
import { depthwiseSeparableConv } from '../common/depthwiseSeparableConv';
import { depthwiseSeparableConv } from '../common';
import { toNetInput } from '../dom';
import { NeuralNetwork } from '../NeuralNetwork';
import { normalize } from '../ops';
import { range } from '../utils';
import { extractParams } from './extractParams';

@@ -6,0 +9,0 @@ import { extractParamsFromWeigthMap } from './extractParamsFromWeigthMap';

@@ -1,15 +0,15 @@

import { TfjsImageRecognitionBase } from "tfjs-image-recognition-base";
import { ConvParams, SeparableConvParams } from '../common';
export declare type ReductionBlockParams = {
separable_conv0: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv1: TfjsImageRecognitionBase.SeparableConvParams;
expansion_conv: TfjsImageRecognitionBase.ConvParams;
separable_conv0: SeparableConvParams;
separable_conv1: SeparableConvParams;
expansion_conv: ConvParams;
};
export declare type MainBlockParams = {
separable_conv0: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv1: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv2: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv0: SeparableConvParams;
separable_conv1: SeparableConvParams;
separable_conv2: SeparableConvParams;
};
export declare type TinyXceptionParams = {
entry_flow: {
conv_in: TfjsImageRecognitionBase.ConvParams;
conv_in: ConvParams;
reduction_block_0: ReductionBlockParams;

@@ -21,4 +21,4 @@ reduction_block_1: ReductionBlockParams;

reduction_block: ReductionBlockParams;
separable_conv: TfjsImageRecognitionBase.SeparableConvParams;
separable_conv: SeparableConvParams;
};
};

@@ -1,9 +0,6 @@

let spec_files = ['**/*.test.ts'].concat(
process.env.EXCLUDE_UNCOMPRESSED
? ['!**/*.uncompressed.test.ts']
: []
)
let spec_files = ['**/*.test.ts']
// exclude browser tests
spec_files = spec_files.concat(['!**/*.browser.test.ts'])
spec_files = spec_files.concat(['!**/tests-legacy/**/*.ts'])

@@ -10,0 +7,0 @@ module.exports = {

@@ -5,2 +5,3 @@ const dataFiles = [

'test/data/*.json',
'test/data/*.weights',
'test/media/*.mp4',

@@ -25,4 +26,3 @@ 'weights/**/*',

'ssdMobilenetv1',
'tinyFaceDetector',
'mtcnn'
'tinyFaceDetector'
]

@@ -34,12 +34,6 @@ : []

exclude = exclude.concat(
process.env.EXCLUDE_UNCOMPRESSED
? ['**/*.uncompressed.test.ts']
: []
)
// exclude nodejs tests
exclude = exclude.concat(['**/*.node.test.ts'])
exclude = exclude.concat(['test/env.node.ts'])
exclude = exclude.concat(['test/tests-legacy/**/*.ts'])

@@ -46,0 +40,0 @@

{
"name": "face-api.js",
"version": "0.21.0",
"version": "0.22.0",
"description": "JavaScript API for face detection and face recognition in the browser with tensorflow.js",

@@ -14,7 +14,5 @@ "module": "./build/es6/index.js",

"build": "rm -rf ./build && rm -rf ./dist && npm run rollup && npm run rollup-min && npm run tsc && npm run tsc-es6",
"test": "karma start",
"test": "npm run test-browser && npm run test-node",
"test-browser": "karma start --single-run",
"test-node": "ts-node -r ./test/env.node.ts node_modules/jasmine/bin/jasmine --config=jasmine-node.js",
"test-all": "npm run test-browser-exclude-uncompressed && npm run test-node-exclude-uncompressed",
"test-all-include-uncompressed": "npm run test-browser && npm run test-node",
"test-facelandmarknets": "set UUT=faceLandmarkNet&& karma start",

@@ -26,7 +24,3 @@ "test-facerecognitionnet": "set UUT=faceRecognitionNet&& karma start",

"test-globalapi": "set UUT=globalApi&& karma start",
"test-mtcnn": "set UUT=mtcnn&& karma start",
"test-cpu": "set BACKEND_CPU=true&& karma start",
"test-exclude-uncompressed": "set EXCLUDE_UNCOMPRESSED=true&& karma start",
"test-browser-exclude-uncompressed": "set EXCLUDE_UNCOMPRESSED=true&& karma start --single-run",
"test-node-exclude-uncompressed": "set EXCLUDE_UNCOMPRESSED=true&& npm run test-node",
"docs": "typedoc --options ./typedoc.config.js ./src"

@@ -44,25 +38,24 @@ },

"dependencies": {
"@tensorflow/tfjs-core": "1.2.9",
"tfjs-image-recognition-base": "^0.6.2",
"@tensorflow/tfjs-core": "1.4.0",
"tslib": "^1.10.0"
},
"devDependencies": {
"@tensorflow/tfjs-node": "^1.2.9",
"@types/jasmine": "^3.4.0",
"@types/node": "^12.7.5",
"canvas": "2.5.0",
"jasmine": "^3.4.0",
"jasmine-core": "^3.4.0",
"karma": "^4.3.0",
"karma-chrome-launcher": "^2.2.0",
"@tensorflow/tfjs-node": "1.4.0",
"@types/jasmine": "^3.5.0",
"@types/node": "^12.12.17",
"canvas": "2.6.0",
"jasmine": "^3.5.0",
"jasmine-core": "^3.5.0",
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-jasmine": "^2.0.1",
"karma-typescript": "^4.1.1",
"rollup": "^1.21.2",
"rollup": "^1.27.13",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-typescript2": "^0.24.2",
"rollup-plugin-uglify": "^6.0.3",
"ts-node": "^8.3.0",
"typescript": "^3.6.3"
"rollup-plugin-typescript2": "^0.25.3",
"rollup-plugin-uglify": "^6.0.4",
"ts-node": "^8.5.4",
"typescript": "^3.7.3"
}
}

@@ -28,3 +28,3 @@ # face-api.js

* **[Loading the Models](#getting-started-loading-models)**
* **[High Level API](#getting-started-high-level-api)**
* **[High Level API](#high-level-api)**
* **[Displaying Detection Results](#getting-started-displaying-detection-results)**

@@ -139,4 +139,3 @@ * **[Face Detection Options](#getting-started-face-detection-options)**

// patch nodejs environment, we need to provide an implementation of
// HTMLCanvasElement and HTMLImageElement, additionally an implementation
// of ImageData is required, in case you want to use the MTCNN
// HTMLCanvasElement and HTMLImageElement
const { Canvas, Image, ImageData } = canvas

@@ -165,3 +164,2 @@ faceapi.env.monkeyPatch({ Canvas, Image, ImageData })

// tinyFaceDetector
// mtcnn
// tinyYolov2

@@ -252,3 +250,2 @@ ```

const detections2 = await faceapi.detectAllFaces(input, new faceapi.TinyFaceDetectorOptions())
const detections3 = await faceapi.detectAllFaces(input, new faceapi.MtcnnOptions())
```

@@ -599,36 +596,2 @@

### MtcnnOptions
``` javascript
export interface IMtcnnOptions {
// minimum face size to expect, the higher the faster processing will be,
// but smaller faces won't be detected
// default: 20
minFaceSize?: number
// the score threshold values used to filter the bounding
// boxes of stage 1, 2 and 3
// default: [0.6, 0.7, 0.7]
scoreThresholds?: number[]
// scale factor used to calculate the scale steps of the image
// pyramid used in stage 1
// default: 0.709
scaleFactor?: number
// number of scaled versions of the input image passed through the CNN
// of the first stage, lower numbers will result in lower inference time,
// but will also be less accurate
// default: 10
maxNumScales?: number
// instead of specifying scaleFactor and maxNumScales you can also
// set the scaleSteps manually
scaleSteps?: number[]
}
// example
const options = new faceapi.MtcnnOptions({ minFaceSize: 100, scaleFactor: 0.8 })
```
<a name="getting-started-utility-classes"></a>

@@ -734,3 +697,2 @@

const detections2 = await faceapi.tinyFaceDetector(input, options)
const detections3 = await faceapi.mtcnn(input, options)
const landmarks1 = await faceapi.detectFaceLandmarks(faceImage)

@@ -848,10 +810,2 @@ const landmarks2 = await faceapi.detectFaceLandmarksTiny(faceImage)

### MTCNN
**Note, this model is mostly kept in this repo for experimental reasons. In general the other face detectors should perform better, but of course you are free to play around with MTCNN.**
MTCNN (Multi-task Cascaded Convolutional Neural Networks) represents an alternative face detector to SSD Mobilenet v1 and Tiny Yolo v2, which offers much more room for configuration. By tuning the input parameters, MTCNN should be able to detect a wide range of face bounding box sizes. MTCNN is a 3 stage cascaded CNN, which simultaneously returns 5 face landmark points along with the bounding boxes and scores for each face. Additionally the model size is only 2MB.
MTCNN has been presented in the paper [Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks](https://kpzhang93.github.io/MTCNN_face_detection_alignment/paper/spl.pdf) by Zhang et al. and the model weights are provided in the official [repo](https://github.com/kpzhang93/MTCNN_face_detection_alignment) of the MTCNN implementation.
<a name="models-face-landmark-detection"></a>

@@ -858,0 +812,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc