Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
rebuild types
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic committed Jan 17, 2024
1 parent 4719b81 commit 697b265
Show file tree
Hide file tree
Showing 20 changed files with 98 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"output": "build.log"
},
"profiles": {
"production": ["compile", "typedoc", "lint", "changelog"],
"production": ["compile", "typings", "typedoc", "lint", "changelog"],
"development": ["serve", "watch", "compile"]
},
"clean": {
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

## Changelog

### **HEAD -> master** 2024/01/17 mandic00@live.com


### **1.7.13** 2024/01/17 mandic00@live.com


Expand Down
2 changes: 1 addition & 1 deletion dist/face-api.esm.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
},
"scripts": {
"start": "node --no-warnings demo/node.js",
"dev": "build --profile development",
"build": "node build.js",
"dev": "build --profile development",
"typings": "build --profile typings",
"lint": "eslint src/ demo/",
"test": "node --trace-warnings test/test-node.js",
"scan": "npx auditjs@latest ossi --dev --quiet"
Expand Down
53 changes: 38 additions & 15 deletions types/face-api.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="../src/types/webgpu.d.ts" />
/// <reference types="node" />

declare const add: typeof add_;

Expand Down Expand Up @@ -1221,7 +1222,7 @@ export declare function extractFaces(input: TNetInput, detections: Array<FaceDet
*/
export declare function extractFaceTensors(imageTensor: tf.Tensor3D | tf.Tensor4D, detections: Array<FaceDetection | Rect>): Promise<tf.Tensor3D[]>;

export declare const FACE_EXPRESSION_LABELS: string[];
export declare const FACE_EXPRESSION_LABELS: readonly ["neutral", "happy", "sad", "angry", "fearful", "disgusted", "surprised"];

export declare class FaceDetection extends ObjectDetection implements IFaceDetecion {
constructor(score: number, relativeBox: Rect, imageDims: IDimensions);
Expand All @@ -1239,7 +1240,7 @@ export declare class FaceExpressionNet extends FaceProcessor<FaceFeatureExtracto
constructor(faceFeatureExtractor?: FaceFeatureExtractor);
forwardInput(input: NetInput | tf.Tensor4D): tf.Tensor2D;
forward(input: TNetInput): Promise<tf.Tensor2D>;
predictExpressions(input: TNetInput): Promise<any>;
predictExpressions(input: TNetInput): Promise<FaceExpressions | FaceExpressions[]>;
protected getDefaultModelName(): string;
protected getClassifierChannelsIn(): number;
protected getClassifierChannelsOut(): number;
Expand All @@ -1255,7 +1256,7 @@ export declare class FaceExpressions {
surprised: number;
constructor(probabilities: number[] | Float32Array);
asSortedArray(): {
expression: string;
expression: "neutral" | "happy" | "sad" | "angry" | "fearful" | "disgusted" | "surprised";
probability: number;
}[];
}
Expand Down Expand Up @@ -1431,7 +1432,7 @@ export declare function fetchOrThrow(url: string, init?: RequestInit): Promise<R
export declare function fetchVideo(uri: string): Promise<HTMLVideoElement>;

declare type FileSystem_2 = {
readFile: (filePath: string) => Promise<any>;
readFile: (filePath: string) => Promise<string | Buffer>;
};
export { FileSystem_2 as FileSystem }

Expand Down Expand Up @@ -2113,6 +2114,12 @@ declare function loadWeights(manifest: WeightsManifestConfig, filePathPrefix?: s

export declare const locateFaces: (input: TNetInput, options: SsdMobilenetv1Options) => Promise<FaceDetection[]>;

declare type MainBlockParams = {
separable_conv0: SeparableConvParams;
separable_conv1: SeparableConvParams;
separable_conv2: SeparableConvParams;
};

export declare function matchDimensions(input: IDimensions, reference: IDimensions, useMediaDimensions?: boolean): {
width: number;
height: number;
Expand Down Expand Up @@ -2616,15 +2623,15 @@ export declare abstract class NeuralNetwork<TNetParams> {
reassignParamFromPath(paramPath: string, tensor: tf.Tensor): void;
getParamList(): {
path: string;
tensor: tf.Tensor;
tensor: tf.Tensor<tf.Rank>;
}[];
getTrainableParams(): {
path: string;
tensor: tf.Tensor;
tensor: tf.Tensor<tf.Rank>;
}[];
getFrozenParams(): {
path: string;
tensor: tf.Tensor;
tensor: tf.Tensor<tf.Rank>;
}[];
variable(): void;
freeze(): void;
Expand Down Expand Up @@ -2834,8 +2841,8 @@ export declare const predictAgeAndGender: (input: TNetInput) => Promise<AgeAndGe
declare class PredictAgeAndGenderTaskBase<TReturn, TParentReturn> extends ComposableTask<TReturn> {
protected parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>;
protected input: TNetInput;
protected extractedFaces?: any[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: any[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}

declare class PredictAllAgeAndGenderTask<TSource extends WithFaceDetection<{}>> extends PredictAgeAndGenderTaskBase<WithAge<WithGender<TSource>>[], TSource[]> {
Expand Down Expand Up @@ -2870,8 +2877,8 @@ export declare class PredictedBox extends LabeledBox {
declare class PredictFaceExpressionsTaskBase<TReturn, TParentReturn> extends ComposableTask<TReturn> {
protected parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>;
protected input: TNetInput;
protected extractedFaces?: any[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: any[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}

declare type PredictionLayerParams = {
Expand Down Expand Up @@ -3316,8 +3323,14 @@ declare function softmax_<T extends Tensor>(logits: T | TensorLike, dim?: number

export declare class SsdMobilenetv1 extends NeuralNetwork<NetParams_4> {
constructor();
forwardInput(input: NetInput): any;
forward(input: TNetInput): Promise<any>;
forwardInput(input: NetInput): {
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
};
forward(input: TNetInput): Promise<{
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
}>;
locateFaces(input: TNetInput, options?: ISsdMobilenetv1Options): Promise<FaceDetection[]>;
protected getDefaultModelName(): string;
protected extractParamsFromWeightMap(weightMap: tf.NamedTensorMap): {
Expand Down Expand Up @@ -4116,7 +4129,7 @@ declare type TinyXceptionParams = {
reduction_block_0: ReductionBlockParams;
reduction_block_1: ReductionBlockParams;
};
middle_flow: any;
middle_flow: Record<`main_block_${number}`, MainBlockParams>;
exit_flow: {
reduction_block: ReductionBlockParams;
separable_conv: SeparableConvParams;
Expand Down Expand Up @@ -4165,7 +4178,7 @@ declare class TinyYolov2Base extends NeuralNetwork<TinyYolov2NetParams> {
params: TinyYolov2NetParams;
paramMappings: ParamMapping[];
};
protected extractBoxes(outputTensor: tf.Tensor4D, inputBlobDimensions: Dimensions, scoreThreshold?: number): Promise<any>;
protected extractBoxes(outputTensor: tf.Tensor4D, inputBlobDimensions: Dimensions, scoreThreshold?: number): Promise<TinyYolov2ExtractBoxesResult[]>;
private extractPredictedClass;
}

Expand All @@ -4180,6 +4193,16 @@ export declare type TinyYolov2Config = {
isFirstLayerConv2d?: boolean;
};

export declare type TinyYolov2ExtractBoxesResult = {
box: BoundingBox;
score: number;
classScore: number;
label: number;
row: number;
col: number;
anchor: number;
};

export declare type TinyYolov2NetParams = DefaultTinyYolov2NetParams | MobilenetParams;

export declare class TinyYolov2Options {
Expand Down
6 changes: 3 additions & 3 deletions types/lib/src/NeuralNetwork.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export declare abstract class NeuralNetwork<TNetParams> {
reassignParamFromPath(paramPath: string, tensor: tf.Tensor): void;
getParamList(): {
path: string;
tensor: tf.Tensor;
tensor: tf.Tensor<tf.Rank>;
}[];
getTrainableParams(): {
path: string;
tensor: tf.Tensor;
tensor: tf.Tensor<tf.Rank>;
}[];
getFrozenParams(): {
path: string;
tensor: tf.Tensor;
tensor: tf.Tensor<tf.Rank>;
}[];
variable(): void;
freeze(): void;
Expand Down
3 changes: 2 additions & 1 deletion types/lib/src/env/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference types="node" />
export type FileSystem = {
readFile: (filePath: string) => Promise<any>;
readFile: (filePath: string) => Promise<string | Buffer>;
};
export type Environment = FileSystem & {
Canvas: typeof HTMLCanvasElement;
Expand Down
3 changes: 2 additions & 1 deletion types/lib/src/faceExpressionNet/FaceExpressionNet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { NetInput, TNetInput } from '../dom/index';
import { FaceFeatureExtractor } from '../faceFeatureExtractor/FaceFeatureExtractor';
import { FaceFeatureExtractorParams } from '../faceFeatureExtractor/types';
import { FaceProcessor } from '../faceProcessor/FaceProcessor';
import { FaceExpressions } from './FaceExpressions';
export declare class FaceExpressionNet extends FaceProcessor<FaceFeatureExtractorParams> {
constructor(faceFeatureExtractor?: FaceFeatureExtractor);
forwardInput(input: NetInput | tf.Tensor4D): tf.Tensor2D;
forward(input: TNetInput): Promise<tf.Tensor2D>;
predictExpressions(input: TNetInput): Promise<any>;
predictExpressions(input: TNetInput): Promise<FaceExpressions | FaceExpressions[]>;
protected getDefaultModelName(): string;
protected getClassifierChannelsIn(): number;
protected getClassifierChannelsOut(): number;
Expand Down
4 changes: 2 additions & 2 deletions types/lib/src/faceExpressionNet/FaceExpressions.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export declare const FACE_EXPRESSION_LABELS: string[];
export declare const FACE_EXPRESSION_LABELS: readonly ["neutral", "happy", "sad", "angry", "fearful", "disgusted", "surprised"];
export declare class FaceExpressions {
neutral: number;
happy: number;
Expand All @@ -9,7 +9,7 @@ export declare class FaceExpressions {
surprised: number;
constructor(probabilities: number[] | Float32Array);
asSortedArray(): {
expression: string;
expression: "neutral" | "happy" | "sad" | "angry" | "fearful" | "disgusted" | "surprised";
probability: number;
}[];
}
5 changes: 3 additions & 2 deletions types/lib/src/globalApi/PredictAgeAndGenderTask.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as tf from '../../dist/tfjs.esm';
import { TNetInput } from '../dom/index';
import { WithAge } from '../factories/WithAge';
import { WithFaceDetection } from '../factories/WithFaceDetection';
Expand All @@ -9,8 +10,8 @@ import { PredictAllFaceExpressionsTask, PredictAllFaceExpressionsWithFaceAlignme
export declare class PredictAgeAndGenderTaskBase<TReturn, TParentReturn> extends ComposableTask<TReturn> {
protected parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>;
protected input: TNetInput;
protected extractedFaces?: any[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: any[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}
export declare class PredictAllAgeAndGenderTask<TSource extends WithFaceDetection<{}>> extends PredictAgeAndGenderTaskBase<WithAge<WithGender<TSource>>[], TSource[]> {
run(): Promise<WithAge<WithGender<TSource>>[]>;
Expand Down
5 changes: 3 additions & 2 deletions types/lib/src/globalApi/PredictFaceExpressionsTask.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as tf from '../../dist/tfjs.esm';
import { TNetInput } from '../dom/index';
import { WithFaceDetection } from '../factories/WithFaceDetection';
import { WithFaceExpressions } from '../factories/WithFaceExpressions';
Expand All @@ -8,8 +9,8 @@ import { PredictAllAgeAndGenderTask, PredictAllAgeAndGenderWithFaceAlignmentTask
export declare class PredictFaceExpressionsTaskBase<TReturn, TParentReturn> extends ComposableTask<TReturn> {
protected parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>;
protected input: TNetInput;
protected extractedFaces?: any[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: any[] | undefined);
protected extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined;
constructor(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: TNetInput, extractedFaces?: (tf.Tensor3D | HTMLCanvasElement)[] | undefined);
}
export declare class PredictAllFaceExpressionsTask<TSource extends WithFaceDetection<{}>> extends PredictFaceExpressionsTaskBase<WithFaceExpressions<TSource>[], TSource[]> {
run(): Promise<WithFaceExpressions<TSource>[]>;
Expand Down
10 changes: 8 additions & 2 deletions types/lib/src/ssdMobilenetv1/SsdMobilenetv1.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import { ISsdMobilenetv1Options } from './SsdMobilenetv1Options';
import { NetParams } from './types';
export declare class SsdMobilenetv1 extends NeuralNetwork<NetParams> {
constructor();
forwardInput(input: NetInput): any;
forward(input: TNetInput): Promise<any>;
forwardInput(input: NetInput): {
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
};
forward(input: TNetInput): Promise<{
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
}>;
locateFaces(input: TNetInput, options?: ISsdMobilenetv1Options): Promise<FaceDetection[]>;
protected getDefaultModelName(): string;
protected extractParamsFromWeightMap(weightMap: tf.NamedTensorMap): {
Expand Down
5 changes: 4 additions & 1 deletion types/lib/src/ssdMobilenetv1/boxPredictionLayer.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import * as tf from '../../dist/tfjs.esm';
import { BoxPredictionParams } from './types';
export declare function boxPredictionLayer(x: tf.Tensor4D, params: BoxPredictionParams): any;
export declare function boxPredictionLayer(x: tf.Tensor4D, params: BoxPredictionParams): {
boxPredictionEncoding: tf.Tensor<tf.Rank>;
classPrediction: tf.Tensor<tf.Rank>;
};
5 changes: 4 additions & 1 deletion types/lib/src/ssdMobilenetv1/mobileNetV1.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import * as tf from '../../dist/tfjs.esm';
import { MobileNetV1 } from './types';
export declare function mobileNetV1(x: tf.Tensor4D, params: MobileNetV1.Params): any;
export declare function mobileNetV1(x: tf.Tensor4D, params: MobileNetV1.Params): {
out: tf.Tensor4D;
conv11: any;
};
5 changes: 4 additions & 1 deletion types/lib/src/ssdMobilenetv1/outputLayer.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import * as tf from '../../dist/tfjs.esm';
import { OutputLayerParams } from './types';
export declare function outputLayer(boxPredictions: tf.Tensor4D, classPredictions: tf.Tensor4D, params: OutputLayerParams): any;
export declare function outputLayer(boxPredictions: tf.Tensor4D, classPredictions: tf.Tensor4D, params: OutputLayerParams): {
boxes: tf.Tensor2D[];
scores: tf.Tensor1D[];
};
2 changes: 1 addition & 1 deletion types/lib/src/ssdMobilenetv1/pointwiseConvLayer.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import * as tf from '../../dist/tfjs.esm';
import { PointwiseConvParams } from './types';
export declare function pointwiseConvLayer(x: tf.Tensor4D, params: PointwiseConvParams, strides: [number, number]): any;
export declare function pointwiseConvLayer(x: tf.Tensor4D, params: PointwiseConvParams, strides: [number, number]): tf.Tensor4D;
5 changes: 4 additions & 1 deletion types/lib/src/ssdMobilenetv1/predictionLayer.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import * as tf from '../../dist/tfjs.esm';
import { PredictionLayerParams } from './types';
export declare function predictionLayer(x: tf.Tensor4D, conv11: tf.Tensor4D, params: PredictionLayerParams): any;
export declare function predictionLayer(x: tf.Tensor4D, conv11: tf.Tensor4D, params: PredictionLayerParams): {
boxPredictions: tf.Tensor4D;
classPredictions: tf.Tensor4D;
};
4 changes: 2 additions & 2 deletions types/lib/src/tinyYolov2/TinyYolov2Base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TNetInput } from '../dom/types';
import { NeuralNetwork } from '../NeuralNetwork';
import { TinyYolov2Config } from './config';
import { ITinyYolov2Options } from './TinyYolov2Options';
import { DefaultTinyYolov2NetParams, MobilenetParams, TinyYolov2NetParams } from './types';
import { DefaultTinyYolov2NetParams, MobilenetParams, TinyYolov2ExtractBoxesResult, TinyYolov2NetParams } from './types';
export declare class TinyYolov2Base extends NeuralNetwork<TinyYolov2NetParams> {
static DEFAULT_FILTER_SIZES: number[];
private _config;
Expand All @@ -28,6 +28,6 @@ export declare class TinyYolov2Base extends NeuralNetwork<TinyYolov2NetParams> {
params: TinyYolov2NetParams;
paramMappings: import("../common/types").ParamMapping[];
};
protected extractBoxes(outputTensor: tf.Tensor4D, inputBlobDimensions: Dimensions, scoreThreshold?: number): Promise<any>;
protected extractBoxes(outputTensor: tf.Tensor4D, inputBlobDimensions: Dimensions, scoreThreshold?: number): Promise<TinyYolov2ExtractBoxesResult[]>;
private extractPredictedClass;
}
10 changes: 10 additions & 0 deletions types/lib/src/tinyYolov2/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as tf from '../../dist/tfjs.esm';
import { BoundingBox } from '../classes';
import { ConvParams } from '../common/index';
import { SeparableConvParams } from '../common/types';
export type BatchNorm = {
Expand Down Expand Up @@ -32,3 +33,12 @@ export type DefaultTinyYolov2NetParams = {
conv8: ConvParams;
};
export type TinyYolov2NetParams = DefaultTinyYolov2NetParams | MobilenetParams;
export type TinyYolov2ExtractBoxesResult = {
box: BoundingBox;
score: number;
classScore: number;
label: number;
row: number;
col: number;
anchor: number;
};
2 changes: 1 addition & 1 deletion types/lib/src/xception/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type TinyXceptionParams = {
reduction_block_0: ReductionBlockParams;
reduction_block_1: ReductionBlockParams;
};
middle_flow: any;
middle_flow: Record<`main_block_${number}`, MainBlockParams>;
exit_flow: {
reduction_block: ReductionBlockParams;
separable_conv: SeparableConvParams;
Expand Down

0 comments on commit 697b265

Please sign in to comment.