diff --git a/build/package.json b/build/package.json index 8acd0bb..b171c2a 100644 --- a/build/package.json +++ b/build/package.json @@ -2,11 +2,8 @@ "name": "@vladmandic/face-api", "version": "0.5.1", "description": "JavaScript module for Face Detection and Face Recognition Using Tensorflow/JS", - "main": "dist/face-api.cjs", - "module": "dist/face-api.ejs", - "browser": "dist/face-api.js", - "jsdelivr": "dist/face-api.js", - "unpkg": "dist/face-api.js", + "main": "dist/face-api.esm.js", + "browser": "dist/face-api.min.js", "typings": "./build/src/index.d.ts", "engines": { "node": ">=12.0.0" @@ -14,10 +11,10 @@ "type": "module", "scripts": { "compile": "tsc", - "clean": "rimraf /build /dist", - "cjs": "esbuild --bundle --outfile=./dist/face-api.cjs --target=es2017 --platform=node --format=cjs --sourcemap --log-level=error --tsconfig=./tsconfig.json build/src/index.js", - "esm": "esbuild --bundle --outfile=./dist/face-api.ejs --target=es2017 --platform=browser --format=esm --sourcemap --log-level=error --tsconfig=./tsconfig.json build/src/index.js", - "iife": "esbuild --bundle --outfile=./dist/face-api.js --target=es2017 --platform=browser --format=iife --global-name=faceapi --sourcemap --log-level=error --tsconfig=./tsconfig.json build/src/index.js", + "clean": "rimraf build dist", + "cjs": "esbuild --bundle --outfile=./dist/face-api.cjs.js --target=es2017 --platform=browser --format=cjs --sourcemap --log-level=error --tsconfig=./tsconfig.json build/src/index.js", + "esm": "esbuild --bundle --outfile=./dist/face-api.esm.js --target=es2017 --platform=browser --format=esm --sourcemap --log-level=error --tsconfig=./tsconfig.json build/src/index.js", + "iife": "esbuild --bundle --outfile=./dist/face-api.iife.js --target=es2017 --platform=browser --format=iife --global-name=faceapi --sourcemap --log-level=error --tsconfig=./tsconfig.json build/src/index.js", "minify": "esbuild --bundle --outfile=./dist/face-api.min.js --target=es2017 --platform=browser --format=iife --sourcemap --global-name=faceapi --log-level=error --minify --tsconfig=./tsconfig.json build/src/index.js", "build": "npm run clean && npm run compile && npm run cjs && npm run esm && npm run iife && npm run minify" }, @@ -44,14 +41,14 @@ }, "homepage": "https://github.com/vladmandic/face-api#readme", "dependencies": { - "@tensorflow/tfjs-core": "^2.3.0" + "@tensorflow/tfjs-core": "^2.4.0" }, "devDependencies": { - "@types/node": "^14.6.4", - "esbuild": "^0.6.32", + "@types/node": "^14.10.2", + "esbuild": "^0.6.34", + "rimraf": "^3.0.2", "ts-node": "^9.0.0", "tslib": "^2.0.1", - "typescript": "^4.1.0-dev.20200908", - "rimraf": "^3.0.2" + "typescript": "^4.1.0-dev.20200916" } } diff --git a/build/src/NeuralNetwork.d.ts.map b/build/src/NeuralNetwork.d.ts.map index da8372a..65649b7 100644 --- a/build/src/NeuralNetwork.d.ts.map +++ b/build/src/NeuralNetwork.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"NeuralNetwork.d.ts","sourceRoot":"","sources":["../../src/NeuralNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAKxC,8BAAsB,aAAa,CAAC,UAAU;IAKhC,SAAS,CAAC,KAAK,EAAE,MAAM;IAHnC,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAY;IACrD,SAAS,CAAC,cAAc,EAAE,YAAY,EAAE,CAAK;gBAEvB,KAAK,EAAE,MAAM;IASnC,IAAW,MAAM,IAAI,UAAU,GAAG,SAAS,CAAwB;IACnE,IAAW,aAAa,IAAI,YAAY,EAAE,CAA+B;IACzE,IAAW,QAAQ,IAAI,OAAO,CAAyB;IAEhD,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM;IAK9C,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM;IAM1D,YAAY;;;;IAOZ,kBAAkB;;;;IAIlB,eAAe;;;;IAIf,QAAQ;IAMR,MAAM;IAQN,OAAO,CAAC,gBAAgB,GAAE,OAAc;IAUxC,eAAe,IAAI,YAAY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,CAAC,MAAM;IAK9C,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM;IAM1D,YAAY;;;;IAOZ,kBAAkB;;;;IAIlB,eAAe;;;;IAIf,QAAQ;IAMR,MAAM;IAQN,OAAO,CAAC,gBAAgB,GAAE,OAAc;IAUxC,eAAe,IAAI,YAAY;IAQzB,IAAI,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IASpE,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IASnC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS;IAoB/C,iBAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,cAAc;IAU9C,cAAc,CAAC,OAAO,EAAE,YAAY;IAU3C,OAAO,CAAC,oBAAoB;IAqB5B,SAAS,CAAC,QAAQ,CAAC,mBAAmB,IAAI,MAAM;IAChD,SAAS,CAAC,QAAQ,CAAC,0BAA0B,CAAC,SAAS,EAAE,EAAE,CAAC,cAAc,GAAG;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,aAAa,EAAE,YAAY,EAAE,CAAA;KAAE;IAClI,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG;QAAE,MAAM,EAAE,UAAU,CAAC;QAAC,aAAa,EAAE,YAAY,EAAE,CAAA;KAAE;CAC/G"} \ No newline at end of file diff --git a/build/src/NeuralNetwork.js b/build/src/NeuralNetwork.js index 740cd39..87ded09 100644 --- a/build/src/NeuralNetwork.js +++ b/build/src/NeuralNetwork.js @@ -7,13 +7,14 @@ export class NeuralNetwork { this._name = _name; this._params = undefined; this._paramMappings = []; + /* try { - const testTensor = tf.tensor([0]); - testTensor.toFloat(); - } - catch (err) { - throw new Error(`module not loaded: load '@tensorflow/tfjs' or '@tensorflow/tfjs-core' with appropriate backend explicitly: ${err}`); + const testTensor = tf.tensor([0]); + testTensor.toFloat(); + } catch (err) { + throw new Error(`tfjs module not loaded: load '@tensorflow/tfjs' or '@tensorflow/tfjs-core' with appropriate backend explicitly`); } + */ } get params() { return this._params; } get paramMappings() { return this._paramMappings; } diff --git a/build/src/NeuralNetwork.js.map b/build/src/NeuralNetwork.js.map index 3b26462..b264e2c 100644 --- a/build/src/NeuralNetwork.js.map +++ b/build/src/NeuralNetwork.js.map @@ -1 +1 @@ -{"version":3,"file":"NeuralNetwork.js","sourceRoot":"","sources":["../../src/NeuralNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAG5C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,MAAM,OAAgB,aAAa;IAKjC,YAAsB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;QAHzB,YAAO,GAA2B,SAAS,CAAA;QAC3C,mBAAc,GAAmB,EAAE,CAAA;QAG3C,IAAI;YACF,MAAM,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAClC,UAAU,CAAC,OAAO,EAAE,CAAC;SACtB;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,8GAA8G,GAAG,EAAE,CAAC,CAAA;SACpI;IACJ,CAAC;IAED,IAAW,MAAM,KAA6B,OAAO,IAAI,CAAC,OAAO,CAAA,CAAC,CAAC;IACnE,IAAW,aAAa,KAAqB,OAAO,IAAI,CAAC,cAAc,CAAA,CAAC,CAAC;IACzE,IAAW,QAAQ,KAAc,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA,CAAC,CAAC;IAEhD,gBAAgB,CAAC,SAAiB;QACvC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAA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KAAK,CAAC,mDAAmD,CAAC,CAAA;SACrE;QAED,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAkD,EAAE,OAAO,EAAE,EAAE;YACzG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;gBACxC,MAAM,IAAI,KAAK,CAAC,wDAAwD,OAAO,cAAc,SAAS,EAAE,CAAC,CAAA;aAC1G;YAED,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAA;QACrE,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QAE5B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;QAC/B,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE;YAC5D,MAAM,IAAI,KAAK,CAAC,8DAA8D,SAAS,EAAE,CAAC,CAAA;SAC3F;QAED,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAA;IACzB,CAAC;CAKF"} \ No newline at end of file diff --git a/build/src/resizeResults.js b/build/src/resizeResults.js index 2d5ec8a..93cd9eb 100644 --- a/build/src/resizeResults.js +++ b/build/src/resizeResults.js @@ -9,6 +9,7 @@ export function resizeResults(results, dimensions) { throw new Error(`resizeResults - invalid dimensions: ${JSON.stringify({ width, height })}`); } if (Array.isArray(results)) { + // return results.map(obj => resizeResults(obj, { width, height })) as any as T return results.map(obj => resizeResults(obj, { width, height })); } if (isWithFaceLandmarks(results)) { diff --git a/build/src/resizeResults.js.map b/build/src/resizeResults.js.map index a041f3b..091f9f8 100644 --- a/build/src/resizeResults.js.map +++ b/build/src/resizeResults.js.map @@ -1 +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AC,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAiB,CAAC,CAAa,CAAA;KAC5G;IAED,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;QAChC,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QACjE,MAAM,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACpH,OAAO,uBAAuB,CAAC,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,CAAA;KACrG;IAED,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE;QAChC,OAAO,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;KAClF;IAED,IAAI,OAAO,YAAY,aAAa,IAAI,OAAO,YAAY,aAAa,EAAE;QACxE,OAAQ,OAAe,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;KAC/C;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"} \ No newline at end of file diff --git a/build/src/ssdMobilenetv1/mobileNetV1.js b/build/src/ssdMobilenetv1/mobileNetV1.js index 3d7fcd7..37f8bd2 100644 --- a/build/src/ssdMobilenetv1/mobileNetV1.js +++ b/build/src/ssdMobilenetv1/mobileNetV1.js @@ -13,7 +13,7 @@ function getStridesForLayerIdx(layerIdx) { } export function mobileNetV1(x, params) { return tf.tidy(() => { - let conv11 = null; + let conv11; let out = pointwiseConvLayer(x, params.conv_0, [2, 2]); const convPairParams = [ params.conv_1, diff --git a/build/src/ssdMobilenetv1/mobileNetV1.js.map b/build/src/ssdMobilenetv1/mobileNetV1.js.map index dd7d536..1ca5e39 100644 --- a/build/src/ssdMobilenetv1/mobileNetV1.js.map +++ b/build/src/ssdMobilenetv1/mobileNetV1.js.map @@ -1 +1 @@ -{"version":3,"file":"mobileNetV1.js","sourceRoot":"","sources":["../../../src/ssdMobilenetv1/mobileNetV1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,MAAM,OAAO,GAAG,qBAAqB,CAAA;AAErC,SAAS,kBAAkB,CACzB,CAAc,EACd,MAAuC,EACvC,OAAyB;IAEzB,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAElB,IAAI,GAAG,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;QAChE,GAAG,GAAG,EAAE,CAAC,SAAS,CAChB,GAAG,EACH,MAAM,CAAC,eAAe,EACtB,MAAM,CAAC,mBAAmB,EAC1B,MAAM,CAAC,iBAAiB,EACxB,MAAM,CAAC,gBAAgB,EACvB,OAAO,CACR,CAAA;QACD,OAAO,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAElC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACtE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAc,EAAE,MAA0B;IACpE,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAElB,IAAI,MAAM,GAAG,IAAI,CAAA;QACjB,IAAI,GAAG,GAAG,kBAAkB,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAEtD,MAAM,cAAc,GAAG;YACrB,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,OAAO;SACf,CAAA;QAED,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAClC,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAA;YACtB,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAC5D,GAAG,GAAG,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAA;YACzE,GAAG,GAAG,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;YAC3D,IAAI,QAAQ,KAAK,EAAE,EAAE;gBACnB,MAAM,GAAG,GAAG,CAAA;aACb;QACH,CAAC,CAAC,CAAA;QAEF,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;SACjE;QAED,OAAO;YACL,GAAG;YACH,MAAM,EAAE,MAAa;SACtB,CAAA;IAEH,CAAC,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"mobileNetV1.js","sourceRoot":"","sources":["../../../src/ssdMobilenetv1/mobileNetV1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAA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YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,MAAM;YACb,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,OAAO;YACd,MAAM,CAAC,OAAO;SACf,CAAA;QAED,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAClC,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAA;YACtB,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAC5D,GAAG,GAAG,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAA;YACzE,GAAG,GAAG,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;YAC3D,IAAI,QAAQ,KAAK,EAAE,EAAE;gBACnB,MAAM,GAAG,GAAG,CAAA;aACb;QACH,CAAC,CAAC,CAAA;QAEF,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;SACjE;QAED,OAAO;YACL,GAAG;YACH,MAAM,EAAE,MAAa;SACtB,CAAA;IAEH,CAAC,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file diff --git a/build/src/tinyYolov2/TinyYolov2Base.d.ts b/build/src/tinyYolov2/TinyYolov2Base.d.ts index 633c1a8..abd6a84 100644 --- a/build/src/tinyYolov2/TinyYolov2Base.d.ts +++ b/build/src/tinyYolov2/TinyYolov2Base.d.ts @@ -1,5 +1,4 @@ import * as tf from '@tensorflow/tfjs-core'; -import { BoundingBox } from '../classes/BoundingBox'; import { Dimensions } from '../classes/Dimensions'; import { ObjectDetection } from '../classes/ObjectDetection'; import { NetInput } from '../dom/NetInput'; @@ -29,15 +28,7 @@ export declare class TinyYolov2Base extends NeuralNetwork { params: TinyYolov2NetParams; paramMappings: import("../common").ParamMapping[]; }; - protected extractBoxes(outputTensor: tf.Tensor4D, inputBlobDimensions: Dimensions, scoreThreshold?: number): Promise<{ - row: number; - col: number; - anchor: number; - box: BoundingBox; - score: number; - classScore: number; - label: number; - }[]>; + protected extractBoxes(outputTensor: tf.Tensor4D, inputBlobDimensions: Dimensions, scoreThreshold?: number): Promise; private extractPredictedClass; } //# sourceMappingURL=TinyYolov2Base.d.ts.map \ No newline at end of file diff --git a/build/src/tinyYolov2/TinyYolov2Base.d.ts.map b/build/src/tinyYolov2/TinyYolov2Base.d.ts.map index ca79b71..de906ed 100644 --- a/build/src/tinyYolov2/TinyYolov2Base.d.ts.map +++ b/build/src/tinyYolov2/TinyYolov2Base.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"TinyYolov2Base.d.ts","sourceRoot":"","sources":["../../../src/tinyYolov2/TinyYolov2Base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAI7D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,OAAO,EAAE,gBAAgB,EAAkB,MAAM,UAAU,CAAC;AAM5D,OAAO,EAAE,kBAAkB,EAAqB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE3F,qBAAa,cAAe,SAAQ,aAAa,CAAC,mBAAmB,CAAC;IAEpE,OAAc,oBA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OAAO,EAAE,YAAY;;;;cAU7B,YAAY,CAC1B,YAAY,EAAE,EAAE,CAAC,QAAQ,EACzB,mBAAmB,EAAE,UAAU,EAC/B,cAAc,CAAC,EAAE,MAAM;YAgEX,qBAAqB;CAWpC"} \ No newline at end of file diff --git a/build/src/tinyYolov2/TinyYolov2Base.js.map b/build/src/tinyYolov2/TinyYolov2Base.js.map index 6a61a62..2329465 100644 --- a/build/src/tinyYolov2/TinyYolov2Base.js.map +++ b/build/src/tinyYolov2/TinyYolov2Base.js.map @@ -1 +1 @@ -{"version":3,"file":"TinyYolov2Base.js","sourceRoot":"","sources":["../../../src/tinyYolov2/TinyYolov2Base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAoB,cAAc,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAsB,iBAAiB,EAAE,MAAM,q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MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC/C,GAAG,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAC3B,UAAU;YACV,KAAK;SACN,CAAC,CAAC;aACF,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACzE,CAAC;;AAtOa,mCAAoB,GAAG;IACnC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;CACzC,CAAA"} \ No newline at end of file diff --git a/dist/face-api.cjs b/dist/face-api.cjs.js similarity index 98% rename from dist/face-api.cjs rename to dist/face-api.cjs.js index 6963ce1..84c3df9 100644 --- a/dist/face-api.cjs +++ b/dist/face-api.cjs.js @@ -519,6 +519,10 @@ var require_tychei = __commonJS((exports2, module2) => { })(exports2, typeof module2 == "object" && module2, typeof define == "function" && define); }); +// disabled:crypto +var require_disabled_crypto = __commonJS(() => { +}); + // node_modules/seedrandom/seedrandom.js var require_seedrandom = __commonJS((exports2, module2) => { (function(pool3, math) { @@ -638,7 +642,7 @@ var require_seedrandom = __commonJS((exports2, module2) => { if (typeof module2 == "object" && module2.exports) { module2.exports = seedrandom2; try { - nodecrypto = require("crypto"); + nodecrypto = require_disabled_crypto(); } catch (ex) { } } else if (typeof define == "function" && define.amd) { @@ -763,8 +767,8 @@ class Environment { } return this.flagRegistry[flagName].evaluationFn(); } - setFlags(flags2) { - this.flags = Object.assign({}, flags2); + setFlags(flags3) { + this.flags = Object.assign({}, flags3); } reset() { this.flags = {}; @@ -1174,8 +1178,8 @@ function shuffle(array) { array[index] = temp; } } -function clamp(min5, x, max7) { - return Math.max(min5, Math.min(x, max7)); +function clamp(min4, x, max6) { + return Math.max(min4, Math.min(x, max6)); } function nearestLargerEven(val) { return val % 2 === 0 ? val : val + 1; @@ -1664,11 +1668,12 @@ class Profiler { outputs = f(); }; const timer = this.backendTimer.time(holdResultWrapperFn); - outputs.map((r) => { - r.data().then((tensorVals) => { - checkComputationForErrors(tensorVals, r.dtype, kernelName); + for (let i = 0; i < outputs.length; i++) { + const output = outputs[i]; + output.data().then((tensorVals) => { + checkComputationForErrors(tensorVals, output.dtype, kernelName); }); - }); + } const kernelProfile = { kernelName, outputs, @@ -2181,7 +2186,7 @@ class Tensor { } Object.defineProperty(Tensor, Symbol.hasInstance, { value: (instance) => { - return !!instance && instance.dataId != null && instance.shape != null && instance.dtype != null; + return !!instance && instance.data != null && instance.dataSync != null && instance.throwIfDisposed != null; } }); class Variable extends Tensor { @@ -3249,6 +3254,7 @@ function convertToTensorArray(arg, argName, functionName, parseAsDtype = "numeri * limitations under the License. * ============================================================================= */ +const OP_SCOPE_SUFFIX = "__op"; function op(f) { const keys = Object.keys(f); if (keys.length !== 1) { @@ -3259,6 +3265,7 @@ function op(f) { if (opName.endsWith("_")) { opName = opName.substring(0, opName.length - 1); } + opName = opName + OP_SCOPE_SUFFIX; const f2 = (...args) => { ENGINE.startScope(opName); try { @@ -3277,6 +3284,2462 @@ function op(f) { return f2; } +// node_modules/@tensorflow/tfjs-core/dist/ops/complex.js +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function complex_(real6, imag6) { + const $real = convertToTensor(real6, "real", "complex"); + const $imag = convertToTensor(imag6, "imag", "complex"); + assertShapesMatch($real.shape, $imag.shape, `real and imag shapes, ${$real.shape} and ${$imag.shape}, must match in call to tf.complex().`); + const forward = (backend2) => { + return backend2.complex($real, $imag); + }; + const inputs = {real: $real, imag: $imag}; + return ENGINE.runKernelFunc(forward, inputs, null, Complex); +} +const complex = op({complex_}); + +// node_modules/@tensorflow/tfjs-core/dist/ops/tensor_ops_util.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function makeTensor(values, shape, inferredShape, dtype) { + if (dtype == null) { + dtype = inferDtype(values); + } + if (dtype === "complex64") { + throw new Error(`Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).`); + } + if (!isTypedArray(values) && !Array.isArray(values) && typeof values !== "number" && typeof values !== "boolean" && typeof values !== "string") { + throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray"); + } + if (shape != null) { + assertNonNegativeIntegerDimensions(shape); + const providedSize = sizeFromShape(shape); + const inferredSize = sizeFromShape(inferredShape); + assert(providedSize === inferredSize, () => `Based on the provided shape, [${shape}], the tensor should have ${providedSize} values but has ${inferredSize}`); + for (let i = 0; i < inferredShape.length; ++i) { + const inferred = inferredShape[i]; + const flatDimsDontMatch = i === inferredShape.length - 1 ? inferred !== sizeFromShape(shape.slice(i)) : true; + assert(inferredShape[i] === shape[i] || !flatDimsDontMatch, () => `Error creating a new Tensor. Inferred shape (${inferredShape}) does not match the provided shape (${shape}). `); + } + } + if (!isTypedArray(values) && !Array.isArray(values)) { + values = [values]; + } + shape = shape || inferredShape; + values = dtype !== "string" ? toTypedArray(values, dtype) : flatten(values, [], true); + return ENGINE.makeTensor(values, shape, dtype); +} + +// node_modules/@tensorflow/tfjs-core/dist/ops/tensor.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function tensor4(values, shape, dtype) { + const inferredShape = inferShape(values, dtype); + return makeTensor(values, shape, inferredShape, dtype); +} + +// node_modules/@tensorflow/tfjs-core/dist/io/types.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +const DTYPE_VALUE_SIZE_MAP = { + float32: 4, + float16: 2, + int32: 4, + uint16: 2, + uint8: 1, + bool: 1, + complex64: 8 +}; + +// node_modules/@tensorflow/tfjs-core/dist/io/io_utils.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +const NUM_BYTES_STRING_LENGTH = 4; +async function encodeWeights(tensors, group) { + const specs = []; + const dataPromises = []; + const names = Array.isArray(tensors) ? tensors.map((tensor17) => tensor17.name) : Object.keys(tensors); + for (let i = 0; i < names.length; ++i) { + const name = names[i]; + const t = Array.isArray(tensors) ? tensors[i].tensor : tensors[name]; + if (t.dtype !== "float32" && t.dtype !== "int32" && t.dtype !== "bool" && t.dtype !== "string" && t.dtype !== "complex64") { + throw new Error(`Unsupported dtype in weight '${name}': ${t.dtype}`); + } + const spec = {name, shape: t.shape, dtype: t.dtype}; + if (t.dtype === "string") { + const utf8bytes = new Promise(async (resolve) => { + const vals = await t.bytes(); + const totalNumBytes = vals.reduce((p, c) => p + c.length, 0) + NUM_BYTES_STRING_LENGTH * vals.length; + const bytes = new Uint8Array(totalNumBytes); + let offset = 0; + for (let i2 = 0; i2 < vals.length; i2++) { + const val = vals[i2]; + const bytesOfLength = new Uint8Array(new Uint32Array([val.length]).buffer); + bytes.set(bytesOfLength, offset); + offset += NUM_BYTES_STRING_LENGTH; + bytes.set(val, offset); + offset += val.length; + } + resolve(bytes); + }); + dataPromises.push(utf8bytes); + } else { + dataPromises.push(t.data()); + } + if (group != null) { + spec.group = group; + } + specs.push(spec); + } + const tensorValues = await Promise.all(dataPromises); + return {data: concatenateTypedArrays(tensorValues), specs}; +} +function decodeWeights(buffer11, specs) { + const out = {}; + let float16Decode; + let offset = 0; + for (const spec of specs) { + const name = spec.name; + const dtype = spec.dtype; + const shape = spec.shape; + const size = sizeFromShape(shape); + let values; + if ("quantization" in spec) { + const quantization = spec.quantization; + if (quantization.dtype === "uint8" || quantization.dtype === "uint16") { + if (!("min" in quantization && "scale" in quantization)) { + throw new Error(`Weight ${spec.name} with quantization ${quantization.dtype} doesn't have corresponding metadata min and scale.`); + } + } else if (quantization.dtype === "float16") { + if (dtype !== "float32") { + throw new Error(`Weight ${spec.name} is quantized with ${quantization.dtype} which only supports weights of type float32 not ${dtype}.`); + } + } else { + throw new Error(`Weight ${spec.name} has unknown quantization dtype ${quantization.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); + } + const quantizationSizeFactor = DTYPE_VALUE_SIZE_MAP[quantization.dtype]; + const byteBuffer = buffer11.slice(offset, offset + size * quantizationSizeFactor); + const quantizedArray = quantization.dtype === "uint8" ? new Uint8Array(byteBuffer) : new Uint16Array(byteBuffer); + if (dtype === "float32") { + if (quantization.dtype === "uint8" || quantization.dtype === "uint16") { + values = new Float32Array(quantizedArray.length); + for (let i = 0; i < quantizedArray.length; i++) { + const v = quantizedArray[i]; + values[i] = v * quantization.scale + quantization.min; + } + } else if (quantization.dtype === "float16") { + if (float16Decode === void 0) { + float16Decode = getFloat16Decoder(); + } + values = float16Decode(quantizedArray); + } else { + throw new Error(`Unsupported quantization type ${quantization.dtype} for weight type float32.`); + } + } else if (dtype === "int32") { + if (quantization.dtype !== "uint8" && quantization.dtype !== "uint16") { + throw new Error(`Unsupported quantization type ${quantization.dtype} for weight type int32.`); + } + values = new Int32Array(quantizedArray.length); + for (let i = 0; i < quantizedArray.length; i++) { + const v = quantizedArray[i]; + values[i] = Math.round(v * quantization.scale + quantization.min); + } + } else { + throw new Error(`Unsupported dtype in weight '${name}': ${dtype}`); + } + offset += size * quantizationSizeFactor; + } else if (dtype === "string") { + const size2 = sizeFromShape(spec.shape); + values = []; + for (let i = 0; i < size2; i++) { + const byteLength = new Uint32Array(buffer11.slice(offset, offset + NUM_BYTES_STRING_LENGTH))[0]; + offset += NUM_BYTES_STRING_LENGTH; + const bytes = new Uint8Array(buffer11.slice(offset, offset + byteLength)); + values.push(bytes); + offset += byteLength; + } + } else { + const dtypeFactor = DTYPE_VALUE_SIZE_MAP[dtype]; + const byteBuffer = buffer11.slice(offset, offset + size * dtypeFactor); + if (dtype === "float32") { + values = new Float32Array(byteBuffer); + } else if (dtype === "int32") { + values = new Int32Array(byteBuffer); + } else if (dtype === "bool") { + values = new Uint8Array(byteBuffer); + } else if (dtype === "complex64") { + values = new Float32Array(byteBuffer); + const real6 = new Float32Array(values.length / 2); + const image2 = new Float32Array(values.length / 2); + for (let i = 0; i < real6.length; i++) { + real6[i] = values[i * 2]; + image2[i] = values[i * 2 + 1]; + } + const realTensor = tensor4(real6, shape, "float32"); + const imageTensor = tensor4(image2, shape, "float32"); + out[name] = complex(realTensor, imageTensor); + } else { + throw new Error(`Unsupported dtype in weight '${name}': ${dtype}`); + } + offset += size * dtypeFactor; + } + if (dtype !== "complex64") { + out[name] = tensor4(values, shape, dtype); + } + } + return out; +} +function concatenateTypedArrays(xs) { + if (xs === null) { + throw new Error(`Invalid input value: ${JSON.stringify(xs)}`); + } + let totalByteLength = 0; + const normalizedXs = []; + xs.forEach((x) => { + totalByteLength += x.byteLength; + normalizedXs.push(x.byteLength === x.buffer.byteLength ? x : new x.constructor(x)); + if (!(x instanceof Float32Array || x instanceof Int32Array || x instanceof Uint8Array)) { + throw new Error(`Unsupported TypedArray subtype: ${x.constructor.name}`); + } + }); + const y = new Uint8Array(totalByteLength); + let offset = 0; + normalizedXs.forEach((x) => { + y.set(new Uint8Array(x.buffer), offset); + offset += x.byteLength; + }); + return y.buffer; +} +const useNodeBuffer = typeof Buffer !== "undefined" && (typeof Blob === "undefined" || typeof atob === "undefined" || typeof btoa === "undefined"); +function stringByteLength(str) { + if (useNodeBuffer) { + return Buffer.byteLength(str); + } + return new Blob([str]).size; +} +function concatenateArrayBuffers(buffers) { + if (buffers.length === 1) { + return buffers[0]; + } + let totalByteLength = 0; + buffers.forEach((buffer11) => { + totalByteLength += buffer11.byteLength; + }); + const temp = new Uint8Array(totalByteLength); + let offset = 0; + buffers.forEach((buffer11) => { + temp.set(new Uint8Array(buffer11), offset); + offset += buffer11.byteLength; + }); + return temp.buffer; +} +function basename(path) { + const SEPARATOR = "/"; + path = path.trim(); + while (path.endsWith(SEPARATOR)) { + path = path.slice(0, path.length - 1); + } + const items = path.split(SEPARATOR); + return items[items.length - 1]; +} +function getModelArtifactsInfoForJSON(modelArtifacts) { + if (modelArtifacts.modelTopology instanceof ArrayBuffer) { + throw new Error("Expected JSON model topology, received ArrayBuffer."); + } + return { + dateSaved: new Date(), + modelTopologyType: "JSON", + modelTopologyBytes: modelArtifacts.modelTopology == null ? 0 : stringByteLength(JSON.stringify(modelArtifacts.modelTopology)), + weightSpecsBytes: modelArtifacts.weightSpecs == null ? 0 : stringByteLength(JSON.stringify(modelArtifacts.weightSpecs)), + weightDataBytes: modelArtifacts.weightData == null ? 0 : modelArtifacts.weightData.byteLength + }; +} +function computeFloat16MantisaTable() { + const convertMantissa = (i) => { + let m = i << 13; + let e = 0; + while ((m & 8388608) === 0) { + e -= 8388608; + m <<= 1; + } + m &= ~8388608; + e += 947912704; + return m | e; + }; + const mantisaTable = new Uint32Array(2048); + mantisaTable[0] = 0; + for (let i = 1; i < 1024; i++) { + mantisaTable[i] = convertMantissa(i); + } + for (let i = 1024; i < 2048; i++) { + mantisaTable[i] = 939524096 + (i - 1024 << 13); + } + return mantisaTable; +} +function computeFloat16ExponentTable() { + const exponentTable = new Uint32Array(64); + exponentTable[0] = 0; + exponentTable[31] = 1199570944; + exponentTable[32] = 2147483648; + exponentTable[63] = 3347054592; + for (let i = 1; i < 31; i++) { + exponentTable[i] = i << 23; + } + for (let i = 33; i < 63; i++) { + exponentTable[i] = 2147483648 + (i - 32 << 23); + } + return exponentTable; +} +function computeFloat16OffsetTable() { + const offsetTable = new Uint32Array(64); + for (let i = 0; i < 64; i++) { + offsetTable[i] = 1024; + } + offsetTable[0] = offsetTable[32] = 0; + return offsetTable; +} +function getFloat16Decoder() { + const mantisaTable = computeFloat16MantisaTable(); + const exponentTable = computeFloat16ExponentTable(); + const offsetTable = computeFloat16OffsetTable(); + return (quantizedArray) => { + const buffer11 = new ArrayBuffer(4 * quantizedArray.length); + const bufferUint32View = new Uint32Array(buffer11); + for (let index = 0; index < quantizedArray.length; index++) { + const float16Bits = quantizedArray[index]; + const float32Bits = mantisaTable[offsetTable[float16Bits >> 10] + (float16Bits & 1023)] + exponentTable[float16Bits >> 10]; + bufferUint32View[index] = float32Bits; + } + return new Float32Array(buffer11); + }; +} + +// node_modules/@tensorflow/tfjs-core/dist/io/router_registry.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +class IORouterRegistry { + constructor() { + this.saveRouters = []; + this.loadRouters = []; + } + static getInstance() { + if (IORouterRegistry.instance == null) { + IORouterRegistry.instance = new IORouterRegistry(); + } + return IORouterRegistry.instance; + } + static registerSaveRouter(saveRouter) { + IORouterRegistry.getInstance().saveRouters.push(saveRouter); + } + static registerLoadRouter(loadRouter) { + IORouterRegistry.getInstance().loadRouters.push(loadRouter); + } + static getSaveHandlers(url) { + return IORouterRegistry.getHandlers(url, "save"); + } + static getLoadHandlers(url, loadOptions) { + return IORouterRegistry.getHandlers(url, "load", loadOptions); + } + static getHandlers(url, handlerType, loadOptions) { + const validHandlers = []; + const routers = handlerType === "load" ? IORouterRegistry.getInstance().loadRouters : IORouterRegistry.getInstance().saveRouters; + routers.forEach((router) => { + const handler = router(url, loadOptions); + if (handler !== null) { + validHandlers.push(handler); + } + }); + return validHandlers; + } +} +const registerSaveRouter = (loudRouter) => IORouterRegistry.registerSaveRouter(loudRouter); +const registerLoadRouter = (loudRouter) => IORouterRegistry.registerLoadRouter(loudRouter); +const getSaveHandlers = (url) => IORouterRegistry.getSaveHandlers(url); +const getLoadHandlers = (url, loadOptions) => IORouterRegistry.getLoadHandlers(url, loadOptions); + +// node_modules/@tensorflow/tfjs-core/dist/io/model_management.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +const URL_SCHEME_SUFFIX = "://"; +class ModelStoreManagerRegistry { + constructor() { + this.managers = {}; + } + static getInstance() { + if (ModelStoreManagerRegistry.instance == null) { + ModelStoreManagerRegistry.instance = new ModelStoreManagerRegistry(); + } + return ModelStoreManagerRegistry.instance; + } + static registerManager(scheme, manager) { + assert(scheme != null, () => "scheme must not be undefined or null."); + if (scheme.endsWith(URL_SCHEME_SUFFIX)) { + scheme = scheme.slice(0, scheme.indexOf(URL_SCHEME_SUFFIX)); + } + assert(scheme.length > 0, () => "scheme must not be an empty string."); + const registry = ModelStoreManagerRegistry.getInstance(); + assert(registry.managers[scheme] == null, () => `A model store manager is already registered for scheme '${scheme}'.`); + registry.managers[scheme] = manager; + } + static getManager(scheme) { + const manager = this.getInstance().managers[scheme]; + if (manager == null) { + throw new Error(`Cannot find model manager for scheme '${scheme}'`); + } + return manager; + } + static getSchemes() { + return Object.keys(this.getInstance().managers); + } +} +function parseURL(url) { + if (url.indexOf(URL_SCHEME_SUFFIX) === -1) { + throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${ModelStoreManagerRegistry.getSchemes().join(",")}`); + } + return { + scheme: url.split(URL_SCHEME_SUFFIX)[0], + path: url.split(URL_SCHEME_SUFFIX)[1] + }; +} +async function cloneModelInternal(sourceURL, destURL, deleteSource = false) { + assert(sourceURL !== destURL, () => `Old path and new path are the same: '${sourceURL}'`); + const loadHandlers = IORouterRegistry.getLoadHandlers(sourceURL); + assert(loadHandlers.length > 0, () => `Copying failed because no load handler is found for source URL ${sourceURL}.`); + assert(loadHandlers.length < 2, () => `Copying failed because more than one (${loadHandlers.length}) load handlers for source URL ${sourceURL}.`); + const loadHandler = loadHandlers[0]; + const saveHandlers = IORouterRegistry.getSaveHandlers(destURL); + assert(saveHandlers.length > 0, () => `Copying failed because no save handler is found for destination URL ${destURL}.`); + assert(saveHandlers.length < 2, () => `Copying failed because more than one (${loadHandlers.length}) save handlers for destination URL ${destURL}.`); + const saveHandler = saveHandlers[0]; + const sourceScheme = parseURL(sourceURL).scheme; + const sourcePath = parseURL(sourceURL).path; + const sameMedium = sourceScheme === parseURL(sourceURL).scheme; + const modelArtifacts = await loadHandler.load(); + if (deleteSource && sameMedium) { + await ModelStoreManagerRegistry.getManager(sourceScheme).removeModel(sourcePath); + } + const saveResult = await saveHandler.save(modelArtifacts); + if (deleteSource && !sameMedium) { + await ModelStoreManagerRegistry.getManager(sourceScheme).removeModel(sourcePath); + } + return saveResult.modelArtifactsInfo; +} +async function listModels() { + const schemes = ModelStoreManagerRegistry.getSchemes(); + const out = {}; + for (const scheme of schemes) { + const schemeOut = await ModelStoreManagerRegistry.getManager(scheme).listModels(); + for (const path in schemeOut) { + const url = scheme + URL_SCHEME_SUFFIX + path; + out[url] = schemeOut[path]; + } + } + return out; +} +async function removeModel(url) { + const schemeAndPath = parseURL(url); + const manager = ModelStoreManagerRegistry.getManager(schemeAndPath.scheme); + return manager.removeModel(schemeAndPath.path); +} +async function copyModel(sourceURL, destURL) { + const deleteSource = false; + return cloneModelInternal(sourceURL, destURL, deleteSource); +} +async function moveModel(sourceURL, destURL) { + const deleteSource = true; + return cloneModelInternal(sourceURL, destURL, deleteSource); +} + +// node_modules/@tensorflow/tfjs-core/dist/ops/buffer.js +/** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function buffer(shape, dtype = "float32", values) { + dtype = dtype || "float32"; + assertNonNegativeIntegerDimensions(shape); + return new TensorBuffer(shape, dtype, values); +} + +// node_modules/@tensorflow/tfjs-core/dist/ops/cast.js +/** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function cast_(x, dtype) { + const $x = convertToTensor(x, "x", "cast"); + if (!isValidDtype(dtype)) { + throw new Error(`Failed to cast to unknown dtype ${dtype}`); + } + if (dtype === "string" && $x.dtype !== "string" || dtype !== "string" && $x.dtype === "string") { + throw new Error("Only strings can be casted to strings"); + } + const inputs = {x: $x}; + const attrs = {dtype}; + return ENGINE.runKernelFunc((backend2) => backend2.cast($x, dtype), inputs, null, Cast, attrs); +} +const cast = op({cast_}); + +// node_modules/@tensorflow/tfjs-core/dist/ops/clone.js +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function clone_(x) { + const $x = convertToTensor(x, "x", "clone", null); + const forward = () => ENGINE.makeTensorFromDataId($x.dataId, $x.shape, $x.dtype); + const inputs = {x: $x}; + return ENGINE.runKernelFunc(forward, inputs, null, Identity); +} +const clone = op({clone_}); + +// node_modules/@tensorflow/tfjs-core/dist/ops/print.js +/** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function print(x, verbose = false) { + console.log(x.toString(verbose)); +} + +// node_modules/@tensorflow/tfjs-core/dist/base_side_effects.js +/** + * @license + * Copyright 2020 Google Inc. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +getOrMakeEngine(); +const opHandler2 = { + buffer, + cast, + clone, + print +}; +setOpHandler(opHandler2); + +// node_modules/@tensorflow/tfjs-core/dist/io/browser_files.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +const DEFAULT_FILE_NAME_PREFIX = "model"; +const DEFAULT_JSON_EXTENSION_NAME = ".json"; +const DEFAULT_WEIGHT_DATA_EXTENSION_NAME = ".weights.bin"; +function defer(f) { + return new Promise((resolve) => setTimeout(resolve)).then(f); +} +class BrowserDownloads { + constructor(fileNamePrefix) { + if (!env().getBool("IS_BROWSER")) { + throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); + } + if (fileNamePrefix.startsWith(BrowserDownloads.URL_SCHEME)) { + fileNamePrefix = fileNamePrefix.slice(BrowserDownloads.URL_SCHEME.length); + } + if (fileNamePrefix == null || fileNamePrefix.length === 0) { + fileNamePrefix = DEFAULT_FILE_NAME_PREFIX; + } + this.modelTopologyFileName = fileNamePrefix + DEFAULT_JSON_EXTENSION_NAME; + this.weightDataFileName = fileNamePrefix + DEFAULT_WEIGHT_DATA_EXTENSION_NAME; + } + async save(modelArtifacts) { + if (typeof document === "undefined") { + throw new Error("Browser downloads are not supported in this environment since `document` is not present"); + } + const weightsURL = window.URL.createObjectURL(new Blob([modelArtifacts.weightData], {type: "application/octet-stream"})); + if (modelArtifacts.modelTopology instanceof ArrayBuffer) { + throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet."); + } else { + const weightsManifest = [{ + paths: ["./" + this.weightDataFileName], + weights: modelArtifacts.weightSpecs + }]; + const modelTopologyAndWeightManifest = { + modelTopology: modelArtifacts.modelTopology, + format: modelArtifacts.format, + generatedBy: modelArtifacts.generatedBy, + convertedBy: modelArtifacts.convertedBy, + weightsManifest + }; + const modelTopologyAndWeightManifestURL = window.URL.createObjectURL(new Blob([JSON.stringify(modelTopologyAndWeightManifest)], {type: "application/json"})); + const jsonAnchor = this.jsonAnchor == null ? document.createElement("a") : this.jsonAnchor; + jsonAnchor.download = this.modelTopologyFileName; + jsonAnchor.href = modelTopologyAndWeightManifestURL; + await defer(() => jsonAnchor.dispatchEvent(new MouseEvent("click"))); + if (modelArtifacts.weightData != null) { + const weightDataAnchor = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor; + weightDataAnchor.download = this.weightDataFileName; + weightDataAnchor.href = weightsURL; + await defer(() => weightDataAnchor.dispatchEvent(new MouseEvent("click"))); + } + return {modelArtifactsInfo: getModelArtifactsInfoForJSON(modelArtifacts)}; + } + } +} +BrowserDownloads.URL_SCHEME = "downloads://"; +class BrowserFiles { + constructor(files) { + if (files == null || files.length < 1) { + throw new Error(`When calling browserFiles, at least 1 file is required, but received ${files}`); + } + this.files = files; + } + async load() { + const jsonFile = this.files[0]; + const weightFiles = this.files.slice(1); + return new Promise((resolve, reject) => { + const jsonReader = new FileReader(); + jsonReader.onload = (event) => { + const modelJSON = JSON.parse(event.target.result); + const modelTopology = modelJSON.modelTopology; + if (modelTopology == null) { + reject(new Error(`modelTopology field is missing from file ${jsonFile.name}`)); + return; + } + if (weightFiles.length === 0) { + resolve({modelTopology}); + } + const weightsManifest = modelJSON.weightsManifest; + if (weightsManifest == null) { + reject(new Error(`weightManifest field is missing from file ${jsonFile.name}`)); + return; + } + let pathToFile; + try { + pathToFile = this.checkManifestAndWeightFiles(weightsManifest, weightFiles); + } catch (err) { + reject(err); + return; + } + const weightSpecs = []; + const paths = []; + const perFileBuffers = []; + weightsManifest.forEach((weightsGroup) => { + weightsGroup.paths.forEach((path) => { + paths.push(path); + perFileBuffers.push(null); + }); + weightSpecs.push(...weightsGroup.weights); + }); + weightsManifest.forEach((weightsGroup) => { + weightsGroup.paths.forEach((path) => { + const weightFileReader = new FileReader(); + weightFileReader.onload = (event2) => { + const weightData = event2.target.result; + const index = paths.indexOf(path); + perFileBuffers[index] = weightData; + if (perFileBuffers.indexOf(null) === -1) { + resolve({ + modelTopology, + weightSpecs, + weightData: concatenateArrayBuffers(perFileBuffers), + format: modelJSON.format, + generatedBy: modelJSON.generatedBy, + convertedBy: modelJSON.convertedBy, + userDefinedMetadata: modelJSON.userDefinedMetadata + }); + } + }; + weightFileReader.onerror = (error) => reject(`Failed to weights data from file of path '${path}'.`); + weightFileReader.readAsArrayBuffer(pathToFile[path]); + }); + }); + }; + jsonReader.onerror = (error) => reject(`Failed to read model topology and weights manifest JSON from file '${jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`); + jsonReader.readAsText(jsonFile); + }); + } + checkManifestAndWeightFiles(manifest, files) { + const basenames = []; + const fileNames = files.map((file) => basename(file.name)); + const pathToFile = {}; + for (const group of manifest) { + group.paths.forEach((path) => { + const pathBasename = basename(path); + if (basenames.indexOf(pathBasename) !== -1) { + throw new Error(`Duplicate file basename found in weights manifest: '${pathBasename}'`); + } + basenames.push(pathBasename); + if (fileNames.indexOf(pathBasename) === -1) { + throw new Error(`Weight file with basename '${pathBasename}' is not provided.`); + } else { + pathToFile[path] = files[fileNames.indexOf(pathBasename)]; + } + }); + } + if (basenames.length !== files.length) { + throw new Error(`Mismatch in the number of files in weights manifest (${basenames.length}) and the number of weight files provided (${files.length}).`); + } + return pathToFile; + } +} +const browserDownloadsRouter = (url) => { + if (!env().getBool("IS_BROWSER")) { + return null; + } else { + if (!Array.isArray(url) && url.startsWith(BrowserDownloads.URL_SCHEME)) { + return browserDownloads(url.slice(BrowserDownloads.URL_SCHEME.length)); + } else { + return null; + } + } +}; +IORouterRegistry.registerSaveRouter(browserDownloadsRouter); +function browserDownloads(fileNamePrefix = "model") { + return new BrowserDownloads(fileNamePrefix); +} +function browserFiles(files) { + return new BrowserFiles(files); +} + +// node_modules/@tensorflow/tfjs-core/dist/io/progress.js +/** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function monitorPromisesProgress(promises, onProgress, startFraction, endFraction) { + checkPromises(promises); + startFraction = startFraction == null ? 0 : startFraction; + endFraction = endFraction == null ? 1 : endFraction; + checkFraction(startFraction, endFraction); + let resolvedPromise = 0; + const registerMonitor = (promise) => { + promise.then((value) => { + const fraction = startFraction + ++resolvedPromise / promises.length * (endFraction - startFraction); + onProgress(fraction); + return value; + }); + return promise; + }; + function checkPromises(promises2) { + assert(promises2 != null && Array.isArray(promises2) && promises2.length > 0, () => "promises must be a none empty array"); + } + function checkFraction(startFraction2, endFraction2) { + assert(startFraction2 >= 0 && startFraction2 <= 1, () => `Progress fraction must be in range [0, 1], but got startFraction ${startFraction2}`); + assert(endFraction2 >= 0 && endFraction2 <= 1, () => `Progress fraction must be in range [0, 1], but got endFraction ${endFraction2}`); + assert(endFraction2 >= startFraction2, () => `startFraction must be no more than endFraction, but got startFraction ${startFraction2} and endFraction ${endFraction2}`); + } + return Promise.all(promises.map(registerMonitor)); +} + +// node_modules/@tensorflow/tfjs-core/dist/io/weights_loader.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +async function loadWeightsAsArrayBuffer(fetchURLs, loadOptions) { + if (loadOptions == null) { + loadOptions = {}; + } + const fetchFunc = loadOptions.fetchFunc == null ? env().platform.fetch : loadOptions.fetchFunc; + const requests = fetchURLs.map((fetchURL) => fetchFunc(fetchURL, loadOptions.requestInit, {isBinary: true})); + const fetchStartFraction = 0; + const fetchEndFraction = 0.5; + const responses = loadOptions.onProgress == null ? await Promise.all(requests) : await monitorPromisesProgress(requests, loadOptions.onProgress, fetchStartFraction, fetchEndFraction); + const bufferPromises = responses.map((response) => response.arrayBuffer()); + const bufferStartFraction = 0.5; + const bufferEndFraction = 1; + const buffers = loadOptions.onProgress == null ? await Promise.all(bufferPromises) : await monitorPromisesProgress(bufferPromises, loadOptions.onProgress, bufferStartFraction, bufferEndFraction); + return buffers; +} +async function loadWeights(manifest, filePathPrefix = "", weightNames, requestInit) { + const fetchWeights = (fetchUrls) => loadWeightsAsArrayBuffer(fetchUrls, {requestInit}); + const loadWeights2 = weightsLoaderFactory(fetchWeights); + return loadWeights2(manifest, filePathPrefix, weightNames); +} +function weightsLoaderFactory(fetchWeightsFunction) { + return async (manifest, filePathPrefix = "", weightNames) => { + const groupIndicesToFetchMap = manifest.map(() => false); + const groupWeightsToFetch = {}; + const weightsFound = weightNames != null ? weightNames.map(() => false) : []; + const allManifestWeightNames = []; + manifest.forEach((manifestGroupConfig, groupIndex) => { + let groupOffset = 0; + manifestGroupConfig.weights.forEach((weightsEntry) => { + const rawDtype = "quantization" in weightsEntry ? weightsEntry.quantization.dtype : weightsEntry.dtype; + const weightsBytes = DTYPE_VALUE_SIZE_MAP[rawDtype] * sizeFromShape(weightsEntry.shape); + const enqueueWeightsForFetchingFn = () => { + groupIndicesToFetchMap[groupIndex] = true; + if (groupWeightsToFetch[groupIndex] == null) { + groupWeightsToFetch[groupIndex] = []; + } + groupWeightsToFetch[groupIndex].push({ + manifestEntry: weightsEntry, + groupOffset, + sizeBytes: weightsBytes + }); + }; + if (weightNames != null) { + weightNames.forEach((weightName, weightIndex) => { + if (weightName === weightsEntry.name) { + enqueueWeightsForFetchingFn(); + weightsFound[weightIndex] = true; + } + }); + } else { + enqueueWeightsForFetchingFn(); + } + allManifestWeightNames.push(weightsEntry.name); + groupOffset += weightsBytes; + }); + }); + if (!weightsFound.every((found) => found)) { + const weightsNotFound = weightNames.filter((_, i) => !weightsFound[i]); + throw new Error(`Could not find weights in manifest with names: ${weightsNotFound.join(", ")}. +Manifest JSON has weights with names: ${allManifestWeightNames.join(", ")}.`); + } + const groupIndicesToFetch = groupIndicesToFetchMap.reduce((accumulator, shouldFetch, i) => { + if (shouldFetch) { + accumulator.push(i); + } + return accumulator; + }, []); + const fetchUrls = []; + groupIndicesToFetch.forEach((i) => { + manifest[i].paths.forEach((filepath) => { + const fetchUrl = filePathPrefix + (!filePathPrefix.endsWith("/") ? "/" : "") + filepath; + fetchUrls.push(fetchUrl); + }); + }); + const buffers = await fetchWeightsFunction(fetchUrls); + const weightsTensorMap = {}; + let bufferIndexOffset = 0; + groupIndicesToFetch.forEach((i) => { + const numBuffers = manifest[i].paths.length; + let groupBytes = 0; + for (let i2 = 0; i2 < numBuffers; i2++) { + groupBytes += buffers[bufferIndexOffset + i2].byteLength; + } + const groupBuffer = new ArrayBuffer(groupBytes); + const groupByteBuffer = new Uint8Array(groupBuffer); + let groupBufferOffset = 0; + for (let i2 = 0; i2 < numBuffers; i2++) { + const buffer11 = new Uint8Array(buffers[bufferIndexOffset + i2]); + groupByteBuffer.set(buffer11, groupBufferOffset); + groupBufferOffset += buffer11.byteLength; + } + const weightsEntries = groupWeightsToFetch[i]; + weightsEntries.forEach((weightsEntry) => { + const byteBuffer = groupBuffer.slice(weightsEntry.groupOffset, weightsEntry.groupOffset + weightsEntry.sizeBytes); + const nameToTensorMap = decodeWeights(byteBuffer, [weightsEntry.manifestEntry]); + for (const name in nameToTensorMap) { + weightsTensorMap[name] = nameToTensorMap[name]; + } + }); + bufferIndexOffset += numBuffers; + }); + return weightsTensorMap; + }; +} + +// node_modules/@tensorflow/tfjs-core/dist/io/http.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +const OCTET_STREAM_MIME_TYPE = "application/octet-stream"; +const JSON_TYPE = "application/json"; +class HTTPRequest { + constructor(path, loadOptions) { + this.DEFAULT_METHOD = "POST"; + if (loadOptions == null) { + loadOptions = {}; + } + this.weightPathPrefix = loadOptions.weightPathPrefix; + this.onProgress = loadOptions.onProgress; + this.weightUrlConverter = loadOptions.weightUrlConverter; + if (loadOptions.fetchFunc != null) { + assert(typeof loadOptions.fetchFunc === "function", () => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)"); + this.fetch = loadOptions.fetchFunc; + } else { + this.fetch = env().platform.fetch; + } + assert(path != null && path.length > 0, () => "URL path for http must not be null, undefined or empty."); + if (Array.isArray(path)) { + assert(path.length === 2, () => `URL paths for http must have a length of 2, (actual length is ${path.length}).`); + } + this.path = path; + if (loadOptions.requestInit != null && loadOptions.requestInit.body != null) { + throw new Error("requestInit is expected to have no pre-existing body, but has one."); + } + this.requestInit = loadOptions.requestInit || {}; + } + async save(modelArtifacts) { + if (modelArtifacts.modelTopology instanceof ArrayBuffer) { + throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet."); + } + const init = Object.assign({method: this.DEFAULT_METHOD}, this.requestInit); + init.body = new FormData(); + const weightsManifest = [{ + paths: ["./model.weights.bin"], + weights: modelArtifacts.weightSpecs + }]; + const modelTopologyAndWeightManifest = { + modelTopology: modelArtifacts.modelTopology, + format: modelArtifacts.format, + generatedBy: modelArtifacts.generatedBy, + convertedBy: modelArtifacts.convertedBy, + userDefinedMetadata: modelArtifacts.userDefinedMetadata, + weightsManifest + }; + init.body.append("model.json", new Blob([JSON.stringify(modelTopologyAndWeightManifest)], {type: JSON_TYPE}), "model.json"); + if (modelArtifacts.weightData != null) { + init.body.append("model.weights.bin", new Blob([modelArtifacts.weightData], {type: OCTET_STREAM_MIME_TYPE}), "model.weights.bin"); + } + const response = await this.fetch(this.path, init); + if (response.ok) { + return { + modelArtifactsInfo: getModelArtifactsInfoForJSON(modelArtifacts), + responses: [response] + }; + } else { + throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${response.status}.`); + } + } + async load() { + const modelConfigRequest = await this.fetch(this.path, this.requestInit); + if (!modelConfigRequest.ok) { + throw new Error(`Request to ${this.path} failed with status code ${modelConfigRequest.status}. Please verify this URL points to the model JSON of the model to load.`); + } + let modelConfig; + try { + modelConfig = await modelConfigRequest.json(); + } catch (e) { + let message = `Failed to parse model JSON of response from ${this.path}.`; + if (this.path.endsWith(".pb")) { + message += " Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository."; + } else { + message += " Please make sure the server is serving valid JSON for this request."; + } + throw new Error(message); + } + const modelTopology = modelConfig.modelTopology; + const weightsManifest = modelConfig.weightsManifest; + const generatedBy = modelConfig.generatedBy; + const convertedBy = modelConfig.convertedBy; + const format = modelConfig.format; + const userDefinedMetadata = modelConfig.userDefinedMetadata; + if (modelTopology == null && weightsManifest == null) { + throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); + } + let weightSpecs; + let weightData; + if (weightsManifest != null) { + const results = await this.loadWeights(weightsManifest); + [weightSpecs, weightData] = results; + } + return { + modelTopology, + weightSpecs, + weightData, + userDefinedMetadata, + generatedBy, + convertedBy, + format + }; + } + async loadWeights(weightsManifest) { + const weightPath = Array.isArray(this.path) ? this.path[1] : this.path; + const [prefix, suffix] = parseUrl(weightPath); + const pathPrefix = this.weightPathPrefix || prefix; + const weightSpecs = []; + for (const entry of weightsManifest) { + weightSpecs.push(...entry.weights); + } + const fetchURLs = []; + const urlPromises = []; + for (const weightsGroup of weightsManifest) { + for (const path of weightsGroup.paths) { + if (this.weightUrlConverter != null) { + urlPromises.push(this.weightUrlConverter(path)); + } else { + fetchURLs.push(pathPrefix + path + suffix); + } + } + } + if (this.weightUrlConverter) { + fetchURLs.push(...await Promise.all(urlPromises)); + } + const buffers = await loadWeightsAsArrayBuffer(fetchURLs, { + requestInit: this.requestInit, + fetchFunc: this.fetch, + onProgress: this.onProgress + }); + return [weightSpecs, concatenateArrayBuffers(buffers)]; + } +} +HTTPRequest.URL_SCHEME_REGEX = /^https?:\/\//; +function parseUrl(url) { + const lastSlash = url.lastIndexOf("/"); + const lastSearchParam = url.lastIndexOf("?"); + const prefix = url.substring(0, lastSlash); + const suffix = lastSearchParam > lastSlash ? url.substring(lastSearchParam) : ""; + return [prefix + "/", suffix]; +} +function isHTTPScheme(url) { + return url.match(HTTPRequest.URL_SCHEME_REGEX) != null; +} +const httpRouter = (url, loadOptions) => { + if (typeof fetch === "undefined" && (loadOptions == null || loadOptions.fetchFunc == null)) { + return null; + } else { + let isHTTP = true; + if (Array.isArray(url)) { + isHTTP = url.every((urlItem) => isHTTPScheme(urlItem)); + } else { + isHTTP = isHTTPScheme(url); + } + if (isHTTP) { + return http(url, loadOptions); + } + } + return null; +}; +IORouterRegistry.registerSaveRouter(httpRouter); +IORouterRegistry.registerLoadRouter(httpRouter); +function http(path, loadOptions) { + return new HTTPRequest(path, loadOptions); +} +function browserHTTPRequest(path, loadOptions) { + return http(path, loadOptions); +} + +// node_modules/@tensorflow/tfjs-core/dist/io/passthrough.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +class PassthroughLoader { + constructor(modelArtifacts) { + this.modelArtifacts = modelArtifacts; + } + async load() { + return this.modelArtifacts; + } +} +class PassthroughSaver { + constructor(saveHandler) { + this.saveHandler = saveHandler; + } + async save(modelArtifacts) { + return this.saveHandler(modelArtifacts); + } +} +function fromMemory(modelArtifacts, weightSpecs, weightData, trainingConfig) { + if (arguments.length === 1) { + const isModelArtifacts = modelArtifacts.modelTopology != null || modelArtifacts.weightSpecs != null; + if (isModelArtifacts) { + return new PassthroughLoader(modelArtifacts); + } else { + console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."); + return new PassthroughLoader({modelTopology: modelArtifacts}); + } + } else { + console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."); + return new PassthroughLoader({ + modelTopology: modelArtifacts, + weightSpecs, + weightData, + trainingConfig + }); + } +} +function withSaveHandler(saveHandler) { + return new PassthroughSaver(saveHandler); +} + +// node_modules/@tensorflow/tfjs-core/dist/io/io.js +const io_exports = {}; +__export(io_exports, { + browserFiles: () => browserFiles, + browserHTTPRequest: () => browserHTTPRequest, + concatenateArrayBuffers: () => concatenateArrayBuffers, + copyModel: () => copyModel, + decodeWeights: () => decodeWeights, + encodeWeights: () => encodeWeights, + fromMemory: () => fromMemory, + getLoadHandlers: () => getLoadHandlers, + getModelArtifactsInfoForJSON: () => getModelArtifactsInfoForJSON, + getSaveHandlers: () => getSaveHandlers, + http: () => http, + isHTTPScheme: () => isHTTPScheme, + listModels: () => listModels, + loadWeights: () => loadWeights, + moveModel: () => moveModel, + registerLoadRouter: () => registerLoadRouter, + registerSaveRouter: () => registerSaveRouter, + removeModel: () => removeModel, + weightsLoaderFactory: () => weightsLoaderFactory, + withSaveHandler: () => withSaveHandler +}); +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + +// node_modules/@tensorflow/tfjs-core/dist/ops/reshape.js +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function reshape_(x, shape) { + const $x = convertToTensor(x, "x", "reshape", null); + shape = inferFromImplicitShape(shape, $x.size); + assert($x.size === sizeFromShape(shape), () => "new shape and old shape must have the same number of elements."); + const inputs = {x: $x}; + const attrs = {shape}; + const forward = (backend2, save) => { + save([$x]); + return backend2.reshape($x, shape); + }; + return ENGINE.runKernelFunc(forward, inputs, null, Reshape, attrs); +} +const reshape = op({reshape_}); + +// node_modules/@tensorflow/tfjs-core/dist/ops/mat_mul.js +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function matMul_(a, b, transposeA = false, transposeB = false) { + let $a = convertToTensor(a, "a", "matMul"); + let $b = convertToTensor(b, "b", "matMul"); + [$a, $b] = makeTypesMatch($a, $b); + assert($a.rank >= 2 && $b.rank >= 2 && $a.rank === $b.rank, () => `Error in matMul: inputs must have the same rank of at least 2, got ranks ${$a.rank} and ${$b.rank}.`); + const innerShapeA = transposeA ? $a.shape[$a.rank - 2] : $a.shape[$a.rank - 1]; + const innerShapeB = transposeB ? $b.shape[$b.rank - 1] : $b.shape[$b.rank - 2]; + const outerShapeA = transposeA ? $a.shape[$a.rank - 1] : $a.shape[$a.rank - 2]; + const outerShapeB = transposeB ? $b.shape[$b.rank - 2] : $b.shape[$b.rank - 1]; + const outerDimsA = $a.shape.slice(0, -2); + const outerDimsB = $b.shape.slice(0, -2); + const batchDimA = sizeFromShape(outerDimsA); + const batchDimB = sizeFromShape(outerDimsB); + assert(arraysEqual(outerDimsA, outerDimsB), () => `Error in matMul: outer dimensions (${outerDimsA}) and (${outerDimsB}) of Tensors with shapes ${$a.shape} and ${$b.shape} must match.`); + assert(innerShapeA === innerShapeB, () => `Error in matMul: inner shapes (${innerShapeA}) and (${innerShapeB}) of Tensors with shapes ${$a.shape} and ${$b.shape} and transposeA=${transposeA} and transposeB=${transposeB} must match.`); + const outShape = $a.shape.slice(0, -2).concat([outerShapeA, outerShapeB]); + const a3D = transposeA ? reshape($a, [batchDimA, innerShapeA, outerShapeA]) : reshape($a, [batchDimA, outerShapeA, innerShapeA]); + const b3D = transposeB ? reshape($b, [batchDimB, outerShapeB, innerShapeB]) : reshape($b, [batchDimB, innerShapeB, outerShapeB]); + const forward = (backend2, save) => { + save([a3D, b3D]); + return backend2.batchMatMul(a3D, b3D, transposeA, transposeB); + }; + const inputs = {a: a3D, b: b3D}; + const attrs = {transposeA, transposeB}; + const res = ENGINE.runKernelFunc(forward, inputs, null, BatchMatMul, attrs); + return reshape(res, outShape); +} +const matMul = op({matMul_}); + +// node_modules/@tensorflow/tfjs-core/dist/ops/one_hot.js +/** + * @license + * Copyright 2020 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function oneHot_(indices, depth, onValue = 1, offValue = 0) { + if (depth < 2) { + throw new Error(`Error in oneHot: depth must be >=2, but it is ${depth}`); + } + const $indices = convertToTensor(indices, "indices", "oneHot", "int32"); + const outShape = [...$indices.shape, depth]; + const forward = (backend2, save) => { + save([$indices]); + return reshape(backend2.oneHot(reshape($indices, [$indices.size]), depth, onValue, offValue), outShape); + }; + const inputs = {indices: $indices}; + const attrs = {depth, onValue, offValue}; + return ENGINE.runKernelFunc(forward, inputs, null, OneHot, attrs); +} +const oneHot = op({oneHot_}); + +// node_modules/@tensorflow/tfjs-core/dist/ops/transpose.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function transpose_(x, perm) { + const $x = convertToTensor(x, "x", "transpose"); + if (perm == null) { + perm = $x.shape.map((s, i) => i).reverse(); + } + assert($x.rank === perm.length, () => `Error in transpose: rank of input ${$x.rank} must match length of perm ${perm}.`); + perm.forEach((axis) => { + assert(axis >= 0 && axis < $x.rank, () => `All entries in 'perm' must be between 0 and ${$x.rank - 1} but got ${perm}`); + }); + if ($x.rank <= 1) { + return $x.clone(); + } + const inputs = {x: $x}; + const attrs = {perm}; + return ENGINE.runKernelFunc((backend2) => backend2.transpose($x, perm), inputs, null, Transpose, attrs); +} +const transpose = op({transpose_}); + +// node_modules/@tensorflow/tfjs-core/dist/ops/confusion_matrix.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function confusionMatrix_(labels, predictions, numClasses) { + const $labels = convertToTensor(labels, "labels", "confusionMatrix"); + const $predictions = convertToTensor(predictions, "predictions", "confusionMatrix"); + assert(numClasses == null || numClasses > 0 && Number.isInteger(numClasses), () => `If provided, numClasses must be a positive integer, but got ${numClasses}`); + assert($labels.rank === 1, () => `Expected the rank of labels to be 1, but got ${$labels.rank}`); + assert($predictions.rank === 1, () => `Expected the rank of predictions to be 1, but got ${$predictions.rank}`); + assert($labels.shape[0] === $predictions.shape[0], () => `Mismatch in the number of examples: ${$labels.shape[0]} vs. ${$predictions.shape[0]}. Labels and predictions should have the same number of elements.`); + assert(numClasses > 0 && Number.isInteger(numClasses), () => `numClasses is required to be a positive integer, but got ${numClasses}`); + const oneHotLabels = oneHot(cast($labels, "int32"), numClasses); + const oneHotPredictions = oneHot(cast($predictions, "int32"), numClasses); + const oneHotLabelsT = transpose(oneHotLabels); + return cast(matMul(oneHotLabelsT, oneHotPredictions), "int32"); +} +const confusionMatrix = op({confusionMatrix_}); + +// node_modules/@tensorflow/tfjs-core/dist/math.js +const math_exports = {}; +__export(math_exports, { + confusionMatrix: () => confusionMatrix +}); +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + +// node_modules/@tensorflow/tfjs-core/dist/ops/tensor3d.js +/** + * @license + * Copyright 2018 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +function tensor3d(values, shape, dtype) { + assertNonNull(values); + if (shape != null && shape.length !== 3) { + throw new Error("tensor3d() requires shape to have three numbers"); + } + const inferredShape = inferShape(values, dtype); + if (inferredShape.length !== 3 && inferredShape.length !== 1) { + throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); + } + if (inferredShape.length === 1 && shape == null) { + throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); + } + return makeTensor(values, shape, inferredShape, dtype); +} + +// node_modules/@tensorflow/tfjs-core/dist/ops/browser.js +const browser_exports = {}; +__export(browser_exports, { + fromPixels: () => fromPixels, + toPixels: () => toPixels +}); +/** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ +let fromPixels2DContext; +function fromPixels_(pixels, numChannels = 3) { + if (numChannels > 4) { + throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); + } + if (pixels == null) { + throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); + } + let isPixelData = false; + let isImageData = false; + let isVideo = false; + let isImage = false; + let isCanvasLike = false; + if (pixels.data instanceof Uint8Array) { + isPixelData = true; + } else if (typeof ImageData !== "undefined" && pixels instanceof ImageData) { + isImageData = true; + } else if (typeof HTMLVideoElement !== "undefined" && pixels instanceof HTMLVideoElement) { + isVideo = true; + } else if (typeof HTMLImageElement !== "undefined" && pixels instanceof HTMLImageElement) { + isImage = true; + } else if (pixels.getContext != null) { + isCanvasLike = true; + } else { + throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${pixels.constructor.name}`); + } + if (isVideo) { + const HAVE_CURRENT_DATA_READY_STATE = 2; + if (isVideo && pixels.readyState < HAVE_CURRENT_DATA_READY_STATE) { + throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the