diff --git a/CHANGELOG.md b/CHANGELOG.md index 19b26eb..481399d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,10 @@ ## Changelog -### **HEAD -> master** 2021/12/14 mandic00@live.com +### **1.6.2** 2022/01/01 mandic00@live.com + + +### **origin/master** 2021/12/27 mandic00@live.com ### **1.6.1** 2021/12/09 mandic00@live.com diff --git a/demo/node-canvas.js b/demo/node-canvas.js index 073cea2..a8604cd 100644 --- a/demo/node-canvas.js +++ b/demo/node-canvas.js @@ -1,15 +1,13 @@ -// @ts-nocheck - const fs = require('fs'); -const process = require('process'); const path = require('path'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require +const process = require('process'); const log = require('@vladmandic/pilogger'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require, no-unused-vars, @typescript-eslint/no-unused-vars -const tf = require('@tensorflow/tfjs-node'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require const canvas = require('canvas'); -const faceapi = require('../dist/face-api.node.js'); // this is equivalent to '@vladmandic/faceapi' + +// eslint-disable-next-line import/no-extraneous-dependencies, no-unused-vars, @typescript-eslint/no-unused-vars +const tf = require('@tensorflow/tfjs-node'); // in nodejs environments tfjs-node is required to be loaded before face-api +// const faceapi = require('@vladmandic/face-api'); // use this when face-api is installed as module (majority of use cases) +const faceapi = require('../dist/face-api.node.js'); // use this when using face-api in dev mode const modelPathRoot = '../model'; const imgPathRoot = './demo'; // modify to include your sample images @@ -80,7 +78,7 @@ async function main() { for (const face of result) print(face); } const t1 = process.hrtime.bigint(); - log.info('Processed', numImages, 'images in', Math.trunc(parseInt(t1 - t0) / 1000 / 1000), 'ms'); + log.info('Processed', numImages, 'images in', Math.trunc(Number((t1 - t0).toString()) / 1000 / 1000), 'ms'); } else { const param = process.argv[2]; if (fs.existsSync(param) || param.startsWith('http:') || param.startsWith('https:')) { diff --git a/demo/node-image.js b/demo/node-image.js index ae804b0..7114a0e 100644 --- a/demo/node-image.js +++ b/demo/node-image.js @@ -1,11 +1,12 @@ const fs = require('fs'); // eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require -const tf = require('@tensorflow/tfjs-node'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require const image = require('@canvas/image'); // @canvas/image can decode jpeg, png, webp -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require const log = require('@vladmandic/pilogger'); -const faceapi = require('../dist/face-api.node.js'); // this is equivalent to '@vladmandic/faceapi' + +// eslint-disable-next-line import/no-extraneous-dependencies, no-unused-vars, @typescript-eslint/no-unused-vars +const tf = require('@tensorflow/tfjs-node'); // in nodejs environments tfjs-node is required to be loaded before face-api +// const faceapi = require('@vladmandic/face-api'); // use this when face-api is installed as module (majority of use cases) +const faceapi = require('../dist/face-api.node.js'); // use this when using face-api in dev mode const modelPath = 'model/'; const imageFile = 'demo/sample1.jpg'; diff --git a/demo/node-match.js b/demo/node-match.js index 2961d58..6629df1 100644 --- a/demo/node-match.js +++ b/demo/node-match.js @@ -1,8 +1,11 @@ const fs = require('fs'); const path = require('path'); -const tf = require('@tensorflow/tfjs-node'); const log = require('@vladmandic/pilogger'); -const faceapi = require('../dist/face-api.node.js'); + +// eslint-disable-next-line import/no-extraneous-dependencies, no-unused-vars, @typescript-eslint/no-unused-vars +const tf = require('@tensorflow/tfjs-node'); // in nodejs environments tfjs-node is required to be loaded before face-api +// const faceapi = require('@vladmandic/face-api'); // use this when face-api is installed as module (majority of use cases) +const faceapi = require('../dist/face-api.node.js'); // use this when using face-api in dev mode let optionsSSDMobileNet; const minConfidence = 0.1; @@ -13,6 +16,7 @@ const labeledFaceDescriptors = []; async function initFaceAPI() { await faceapi.nets.ssdMobilenetv1.loadFromDisk(modelPath); await faceapi.nets.faceLandmark68Net.loadFromDisk(modelPath); + await faceapi.nets.faceExpressionNet.loadFromDisk(modelPath); await faceapi.nets.faceRecognitionNet.loadFromDisk(modelPath); optionsSSDMobileNet = new faceapi.SsdMobilenetv1Options({ minConfidence, maxResults: 1 }); } @@ -22,6 +26,7 @@ async function getDescriptors(imageFile) { const tensor = tf.node.decodeImage(buffer, 3); const faces = await faceapi.detectAllFaces(tensor, optionsSSDMobileNet) .withFaceLandmarks() + .withFaceExpressions() .withFaceDescriptors(); tf.dispose(tensor); return faces.map((face) => face.descriptor); diff --git a/demo/node-multiprocess-worker.js b/demo/node-multiprocess-worker.js index e84f071..0837686 100644 --- a/demo/node-multiprocess-worker.js +++ b/demo/node-multiprocess-worker.js @@ -2,13 +2,13 @@ const fs = require('fs'); const path = require('path'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require const log = require('@vladmandic/pilogger'); // workers actual import tfjs and faceapi modules -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require -const tf = require('@tensorflow/tfjs-node'); -const faceapi = require('../dist/face-api.node.js'); // this is equivalent to '@vladmandic/faceapi' +// eslint-disable-next-line import/no-extraneous-dependencies, no-unused-vars, @typescript-eslint/no-unused-vars +const tf = require('@tensorflow/tfjs-node'); // in nodejs environments tfjs-node is required to be loaded before face-api +// const faceapi = require('@vladmandic/face-api'); // use this when face-api is installed as module (majority of use cases) +const faceapi = require('../dist/face-api.node.js'); // use this when using face-api in dev mode // options used by faceapi const modelPathRoot = '../model'; diff --git a/demo/node-multiprocess.js b/demo/node-multiprocess.js index f2a7419..a8e2924 100644 --- a/demo/node-multiprocess.js +++ b/demo/node-multiprocess.js @@ -1,11 +1,8 @@ -// @ts-nocheck - const fs = require('fs'); const path = require('path'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require const log = require('@vladmandic/pilogger'); // this is my simple logger with few extra features const child_process = require('child_process'); -// note that main process import faceapi or tfjs at all +// note that main process does not need to import faceapi or tfjs at all as processing is done in a worker process const imgPathRoot = './demo'; // modify to include your sample images const numWorkers = 4; // how many workers will be started @@ -33,14 +30,14 @@ function waitCompletion() { if (activeWorkers > 0) setImmediate(() => waitCompletion()); else { t[1] = process.hrtime.bigint(); - log.info('Processed:', numImages, 'images in', 'total:', Math.trunc(parseInt(t[1] - t[0]) / 1000000), 'ms', 'working:', Math.trunc(parseInt(t[1] - t[2]) / 1000000), 'ms', 'average:', Math.trunc(parseInt(t[1] - t[2]) / numImages / 1000000), 'ms'); + log.info('Processed:', numImages, 'images in', 'total:', Math.trunc(Number(t[1] - t[0]) / 1000000), 'ms', 'working:', Math.trunc(Number(t[1] - t[2]) / 1000000), 'ms', 'average:', Math.trunc(Number(t[1] - t[2]) / numImages / 1000000), 'ms'); } } function measureLatency() { t[3] = process.hrtime.bigint(); - const latencyInitialization = Math.trunc(parseInt(t[2] - t[0]) / 1000 / 1000); - const latencyRoundTrip = Math.trunc(parseInt(t[3] - t[2]) / 1000 / 1000); + const latencyInitialization = Math.trunc(Number(t[2] - t[0]) / 1000 / 1000); + const latencyRoundTrip = Math.trunc(Number(t[3] - t[2]) / 1000 / 1000); log.info('Latency: worker initializtion: ', latencyInitialization, 'message round trip:', latencyRoundTrip); } diff --git a/demo/node-simple.js b/demo/node-simple.js new file mode 100644 index 0000000..b9591d2 --- /dev/null +++ b/demo/node-simple.js @@ -0,0 +1,26 @@ +const fs = require('fs'); + +// const faceapi = require('@vladmandic/face-api'); // use this when face-api is installed as module (majority of use cases) +const faceapi = require('../dist/face-api.node.js'); // use this when using face-api in dev mode + +async function main() { + await faceapi.nets.ssdMobilenetv1.loadFromDisk('model'); // load models from a specific patch + await faceapi.nets.faceLandmark68Net.loadFromDisk('model'); + await faceapi.nets.ageGenderNet.loadFromDisk('model'); + await faceapi.nets.faceRecognitionNet.loadFromDisk('model'); + await faceapi.nets.faceExpressionNet.loadFromDisk('model'); + const options = new faceapi.SsdMobilenetv1Options({ minConfidence: 0.1, maxResults: 10 }); // set model options + const buffer = fs.readFileSync('demo/sample1.jpg'); // load jpg image as binary + const decodeT = faceapi.tf.node.decodeImage(buffer, 3); // decode binary buffer to rgb tensor + const expandT = faceapi.tf.expandDims(decodeT, 0); // add batch dimension to tensor + const result = await faceapi.detectAllFaces(expandT, options) // run detection + .withFaceLandmarks() + .withFaceExpressions() + .withFaceDescriptors() + .withAgeAndGender(); + faceapi.tf.dispose([decodeT, expandT]); // dispose tensors to avoid memory leaks + // eslint-disable-next-line no-console + console.log({ result }); // print results +} + +main(); diff --git a/demo/node.js b/demo/node.js index 8a05b17..099f86b 100644 --- a/demo/node.js +++ b/demo/node.js @@ -1,13 +1,12 @@ -// @ts-nocheck - const fs = require('fs'); const process = require('process'); const path = require('path'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require const log = require('@vladmandic/pilogger'); -// eslint-disable-next-line import/no-extraneous-dependencies, node/no-unpublished-require -const tf = require('@tensorflow/tfjs-node'); -const faceapi = require('../dist/face-api.node.js'); // this is equivalent to '@vladmandic/faceapi' + +// eslint-disable-next-line import/no-extraneous-dependencies, no-unused-vars, @typescript-eslint/no-unused-vars +const tf = require('@tensorflow/tfjs-node'); // in nodejs environments tfjs-node is required to be loaded before face-api +// const faceapi = require('@vladmandic/face-api'); // use this when face-api is installed as module (majority of use cases) +const faceapi = require('../dist/face-api.node.js'); // use this when using face-api in dev mode const modelPathRoot = '../model'; const imgPathRoot = './demo'; // modify to include your sample images @@ -118,7 +117,7 @@ async function main() { tensor.dispose(); } const t1 = process.hrtime.bigint(); - log.info('Processed', dir.length, 'images in', Math.trunc(parseInt(t1 - t0) / 1000 / 1000), 'ms'); + log.info('Processed', dir.length, 'images in', Math.trunc(Number((t1 - t0)) / 1000 / 1000), 'ms'); } else { const param = process.argv[2]; if (fs.existsSync(param) || param.startsWith('http:') || param.startsWith('https:')) { diff --git a/dist/face-api.esm-nobundle.js b/dist/face-api.esm-nobundle.js index df9eabb..88b3f18 100644 --- a/dist/face-api.esm-nobundle.js +++ b/dist/face-api.esm-nobundle.js @@ -2135,7 +2135,7 @@ function drawFaceLandmarks(canvasArg, faceLandmarks) { } // package.json -var version10 = "1.6.1"; +var version10 = "1.6.2"; // src/xception/extractParams.ts function extractorsFactory2(extractWeights, paramMappings) { diff --git a/dist/face-api.esm.js b/dist/face-api.esm.js index 30792e2..ababfa9 100644 --- a/dist/face-api.esm.js +++ b/dist/face-api.esm.js @@ -65931,7 +65931,7 @@ function drawFaceLandmarks(canvasArg, faceLandmarks) { } // package.json -var version5 = "1.6.1"; +var version5 = "1.6.2"; // src/xception/extractParams.ts function extractorsFactory2(extractWeights, paramMappings) { diff --git a/dist/face-api.js b/dist/face-api.js index 8fe40fc..91c250e 100644 --- a/dist/face-api.js +++ b/dist/face-api.js @@ -4616,7 +4616,7 @@ return a / b;`,bte=` } `}};function tse(e){let{inputs:t,backend:n,attrs:r}=e,{x:s,segmentIds:a}=t,{numSegments:o}=r,i=s.shape.length,c=[],l=0,u=_.getAxesPermutation([l],i),d=s;u!=null&&(d=Tn({inputs:{x:s},backend:n,attrs:{perm:u}}),c.push(d),l=_.getInnerMostAxes(1,i)[0]);let p=_.segment_util.computeOutShape(d.shape,l,o),h=k.sizeFromShape([d.shape[l]]),f=ge({inputs:{x:d},backend:n,attrs:{shape:[-1,h]}});c.push(f);let m=Mh(s.dtype),g=(x,w,T,C,D)=>{let F=x.shape[0],O=x.shape[1],$=_.segment_util.segOpComputeOptimalWindowSize(O,D),R={windowSize:$,inSize:O,batchSize:F,numSegments:D},N=new ese(R,w),L=n.compileAndRun(N,[x,T],C);if(c.push(L),L.shape[1]===D)return L;let G=y_({backend:n,attrs:{start:0,stop:D,step:1,dtype:"float32"}}),j=I_({inputs:{x:G},backend:n,attrs:{reps:[O/$]}});return c.push(G),c.push(j),g(L,w,j,C,D)},b=g(f,"unsortedSegmentSum",a,m,o),y=ge({inputs:{x:b},backend:n,attrs:{shape:p}}),v=y;if(u!=null){c.push(y);let x=_.getUndoAxesPermutation(u);v=Tn({inputs:{x:v},backend:n,attrs:{perm:x}})}return c.forEach(x=>n.disposeIntermediateTensorInfo(x)),v}var nse={kernelName:zl,backendName:"webgl",kernelFunc:tse},rse=[Dee,Ree,mY,bY,xY,IY,TY,_Y,AY,FY,OY,LY,WY,GY,ZY,qY,eZ,sZ,nZ,cZ,lZ,pZ,gZ,IZ,TZ,NZ,$Z,PZ,BZ,VZ,Y9,qZ,rJ,aJ,ZZ,uJ,dJ,iJ,fJ,bJ,xJ,kJ,SJ,NJ,$J,PJ,EJ,LJ,WJ,UJ,qJ,ZJ,tQ,sQ,aQ,oQ,cQ,lQ,pQ,fQ,gQ,xQ,IQ,CQ,_Q,DQ,RQ,LQ,VQ,X9,GQ,HZ,qQ,YQ,QQ,J9,ree,iee,uee,gee,hee,xee,Iee,Nee,Oee,Gee,Vee,Kee,Yee,Jee,zee,ete,nte,ote,lte,fte,kte,rY,Ste,Nte,Ate,$te,EZ,Ote,Lte,zte,Ute,qte,eY,Xte,Yte,AZ,yte,Qte,ine,rne,aY,dne,fne,yne,wne,Tne,Nne,Ane,$ne,Pne,Lne,Wne,Une,jne,Xne,Jne,wZ,xte,tre,rre,are,ire,ure,dre,hre,mre,bre,xre,kre,Sre,Nre,Ere,Dre,$re,vte,pY,Ore,Bre,Vre,jre,Xre,hY,Zre,Qre,nse,Mte];for(let e of rse)Vl(e);var $t;(function(e){e[e.float32=0]="float32",e[e.int32=1]="int32",e[e.bool=2]="bool",e[e.string=3]="string",e[e.complex64=4]="complex64"})($t||($t={}));var Yd;(function(e){e[e.linear=0]="linear",e[e.relu=1]="relu",e[e.relu6=2]="relu6",e[e.prelu=3]="prelu",e[e.leakyrelu=4]="leakyrelu",e[e.sigmoid=5]="sigmoid",e[e.elu=6]="elu"})(Yd||(Yd={}));var T_;function sse(e){T_=e.wasm.cwrap(Oo,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])}function ase(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a,bias:o,preluActivationWeights:i}=t;if(s.dtype!=="float32"||a.dtype!=="float32")throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");let{transposeA:c,transposeB:l,activation:u,leakyreluAlpha:d}=r,p=n.dataIdMap.get(s.dataId).id,h=n.dataIdMap.get(a.dataId).id,f=0;if(o!=null){let D=n.dataIdMap.get(o.dataId);if(D.shape.length!==1)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${D.shape.length}.`);f=D.id}let m=i==null?0:n.dataIdMap.get(i.dataId).id,g=Yd[u];if(g==null)throw new Error(`${u} activation not yet supported for FusedConv2D in the wasm backend.`);let b=c?s.shape[2]:s.shape[1],y=l?a.shape[1]:a.shape[2],v=su.assertAndGetBroadcastShape(s.shape.slice(0,-2),a.shape.slice(0,-2)),x=n.makeOutput([...v,b,y],s.dtype),w=n.dataIdMap.get(x.dataId).id,T=new Uint8Array(new Int32Array(s.shape).buffer),C=new Uint8Array(new Int32Array(a.shape).buffer);return T_(p,T,s.shape.length,h,C,a.shape.length,c,l,g,f,m,d||0,w),x}var ose={kernelName:Oo,backendName:"wasm",setupFunc:sse,kernelFunc:ase};function un(e,t){let n;function r(a){n=a.wasm.cwrap(e,null,["number","number","number"])}function s(a){let{backend:o,inputs:{x:i}}=a,c=o.dataIdMap.get(i.dataId).id,l=o.makeOutput(i.shape,t||i.dtype),u=o.dataIdMap.get(l.dataId).id;return k.sizeFromShape(l.shape)===0||n(c,$t[i.dtype],u),l}return{kernelName:e,backendName:"wasm",setupFunc:r,kernelFunc:s}}var ise=un(Yi);function Cn(e,t,n){let r;function s(o){r=o.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])}function a(o){let{backend:i,inputs:c}=o,{a:l,b:u}=c,d=i.dataIdMap.get(l.dataId).id,p=i.dataIdMap.get(u.dataId).id,h=n!=null?n:l.dtype,f=_.assertAndGetBroadcastShape(l.shape,u.shape),m=i.makeOutput(f,h);if(k.sizeFromShape(f)===0)return m;let g=new Uint8Array(new Int32Array(l.shape).buffer),b=new Uint8Array(new Int32Array(u.shape).buffer),y=i.dataIdMap.get(m.dataId).id;return(()=>r(d,g,l.shape.length,p,b,u.shape.length,$t[l.dtype],y))(),m}return{kernelName:e,backendName:"wasm",setupFunc:s,kernelFunc:a}}var cse=!0,use=Cn(Zs,cse),C_;function lse(e){C_=e.wasm.cwrap(Ba,null,["array","number","number","number"])}function dse(e){let{inputs:t,backend:n}=e,r=n.makeOutput(t[0].shape,t[0].dtype);if(k.sizeFromShape(r.shape)===0)return r;let s=t.map(i=>n.dataIdMap.get(i.dataId).id),a=new Uint8Array(new Int32Array(s).buffer),o=n.dataIdMap.get(r.dataId).id;return C_(a,s.length,$t[r.dtype],o),r}var pse={kernelName:Ba,backendName:"wasm",setupFunc:lse,kernelFunc:dse};function Pm(e){let{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype),s=n.typedArrayFromHeap(t);return n.typedArrayFromHeap(r).set(s),r}var hse={kernelName:so,backendName:"wasm",kernelFunc:Pm},N_;function fse(e){N_=e.wasm.cwrap(Po,null,["number","array","number","number","number","array","number"])}function Bu(e){let{inputs:t,backend:n,attrs:r}=e,[s,a]=gse(t.x.shape,r.perm),o=!0;for(let f=0;f=s&&(a===-1||r[a]>r[o])&&(a=o);r[a]=s}return[n,r]}var bse={kernelName:Po,backendName:"wasm",kernelFunc:Bu,setupFunc:fse};function Ca(e,t,n){let r=e.shape,s=e.shape.length,a=k.parseAxisParam(t,r),o=a,i=_.getAxesPermutation(o,s),c=null,l=!1;if(i!=null){let u=new Array(s);for(let h=0;h`new shape: ${o}, old shape: ${r.shape}. New shape and old shape must have the same number of elements.`),e.backend.incRef(r.dataId),{dataId:r.dataId,shape:o,dtype:r.dtype}}var Ase={kernelName:Pc,backendName:"wasm",kernelFunc:Vn},F_;function Dse(e){F_=e.wasm.cwrap(Va,null,["number","array","number","number","array","number","number","number","number"])}function Fse(e){let{inputs:t,backend:n,attrs:r}=e,{a:s,b:a}=t,{transposeA:o,transposeB:i}=r;if(s.dtype!=="float32"||a.dtype!=="float32")throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");let c=s.shape.length,l=a.shape.length,u=o?s.shape[c-2]:s.shape[c-1],d=i?a.shape[l-1]:a.shape[l-2],p=o?s.shape[c-1]:s.shape[c-2],h=i?a.shape[l-2]:a.shape[l-1],f=s.shape.slice(0,-2),m=a.shape.slice(0,-2),g=k.sizeFromShape(f),b=k.sizeFromShape(m),v=su.assertAndGetBroadcastShape(s.shape.slice(0,-2),a.shape.slice(0,-2)).concat([p,h]);k.assert(u===d,()=>`Error in matMul: inner shapes (${u}) and (${d}) of Tensors with shapes ${s.shape} and ${a.shape} and transposeA=${o} and transposeB=${i} must match.`);let x=o?[g,u,p]:[g,p,u],w=i?[b,h,d]:[b,d,h],T=Vn({inputs:{x:s},backend:n,attrs:{shape:x}}),C=Vn({inputs:{x:a},backend:n,attrs:{shape:w}}),D=n.dataIdMap.get(T.dataId).id,F=n.dataIdMap.get(C.dataId).id,O=o?T.shape[2]:T.shape[1],$=i?C.shape[1]:C.shape[2],R=Math.max(g,b),N=n.makeOutput([R,O,$],T.dtype),L=n.dataIdMap.get(N.dataId).id,G=new Uint8Array(new Int32Array(T.shape).buffer),j=new Uint8Array(new Int32Array(C.shape).buffer);return F_(D,G,T.shape.length,F,j,C.shape.length,o,i,L),n.disposeData(T.dataId),n.disposeData(C.dataId),N.shape=v,N}var $se={kernelName:Va,backendName:"wasm",setupFunc:Dse,kernelFunc:Fse};function xi(e){let{inputs:{x:t},attrs:{begin:n,size:r},backend:s}=e,[a,o]=Gt.parseSliceParams(t,n,r),i=Gt.isSliceContinous(t.shape,a,o),c=s.readSync(t.dataId),l=s.makeOutput(o,t.dtype),u=k.computeStrides(t.shape),d=s.dataIdMap.get(l.dataId);if(i){let f=Gt.computeFlatOffset(a,u);return t.dtype==="string"?d.stringBytes=c.slice(f,f+k.sizeFromShape(o)):s.typedArrayFromHeap(l).set(c.subarray(f,f+k.sizeFromShape(o))),l}if(t.dtype==="string"){let f=pm(c,a,o,t.shape,t.dtype);return d.stringBytes=f,l}let p=s.typedArrayFromHeap(l),h=t.shape.length;if(h===2)Rse(c,u[0],p,a,o);else if(h===3)Pse(c,u[0],u[1],p,a,o);else if(h===4)Ose(c,u[0],u[1],u[2],p,a,o);else{let f=pm(c,a,o,t.shape,t.dtype);p.set(f)}return l}function Rse(e,t,n,r,s){let a=0,o=r[0],i=r[1],c=o+s[0];for(let l=o;lb*y),c=_.getReshaped(s.shape,a,i),l=_.getPermuted(c.length,a.length),u=_.getReshapedPermuted(s.shape,a,i),d=_.getSliceBeginCoords(o,a.length),p=_.getSliceSize(u,o,a.length),h=Vn({inputs:{x:s},backend:n,attrs:{shape:c}}),f=Bu({inputs:{x:h},backend:n,attrs:{perm:l}}),m=Vn({inputs:{x:f},backend:n,attrs:{shape:u}}),g=xi({inputs:{x:m},backend:n,attrs:{begin:d,size:p}});return n.disposeData(h.dataId),n.disposeData(f.dataId),n.disposeData(h.dataId),g}var Bse={kernelName:oc,backendName:"wasm",kernelFunc:Lse};function Zd(e){let{inputs:{x:t},attrs:{dtype:n},backend:r}=e,s=r.makeOutput(t.shape,n),a=r.typedArrayFromHeap(t);return r.typedArrayFromHeap(s).set(a),s}var zse={kernelName:Ua,backendName:"wasm",kernelFunc:Zd},Wse=un(Ga),$_;function Vse(e){$_=e.wasm.cwrap(Js,null,["number","number","number","number"])}function Use(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{clipValueMin:a,clipValueMax:o}=r,i=n.dataIdMap.get(s.dataId).id,c=n.makeOutput(s.shape,s.dtype),l=n.dataIdMap.get(c.dataId).id;return $_(i,a,o,l),c}var Gse={kernelName:Js,backendName:"wasm",setupFunc:Vse,kernelFunc:Use};function R_(e){let{inputs:t,backend:n}=e,r=k.parseAxisParam(e.attrs.axis,t[0].shape)[0],s=_.computeOutShape(t.map(h=>h.shape),r),a=t.filter(h=>k.sizeFromShape(h.shape)>0);if(a.length===1)return Pm({inputs:{x:a[0]},backend:n});let o=n.makeOutput(s,t[0].dtype);if(k.sizeFromShape(s)===0)return o;let i=a.map(h=>h.shape);if(_.assertParamsConsistent(i,r),a[0].dtype==="string"){let h=a.map(v=>{let x=k.sizeFromShape(v.shape.slice(r));return Vn({inputs:{x:v},backend:n,attrs:{shape:[-1,x]}})}),f=h.map(v=>({vals:n.readSync(v.dataId),shape:v.shape}));s=_.computeOutShape(h.map(v=>v.shape),1);let m=h[0].shape[0]===1,g=_w(f,s,t[0].dtype,m),b=_.computeOutShape(a.map(v=>v.shape),r);o.shape=b;let y=n.dataIdMap.get(o.dataId);return y.stringBytes=_.fromStringArrayToUint8(g),h.forEach(v=>n.disposeData(v.dataId)),o}let c=k.sizeFromShape(a[0].shape.slice(0,r)),l=0,u=a.map(h=>{let f=k.sizeFromShape(h.shape.slice(r));return l+=f,f}),d=a.map(h=>n.typedArrayFromHeap(h)),p=n.typedArrayFromHeap(o);for(let h=0;h`cumsum does not support ${s.dtype} tensors in the WASM backend`);let l=_.getAxesPermutation([a],c),u=s;l!==null&&(u=Bu({inputs:{x:s},attrs:{perm:l},backend:n}));let d=_.getInnerMostAxes(1,c)[0];_.assertAxesAreInnerMostDims("cumsum",[d],c);let p=n.makeOutput(u.shape,u.dtype),h=u.shape[d],f=n.dataIdMap.get(u.dataId).id,m=n.dataIdMap.get(p.dataId).id;L_(f,o?1:0,i?1:0,h,m,$t[s.dtype]);let g=p;if(l!==null){let b=_.getUndoAxesPermutation(l);g=Bu({inputs:{x:p},attrs:{perm:b},backend:n}),n.disposeData(u.dataId),n.disposeData(p.dataId)}return g}var aae={kernelName:Xa,backendName:"wasm",setupFunc:rae,kernelFunc:sae},B_;function oae(e){B_=e.wasm.cwrap(uc,null,["number","number","number","array","number","array","array","number","number"])}function iae(e){let{backend:t,inputs:n,attrs:r}=e,{x:s}=n,{blockSize:a,dataFormat:o}=r,i=s.shape[0],c=o==="NHWC"?s.shape[1]:s.shape[2],l=o==="NHWC"?s.shape[2]:s.shape[3],u=o==="NHWC"?s.shape[3]:s.shape[1],d=c*a,p=l*a,h=u/(a*a),f=o==="NHWC"?[i,d,p,h]:[i,h,d,p],m=t.makeOutput(f,"float32"),b=t.dataIdMap.get(s.dataId).id,y=new Uint8Array(new Int32Array(k.computeStrides(s.shape)).buffer),v=new Uint8Array(new Int32Array(f).buffer),x=new Uint8Array(new Int32Array(k.computeStrides(f)).buffer),w=t.dataIdMap.get(m.dataId).id;return B_(b,a,o==="NHWC"?1:0,y,s.shape.length-1,v,x,f.length,w),m}var cae={kernelName:uc,backendName:"wasm",setupFunc:oae,kernelFunc:iae},z_;function uae(e){z_=e.wasm.cwrap(Ya,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function lae(e){let{inputs:t,attrs:n,backend:r}=e,{x:s,filter:a}=t,o=r.dataIdMap.get(s.dataId).id,i=r.dataIdMap.get(a.dataId).id,{strides:c,dilations:l,pad:u,dimRoundingMode:d}=n,p=l==null?[1,1]:l,h=_.computeConv2DInfo(s.shape,a.shape,c,p,u,d,!0),f=h.filterHeight,m=h.filterWidth,g=h.padInfo.top,b=h.padInfo.right,y=h.padInfo.bottom,v=h.padInfo.left,x=h.dilationHeight,w=h.dilationWidth,T=h.strideHeight,C=h.strideWidth,D=h.inChannels,F=h.outChannels,O=h.padInfo.type==="SAME"?1:0;if(h.dataFormat!=="channelsLast")throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${h.dataFormat}'. Please use 'channelsLast'.`);let $=r.makeOutput(h.outShape,"float32"),R=r.dataIdMap.get($.dataId).id;return z_(o,s.shape[0],s.shape[1],s.shape[2],i,f,m,g,b,y,v,O,x,w,T,C,D,F,R),$}var dae={kernelName:Ya,backendName:"wasm",setupFunc:uae,kernelFunc:lae},pae=un(Ja),hae=!1,fae=Cn(dc,hae,"bool"),mae=un(Qa,"float32");function i1(e){let{inputs:t,attrs:n,backend:r}=e,{input:s}=t,{dim:a}=n,o=s.shape.length,i=s.shape.slice(),c=a;return a<0&&(k.assert(-(o+1)<=a,()=>`Axis must be in the interval [${-(o+1)}, ${o}]`),c=o+a+1),i.splice(c,0,1),Vn({inputs:{x:s},backend:r,attrs:{shape:i}})}var gae={kernelName:pc,backendName:"wasm",kernelFunc:i1};function W_(e){let{attrs:{shape:t,value:n,dtype:r},backend:s}=e,a=s.makeOutput(t,r);return s.typedArrayFromHeap(a).fill(n),a}var bae={kernelName:El,backendName:"wasm",kernelFunc:W_},V_;function yae(e){V_=e.wasm.cwrap(fc,null,["number","number","number","number","number","number"])}function vae(e){let{inputs:t,backend:n}=e,{image:r}=t,s=n.makeOutput(r.shape,r.dtype),a=n.dataIdMap.get(r.dataId).id,o=n.dataIdMap.get(s.dataId).id,[i,c,l,u]=r.shape;return V_(a,i,c,l,u,o),s}var xae={kernelName:fc,backendName:"wasm",kernelFunc:vae,setupFunc:yae},wae=un(eo),kae=!1,Iae=Cn(to,kae),U_;function Sae(e){U_=e.wasm.cwrap(no,null,["number","number","number","number","number","number","number"])}function Tae(e){let{backend:t,inputs:n,attrs:r}=e,{varianceEpsilon:s}=r,{x:a,mean:o,variance:i,offset:c,scale:l}=n,u=t.dataIdMap.get(a.dataId).id,d=t.dataIdMap.get(o.dataId).id,p=t.dataIdMap.get(i.dataId).id,h=c!=null?t.dataIdMap.get(c.dataId).id:0,f=l!=null?t.dataIdMap.get(l.dataId).id:0,m=t.makeOutput(a.shape,a.dtype);if(k.sizeFromShape(a.shape)===0)return m;let g=t.dataIdMap.get(m.dataId).id;return U_(u,d,p,h,f,s,g),m}var Cae={kernelName:no,backendName:"wasm",setupFunc:Sae,kernelFunc:Tae},G_;function Nae(e){G_=e.wasm.cwrap(Mo,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function _ae(e){let{inputs:t,attrs:n,backend:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:c,pad:l,dilations:u,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=n,m=_.computeConv2DInfo(s.shape,a.shape,c,u,l,p),g=Yd[h];if(g==null)throw new Error(`${h} activation not yet supported for FusedConv2D in the wasm backend.`);let b=r.dataIdMap.get(s.dataId).id,y=r.dataIdMap.get(a.dataId).id,v=m.outChannels,x=0;if(o!=null){let re=r.dataIdMap.get(o.dataId);if(re.shape.length!==1)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${re.shape.length}.`);if(re.shape[0]!==v)throw new Error(`FusedConv2D bias shape (${re.shape}) does not match the number of output channels (${v})`);x=re.id}let w=m.filterHeight,T=m.filterWidth,C=m.padInfo.top,D=m.padInfo.right,F=m.padInfo.bottom,O=m.padInfo.left,$=m.dilationHeight,R=m.dilationWidth,N=m.strideHeight,L=m.strideWidth,G=m.inChannels,j=m.padInfo.type==="SAME"?1:0,K=m.batchSize,q=m.inHeight,Z=m.inWidth;if(d!=="NHWC")throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);let te=r.makeOutput(m.outShape,"float32"),se=r.dataIdMap.get(te.dataId).id,oe=i==null?0:r.dataIdMap.get(i.dataId).id;return G_(b,K,q,Z,y,w,T,x,C,D,F,O,j,$,R,N,L,G,v,g,oe,f||0,se),te}var Eae={kernelName:Mo,backendName:"wasm",setupFunc:Nae,kernelFunc:_ae},H_;function Aae(e){H_=e.wasm.cwrap(Lo,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function Dae(e){let{inputs:t,attrs:n,backend:r}=e,{x:s,filter:a,bias:o,preluActivationWeights:i}=t,{strides:c,pad:l,dilations:u,dataFormat:d,dimRoundingMode:p,activation:h,leakyreluAlpha:f}=n,m=_.computeConv2DInfo(s.shape,a.shape,c,u,l,p,!0),g=Yd[h];if(g==null)throw new Error(`${h} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);let b=r.dataIdMap.get(s.dataId).id,y=r.dataIdMap.get(a.dataId).id,v=m.outChannels,x=0;if(o!=null){let re=r.dataIdMap.get(o.dataId);if(re.shape.length!==1)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${re.shape.length}.`);if(re.shape[0]!==v)throw new Error(`FusedDepthwiseConv2D bias shape (${re.shape}) does not match the number of output channels (${v})`);x=re.id}let w=m.filterHeight,T=m.filterWidth,C=m.padInfo.top,D=m.padInfo.right,F=m.padInfo.bottom,O=m.padInfo.left,$=m.dilationHeight,R=m.dilationWidth,N=m.strideHeight,L=m.strideWidth,G=m.inChannels,j=m.padInfo.type==="SAME"?1:0,K=m.batchSize,q=m.inHeight,Z=m.inWidth;if(d!=="NHWC")throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${d}'. Please use 'NHWC'.`);let te=r.makeOutput(m.outShape,"float32"),se=r.dataIdMap.get(te.dataId).id,oe=i==null?0:r.dataIdMap.get(i.dataId).id;return H_(b,K,q,Z,y,w,T,x,C,D,F,O,j,$,R,N,L,G,v,g,oe,f||0,se),te}var Fae={kernelName:Lo,backendName:"wasm",setupFunc:Aae,kernelFunc:Dae},j_;function $ae(e){j_=e.wasm.cwrap(gc,null,["number","number","number","number","number","number","array","number"])}function Rae(e){let{backend:t,inputs:n}=e,{params:r,indices:s}=n,[a,o,i,c]=xy.prepareAndValidate(r,s),l=t.makeOutput(a,r.dtype);if(o===0)return l;let u=s.shape,d=u[u.length-1],h=t.dataIdMap.get(r.dataId).id,m=t.dataIdMap.get(s.dataId).id,g=new Uint8Array(new Int32Array(c).buffer),b=t.dataIdMap.get(l.dataId).id;return j_(h,$t[r.dtype],m,o,d,i,g,b),l}var Pae={kernelName:gc,backendName:"wasm",setupFunc:$ae,kernelFunc:Rae},q_;function Oae(e){q_=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])}function Mae(e){let{backend:t,inputs:n,attrs:r}=e,{x:s,indices:a}=n,{axis:o,batchDims:i}=r,c=k.parseAxisParam(o,s.shape)[0],l=t.readSync(a.dataId),u=s.shape[c];for(let F=0;F=0,()=>`GatherV2: the index value ${O} is not in [0, ${u-1}]`)}let d=_.segment_util.collectGatherOpShapeInfo(s,a,c,i),p=Vn({inputs:{x:s},attrs:{shape:[d.batchSize,d.outerSize,d.dimSize,d.sliceSize]},backend:t}),h=k.sizeFromShape(a.shape),f=Vn({inputs:{x:a},attrs:{shape:[d.batchSize,h/d.batchSize]},backend:t}),m=[d.batchSize,d.outerSize,h/d.batchSize,d.sliceSize],g=t.makeOutput(m,s.dtype);if(k.sizeFromShape(s.shape)===0)return g;let b=p.shape.length-1,v=t.dataIdMap.get(p.dataId).id,w=t.dataIdMap.get(f.dataId).id,T=t.dataIdMap.get(g.dataId).id,C=new Uint8Array(new Int32Array(k.computeStrides(p.shape)).buffer),D=new Uint8Array(new Int32Array(k.computeStrides(m)).buffer);return q_(v,$t[s.dtype],C,b,w,d.batchSize,D,T),t.disposeData(p.dataId),t.disposeData(f.dataId),g.shape=d.outputShape,g}var Lae={kernelName:mc,backendName:"wasm",setupFunc:Oae,kernelFunc:Mae},Bae=!1,zae=Cn(bc,Bae,"bool"),Wae=!1,Vae=Cn(ro,Wae,"bool"),K_;function Uae(e){K_=e.wasm.cwrap(ao,null,["number","number","number","number"])}function Gae(e){let{inputs:{x:t},attrs:{alpha:n},backend:r}=e,s=r.dataIdMap.get(t.dataId).id,a=r.makeOutput(t.shape,"float32");if(k.sizeFromShape(t.shape)!==0){let o=r.dataIdMap.get(a.dataId).id;K_(s,$t[t.dtype],n,o)}return a}var Hae={kernelName:ao,backendName:"wasm",setupFunc:Uae,kernelFunc:Gae},jae=!1,qae=Cn(wc,jae,"bool"),Kae=!1,Xae=Cn(kc,Kae,"bool"),Yae=un(oo),Zae=!1,Jae=Cn(Sc,Zae,"bool"),X_;function Qae(e){X_=e.wasm.cwrap(io,null,["number","number","number","number"])}function eoe(e){let{backend:t,inputs:n,attrs:r}=e,{reductionIndices:s,keepDims:a}=r,{x:o}=n,c=t.dataIdMap.get(o.dataId).id,l=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Ca(o,s,t);if(h){let v=t.dataIdMap.get(u.dataId).id;l=u,c=v}let f=l.shape.length;_.assertAxesAreInnerMostDims("max",d,f);let[m,g]=_.computeOutAndReduceShapes(l.shape,d),b=k.sizeFromShape(g),y=t.makeOutput(m,o.dtype);if(k.sizeFromShape(l.shape)!==0){let v=t.dataIdMap.get(y.dataId).id;X_(c,$t[o.dtype],b,v)}if(h&&t.disposeData(u.dataId),a){let v=_.expandShapeToKeepDim(y.shape,p);y.shape=v}return y}var toe={kernelName:io,backendName:"wasm",setupFunc:Qae,kernelFunc:eoe},noe=!1,roe=Cn(co,noe),Y_;function soe(e){Y_=e.wasm.cwrap(uo,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])}function aoe(e){let{inputs:t,attrs:n,backend:r}=e,s=t.x,a=r.dataIdMap.get(s.dataId).id;k.assert(s.dtype==="float32",()=>`Error in MaxPool: only float32 input is supported. Got ${s.dtype}.`);let{filterSize:o,strides:i,pad:c,dimRoundingMode:l}=n,u=_.computePool2DInfo(s.shape,o,i,1,c,l),d=u.filterHeight,p=u.filterWidth,h=u.padInfo.top,f=u.padInfo.right,m=u.padInfo.bottom,g=u.padInfo.left,b=u.dilationHeight,y=u.dilationWidth,v=u.strideHeight,x=u.strideWidth,w=u.inChannels,T=u.outChannels;if(u.dataFormat!=="channelsLast")throw new Error(`wasm backend does not support dataFormat:'${u.dataFormat}'. Please use 'channelsLast'.`);let C=r.makeOutput(u.outShape,"float32"),D=r.dataIdMap.get(C.dataId).id;return Y_(a,s.shape[0],s.shape[1],s.shape[2],d,p,h,f,m,g,b,y,v,x,w,T,D),C}var ooe={kernelName:uo,backendName:"wasm",setupFunc:soe,kernelFunc:aoe},Z_;function ioe(e){Z_=e.wasm.cwrap(lo,null,["number, number, number"])}function coe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,c=i,l=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Ca(o,s,t),f=d;if(h){let x=t.dataIdMap.get(u.dataId).id;x!==i&&(l=u,c=x,f=_.getInnerMostAxes(f.length,l.shape.length))}_.assertAxesAreInnerMostDims("mean",f,l.shape.length);let[m,g]=_.computeOutAndReduceShapes(l.shape,f),b=k.sizeFromShape(g),y=l;l.dtype!=="float32"&&(y=Zd({backend:t,inputs:{x:l},attrs:{dtype:"float32"}}),c=t.dataIdMap.get(y.dataId).id);let v=t.makeOutput(m,"float32");if(k.sizeFromShape(l.shape)!==0){let x=t.dataIdMap.get(v.dataId).id;Z_(c,b,x)}if(h&&t.disposeData(u.dataId),a){let x=_.expandShapeToKeepDim(v.shape,p);v.shape=x}return l.dtype!=="float32"&&t.disposeData(y.dataId),v}var uoe={kernelName:lo,backendName:"wasm",setupFunc:ioe,kernelFunc:coe},J_;function loe(e){J_=e.wasm.cwrap(po,null,["number","number","number","number"])}function doe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,c=i,l=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Ca(o,s,t);if(h){let v=t.dataIdMap.get(u.dataId).id;v!==i&&(l=u,c=v)}let f=l.shape.length;_.assertAxesAreInnerMostDims("min",d,f);let[m,g]=_.computeOutAndReduceShapes(l.shape,d),b=k.sizeFromShape(g),y=t.makeOutput(m,l.dtype);if(k.sizeFromShape(l.shape)!==0){let v=t.dataIdMap.get(y.dataId).id;J_(c,$t[o.dtype],b,v)}if(h&&t.disposeData(u.dataId),a){let v=_.expandShapeToKeepDim(y.shape,p);y.shape=v}return y}var poe={kernelName:po,backendName:"wasm",setupFunc:loe,kernelFunc:doe},hoe=!1,foe=Cn(ho,hoe),c1;(function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"})(c1||(c1={}));var Q_;function moe(e){Q_=e.wasm.cwrap(fo,null,["number","array","number","number","array","array","number","number"])}function goe(e){let{inputs:{x:t},backend:n,attrs:{paddings:r,mode:s}}=e,a=r.map((f,m)=>f[0]+t.shape[m]+f[1]),o=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(a,t.dtype),c=n.dataIdMap.get(i.dataId).id,l=new Uint8Array(new Int32Array(t.shape).buffer),u=r.map(f=>f[0]),d=r.map(f=>f[1]),p=new Uint8Array(new Int32Array(u).buffer),h=new Uint8Array(new Int32Array(d).buffer);return Q_(o,l,t.shape.length,$t[t.dtype],p,h,c1[s],c),i}var boe={kernelName:fo,backendName:"wasm",kernelFunc:goe,setupFunc:moe},yoe=!0,voe=Cn(mo,yoe),xoe=un(Cc);function u1(e,t){let n=new Int32Array(e.wasm.HEAPU8.buffer,t,4),r=n[0],s=n[1],a=n[2],o=n[3];return e.wasm._free(t),{pSelectedIndices:r,selectedSize:s,pSelectedScores:a,pValidOutputs:o}}var eE;function woe(e){eE=e.wasm.cwrap(_c,"number",["number","number","number","number","number"])}function koe(e){let{backend:t,inputs:n,attrs:r}=e,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o}=r,{boxes:i,scores:c}=n,l=t.dataIdMap.get(i.dataId).id,u=t.dataIdMap.get(c.dataId).id,d=eE(l,u,a,s,o),{pSelectedIndices:p,selectedSize:h,pSelectedScores:f,pValidOutputs:m}=u1(t,d);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([h],"int32",p)}var Ioe={kernelName:_c,backendName:"wasm",setupFunc:woe,kernelFunc:koe},tE;function Soe(e){tE=e.wasm.cwrap(Ec,"number",["number","number","number","number","number","bool"])}function Toe(e){let{backend:t,inputs:n,attrs:r}=e,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o,padToMaxOutputSize:i}=r,{boxes:c,scores:l}=n,u=t.dataIdMap.get(c.dataId).id,d=t.dataIdMap.get(l.dataId).id,p=tE(u,d,a,s,o,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=u1(t,p);t.wasm._free(m);let b=t.makeOutput([f],"int32",h),y=t.makeOutput([],"int32",g);return[b,y]}var Coe={kernelName:Ec,backendName:"wasm",setupFunc:Soe,kernelFunc:Toe},nE;function Noe(e){nE=e.wasm.cwrap(Ac,"number",["number","number","number","number","number","number"])}function _oe(e){let{backend:t,inputs:n,attrs:r}=e,{iouThreshold:s,maxOutputSize:a,scoreThreshold:o,softNmsSigma:i}=r,{boxes:c,scores:l}=n,u=t.dataIdMap.get(c.dataId).id,d=t.dataIdMap.get(l.dataId).id,p=nE(u,d,a,s,o,i),{pSelectedIndices:h,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=u1(t,p);t.wasm._free(g);let b=t.makeOutput([f],"int32",h),y=t.makeOutput([f],"float32",m);return[b,y]}var Eoe={kernelName:Ac,backendName:"wasm",setupFunc:Noe,kernelFunc:_oe},Aoe=!1,Doe=Cn(Nc,Aoe,"bool"),rE;function Foe(e){rE=e.wasm.cwrap(go,null,["number","number","number","number","number"])}function $oe(e){let{inputs:t,backend:n,attrs:r}=e,{indices:s}=t,{depth:a,onValue:o,offValue:i}=r,c=n.makeOutput([...s.shape,a],"int32"),l=n.dataIdMap.get(c.dataId).id,d=n.dataIdMap.get(s.dataId).id;return rE(d,a,o,i,l),c}var Roe={kernelName:go,backendName:"wasm",setupFunc:Foe,kernelFunc:$oe};function Poe(e){let{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(1),r}var Ooe={kernelName:Dc,backendName:"wasm",kernelFunc:Poe};function Moe(e){let{inputs:t,backend:n,attrs:r}=e,{axis:s}=r;if(t.length===1)return i1({inputs:{input:t[0]},backend:n,attrs:{dim:s}});let a=t[0].shape,o=t[0].dtype;t.forEach(u=>{k.assertShapesMatch(a,u.shape,"All tensors passed to stack must have matching shapes"),k.assert(o===u.dtype,()=>"All tensors passed to stack must have matching dtypes")});let i=[],c=t.map(u=>{let d=i1({inputs:{input:u},backend:n,attrs:{dim:s}});return i.push(d),d}),l=R_({inputs:c,backend:n,attrs:{axis:s}});return i.forEach(u=>n.disposeData(u.dataId)),l}var Loe={kernelName:Fc,backendName:"wasm",kernelFunc:Moe},sE;function Boe(e){sE=e.wasm.cwrap(bo,null,["number","array","number","number","array","array","number","number"])}function zoe(e){let{inputs:{x:t},backend:n,attrs:{paddings:r,constantValue:s}}=e,a=r.map((m,g)=>m[0]+t.shape[g]+m[1]);if(k.sizeFromShape(t.shape)===0)return W_({backend:n,attrs:{shape:a,value:s,dtype:t.dtype}});let o=n.dataIdMap.get(t.dataId).id,i=n.makeOutput(a,t.dtype),l=n.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(t.shape).buffer),d=r.map(m=>m[0]),p=r.map(m=>m[1]),h=new Uint8Array(new Int32Array(d).buffer),f=new Uint8Array(new Int32Array(p).buffer);return sE(o,u,t.shape.length,$t[t.dtype],h,f,s,l),i}var aE={kernelName:bo,backendName:"wasm",kernelFunc:zoe,setupFunc:Boe},Woe=!1,Voe=Cn(yo,Woe),oE;function Uoe(e){oE=e.wasm.cwrap(vo,null,["number","number","number"])}function Goe(e){let{inputs:t,backend:n}=e,{x:r,alpha:s}=t,a=n.dataIdMap.get(r.dataId).id,o=n.dataIdMap.get(s.dataId).id,i=a,c=r,l=c;c.dtype!=="float32"&&(l=Zd({backend:n,inputs:{x:r},attrs:{dtype:"float32"}}),i=n.dataIdMap.get(l.dataId).id);let u=n.makeOutput(r.shape,"float32"),d=n.dataIdMap.get(u.dataId).id;return oE(i,o,d),c.dtype!=="float32"&&n.disposeData(l.dataId),u}var Hoe={kernelName:vo,backendName:"wasm",setupFunc:Uoe,kernelFunc:Goe},iE;function joe(e){iE=e.wasm.cwrap($c,null,["number","number","number","number"])}function qoe(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,c=i,l=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Ca(o,s,t),f=d;if(h){let v=t.dataIdMap.get(u.dataId).id;v!==i&&(l=u,c=v,f=_.getInnerMostAxes(f.length,l.shape.length))}_.assertAxesAreInnerMostDims("prod",f,l.shape.length);let[m,g]=_.computeOutAndReduceShapes(l.shape,f),b=k.sizeFromShape(g),y=t.makeOutput(m,l.dtype);if(k.sizeFromShape(l.shape)!==0){let v=t.dataIdMap.get(y.dataId).id;iE(c,b,$t[y.dtype],v)}if(h&&t.disposeData(u.dataId),a){let v=_.expandShapeToKeepDim(y.shape,p);y.shape=v}return y}var Koe={kernelName:$c,backendName:"wasm",setupFunc:joe,kernelFunc:qoe},Xoe=e=>{let{backend:t,attrs:n}=e,{start:r,stop:s,step:a,dtype:o}=n,i=Dw(r,s,a,o),c=t.makeOutput([i.length],o);return t.typedArrayFromHeap(c).set(i),c},Yoe={kernelName:Rl,backendName:"wasm",kernelFunc:Xoe},Zoe=!0,Joe=Cn(Za,Zoe),Qoe=un(xo),eie=un(ko),cE;function tie(e){cE=e.wasm.cwrap(wo,null,["number","number","number","number","number","number","number","number","number","number"])}function nie(e){let{backend:t,inputs:n,attrs:r}=e,{images:s}=n,{alignCorners:a,halfPixelCenters:o,size:i}=r,[c,l]=i,[u,d,p,h]=s.shape,f=[u,c,l,h],m=t.dataIdMap.get(s.dataId),g;m.dtype!=="float32"&&(g=Zd({backend:t,inputs:{x:s},attrs:{dtype:"float32"}}),m=t.dataIdMap.get(g.dataId));let b=m.id,y=t.makeOutput(f,"float32");if(k.sizeFromShape(s.shape)===0)return y;let v=t.dataIdMap.get(y.dataId).id;return cE(b,u,d,p,h,c,l,a?1:0,o?1:0,v),g!=null&&t.disposeData(g.dataId),y}var rie={kernelName:wo,backendName:"wasm",setupFunc:tie,kernelFunc:nie},uE;function sie(e){uE=e.wasm.cwrap(Io,null,["number","array","number","array","number","number"])}function aie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{dims:a}=r,o=k.parseAxisParam(a,s.shape);if(s.shape.length===0)return Pm({inputs:{x:s},backend:n});let i=n.makeOutput(s.shape,s.dtype),c=n.dataIdMap.get(s.dataId).id,l=n.dataIdMap.get(i.dataId).id,u=new Uint8Array(new Int32Array(o).buffer),d=new Uint8Array(new Int32Array(s.shape).buffer);uE(c,u,o.length,d,s.shape.length,l);let p=Vn({inputs:{x:i},attrs:{shape:s.shape},backend:n});return n.disposeData(i.dataId),p}var oie={kernelName:Io,backendName:"wasm",kernelFunc:aie,setupFunc:sie},lE;function iie(e){lE=e.wasm.cwrap(Zc,null,["number","number","number","number","number","number","number","number","array","number","number"])}function cie(e){let{inputs:t,backend:n,attrs:r}=e,{image:s}=t,{radians:a,fillValue:o,center:i}=r,c=n.makeOutput(s.shape,s.dtype),l=n.dataIdMap.get(s.dataId).id,u=n.dataIdMap.get(c.dataId).id,[d,p,h,f]=s.shape,[m,g]=_.getImageCenter(i,p,h),b=o===0,y=255,v=typeof o=="number"?[o,o,o,b?0:y]:[...o,y],x=new Uint8Array(new Int32Array(v).buffer);return lE(l,d,p,h,f,a,m,g,x,v.length,u),c}var uie={kernelName:Zc,backendName:"wasm",kernelFunc:cie,setupFunc:iie},lie=un(So),die=un(To),dE;function pie(e){dE=e.wasm.cwrap(Oc,null,["number","number","number","number","number","number","array","number","number"])}function hie(e){let{backend:t,inputs:n,attrs:r}=e,{indices:s,updates:a}=n,{shape:o}=r,i=t.makeOutput(o,a.dtype);if(k.sizeFromShape(o)===0)return i;let{sliceRank:c,numUpdates:l,sliceSize:u,strides:d,outputSize:p}=wy.calculateShapes(a,s,o),f=t.dataIdMap.get(s.dataId).id,g=t.dataIdMap.get(a.dataId).id,b=new Uint8Array(new Int32Array(d).buffer),y=t.dataIdMap.get(i.dataId).id;return dE(f,g,$t[a.dtype],c,l,u,b,p,y),i}var fie={kernelName:Oc,backendName:"wasm",setupFunc:pie,kernelFunc:hie},pE;function mie(e){pE=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}function gie(e){let{inputs:t,backend:n}=e,{condition:r,t:s,e:a}=t,o=n.dataIdMap.get(r.dataId).id,i=n.dataIdMap.get(s.dataId).id,c=n.dataIdMap.get(a.dataId).id,l=n.makeOutput(s.shape,s.dtype),u=n.dataIdMap.get(l.dataId).id,d=r.shape.length,p=s.shape.length,h=d===0||d>1||p===1?1:k.sizeFromShape(s.shape.slice(1));return pE(o,i,c,h,u),l}var bie={kernelName:Mc,backendName:"wasm",kernelFunc:gie,setupFunc:mie},hE;function yie(e){hE=e.wasm.cwrap(No,null,["number","number"])}function vie(e){let{backend:t,inputs:{x:n}}=e,r=t.dataIdMap.get(n.dataId).id,s=t.makeOutput(n.shape,n.dtype),a=t.dataIdMap.get(s.dataId).id;return k.sizeFromShape(s.shape)===0||hE(r,a),s}var xie={kernelName:"Sigmoid",backendName:"wasm",setupFunc:yie,kernelFunc:vie},wie=un(Co),fE;function kie(e){fE=e.wasm.cwrap(Ao,null,["number","number","number","number"])}function Iie(e){let{backend:t,inputs:{logits:n},attrs:{dim:r}}=e,s=t.dataIdMap.get(n.dataId).id,a=t.makeOutput(n.shape,n.dtype),o=t.dataIdMap.get(a.dataId).id,i=n.shape[r],c=k.sizeFromShape(n.shape)/i;return k.sizeFromShape(a.shape)===0||fE(s,o,i,c),a}var Sie={kernelName:Ao,backendName:"wasm",setupFunc:kie,kernelFunc:Iie};function Tie(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,{blockShape:a,paddings:o}=r,i=k.sizeFromShape(a),c=[[0,0]];c.push(...o);for(let T=1+a.length;T0?c+1:0;if(u<0)throw new Error(_.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let d=s.shape.slice();d[0]=u;let p=n.dataIdMap.get(s.dataId).id,h=n.dataIdMap.get(a.dataId).id,f=n.dataIdMap.get(o.dataId).id,m=n.makeOutput(d,s.dtype),g=n.dataIdMap.get(m.dataId).id,b=n.makeOutput([4],"int32"),y=n.dataIdMap.get(b.dataId).id;bE(p,$t[s.dtype],s.shape[0],h,f,g,y,t,0);let v=n.readSync(b.dataId),x;switch(v[0]){case 0:{x=_.getSparseSegmentReductionNegativeSegmentIdsErrorMessage();break}case 1:{x=_.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage();break}case 2:x=_.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(v[1],v[2]);break;case 3:x=_.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(v[1],v[2],v[3]);break;default:x=""}if(n.disposeData(b.dataId),x)throw n.disposeData(m.dataId),new Error(x);return m}function $ie(e){return vE(e,!0)}var Rie={kernelName:Ml,backendName:"wasm",setupFunc:yE,kernelFunc:$ie};function Pie(e){return vE(e,!1)}var Oie={kernelName:Ll,backendName:"wasm",setupFunc:yE,kernelFunc:Pie};function Mie(e){let{inputs:t,attrs:n,backend:r}=e,{x:s}=t,{numOrSizeSplits:a,axis:o}=n,i=k.parseAxisParam(o,s.shape)[0],c=_.prepareSplitSize(s,a,i),l=new Array(s.shape.length).fill(0),u=s.shape.slice();return c.map(d=>{let p=[...u];p[i]=d;let h=xi({inputs:{x:s},attrs:{begin:l,size:p},backend:r});return l[i]+=d,h})}var Lie={kernelName:Gc,backendName:"wasm",kernelFunc:Mie},Bie=un(_o),zie=un(Bl),Wie=!0,Vie=Cn(Do,Wie),xE;function Uie(e){xE=e.wasm.cwrap(ea,null,["number","number","number","number"])}function Gie(e){let{backend:t,inputs:n,attrs:r}=e,{alpha:s}=r,{x:a}=n,o=t.dataIdMap.get(a.dataId).id,i=t.makeOutput(a.shape,a.dtype),c=t.dataIdMap.get(i.dataId).id;return xE(o,s,$t[a.dtype],c),i}var Hie={kernelName:ea,backendName:"wasm",setupFunc:Uie,kernelFunc:Gie},wE;function jie(e){wE=e.wasm.cwrap(jc,null,["number","array","number","array","array","array","array","array","number","number"])}function qie(e){let{backend:t,inputs:n,attrs:r}=e,{x:s}=n,{begin:a,end:o,strides:i,beginMask:c,endMask:l,ellipsisMask:u,newAxisMask:d,shrinkAxisMask:p}=r,{finalShapeSparse:h,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:b,begin:y,end:v,strides:x}=Gt.sliceInfo(s.shape,a,o,i,c,l,u,d,p),w;if(m)w=Vn({inputs:{x:s},backend:t,attrs:{shape:f}});else if(g||b){k.assert(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);let T=Gt.computeOutShape(y,v,x),C=xi({inputs:{x:s},backend:t,attrs:{begin:y,size:T}});w=Vn({inputs:{x:C},backend:t,attrs:{shape:f}}),t.disposeData(C.dataId)}else{let T=t.makeOutput(h,"float32"),C=t.dataIdMap.get(s.dataId).id,D=new Uint8Array(new Int32Array(k.computeStrides(s.shape)).buffer),F=new Uint8Array(new Int32Array(y).buffer),O=new Uint8Array(new Int32Array(v).buffer),$=new Uint8Array(new Int32Array(x).buffer),R=new Uint8Array(new Int32Array(h).buffer),N=new Uint8Array(new Int32Array(k.computeStrides(h)).buffer),L=t.dataIdMap.get(T.dataId).id;wE(C,D,s.shape.length,F,O,$,R,N,h.length,L),w=Vn({inputs:{x:T},backend:t,attrs:{shape:f}}),t.disposeData(T.dataId)}return w}var Kie={kernelName:jc,backendName:"wasm",setupFunc:jie,kernelFunc:qie},Xie=!0,Yie=Cn(Fo,Xie),kE;function Zie(e){kE=e.wasm.cwrap(Eo,null,["number","number","number","number"])}function Jie(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,c=i,l=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Ca(o,s,t),f=d;if(h){let v=t.dataIdMap.get(u.dataId).id;v!==i&&(l=u,c=v,f=_.getInnerMostAxes(f.length,l.shape.length))}_.assertAxesAreInnerMostDims("sum",f,l.shape.length);let[m,g]=_.computeOutAndReduceShapes(l.shape,f),b=k.sizeFromShape(g),y=t.makeOutput(m,l.dtype);if(k.sizeFromShape(l.shape)!==0){let v=t.dataIdMap.get(y.dataId).id;kE(c,b,$t[y.dtype],v)}if(h&&t.disposeData(u.dataId),a){let v=_.expandShapeToKeepDim(y.shape,p);y.shape=v}return y}var Qie={kernelName:Eo,backendName:"wasm",setupFunc:Zie,kernelFunc:Jie},ece=un($o),tce=un(Ro),IE;function nce(e){IE=e.wasm.cwrap(Qs,null,["number","array","number","array","number","number"])}function rce(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,a=n.dataIdMap.get(s.dataId).id,{reps:o}=r,i=new Array(s.shape.length);for(let p=0;p{let{x:r}=e,{k:s,sorted:a}=n,o=t.dataIdMap.get(r.dataId).id,i=new Uint8Array(new Int32Array(r.shape).buffer),c=r.shape.slice();c[c.length-1]=s;let l=t.makeOutput(c,r.dtype),u=t.dataIdMap.get(l.dataId).id,d=t.makeOutput(c,"int32"),p=t.dataIdMap.get(d.dataId).id;return SE(o,i,r.shape.length,$t[r.dtype],s,a,u,p),[l,d]},ice={kernelName:qc,backendName:"wasm",setupFunc:ace,kernelFunc:oce},TE;function cce(e){TE=e.wasm.cwrap(Kc,null,["number","number","bool","number","number","number","number","number","number","array","number","number","number","number","number"])}function uce(e){let{backend:t,inputs:n,attrs:r}=e,{image:s,transforms:a}=n,{interpolation:o,fillMode:i,fillValue:c,outputShape:l}=r,[u,d,p,h]=s.shape,[f,m]=l!=null?l:[d,p],g=[u,f,m,h],b=new Uint8Array(new Int32Array(k.computeStrides(s.shape)).buffer),y=t.makeOutput(g,s.dtype),v=t.dataIdMap.get(y.dataId).id,w=t.dataIdMap.get(s.dataId).id,C=t.dataIdMap.get(a.dataId).id,D=o==="nearest"?1:2,F;switch(i){case"constant":F=1;break;case"reflect":F=2;break;case"wrap":F=3;break;case"nearest":F=4;break;default:F=1;break}return TE(w,C,a.shape[0]>1,u,f,m,h,p,d,b,s.shape.length-1,D,F,c,v),y}var lce={kernelName:Kc,backendName:"wasm",setupFunc:cce,kernelFunc:uce};function dce(e){let{inputs:t,backend:n,attrs:r}=e,{value:s}=t,{axis:a}=r;a<0&&(a+=s.shape.length);let o=s.shape[a],i=s.shape.length,c=new Array(i-1),l=0;for(let h=0;h({dataId:h,dtype:f,shape:c}))}var pce={kernelName:Xc,backendName:"wasm",kernelFunc:dce};function hce(e){let{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(0),r}var fce={kernelName:Yc,backendName:"wasm",kernelFunc:hce},mce=[ise,use,pse,xse,Ise,Cse,Ese,$se,Bse,zse,Wse,Gse,Hse,Kse,Zse,Jse,Qse,nae,aae,cae,dae,pae,fae,mae,gae,bae,xae,wae,Iae,ose,Cae,Eae,Fae,Pae,Lae,zae,Vae,hse,Hae,qae,Xae,Yae,Jae,toe,roe,ooe,uoe,poe,foe,boe,voe,xoe,Ioe,Coe,Eoe,Doe,Roe,Ooe,Loe,aE,Voe,Hoe,Koe,Yoe,Joe,Qoe,eie,Ase,rie,oie,uie,die,lie,fie,bie,xie,wie,Mse,Sie,Cie,Eie,Fie,Rie,Oie,Lie,Bie,zie,Vie,Hie,Kie,Yie,Qie,ece,tce,sce,ice,lce,bse,pce,fce];for(let e of mce)Vl(e);var l1=Q();l1.registerFlag("WASM_HAS_SIMD_SUPPORT",async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11])));l1.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",async()=>{if(l1.get("IS_NODE"))return!1;try{return new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch(e){return!1}});var CE=Oa(BD()),gce='var Module={};function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;this.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);Module["wasmModule"]=null;receiveInstance(instance);return instance.exports};function moduleLoaded(){}this.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module).then(function(instance){Module=instance;moduleLoaded()})}else if(e.data.cmd==="objectTransfer"){Module["PThread"].receiveObjectTransfer(e.data)}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["_emscripten_tls_init"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].setThreadStatus(Module["_pthread_self"](),1);try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(!Module["getNoExitRuntime"]())Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["getNoExitRuntime"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}};if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){self={location:{href:__filename}};var onmessage=this.onmessage;var nodeWorkerThreads=require("worker_threads");global.Worker=nodeWorkerThreads.Worker;var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var nodeFS=require("fs");var nodeRead=function(filename){return nodeFS.readFileSync(filename,"utf8")};function globalEval(x){global.require=require;global.Module=Module;eval.call(null,x)}importScripts=function(f){globalEval(nodeRead(f))};postMessage=function(msg){parentPort.postMessage(msg)};if(typeof performance==="undefined"){performance={now:function(){return Date.now()}}}}',bce=Oa(zD()),NE=class extends wl{constructor(e){super();this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(EE),p1=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new jp(this,ks())}write(e,t,n){let r={id:this.dataIdNextNumber++};return this.move(r,e,t,n,1),r}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){let t=k.now();return e(),{kernelMs:k.now()-t}}move(e,t,n,r,s){let a=this.dataIdNextNumber++;if(r==="string"){let l=t;this.dataIdMap.set(e,{id:a,stringBytes:l,shape:n,dtype:r,memoryOffset:null,refCount:s});return}let o=k.sizeFromShape(n),i=o*k.bytesPerElement(r),c=this.wasm._malloc(i);this.dataIdMap.set(e,{id:a,memoryOffset:c,shape:n,dtype:r,refCount:s}),this.wasm.tfjs.registerTensor(a,o,c),t!=null&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,i),c)}async read(e){return this.readSync(e)}readSync(e,t,n){let{memoryOffset:r,dtype:s,shape:a,stringBytes:o}=this.dataIdMap.get(e);if(s==="string")return(t==null||t===0)&&(n==null||n>=o.length)?o:o.slice(t,n);t=t||0,n=n||k.sizeFromShape(a);let i=k.bytesPerElement(s),c=this.wasm.HEAPU8.slice(r+t*i,r+n*i);return xce(c.buffer,s)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){let n=this.dataIdMap.get(e);if(n.refCount--,!t&&n.refCount>0)return!1;this.wasm._free(n.memoryOffset),this.wasm.tfjs.disposeData(n.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){let t=this.dataIdMap.get(e);t!=null&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,n){let r;if(n==null)r=this.write(null,e,t);else{let s=this.dataIdNextNumber++;r={id:s},this.dataIdMap.set(r,{id:s,memoryOffset:n,shape:e,dtype:t,refCount:1});let a=k.sizeFromShape(e);this.wasm.tfjs.registerTensor(s,a,n)}return{dataId:r,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){let r=this.wasm.HEAPU8.buffer,{memoryOffset:s}=this.dataIdMap.get(n),a=k.sizeFromShape(e);switch(t){case"float32":return new Float32Array(r,s,a);case"int32":return new Int32Array(r,s,a);case"bool":return new Uint8Array(r,s,a);default:throw new Error(`Unknown dtype ${t}`)}}};function yce(e){return(t,n)=>(k.fetch(e,{credentials:"same-origin"}).then(r=>{r.ok||t.env.a(`failed to load wasm binary file at '${e}'`),r.arrayBuffer().then(s=>{WebAssembly.instantiate(s,t).then(a=>{n(a.instance,a.module)})})}),{})}function _E(e,t,n){if(Om!=null)return Om;let r="tfjs-backend-wasm.wasm";return e&&t?r="tfjs-backend-wasm-threaded-simd.wasm":e&&(r="tfjs-backend-wasm-simd.wasm"),Qd!=null&&Qd[r]!=null?Qd[r]:n+r}async function vce(){let[e,t]=await Promise.all([Q().getAsync("WASM_HAS_SIMD_SUPPORT"),Q().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise((n,r)=>{let s={};s.locateFile=(i,c)=>{if(i.endsWith(".worker.js")){let l=gce,u=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(u)}return i.endsWith(".wasm")?_E(e,t,Jd!=null?Jd:c):c+i},d1&&(s.instantiateWasm=yce(_E(e,t,Jd!=null?Jd:"")));let a=!1;s.onAbort=()=>{if(a||ep)return;ep=!0,r({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"})};let o;t&&e&&Om==null?(s.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+CE.default.toString()],{type:"text/javascript"}),o=(0,CE.default)(s)):o=(0,bce.default)(s),o.then(i=>{a=!0,ep=!1;let c=null;i.tfjs={init:i.cwrap("init",null,[]),initWithThreadsCount:i.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:i.cwrap("get_threads_count","number",[]),registerTensor:i.cwrap("register_tensor",null,["number","number","number"]),disposeData:i.cwrap("dispose_data",c,["number"]),dispose:i.cwrap("dispose",c,[])},n({wasm:i})})})}function xce(e,t){switch(t){case"float32":return new Float32Array(e);case"int32":return new Int32Array(e);case"bool":return new Uint8Array(e);default:throw new Error(`Unknown dtype ${t}`)}}var wce=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"],Om=null,Jd=null,Qd={},ep=!1,d1=!1;function kce(e,t=!1){if(_y("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."),ep)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`");Om=e,d1=t}function Ice(e,t=!1){if(ep)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`");if(typeof e=="string")Jd=e;else{Qd=e;let n=wce.filter(r=>Qd[r]==null);if(n.length>0)throw new Error(`There were no entries found for the following binaries: ${n.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`)}d1=t}var EE=-1,p1=-1;function Sce(e){EE=e}function Tce(){if(p1===-1)throw new Error("WASM backend not initialized.");return p1}var Cce="3.12.0",Nce=2;Vh("wasm",async()=>{let{wasm:e}=await vce();return new NE(e)},Nce);var _ce="3.12.0",Ece="3.12.0",Ace="3.12.0",Dce="3.12.0",Fce="3.12.0",$ce="3.12.0",Rce="3.12.0",Pce="3.12.0",Oce={tfjs:_ce,"tfjs-core":Ece,"tfjs-data":Ace,"tfjs-layers":Dce,"tfjs-converter":Fce,"tfjs-backend-cpu":$ce,"tfjs-backend-webgl":Rce,"tfjs-backend-wasm":Pce};var L1={};Up(L1,{AnchorPosition:()=>fs,DrawBox:()=>zm,DrawBoxOptions:()=>N1,DrawFaceLandmarks:()=>M1,DrawFaceLandmarksOptions:()=>O1,DrawTextField:()=>_a,DrawTextFieldOptions:()=>ap,drawContour:()=>Fs,drawDetections:()=>Hce,drawFaceExpressions:()=>Yce,drawFaceLandmarks:()=>Jce});function Fs(e,t,n=!1){if(e.beginPath(),t.slice(1).forEach(({x:r,y:s},a)=>{let o=t[a];e.moveTo(o.x,o.y),e.lineTo(r,s)}),n){let r=t[t.length-1],s=t[0];if(!r||!s)return;e.moveTo(r.x,r.y),e.lineTo(s.x,s.y)}e.stroke()}var b1={};Up(b1,{computeReshapedDimensions:()=>g1,getCenterPoint:()=>Ii,isDimensions:()=>Lm,isEven:()=>Mm,isFloat:()=>m1,isTensor:()=>wi,isTensor1D:()=>Mce,isTensor2D:()=>f1,isTensor3D:()=>$s,isTensor4D:()=>br,isValidNumber:()=>Kr,isValidProbablitiy:()=>zu,range:()=>ps,round:()=>ki});var Nn=class{constructor(t,n){if(!Kr(t)||!Kr(n))throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({width:t,height:n})}`);this._width=t,this._height=n}get width(){return this._width}get height(){return this._height}reverse(){return new Nn(1/this.width,1/this.height)}};function wi(e,t){return e instanceof Ee&&e.shape.length===t}function Mce(e){return wi(e,1)}function f1(e){return wi(e,2)}function $s(e){return wi(e,3)}function br(e){return wi(e,4)}function m1(e){return e%1!=0}function Mm(e){return e%2==0}function ki(e,t=2){let n=10**t;return Math.floor(e*n)/n}function Lm(e){return e&&e.width&&e.height}function g1({width:e,height:t},n){let r=n/Math.max(t,e);return new Nn(Math.round(e*r),Math.round(t*r))}function Ii(e){return e.reduce((t,n)=>t.add(n),new Pe(0,0)).div(new Pe(e.length,e.length))}function ps(e,t,n){return Array(e).fill(0).map((r,s)=>t+s*n)}function Kr(e){return!!e&&e!==1/0&&e!==-1/0&&!Number.isNaN(e)||e===0}function zu(e){return Kr(e)&&e>=0&&e<=1}var Pe=class{constructor(t,n){this._x=t,this._y=n}get x(){return this._x}get y(){return this._y}add(t){return new Pe(this.x+t.x,this.y+t.y)}sub(t){return new Pe(this.x-t.x,this.y-t.y)}mul(t){return new Pe(this.x*t.x,this.y*t.y)}div(t){return new Pe(this.x/t.x,this.y/t.y)}abs(){return new Pe(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new Pe(Math.floor(this.x),Math.floor(this.y))}};var ut=class{static isRect(t){return!!t&&[t.x,t.y,t.width,t.height].every(Kr)}static assertIsValidBox(t,n,r=!1){if(!ut.isRect(t))throw new Error(`${n} - invalid box: ${JSON.stringify(t)}, expected object with properties x, y, width, height`);if(!r&&(t.width<0||t.height<0))throw new Error(`${n} - width (${t.width}) and height (${t.height}) must be positive numbers`)}constructor(t,n=!0){let r=t||{},s=[r.left,r.top,r.right,r.bottom].every(Kr),a=[r.x,r.y,r.width,r.height].every(Kr);if(!a&&!s)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(r)}`);let[o,i,c,l]=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top];ut.assertIsValidBox({x:o,y:i,width:c,height:l},"Box.constructor",n),this._x=o,this._y=i,this._width=c,this._height=l}get x(){return this._x}get y(){return this._y}get width(){return this._width}get height(){return this._height}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get area(){return this.width*this.height}get topLeft(){return new Pe(this.left,this.top)}get topRight(){return new Pe(this.right,this.top)}get bottomLeft(){return new Pe(this.left,this.bottom)}get bottomRight(){return new Pe(this.right,this.bottom)}round(){let[t,n,r,s]=[this.x,this.y,this.width,this.height].map(a=>Math.round(a));return new ut({x:t,y:n,width:r,height:s})}floor(){let[t,n,r,s]=[this.x,this.y,this.width,this.height].map(a=>Math.floor(a));return new ut({x:t,y:n,width:r,height:s})}toSquare(){let{x:t,y:n,width:r,height:s}=this,a=Math.abs(r-s);return rn&&(i=-d+n+r,d=n),p>t&&(c=-p+t+s,p=t),l<1&&(c=2-l,l=1),u<1&&(c=2-u,u=1),{dy:o,edy:c,dx:a,edx:i,y:u,ey:p,x:l,ex:d,w:r,h:s}}calibrate(t){return new ut({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()}};var Wu=class extends ut{constructor(t,n,r,s,a=!1){super({left:t,top:n,right:r,bottom:s},a)}};var Na=class{constructor(t,n,r,s,a){this._imageDims=new Nn(a.width,a.height),this._score=t,this._classScore=n,this._className=r,this._box=new ut(s).rescale(this._imageDims)}get score(){return this._score}get classScore(){return this._classScore}get className(){return this._className}get box(){return this._box}get imageDims(){return this._imageDims}get imageWidth(){return this.imageDims.width}get imageHeight(){return this.imageDims.height}get relativeBox(){return new ut(this._box).rescale(this.imageDims.reverse())}forSize(t,n){return new Na(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:n})}};var xt=class extends Na{constructor(t,n,r){super(t,t,"",n,r)}forSize(t,n){let{score:r,relativeBox:s,imageDims:a}=super.forSize(t,n);return new xt(r,s,a)}};function y1(e,t,n=!0){let r=Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left)),s=Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)),a=r*s;return n?a/(e.area+t.area-a):a/Math.min(e.area,t.area)}function v1(e){let t=e.map(i=>i.x),n=e.map(i=>i.y),r=t.reduce((i,c)=>ccii({score:o,boxIndex:i})).sort((o,i)=>o.score-i.score).map(o=>o.boxIndex),a=[];for(;s.length>0;){let o=s.pop();a.push(o);let i=s,c=[];for(let l=0;lc[u]<=n)}return a}function Xr(e,t){return M(()=>{let[n,r,s]=t,a=xn([...e.shape.slice(0,3),1],n,"float32"),o=xn([...e.shape.slice(0,3),1],r,"float32"),i=xn([...e.shape.slice(0,3),1],s,"float32"),c=et([a,o,i],3);return fe(e,c)})}function w1(e,t=!1){return M(()=>{let[n,r]=e.shape.slice(1);if(n===r)return e;let s=Math.abs(n-r),a=Math.round(s*(t?.5:1)),o=n>r?2:1,i=p=>{let h=e.shape.slice();return h[o]=p,xn(h,0,"float32")},c=i(a),l=s-c.shape[o],d=[t&&l?i(l):null,e,c].filter(p=>!!p).map(p=>ce(p,"float32"));return et(d,o)})}function Lce(e){let t=e.slice();for(let n=t.length-1;n>0;n--){let r=Math.floor(Math.random()*(n+1)),s=t[n];t[n]=t[r],t[r]=s}return t}function tp(e){return 1/(1+Math.exp(-e))}function Bce(e){return Math.log(e/(1-e))}var Vu=class extends ut{constructor(t,n,r,s,a=!1){super({x:t,y:n,width:r,height:s},a)}};var zce=.5,Wce=.43,Vce=.45,yr=class{constructor(t,n,r=new Pe(0,0)){let{width:s,height:a}=n;this._imgDims=new Nn(s,a),this._shift=r,this._positions=t.map(o=>o.mul(new Pe(s,a)).add(r))}get shift(){return new Pe(this._shift.x,this._shift.y)}get imageWidth(){return this._imgDims.width}get imageHeight(){return this._imgDims.height}get positions(){return this._positions}get relativePositions(){return this._positions.map(t=>t.sub(this._shift).div(new Pe(this.imageWidth,this.imageHeight)))}forSize(t,n){return new this.constructor(this.relativePositions,{width:t,height:n})}shiftBy(t,n){return new this.constructor(this.relativePositions,this._imgDims,new Pe(t,n))}shiftByPoint(t){return this.shiftBy(t.x,t.y)}align(t,n={}){if(t){let a=t instanceof xt?t.box.floor():new ut(t);return this.shiftBy(a.x,a.y).align(null,n)}let{useDlibAlignment:r,minBoxPadding:s}={useDlibAlignment:!1,minBoxPadding:.2,...n};return r?this.alignDlib():this.alignMinBbox(s)}alignDlib(){let t=this.getRefPointsForAlignment(),[n,r,s]=t,a=d=>s.sub(d).magnitude(),o=(a(n)+a(r))/2,i=Math.floor(o/Vce),c=Ii(t),l=Math.floor(Math.max(0,c.x-zce*i)),u=Math.floor(Math.max(0,c.y-Wce*i));return new Vu(l,u,Math.min(i,this.imageWidth+l),Math.min(i,this.imageHeight+u))}alignMinBbox(t){let n=v1(this.positions);return n.pad(n.width*t,n.height*t)}getRefPointsForAlignment(){throw new Error("getRefPointsForAlignment not implemented by base class")}};var AE=class extends yr{getRefPointsForAlignment(){let t=this.positions;return[t[0],t[1],Ii([t[3],t[4]])]}};var Uu=class extends yr{getJawOutline(){return this.positions.slice(0,17)}getLeftEyeBrow(){return this.positions.slice(17,22)}getRightEyeBrow(){return this.positions.slice(22,27)}getNose(){return this.positions.slice(27,36)}getLeftEye(){return this.positions.slice(36,42)}getRightEye(){return this.positions.slice(42,48)}getMouth(){return this.positions.slice(48,68)}getRefPointsForAlignment(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Ii)}};var np=class{constructor(t,n){this._label=t,this._distance=n}get label(){return this._label}get distance(){return this._distance}toString(t=!0){return`${this.label}${t?` (${ki(this.distance)})`:""}`}};var rp=class extends ut{static assertIsValidLabeledBox(t,n){if(ut.assertIsValidBox(t,n),!Kr(t.label))throw new Error(`${n} - expected property label (${t.label}) to be a number`)}constructor(t,n){super(t);this._label=n}get label(){return this._label}};var Rs=class{constructor(t,n){if(typeof t!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(n)||n.some(r=>!(r instanceof Float32Array)))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=n}get label(){return this._label}get descriptors(){return this._descriptors}toJSON(){return{label:this.label,descriptors:this.descriptors.map(t=>Array.from(t))}}static fromJSON(t){let n=t.descriptors.map(r=>new Float32Array(r));return new Rs(t.label,n)}};var DE=class extends rp{static assertIsValidPredictedBox(t,n){if(rp.assertIsValidLabeledBox(t,n),!zu(t.score)||!zu(t.classScore))throw new Error(`${n} - expected properties score (${t.score}) and (${t.classScore}) to be a number between [0, 1]`)}constructor(t,n,r,s){super(t,n);this._score=r,this._classScore=s}get score(){return this._score}get classScore(){return this._classScore}};function hs(e){return e.detection instanceof xt}function Si(e,t){return{...e,...{detection:t}}}function k1(){let e=window.fetch;if(!e)throw new Error("fetch - missing fetch implementation for browser environment");return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D,Image:HTMLImageElement,ImageData,Video:HTMLVideoElement,createCanvasElement:()=>document.createElement("canvas"),createImageElement:()=>document.createElement("img"),createVideoElement:()=>document.createElement("video"),fetch:e,readFile:()=>{throw new Error("readFile - filesystem not available for browser environment")}}}function sp(){return typeof global=="object"&&typeof process!="undefined"&&process.versions!=null&&process.versions.node!=null}function Bm(e){let t="";if(!e&&sp())try{e=pD("fs")}catch(r){t=r.toString()}return{readFile:e?r=>new Promise((s,a)=>{e.readFile(r,(o,i)=>o?a(o):s(i))}):()=>{throw new Error(`readFile - failed to require fs in nodejs environment with error: ${t}`)}}}function I1(){let e=global.Canvas||global.HTMLCanvasElement,t=global.Image||global.HTMLImageElement,n=global.Video||global.HTMLVideoElement,r=()=>{if(e)return new e;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},s=()=>{if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},a=()=>{if(n)return new n;throw new Error("createVideoElement - missing Video implementation for nodejs environment")},o=global.fetch,i=Bm();return{Canvas:e||class{},CanvasRenderingContext2D:global.CanvasRenderingContext2D||class{},Image:t||class{},ImageData:global.ImageData||class{},Video:global.HTMLVideoElement||class{},createCanvasElement:r,createImageElement:s,createVideoElement:a,fetch:o,...i}}function S1(){return typeof window=="object"&&typeof document!="undefined"&&typeof HTMLImageElement!="undefined"&&typeof HTMLCanvasElement!="undefined"&&typeof HTMLVideoElement!="undefined"&&typeof ImageData!="undefined"&&typeof CanvasRenderingContext2D!="undefined"}var nn;function Uce(){if(!nn)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return nn}function T1(e){nn=e}function C1(){return S1()?T1(k1()):sp()?T1(I1()):null}function Gce(e){if(nn||C1(),!nn)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");let{Canvas:t=nn.Canvas,Image:n=nn.Image}=e;nn.Canvas=t,nn.Image=n,nn.createCanvasElement=e.createCanvasElement||(()=>new t),nn.createImageElement=e.createImageElement||(()=>new n),nn.ImageData=e.ImageData||nn.ImageData,nn.Video=e.Video||nn.Video,nn.fetch=e.fetch||nn.fetch,nn.readFile=e.readFile||nn.readFile}var tt={getEnv:Uce,setEnv:T1,initialize:C1,createBrowserEnv:k1,createFileSystem:Bm,createNodejsEnv:I1,monkeyPatch:Gce,isBrowser:S1,isNodejs:sp};C1();function Ti(e){return!tt.isNodejs()&&typeof e=="string"?document.getElementById(e):e}function Un(e){let{Canvas:t,CanvasRenderingContext2D:n}=tt.getEnv();if(e instanceof n)return e;let r=Ti(e);if(!(r instanceof t))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");let s=r.getContext("2d");if(!s)throw new Error("resolveContext2d - canvas 2d context is null");return s}var fs;(function(s){s.TOP_LEFT="TOP_LEFT",s.TOP_RIGHT="TOP_RIGHT",s.BOTTOM_LEFT="BOTTOM_LEFT",s.BOTTOM_RIGHT="BOTTOM_RIGHT"})(fs||(fs={}));var ap=class{constructor(t={}){let{anchorPosition:n,backgroundColor:r,fontColor:s,fontSize:a,fontStyle:o,padding:i}=t;this.anchorPosition=n||fs.TOP_LEFT,this.backgroundColor=r||"rgba(0, 0, 0, 0.5)",this.fontColor=s||"rgba(255, 255, 255, 1)",this.fontSize=a||14,this.fontStyle=o||"Georgia",this.padding=i||4}},_a=class{constructor(t,n,r={}){this.text=typeof t=="string"?[t]:t instanceof _a?t.text:t,this.anchor=n,this.options=new ap(r)}measureWidth(t){let{padding:n}=this.options;return this.text.map(r=>t.measureText(r).width).reduce((r,s)=>r{let f=c+d.x,m=c+d.y+(h+1)*o;r.fillText(p,f,m)})}};var N1=class{constructor(t={}){let{boxColor:n,lineWidth:r,label:s,drawLabelOptions:a}=t;this.boxColor=n||"rgba(0, 0, 255, 1)",this.lineWidth=r||2,this.label=s;let o={anchorPosition:fs.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new ap({...o,...a})}},zm=class{constructor(t,n={}){this.box=new ut(t),this.options=new N1(n)}draw(t){let n=Un(t),{boxColor:r,lineWidth:s}=this.options,{x:a,y:o,width:i,height:c}=this.box;n.strokeStyle=r,n.lineWidth=s,n.strokeRect(a,o,i,c);let{label:l}=this.options;l&&new _a([l],{x:a-s/2,y:o},this.options.drawLabelOptions).draw(t)}};function Hce(e,t){(Array.isArray(t)?t:[t]).forEach(r=>{let s=r instanceof xt?r.score:hs(r)?r.detection.score:void 0,a=r instanceof xt?r.box:hs(r)?r.detection.box:new ut(r),o=s?`${ki(s)}`:void 0;new zm(a,{label:o}).draw(e)})}function op(e){let{Image:t,Video:n}=tt.getEnv();return e instanceof t&&e.complete||e instanceof n&&e.readyState>=3}function _1(e){return new Promise((t,n)=>{(e instanceof tt.getEnv().Canvas||op(e))&&t(null);function r(a){!a.currentTarget||(a.currentTarget.removeEventListener("load",s),a.currentTarget.removeEventListener("error",r),n(a))}function s(a){!a.currentTarget||(a.currentTarget.removeEventListener("load",s),a.currentTarget.removeEventListener("error",r),t(a))}e.addEventListener("load",s),e.addEventListener("error",r)})}function E1(e){return new Promise((t,n)=>{e instanceof Blob||n(new Error("bufferToImage - expected buf to be of type: Blob"));let r=new FileReader;r.onload=()=>{typeof r.result!="string"&&n(new Error("bufferToImage - expected reader.result to be a string, in onload"));let s=tt.getEnv().createImageElement();s.onload=()=>t(s),s.onerror=n,s.src=r.result},r.onerror=n,r.readAsDataURL(e)})}function Ci(e){let{Image:t,Video:n}=tt.getEnv();return e instanceof t?new Nn(e.naturalWidth,e.naturalHeight):e instanceof n?new Nn(e.videoWidth,e.videoHeight):new Nn(e.width,e.height)}function Ni({width:e,height:t}){let{createCanvasElement:n}=tt.getEnv(),r=n();return r.width=e,r.height=t,r}function ip(e,t){let{ImageData:n}=tt.getEnv();if(!(e instanceof n)&&!op(e))throw new Error("createCanvasFromMedia - media has not finished loading yet");let{width:r,height:s}=t||Ci(e),a=Ni({width:r,height:s});return e instanceof n?Un(a).putImageData(e,0,0):Un(a).drawImage(e,0,0,r,s),a}async function A1(e,t){let n=t||tt.getEnv().createCanvasElement(),[r,s,a]=e.shape.slice(br(e)?1:0),o=M(()=>e.as3D(r,s,a).toInt());return await Go.toPixels(o,n),o.dispose(),n}function Wm(e){let{Image:t,Canvas:n,Video:r}=tt.getEnv();return e instanceof t||e instanceof n||e instanceof r}function D1(e,t,n=!1){let{Image:r,Canvas:s}=tt.getEnv();if(!(e instanceof r||e instanceof s))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");if(t<=0)return Ni({width:1,height:1});let a=Ci(e),o=t/Math.max(a.height,a.width),i=o*a.width,c=o*a.height,l=Ni({width:t,height:t}),u=e instanceof s?e:ip(e),d=Math.abs(i-c)/2,p=n&&i0&&u.height>0&&Un(l).drawImage(u,p,h,i,c),l}var Ps=class{constructor(t,n=!1){this._imageTensors=[];this._canvases=[];this._treatAsBatchInput=!1;this._inputDimensions=[];this._inputSize=0;if(!Array.isArray(t))throw new Error(`NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have ${t}`);this._treatAsBatchInput=n,this._batchSize=t.length,t.forEach((r,s)=>{if($s(r)){this._imageTensors[s]=r,this._inputDimensions[s]=r.shape;return}if(br(r)){let o=r.shape[0];if(o!==1)throw new Error(`NetInput - tf.Tensor4D with batchSize ${o} passed, but not supported in input array`);this._imageTensors[s]=r,this._inputDimensions[s]=r.shape.slice(1);return}let a=r instanceof tt.getEnv().Canvas?r:ip(r);this._canvases[s]=a,this._inputDimensions[s]=[a.height,a.width,3]})}get imageTensors(){return this._imageTensors}get canvases(){return this._canvases}get isBatchInput(){return this.batchSize>1||this._treatAsBatchInput}get batchSize(){return this._batchSize}get inputDimensions(){return this._inputDimensions}get inputSize(){return this._inputSize}get reshapedInputDimensions(){return ps(this.batchSize,0,1).map((t,n)=>this.getReshapedInputDimensions(n))}getInput(t){return this.canvases[t]||this.imageTensors[t]}getInputDimensions(t){return this._inputDimensions[t]}getInputHeight(t){return this._inputDimensions[t][0]}getInputWidth(t){return this._inputDimensions[t][1]}getReshapedInputDimensions(t){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");let n=this.getInputWidth(t),r=this.getInputHeight(t);return g1({width:n,height:r},this.inputSize)}toBatchTensor(t,n=!0){return this._inputSize=t,M(()=>{let r=ps(this.batchSize,0,1).map(a=>{let o=this.getInput(a);if(o instanceof Ee){let i=br(o)?o:mn(o);return i=w1(i,n),(i.shape[1]!==t||i.shape[2]!==t)&&(i=er.resizeBilinear(i,[t,t],!1,!1)),i.as3D(t,t,3)}if(o instanceof tt.getEnv().Canvas)return Go.fromPixels(D1(o,t,n));throw new Error(`toBatchTensor - at batchIdx ${a}, expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have ${o}`)});return Ot(r.map(a=>ce(a,"float32"))).as4D(this.batchSize,t,t,3)})}};async function bt(e){if(e instanceof Ps)return e;let t=Array.isArray(e)?e:[e];if(!t.length)throw new Error("toNetInput - empty array passed as input");let n=s=>Array.isArray(e)?` at input index ${s}:`:"",r=t.map(Ti);return r.forEach((s,a)=>{if(!Wm(s)&&!$s(s)&&!br(s))throw typeof t[a]=="string"?new Error(`toNetInput -${n(a)} string passed, but could not resolve HTMLElement for element id ${t[a]}`):new Error(`toNetInput -${n(a)} expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id`);if(br(s)){let o=s.shape[0];if(o!==1)throw new Error(`toNetInput -${n(a)} tf.Tensor4D with batchSize ${o} passed, but not supported in input array`)}}),await Promise.all(r.map(s=>Wm(s)&&_1(s))),new Ps(r,Array.isArray(e))}async function Gu(e,t){let{Canvas:n}=tt.getEnv(),r=e;if(!(e instanceof n)){let o=await bt(e);if(o.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");let i=o.getInput(0);r=i instanceof n?i:await A1(i)}let s=Un(r);return t.map(o=>o instanceof xt?o.forSize(r.width,r.height).box.floor():o).map(o=>o.clipAtImageBorders(r.width,r.height)).map(({x:o,y:i,width:c,height:l})=>{let u=Ni({width:c,height:l});return c>0&&l>0&&Un(u).putImageData(s.getImageData(o,i,c,l),0,0),u})}async function Hu(e,t){if(!$s(e)&&!br(e))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(br(e)&&e.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return M(()=>{let[n,r,s]=e.shape.slice(br(e)?1:0);return t.map(i=>i instanceof xt?i.forSize(r,n).box:i).map(i=>i.clipAtImageBorders(r,n)).map(({x:i,y:c,width:l,height:u})=>pu(e.as3D(n,r,s),[c,i,0],[u,l,s]))})}async function Os(e,t){let{fetch:n}=tt.getEnv(),r=await n(e,t);if(!(r.status<400))throw new Error(`failed to fetch: (${r.status}) ${r.statusText}, from url: ${r.url}`);return r}async function jce(e){let t=await Os(e),n=await t.blob();if(!n.type.startsWith("image/"))throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${n.type}, for url: ${t.url}`);return E1(n)}async function F1(e){return(await Os(e)).json()}async function qce(e){return new Float32Array(await(await Os(e)).arrayBuffer())}function FE(e){return new Promise((t,n)=>{e instanceof Blob||n(new Error("bufferToVideo - expected buf to be of type: Blob"));let r=tt.getEnv().createVideoElement();r.oncanplay=()=>t(r),r.onerror=n,r.playsInline=!0,r.muted=!0,r.src=URL.createObjectURL(e),r.play()})}async function Kce(e){let t=await Os(e),n=await t.blob();if(!n.type.startsWith("video/"))throw new Error(`fetchVideo - expected blob type to be of type video/*, instead have: ${n.type}, for url: ${t.url}`);return FE(n)}function Vm(e,t){let n=`${t}-weights_manifest.json`;if(!e)return{modelBaseUri:"",manifestUri:n};if(e==="/")return{modelBaseUri:"/",manifestUri:`/${n}`};let r=e.startsWith("http://")?"http://":e.startsWith("https://")?"https://":"";e=e.replace(r,"");let s=e.split("/").filter(i=>i),a=e.endsWith(".json")?s[s.length-1]:n,o=r+(e.endsWith(".json")?s.slice(0,s.length-1):s).join("/");return o=e.startsWith("/")?`/${o}`:o,{modelBaseUri:o,manifestUri:o==="/"?`/${a}`:`${o}/${a}`}}async function $1(e,t){let{manifestUri:n,modelBaseUri:r}=Vm(e,t),s=await F1(n);return Yt.loadWeights(s,r)}function Xce(e,t,n=!1){let{width:r,height:s}=n?Ci(t):t;return e.width=r,e.height=s,{width:r,height:s}}var ln=class{constructor(t){this._params=void 0;this._paramMappings=[];this._name=t}get params(){return this._params}get paramMappings(){return this._paramMappings}get isLoaded(){return!!this.params}getParamFromPath(t){let{obj:n,objProp:r}=this.traversePropertyPath(t);return n[r]}reassignParamFromPath(t,n){let{obj:r,objProp:s}=this.traversePropertyPath(t);r[s].dispose(),r[s]=n}getParamList(){return this._paramMappings.map(({paramPath:t})=>({path:t,tensor:this.getParamFromPath(t)}))}getTrainableParams(){return this.getParamList().filter(t=>t.tensor instanceof ra)}getFrozenParams(){return this.getParamList().filter(t=>!(t.tensor instanceof ra))}variable(){this.getFrozenParams().forEach(({path:t,tensor:n})=>{this.reassignParamFromPath(t,n.variable())})}freeze(){this.getTrainableParams().forEach(({path:t,tensor:n})=>{let r=Kn(n.dataSync());n.dispose(),this.reassignParamFromPath(t,r)})}dispose(t=!0){this.getParamList().forEach(n=>{if(t&&n.tensor.isDisposed)throw new Error(`param tensor has already been disposed for path ${n.path}`);n.tensor.dispose()}),this._params=void 0}serializeParams(){return new Float32Array(this.getParamList().map(({tensor:t})=>Array.from(t.dataSync())).reduce((t,n)=>t.concat(n)))}async load(t){if(t instanceof Float32Array){this.extractWeights(t);return}await this.loadFromUri(t)}async loadFromUri(t){if(t&&typeof t!="string")throw new Error(`${this._name}.loadFromUri - expected model uri`);let n=await $1(t,this.getDefaultModelName());this.loadFromWeightMap(n)}async loadFromDisk(t){if(t&&typeof t!="string")throw new Error(`${this._name}.loadFromDisk - expected model file path`);let{readFile:n}=tt.getEnv(),{manifestUri:r,modelBaseUri:s}=Vm(t,this.getDefaultModelName()),a=l=>Promise.all(l.map(u=>n(u).then(d=>d.buffer))),o=Yt.weightsLoaderFactory(a),i=JSON.parse((await n(r)).toString()),c=await o(i,s);this.loadFromWeightMap(c)}loadFromWeightMap(t){let{paramMappings:n,params:r}=this.extractParamsFromWeightMap(t);this._paramMappings=n,this._params=r}extractWeights(t){let{paramMappings:n,params:r}=this.extractParams(t);this._paramMappings=n,this._params=r}traversePropertyPath(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");let n=t.split("/").reduce((a,o)=>{if(!a.nextObj.hasOwnProperty(o))throw new Error(`traversePropertyPath - object does not have property ${o}, for path ${t}`);return{obj:a.nextObj,objProp:o,nextObj:a.nextObj[o]}},{nextObj:this.params}),{obj:r,objProp:s}=n;if(!r||!s||!(r[s]instanceof Ee))throw new Error(`traversePropertyPath - parameter is not a tensor, for path ${t}`);return{obj:r,objProp:s}}};function Gn(e,t,n){return M(()=>{let r=ei(e,t.depthwise_filter,t.pointwise_filter,n,"same");return r=Y(r,t.bias),r})}function Um(e,t,n=!1){return M(()=>{let r=qe(n?Y(Rt(e,t.conv0.filters,[2,2],"same"),t.conv0.bias):Gn(e,t.conv0,[2,2])),s=Gn(r,t.conv1,[1,1]),a=qe(Y(r,s)),o=Gn(a,t.conv2,[1,1]);return qe(Y(r,Y(s,o)))})}function cp(e,t,n=!1,r=!0){return M(()=>{let s=qe(n?Y(Rt(e,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):Gn(e,t.conv0,r?[2,2]:[1,1])),a=Gn(s,t.conv1,[1,1]),o=qe(Y(s,a)),i=Gn(o,t.conv2,[1,1]),c=qe(Y(s,Y(a,i))),l=Gn(c,t.conv3,[1,1]);return qe(Y(s,Y(a,Y(i,l))))})}function _i(e,t,n="same",r=!1){return M(()=>{let s=Y(Rt(e,t.filters,[1,1],n),t.bias);return r?qe(s):s})}function _n(e,t){Object.keys(e).forEach(n=>{t.some(r=>r.originalPath===n)||e[n].dispose()})}function ju(e,t){return(n,r,s,a)=>{let o=Br(e(n*r*s*s),[s,s,n,r]),i=He(e(r));return t.push({paramPath:`${a}/filters`},{paramPath:`${a}/bias`}),{filters:o,bias:i}}}function Gm(e,t){return(n,r,s)=>{let a=Lr(e(n*r),[n,r]),o=He(e(r));return t.push({paramPath:`${s}/weights`},{paramPath:`${s}/bias`}),{weights:a,bias:o}}}var Hm=class{constructor(t,n,r){this.depthwise_filter=t;this.pointwise_filter=n;this.bias=r}};function qu(e,t){return(n,r,s)=>{let a=Br(e(3*3*n),[3,3,n,1]),o=Br(e(n*r),[1,1,n,r]),i=He(e(r));return t.push({paramPath:`${s}/depthwise_filter`},{paramPath:`${s}/pointwise_filter`},{paramPath:`${s}/bias`}),new Hm(a,o,i)}}function Ku(e){return t=>{let n=e(`${t}/depthwise_filter`,4),r=e(`${t}/pointwise_filter`,4),s=e(`${t}/bias`,1);return new Hm(n,r,s)}}function ar(e,t){return(n,r,s)=>{let a=e[n];if(!wi(a,r))throw new Error(`expected weightMap[${n}] to be a Tensor${r}D, instead have ${a}`);return t.push({originalPath:n,paramPath:s||n}),a}}function En(e){let t=e;function n(s){let a=t.slice(0,s);return t=t.slice(s),a}function r(){return t}return{extractWeights:n,getRemainingWeights:r}}function jm(e,t){let n=ju(e,t),r=qu(e,t);function s(o,i,c,l=!1){let u=l?n(o,i,3,`${c}/conv0`):r(o,i,`${c}/conv0`),d=r(i,i,`${c}/conv1`),p=r(i,i,`${c}/conv2`);return{conv0:u,conv1:d,conv2:p}}function a(o,i,c,l=!1){let{conv0:u,conv1:d,conv2:p}=s(o,i,c,l),h=r(i,i,`${c}/conv3`);return{conv0:u,conv1:d,conv2:p,conv3:h}}return{extractDenseBlock3Params:s,extractDenseBlock4Params:a}}function $E(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),{extractDenseBlock4Params:s}=jm(n,t),a=s(3,32,"dense0",!0),o=s(32,64,"dense1"),i=s(64,128,"dense2"),c=s(128,256,"dense3");if(r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{dense0:a,dense1:o,dense2:i,dense3:c}}}function qm(e){return t=>{let n=e(`${t}/filters`,4),r=e(`${t}/bias`,1);return{filters:n,bias:r}}}function Km(e,t){let n=ar(e,t),r=qm(n),s=Ku(n);function a(i,c=!1){let l=c?r(`${i}/conv0`):s(`${i}/conv0`),u=s(`${i}/conv1`),d=s(`${i}/conv2`);return{conv0:l,conv1:u,conv2:d}}function o(i,c=!1){let l=c?r(`${i}/conv0`):s(`${i}/conv0`),u=s(`${i}/conv1`),d=s(`${i}/conv2`),p=s(`${i}/conv3`);return{conv0:l,conv1:u,conv2:d,conv3:p}}return{extractDenseBlock3Params:a,extractDenseBlock4Params:o}}function RE(e){let t=[],{extractDenseBlock4Params:n}=Km(e,t),r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2"),dense3:n("dense3")};return _n(e,t),{params:r,paramMappings:t}}var up=class extends ln{constructor(){super("FaceFeatureExtractor")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("FaceFeatureExtractor - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(112,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=cp(a,n.dense0,!0);return o=cp(o,n.dense1),o=cp(o,n.dense2),o=cp(o,n.dense3),o=lr(o,[7,7],[2,2],"valid"),o})}async forward(t){return this.forwardInput(await bt(t))}getDefaultModelName(){return"face_feature_extractor_model"}extractParamsFromWeightMap(t){return RE(t)}extractParams(t){return $E(t)}};function lp(e,t){return M(()=>Y(De(e,t.weights),t.bias))}function PE(e,t,n){let r=[],{extractWeights:s,getRemainingWeights:a}=En(e),i=Gm(s,r)(t,n,"fc");if(a().length!==0)throw new Error(`weights remaing after extract: ${a().length}`);return{paramMappings:r,params:{fc:i}}}function OE(e){let t=[],n=ar(e,t);function r(a){let o=n(`${a}/weights`,2),i=n(`${a}/bias`,1);return{weights:o,bias:i}}let s={fc:r("fc")};return _n(e,t),{params:s,paramMappings:t}}function Xm(e){let t={},n={};return Object.keys(e).forEach(r=>{let s=r.startsWith("fc")?n:t;s[r]=e[r]}),{featureExtractorMap:t,classifierMap:n}}var dp=class extends ln{constructor(t,n){super(t);this._faceFeatureExtractor=n}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(t){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return M(()=>{let r=t instanceof Ps?this.faceFeatureExtractor.forwardInput(t):t;return lp(r.as2D(r.shape[0],-1),n.fc)})}dispose(t=!0){this.faceFeatureExtractor.dispose(t),super.dispose(t)}loadClassifierParams(t){let{params:n,paramMappings:r}=this.extractClassifierParams(t);this._params=n,this._paramMappings=r}extractClassifierParams(t){return PE(t,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())}extractParamsFromWeightMap(t){let{featureExtractorMap:n,classifierMap:r}=Xm(t);return this.faceFeatureExtractor.loadFromWeightMap(n),OE(r)}extractParams(t){let n=this.getClassifierChannelsIn(),r=this.getClassifierChannelsOut(),s=r*n+r,a=t.slice(0,t.length-s),o=t.slice(t.length-s);return this.faceFeatureExtractor.extractWeights(a),this.extractClassifierParams(o)}};var R1=["neutral","happy","sad","angry","fearful","disgusted","surprised"],Ea=class{constructor(t){this.neutral=0;this.happy=0;this.sad=0;this.angry=0;this.fearful=0;this.disgusted=0;this.surprised=0;if(t.length!==7)throw new Error(`FaceExpressions.constructor - expected probabilities.length to be 7, have: ${t.length}`);R1.forEach((n,r)=>{this[n]=t[r]})}asSortedArray(){return R1.map(t=>({expression:t,probability:this[t]})).sort((t,n)=>n.probability-t.probability)}};var Ym=class extends dp{constructor(t=new up){super("FaceExpressionNet",t)}forwardInput(t){return M(()=>Mr(this.runNet(t)))}async forward(t){return this.forwardInput(await bt(t))}async predictExpressions(t){let n=await bt(t),r=await this.forwardInput(n),s=await Promise.all(ht(r).map(async o=>{let i=o.dataSync();return o.dispose(),i}));r.dispose();let a=s.map(o=>new Ea(o));return n.isBatchInput?a:a[0]}getDefaultModelName(){return"face_expression_model"}getClassifierChannelsIn(){return 256}getClassifierChannelsOut(){return 7}};function P1(e){return e.expressions instanceof Ea}function Zm(e,t){return{...e,...{expressions:t}}}function Yce(e,t,n=.1,r){(Array.isArray(t)?t:[t]).forEach(a=>{let o=a instanceof Ea?a:P1(a)?a.expressions:void 0;if(!o)throw new Error("drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof");let c=o.asSortedArray().filter(d=>d.probability>n),l=hs(a)?a.detection.box.bottomLeft:r||new Pe(0,0);new _a(c.map(d=>`${d.expression} (${ki(d.probability)})`),l).draw(e)})}function Ei(e){return hs(e)&&e.landmarks instanceof yr&&e.unshiftedLandmarks instanceof yr&&e.alignedRect instanceof xt}function Zce(e){let t=(i,c,l,u)=>Math.atan2(u-c,l-i)%Math.PI,n=i=>i*180/Math.PI,r={roll:void 0,pitch:void 0,yaw:void 0};if(!e||!e._positions||e._positions.length!==68)return r;let s=e._positions;r.roll=-t(s[36]._x,s[36]._y,s[45]._x,s[45]._y),r.pitch=t(0,Math.abs(s[0]._x-s[30]._x)/s[30]._x,Math.PI,Math.abs(s[16]._x-s[30]._x)/s[30]._x);let a=s.reduce((i,c)=>ii>c._y?i:c._y,-1/0);return r.yaw=Math.PI*(e._imgDims._height/(o-a)/1.4-1),r}function Xu(e,t){let{box:n}=e.detection,r=t.shiftBy(n.x,n.y),s=r.align(),{imageDims:a}=e.detection,o=new xt(e.detection.score,s.rescale(a.reverse()),a),i=Zce(t);return{...e,...{landmarks:r,unshiftedLandmarks:t,alignedRect:o,angle:i}}}var O1=class{constructor(t={}){let{drawLines:n=!0,drawPoints:r=!0,lineWidth:s,lineColor:a,pointSize:o,pointColor:i}=t;this.drawLines=n,this.drawPoints=r,this.lineWidth=s||1,this.pointSize=o||2,this.lineColor=a||"rgba(0, 255, 255, 1)",this.pointColor=i||"rgba(255, 0, 255, 1)"}},M1=class{constructor(t,n={}){this.faceLandmarks=t,this.options=new O1(n)}draw(t){let n=Un(t),{drawLines:r,drawPoints:s,lineWidth:a,lineColor:o,pointSize:i,pointColor:c}=this.options;if(r&&this.faceLandmarks instanceof Uu&&(n.strokeStyle=o,n.lineWidth=a,Fs(n,this.faceLandmarks.getJawOutline()),Fs(n,this.faceLandmarks.getLeftEyeBrow()),Fs(n,this.faceLandmarks.getRightEyeBrow()),Fs(n,this.faceLandmarks.getNose()),Fs(n,this.faceLandmarks.getLeftEye(),!0),Fs(n,this.faceLandmarks.getRightEye(),!0),Fs(n,this.faceLandmarks.getMouth(),!0)),s){n.strokeStyle=c,n.fillStyle=c;let l=u=>{n.beginPath(),n.arc(u.x,u.y,i,0,2*Math.PI),n.fill()};this.faceLandmarks.positions.forEach(l)}}};function Jce(e,t){(Array.isArray(t)?t:[t]).forEach(r=>{let s=r instanceof yr?r:Ei(r)?r.landmarks:void 0;if(!s)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks> or array thereof");new M1(s).draw(e)})}var ME="1.6.1";function eue(e,t){let n=ju(e,t),r=qu(e,t);function s(o,i,c){let l=r(o,i,`${c}/separable_conv0`),u=r(i,i,`${c}/separable_conv1`),d=n(o,i,1,`${c}/expansion_conv`);return{separable_conv0:l,separable_conv1:u,expansion_conv:d}}function a(o,i){let c=r(o,o,`${i}/separable_conv0`),l=r(o,o,`${i}/separable_conv1`),u=r(o,o,`${i}/separable_conv2`);return{separable_conv0:c,separable_conv1:l,separable_conv2:u}}return{extractConvParams:n,extractSeparableConvParams:r,extractReductionBlockParams:s,extractMainBlockParams:a}}function LE(e,t){let n=[],{extractWeights:r,getRemainingWeights:s}=En(e),{extractConvParams:a,extractSeparableConvParams:o,extractReductionBlockParams:i,extractMainBlockParams:c}=eue(r,n),l=a(3,32,3,"entry_flow/conv_in"),u=i(32,64,"entry_flow/reduction_block_0"),d=i(64,128,"entry_flow/reduction_block_1"),p={conv_in:l,reduction_block_0:u,reduction_block_1:d},h={};ps(t,0,1).forEach(b=>{h[`main_block_${b}`]=c(128,`middle_flow/main_block_${b}`)});let f=i(128,256,"exit_flow/reduction_block"),m=o(256,512,"exit_flow/separable_conv"),g={reduction_block:f,separable_conv:m};if(s().length!==0)throw new Error(`weights remaing after extract: ${s().length}`);return{paramMappings:n,params:{entry_flow:p,middle_flow:h,exit_flow:g}}}function tue(e,t){let n=ar(e,t),r=qm(n),s=Ku(n);function a(i){let c=s(`${i}/separable_conv0`),l=s(`${i}/separable_conv1`),u=r(`${i}/expansion_conv`);return{separable_conv0:c,separable_conv1:l,expansion_conv:u}}function o(i){let c=s(`${i}/separable_conv0`),l=s(`${i}/separable_conv1`),u=s(`${i}/separable_conv2`);return{separable_conv0:c,separable_conv1:l,separable_conv2:u}}return{extractConvParams:r,extractSeparableConvParams:s,extractReductionBlockParams:a,extractMainBlockParams:o}}function BE(e,t){let n=[],{extractConvParams:r,extractSeparableConvParams:s,extractReductionBlockParams:a,extractMainBlockParams:o}=tue(e,n),i=r("entry_flow/conv_in"),c=a("entry_flow/reduction_block_0"),l=a("entry_flow/reduction_block_1"),u={conv_in:i,reduction_block_0:c,reduction_block_1:l},d={};ps(t,0,1).forEach(m=>{d[`main_block_${m}`]=o(`middle_flow/main_block_${m}`)});let p=a("exit_flow/reduction_block"),h=s("exit_flow/separable_conv"),f={reduction_block:p,separable_conv:h};return _n(e,n),{params:{entry_flow:u,middle_flow:d,exit_flow:f},paramMappings:n}}function zE(e,t,n){return Y(Rt(e,t.filters,n,"same"),t.bias)}function B1(e,t,n=!0){let r=n?qe(e):e;return r=Gn(r,t.separable_conv0,[1,1]),r=Gn(qe(r),t.separable_conv1,[1,1]),r=Pt(r,[3,3],[2,2],"same"),r=Y(r,zE(e,t.expansion_conv,[2,2])),r}function nue(e,t){let n=Gn(qe(e),t.separable_conv0,[1,1]);return n=Gn(qe(n),t.separable_conv1,[1,1]),n=Gn(qe(n),t.separable_conv2,[1,1]),n=Y(n,e),n}var z1=class extends ln{constructor(t){super("TinyXception");this._numMainBlocks=t}forwardInput(t){let{params:n}=this;if(!n)throw new Error("TinyXception - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(112,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=qe(zE(a,n.entry_flow.conv_in,[2,2]));return o=B1(o,n.entry_flow.reduction_block_0,!1),o=B1(o,n.entry_flow.reduction_block_1),ps(this._numMainBlocks,0,1).forEach(i=>{o=nue(o,n.middle_flow[`main_block_${i}`])}),o=B1(o,n.exit_flow.reduction_block),o=qe(Gn(o,n.exit_flow.separable_conv,[1,1])),o})}async forward(t){return this.forwardInput(await bt(t))}getDefaultModelName(){return"tiny_xception_model"}extractParamsFromWeightMap(t){return BE(t,this._numMainBlocks)}extractParams(t){return LE(t,this._numMainBlocks)}};function WE(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),s=Gm(n,t),a=s(512,1,"fc/age"),o=s(512,2,"fc/gender");if(r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{fc:{age:a,gender:o}}}}function VE(e){let t=[],n=ar(e,t);function r(a){let o=n(`${a}/weights`,2),i=n(`${a}/bias`,1);return{weights:o,bias:i}}let s={fc:{age:r("fc/age"),gender:r("fc/gender")}};return _n(e,t),{params:s,paramMappings:t}}var Ms;(function(n){n.FEMALE="female",n.MALE="male"})(Ms||(Ms={}));var Jm=class extends ln{constructor(t=new z1(2)){super("AgeGenderNet");this._faceFeatureExtractor=t}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(t){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return M(()=>{let r=t instanceof Ps?this.faceFeatureExtractor.forwardInput(t):t,s=lr(r,[7,7],[2,2],"valid").as2D(r.shape[0],-1),a=lp(s,n.fc.age).as1D(),o=lp(s,n.fc.gender);return{age:a,gender:o}})}forwardInput(t){return M(()=>{let{age:n,gender:r}=this.runNet(t);return{age:n,gender:Mr(r)}})}async forward(t){return this.forwardInput(await bt(t))}async predictAgeAndGender(t){let n=await bt(t),r=await this.forwardInput(n),s=ht(r.age),a=ht(r.gender),o=s.map((c,l)=>({ageTensor:c,genderTensor:a[l]})),i=await Promise.all(o.map(async({ageTensor:c,genderTensor:l})=>{let u=c.dataSync()[0],d=l.dataSync()[0],p=d>.5,h=p?Ms.MALE:Ms.FEMALE,f=p?d:1-d;return c.dispose(),l.dispose(),{age:u,gender:h,genderProbability:f}}));return r.age.dispose(),r.gender.dispose(),n.isBatchInput?i:i[0]}getDefaultModelName(){return"age_gender_model"}dispose(t=!0){this.faceFeatureExtractor.dispose(t),super.dispose(t)}loadClassifierParams(t){let{params:n,paramMappings:r}=this.extractClassifierParams(t);this._params=n,this._paramMappings=r}extractClassifierParams(t){return WE(t)}extractParamsFromWeightMap(t){let{featureExtractorMap:n,classifierMap:r}=Xm(t);return this.faceFeatureExtractor.loadFromWeightMap(n),VE(r)}extractParams(t){let n=512*1+1+(512*2+2),r=t.slice(0,t.length-n),s=t.slice(t.length-n);return this.faceFeatureExtractor.extractWeights(r),this.extractClassifierParams(s)}};var pp=class extends dp{postProcess(t,n,r){let s=r.map(({width:o,height:i})=>{let c=n/Math.max(i,o);return{width:o*c,height:i*c}}),a=s.length;return M(()=>{let o=(d,p)=>Ot([xn([68],d,"float32"),xn([68],p,"float32")],1).as2D(1,136).as1D(),i=(d,p)=>{let{width:h,height:f}=s[d];return p(h,f)?Math.abs(h-f)/2:0},c=d=>i(d,(p,h)=>pi(d,(p,h)=>ho(c(p),l(p))))).div(Ot(Array.from(Array(a),(d,p)=>o(s[p].width,s[p].height))))})}forwardInput(t){return M(()=>{let n=this.runNet(t);return this.postProcess(n,t.inputSize,t.inputDimensions.map(([r,s])=>({height:r,width:s})))})}async forward(t){return this.forwardInput(await bt(t))}async detectLandmarks(t){let n=await bt(t),r=M(()=>ht(this.forwardInput(n))),s=await Promise.all(r.map(async(a,o)=>{let i=Array.from(a.dataSync()),c=i.filter((u,d)=>Mm(d)),l=i.filter((u,d)=>!Mm(d));return new Uu(Array(68).fill(0).map((u,d)=>new Pe(c[d],l[d])),{height:n.getInputHeight(o),width:n.getInputWidth(o)})}));return r.forEach(a=>a.dispose()),n.isBatchInput?s:s[0]}getClassifierChannelsOut(){return 136}};var Yu=class extends pp{constructor(t=new up){super("FaceLandmark68Net",t)}getDefaultModelName(){return"face_landmark_68_model"}getClassifierChannelsIn(){return 256}};function UE(e){let t=[],{extractDenseBlock3Params:n}=Km(e,t),r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2")};return _n(e,t),{params:r,paramMappings:t}}function GE(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),{extractDenseBlock3Params:s}=jm(n,t),a=s(3,32,"dense0",!0),o=s(32,64,"dense1"),i=s(64,128,"dense2");if(r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{dense0:a,dense1:o,dense2:i}}}var W1=class extends ln{constructor(){super("TinyFaceFeatureExtractor")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("TinyFaceFeatureExtractor - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(112,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=Um(a,n.dense0,!0);return o=Um(o,n.dense1),o=Um(o,n.dense2),o=lr(o,[14,14],[2,2],"valid"),o})}async forward(t){return this.forwardInput(await bt(t))}getDefaultModelName(){return"face_feature_extractor_tiny_model"}extractParamsFromWeightMap(t){return UE(t)}extractParams(t){return GE(t)}};var Qm=class extends pp{constructor(t=new W1){super("FaceLandmark68TinyNet",t)}getDefaultModelName(){return"face_landmark_68_tiny_model"}getClassifierChannelsIn(){return 128}};var HE=class extends Yu{};function jE(e,t){return Y(V(e,t.weights),t.biases)}function V1(e,t,n,r,s="same"){let{filters:a,bias:o}=t.conv,i=Rt(e,a,n,s);return i=Y(i,o),i=jE(i,t.scale),r?qe(i):i}function qE(e,t){return V1(e,t,[1,1],!0)}function U1(e,t){return V1(e,t,[1,1],!1)}function eg(e,t){return V1(e,t,[2,2],!0,"valid")}function rue(e,t){function n(i,c,l){let u=e(i),d=u.length/(c*l*l);if(m1(d))throw new Error(`depth has to be an integer: ${d}, weights.length: ${u.length}, numFilters: ${c}, filterSize: ${l}`);return M(()=>Re(Br(u,[c,d,l,l]),[2,3,1,0]))}function r(i,c,l,u){let d=n(i,c,l),p=He(e(c));return t.push({paramPath:`${u}/filters`},{paramPath:`${u}/bias`}),{filters:d,bias:p}}function s(i,c){let l=He(e(i)),u=He(e(i));return t.push({paramPath:`${c}/weights`},{paramPath:`${c}/biases`}),{weights:l,biases:u}}function a(i,c,l,u){let d=r(i,c,l,`${u}/conv`),p=s(c,`${u}/scale`);return{conv:d,scale:p}}function o(i,c,l,u,d=!1){let p=a((d?.5:1)*i,c,l,`${u}/conv1`),h=a(i,c,l,`${u}/conv2`);return{conv1:p,conv2:h}}return{extractConvLayerParams:a,extractResidualLayerParams:o}}function KE(e){let{extractWeights:t,getRemainingWeights:n}=En(e),r=[],{extractConvLayerParams:s,extractResidualLayerParams:a}=rue(t,r),o=s(4704,32,7,"conv32_down"),i=a(9216,32,3,"conv32_1"),c=a(9216,32,3,"conv32_2"),l=a(9216,32,3,"conv32_3"),u=a(36864,64,3,"conv64_down",!0),d=a(36864,64,3,"conv64_1"),p=a(36864,64,3,"conv64_2"),h=a(36864,64,3,"conv64_3"),f=a(147456,128,3,"conv128_down",!0),m=a(147456,128,3,"conv128_1"),g=a(147456,128,3,"conv128_2"),b=a(589824,256,3,"conv256_down",!0),y=a(589824,256,3,"conv256_1"),v=a(589824,256,3,"conv256_2"),x=a(589824,256,3,"conv256_down_out"),w=M(()=>Re(Lr(t(256*128),[128,256]),[1,0]));if(r.push({paramPath:"fc"}),n().length!==0)throw new Error(`weights remaing after extract: ${n().length}`);return{params:{conv32_down:o,conv32_1:i,conv32_2:c,conv32_3:l,conv64_down:u,conv64_1:d,conv64_2:p,conv64_3:h,conv128_down:f,conv128_1:m,conv128_2:g,conv256_down:b,conv256_1:y,conv256_2:v,conv256_down_out:x,fc:w},paramMappings:r}}function sue(e,t){let n=ar(e,t);function r(o){let i=n(`${o}/scale/weights`,1),c=n(`${o}/scale/biases`,1);return{weights:i,biases:c}}function s(o){let i=n(`${o}/conv/filters`,4),c=n(`${o}/conv/bias`,1),l=r(o);return{conv:{filters:i,bias:c},scale:l}}function a(o){return{conv1:s(`${o}/conv1`),conv2:s(`${o}/conv2`)}}return{extractConvLayerParams:s,extractResidualLayerParams:a}}function XE(e){let t=[],{extractConvLayerParams:n,extractResidualLayerParams:r}=sue(e,t),s=n("conv32_down"),a=r("conv32_1"),o=r("conv32_2"),i=r("conv32_3"),c=r("conv64_down"),l=r("conv64_1"),u=r("conv64_2"),d=r("conv64_3"),p=r("conv128_down"),h=r("conv128_1"),f=r("conv128_2"),m=r("conv256_down"),g=r("conv256_1"),b=r("conv256_2"),y=r("conv256_down_out"),{fc:v}=e;if(t.push({originalPath:"fc",paramPath:"fc"}),!f1(v))throw new Error(`expected weightMap[fc] to be a Tensor2D, instead have ${v}`);let x={conv32_down:s,conv32_1:a,conv32_2:o,conv32_3:i,conv64_down:c,conv64_1:l,conv64_2:u,conv64_3:d,conv128_down:p,conv128_1:h,conv128_2:f,conv256_down:m,conv256_1:g,conv256_2:b,conv256_down_out:y,fc:v};return _n(e,t),{params:x,paramMappings:t}}function Yr(e,t){let n=qE(e,t.conv1);return n=U1(n,t.conv2),n=Y(n,e),n=qe(n),n}function hp(e,t){let n=eg(e,t.conv1);n=U1(n,t.conv2);let r=lr(e,2,2,"valid"),s=St(r.shape),a=r.shape[3]!==n.shape[3];if(r.shape[1]!==n.shape[1]||r.shape[2]!==n.shape[2]){let i=[...n.shape];i[1]=1;let c=St(i);n=et([n,c],1);let l=[...n.shape];l[2]=1;let u=St(l);n=et([n,u],2)}return r=a?et([r,s],3):r,n=Y(r,n),n=qe(n),n}var Zu=class extends ln{constructor(){super("FaceRecognitionNet")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("FaceRecognitionNet - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(150,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=eg(a,n.conv32_down);o=Pt(o,3,2,"valid"),o=Yr(o,n.conv32_1),o=Yr(o,n.conv32_2),o=Yr(o,n.conv32_3),o=hp(o,n.conv64_down),o=Yr(o,n.conv64_1),o=Yr(o,n.conv64_2),o=Yr(o,n.conv64_3),o=hp(o,n.conv128_down),o=Yr(o,n.conv128_1),o=Yr(o,n.conv128_2),o=hp(o,n.conv256_down),o=Yr(o,n.conv256_1),o=Yr(o,n.conv256_2),o=hp(o,n.conv256_down_out);let i=o.mean([1,2]);return De(i,n.fc)})}async forward(t){return this.forwardInput(await bt(t))}async computeFaceDescriptor(t){var a;if((a=t==null?void 0:t.shape)==null?void 0:a.some(o=>o<=0))return new Float32Array(128);let n=await bt(t),r=M(()=>ht(this.forwardInput(n))),s=await Promise.all(r.map(o=>o.data()));return r.forEach(o=>o.dispose()),n.isBatchInput?s:s[0]}getDefaultModelName(){return"face_recognition_model"}extractParamsFromWeightMap(t){return XE(t)}extractParams(t){return KE(t)}};function aue(e){let t=new Zu;return t.extractWeights(e),t}function tg(e,t){return{...e,...{descriptor:t}}}function oue(e){return typeof e.age=="number"}function ng(e,t){return{...e,...{age:t}}}function iue(e){return(e.gender===Ms.MALE||e.gender===Ms.FEMALE)&&zu(e.genderProbability)}function rg(e,t,n){return{...e,...{gender:t,genderProbability:n}}}function cue(e,t){function n(c,l){let u=Br(e(3*3*c),[3,3,c,1]),d=He(e(c)),p=He(e(c)),h=He(e(c)),f=He(e(c));return t.push({paramPath:`${l}/filters`},{paramPath:`${l}/batch_norm_scale`},{paramPath:`${l}/batch_norm_offset`},{paramPath:`${l}/batch_norm_mean`},{paramPath:`${l}/batch_norm_variance`}),{filters:u,batch_norm_scale:d,batch_norm_offset:p,batch_norm_mean:h,batch_norm_variance:f}}function r(c,l,u,d,p){let h=Br(e(c*l*u*u),[u,u,c,l]),f=He(e(l));return t.push({paramPath:`${d}/filters`},{paramPath:`${d}/${p?"batch_norm_offset":"bias"}`}),{filters:h,bias:f}}function s(c,l,u,d){let{filters:p,bias:h}=r(c,l,u,d,!0);return{filters:p,batch_norm_offset:h}}function a(c,l,u){let d=n(c,`${u}/depthwise_conv`),p=s(c,l,1,`${u}/pointwise_conv`);return{depthwise_conv:d,pointwise_conv:p}}function o(){let c=s(3,32,3,"mobilenetv1/conv_0"),l=a(32,64,"mobilenetv1/conv_1"),u=a(64,128,"mobilenetv1/conv_2"),d=a(128,128,"mobilenetv1/conv_3"),p=a(128,256,"mobilenetv1/conv_4"),h=a(256,256,"mobilenetv1/conv_5"),f=a(256,512,"mobilenetv1/conv_6"),m=a(512,512,"mobilenetv1/conv_7"),g=a(512,512,"mobilenetv1/conv_8"),b=a(512,512,"mobilenetv1/conv_9"),y=a(512,512,"mobilenetv1/conv_10"),v=a(512,512,"mobilenetv1/conv_11"),x=a(512,1024,"mobilenetv1/conv_12"),w=a(1024,1024,"mobilenetv1/conv_13");return{conv_0:c,conv_1:l,conv_2:u,conv_3:d,conv_4:p,conv_5:h,conv_6:f,conv_7:m,conv_8:g,conv_9:b,conv_10:y,conv_11:v,conv_12:x,conv_13:w}}function i(){let c=s(1024,256,1,"prediction_layer/conv_0"),l=s(256,512,3,"prediction_layer/conv_1"),u=s(512,128,1,"prediction_layer/conv_2"),d=s(128,256,3,"prediction_layer/conv_3"),p=s(256,128,1,"prediction_layer/conv_4"),h=s(128,256,3,"prediction_layer/conv_5"),f=s(256,64,1,"prediction_layer/conv_6"),m=s(64,128,3,"prediction_layer/conv_7"),g=r(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),b=r(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),y=r(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),v=r(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),x=r(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),w=r(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),T=r(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),C=r(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),D=r(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),F=r(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),O=r(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),$=r(128,18,1,"prediction_layer/box_predictor_5/class_predictor");return{conv_0:c,conv_1:l,conv_2:u,conv_3:d,conv_4:p,conv_5:h,conv_6:f,conv_7:m,box_predictor_0:{box_encoding_predictor:g,class_predictor:b},box_predictor_1:{box_encoding_predictor:y,class_predictor:v},box_predictor_2:{box_encoding_predictor:x,class_predictor:w},box_predictor_3:{box_encoding_predictor:T,class_predictor:C},box_predictor_4:{box_encoding_predictor:D,class_predictor:F},box_predictor_5:{box_encoding_predictor:O,class_predictor:$}}}return{extractMobilenetV1Params:o,extractPredictionLayerParams:i}}function YE(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),{extractMobilenetV1Params:s,extractPredictionLayerParams:a}=cue(n,t),o=s(),i=a(),l={extra_dim:zh(n(5118*4),[1,5118,4])};if(t.push({paramPath:"output_layer/extra_dim"}),r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{params:{mobilenetv1:o,prediction_layer:i,output_layer:l},paramMappings:t}}function uue(e,t){let n=ar(e,t);function r(l,u,d){let p=n(`${l}/Conv2d_${u}_pointwise/weights`,4,`${d}/filters`),h=n(`${l}/Conv2d_${u}_pointwise/convolution_bn_offset`,1,`${d}/batch_norm_offset`);return{filters:p,batch_norm_offset:h}}function s(l){let u=`mobilenetv1/conv_${l}`,d=`MobilenetV1/Conv2d_${l}_depthwise`,p=`${u}/depthwise_conv`,h=`${u}/pointwise_conv`,f=n(`${d}/depthwise_weights`,4,`${p}/filters`),m=n(`${d}/BatchNorm/gamma`,1,`${p}/batch_norm_scale`),g=n(`${d}/BatchNorm/beta`,1,`${p}/batch_norm_offset`),b=n(`${d}/BatchNorm/moving_mean`,1,`${p}/batch_norm_mean`),y=n(`${d}/BatchNorm/moving_variance`,1,`${p}/batch_norm_variance`);return{depthwise_conv:{filters:f,batch_norm_scale:m,batch_norm_offset:g,batch_norm_mean:b,batch_norm_variance:y},pointwise_conv:r("MobilenetV1",l,h)}}function a(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:s(1),conv_2:s(2),conv_3:s(3),conv_4:s(4),conv_5:s(5),conv_6:s(6),conv_7:s(7),conv_8:s(8),conv_9:s(9),conv_10:s(10),conv_11:s(11),conv_12:s(12),conv_13:s(13)}}function o(l,u){let d=n(`${l}/weights`,4,`${u}/filters`),p=n(`${l}/biases`,1,`${u}/bias`);return{filters:d,bias:p}}function i(l){let u=o(`Prediction/BoxPredictor_${l}/BoxEncodingPredictor`,`prediction_layer/box_predictor_${l}/box_encoding_predictor`),d=o(`Prediction/BoxPredictor_${l}/ClassPredictor`,`prediction_layer/box_predictor_${l}/class_predictor`);return{box_encoding_predictor:u,class_predictor:d}}function c(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:i(0),box_predictor_1:i(1),box_predictor_2:i(2),box_predictor_3:i(3),box_predictor_4:i(4),box_predictor_5:i(5)}}return{extractMobilenetV1Params:a,extractPredictionLayerParams:c}}function ZE(e){let t=[],{extractMobilenetV1Params:n,extractPredictionLayerParams:r}=uue(e,t),s=e["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!$s(s))throw new Error(`expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have ${s}`);let a={mobilenetv1:n(),prediction_layer:r(),output_layer:{extra_dim:s}};return _n(e,t),{params:a,paramMappings:t}}function Fr(e,t,n){return M(()=>{let r=Rt(e,t.filters,n,"same");return r=Y(r,t.batch_norm_offset),Jt(r,0,6)})}var lue=.0010000000474974513;function due(e,t,n){return M(()=>{let r=ua(e,t.filters,n,"same");return r=Is(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,lue),Jt(r,0,6)})}function pue(e){return[2,4,6,12].some(t=>t===e)?[2,2]:[1,1]}function JE(e,t){return M(()=>{let n,r=Fr(e,t.conv_0,[2,2]);if([t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13].forEach((a,o)=>{let i=o+1,c=pue(i);r=due(r,a.depthwise_conv,c),r=Fr(r,a.pointwise_conv,[1,1]),i===11&&(n=r)}),n===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:n}})}function hue(e,t,n){let r=e.arraySync(),s=Math.min(r[t][0],r[t][2]),a=Math.min(r[t][1],r[t][3]),o=Math.max(r[t][0],r[t][2]),i=Math.max(r[t][1],r[t][3]),c=Math.min(r[n][0],r[n][2]),l=Math.min(r[n][1],r[n][3]),u=Math.max(r[n][0],r[n][2]),d=Math.max(r[n][1],r[n][3]),p=(o-s)*(i-a),h=(u-c)*(d-l);if(p<=0||h<=0)return 0;let f=Math.max(s,c),m=Math.max(a,l),g=Math.min(o,u),b=Math.min(i,d),y=Math.max(g-f,0)*Math.max(b-m,0);return y/(p+h-y)}function QE(e,t,n,r,s){let a=e.shape[0],o=Math.min(n,a),i=t.map((u,d)=>({score:u,boxIndex:d})).filter(u=>u.score>s).sort((u,d)=>d.score-u.score),c=u=>u<=r?1:0,l=[];return i.forEach(u=>{if(l.length>=o)return;let d=u.score;for(let p=l.length-1;p>=0;--p){let h=hue(e,u.boxIndex,l[p]);if(h!==0&&(u.score*=c(h),u.score<=s))break}d===u.score&&l.push(u.boxIndex)}),l}function fue(e){let t=ht(Re(e,[1,0])),n=[fe(t[2],t[0]),fe(t[3],t[1])],r=[Y(t[0],me(n[0],2)),Y(t[1],me(n[1],2))];return{sizes:n,centers:r}}function mue(e,t){let{sizes:n,centers:r}=fue(e),s=ht(Re(t,[1,0])),a=me(V(fn(me(s[2],5)),n[0]),2),o=Y(V(me(s[0],10),n[0]),r[0]),i=me(V(fn(me(s[3],5)),n[1]),2),c=Y(V(me(s[1],10),n[1]),r[1]);return Re(Ot([fe(o,a),fe(c,i),Y(o,a),Y(c,i)]),[1,0])}function eA(e,t,n){return M(()=>{let r=e.shape[0],s=mue(U(Pn(n.extra_dim,[r,1,1]),[-1,4]),U(e,[-1,4]));s=U(s,[r,s.shape[0]/r,4]);let a=dr(ze(t,[0,0,1],[-1,-1,-1])),o=ze(a,[0,0,0],[-1,-1,1]);o=U(o,[r,o.shape[1]]);let i=ht(s),c=ht(o);return{boxes:i,scores:c}})}function Ai(e,t){return M(()=>{let n=e.shape[0],r=U(_i(e,t.box_encoding_predictor),[n,-1,1,4]),s=U(_i(e,t.class_predictor),[n,-1,3]);return{boxPredictionEncoding:r,classPrediction:s}})}function tA(e,t,n){return M(()=>{let r=Fr(e,n.conv_0,[1,1]),s=Fr(r,n.conv_1,[2,2]),a=Fr(s,n.conv_2,[1,1]),o=Fr(a,n.conv_3,[2,2]),i=Fr(o,n.conv_4,[1,1]),c=Fr(i,n.conv_5,[2,2]),l=Fr(c,n.conv_6,[1,1]),u=Fr(l,n.conv_7,[2,2]),d=Ai(t,n.box_predictor_0),p=Ai(e,n.box_predictor_1),h=Ai(s,n.box_predictor_2),f=Ai(o,n.box_predictor_3),m=Ai(c,n.box_predictor_4),g=Ai(u,n.box_predictor_5),b=et([d.boxPredictionEncoding,p.boxPredictionEncoding,h.boxPredictionEncoding,f.boxPredictionEncoding,m.boxPredictionEncoding,g.boxPredictionEncoding],1),y=et([d.classPrediction,p.classPrediction,h.classPrediction,f.classPrediction,m.classPrediction,g.classPrediction],1);return{boxPredictions:b,classPredictions:y}})}var $r=class{constructor({minConfidence:t,maxResults:n}={}){this._name="SsdMobilenetv1Options";if(this._minConfidence=t||.5,this._maxResults=n||100,typeof this._minConfidence!="number"||this._minConfidence<=0||this._minConfidence>=1)throw new Error(`${this._name} - expected minConfidence to be a number between 0 and 1`);if(typeof this._maxResults!="number")throw new Error(`${this._name} - expected maxResults to be a number`)}get minConfidence(){return this._minConfidence}get maxResults(){return this._maxResults}};var Di=class extends ln{constructor(){super("SsdMobilenetv1")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("SsdMobilenetv1 - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(512,!1),"float32"),s=fe(me(r,127.5),1),a=JE(s,n.mobilenetv1),{boxPredictions:o,classPredictions:i}=tA(a.out,a.conv11,n.prediction_layer);return eA(o,i,n.output_layer)})}async forward(t){return this.forwardInput(await bt(t))}async locateFaces(t,n={}){let{maxResults:r,minConfidence:s}=new $r(n),a=await bt(t),{boxes:o,scores:i}=this.forwardInput(a),c=o[0],l=i[0];for(let v=1;v{let[x,w]=[Math.max(0,b[v][0]),Math.min(1,b[v][2])].map(D=>D*g),[T,C]=[Math.max(0,b[v][1]),Math.min(1,b[v][3])].map(D=>D*m);return new xt(u[v],new Vu(T,x,C-T,w-x),{height:a.getInputHeight(0),width:a.getInputWidth(0)})});return c.dispose(),l.dispose(),y}getDefaultModelName(){return"ssd_mobilenetv1_model"}extractParamsFromWeightMap(t){return ZE(t)}extractParams(t){return YE(t)}};function nA(e){let t=new Di;return t.extractWeights(e),t}function gue(e){return nA(e)}var rA=class extends Di{};var sA=.4,aA=[new Pe(.738768,.874946),new Pe(2.42204,2.65704),new Pe(4.30971,7.04493),new Pe(10.246,4.59428),new Pe(12.6868,11.8741)],oA=[new Pe(1.603231,2.094468),new Pe(6.041143,7.080126),new Pe(2.882459,3.518061),new Pe(4.266906,5.178857),new Pe(9.041765,10.66308)],iA=[117.001,114.697,97.404],cA="tiny_yolov2_model",uA="tiny_yolov2_separable_conv_model";var sg=e=>typeof e=="number";function G1(e){if(!e)throw new Error(`invalid config: ${e}`);if(typeof e.withSeparableConvs!="boolean")throw new Error(`config.withSeparableConvs has to be a boolean, have: ${e.withSeparableConvs}`);if(!sg(e.iouThreshold)||e.iouThreshold<0||e.iouThreshold>1)throw new Error(`config.iouThreshold has to be a number between [0, 1], have: ${e.iouThreshold}`);if(!Array.isArray(e.classes)||!e.classes.length||!e.classes.every(t=>typeof t=="string"))throw new Error(`config.classes has to be an array class names: string[], have: ${JSON.stringify(e.classes)}`);if(!Array.isArray(e.anchors)||!e.anchors.length||!e.anchors.map(t=>t||{}).every(t=>sg(t.x)&&sg(t.y)))throw new Error(`config.anchors has to be an array of { x: number, y: number }, have: ${JSON.stringify(e.anchors)}`);if(e.meanRgb&&(!Array.isArray(e.meanRgb)||e.meanRgb.length!==3||!e.meanRgb.every(sg)))throw new Error(`config.meanRgb has to be an array of shape [number, number, number], have: ${JSON.stringify(e.meanRgb)}`)}function Ju(e){return M(()=>{let t=V(e,Ie(.10000000149011612));return Y(qe(fe(e,t)),t)})}function Ls(e,t){return M(()=>{let n=pr(e,[[0,0],[1,1],[1,1],[0,0]]);return n=Rt(n,t.conv.filters,[1,1],"valid"),n=fe(n,t.bn.sub),n=V(n,t.bn.truediv),n=Y(n,t.conv.bias),Ju(n)})}function Bs(e,t){return M(()=>{let n=pr(e,[[0,0],[1,1],[1,1],[0,0]]);return n=ei(n,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),n=Y(n,t.bias),Ju(n)})}function bue(e,t){let n=ju(e,t);function r(o,i){let c=He(e(o)),l=He(e(o));return t.push({paramPath:`${i}/sub`},{paramPath:`${i}/truediv`}),{sub:c,truediv:l}}function s(o,i,c){let l=n(o,i,3,`${c}/conv`),u=r(i,`${c}/bn`);return{conv:l,bn:u}}let a=qu(e,t);return{extractConvParams:n,extractConvWithBatchNormParams:s,extractSeparableConvParams:a}}function lA(e,t,n,r){let{extractWeights:s,getRemainingWeights:a}=En(e),o=[],{extractConvParams:i,extractConvWithBatchNormParams:c,extractSeparableConvParams:l}=bue(s,o),u;if(t.withSeparableConvs){let[d,p,h,f,m,g,b,y,v]=r,x=t.isFirstLayerConv2d?i(d,p,3,"conv0"):l(d,p,"conv0"),w=l(p,h,"conv1"),T=l(h,f,"conv2"),C=l(f,m,"conv3"),D=l(m,g,"conv4"),F=l(g,b,"conv5"),O=y?l(b,y,"conv6"):void 0,$=v?l(y,v,"conv7"):void 0,R=i(v||y||b,5*n,1,"conv8");u={conv0:x,conv1:w,conv2:T,conv3:C,conv4:D,conv5:F,conv6:O,conv7:$,conv8:R}}else{let[d,p,h,f,m,g,b,y,v]=r,x=c(d,p,"conv0"),w=c(p,h,"conv1"),T=c(h,f,"conv2"),C=c(f,m,"conv3"),D=c(m,g,"conv4"),F=c(g,b,"conv5"),O=c(b,y,"conv6"),$=c(y,v,"conv7"),R=i(v,5*n,1,"conv8");u={conv0:x,conv1:w,conv2:T,conv3:C,conv4:D,conv5:F,conv6:O,conv7:$,conv8:R}}if(a().length!==0)throw new Error(`weights remaing after extract: ${a().length}`);return{params:u,paramMappings:o}}function yue(e,t){let n=ar(e,t);function r(i){let c=n(`${i}/sub`,1),l=n(`${i}/truediv`,1);return{sub:c,truediv:l}}function s(i){let c=n(`${i}/filters`,4),l=n(`${i}/bias`,1);return{filters:c,bias:l}}function a(i){let c=s(`${i}/conv`),l=r(`${i}/bn`);return{conv:c,bn:l}}let o=Ku(n);return{extractConvParams:s,extractConvWithBatchNormParams:a,extractSeparableConvParams:o}}function dA(e,t){let n=[],{extractConvParams:r,extractConvWithBatchNormParams:s,extractSeparableConvParams:a}=yue(e,n),o;if(t.withSeparableConvs){let i=t.filterSizes&&t.filterSizes.length||9;o={conv0:t.isFirstLayerConv2d?r("conv0"):a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:i>7?a("conv6"):void 0,conv7:i>8?a("conv7"):void 0,conv8:r("conv8")}}else o={conv0:s("conv0"),conv1:s("conv1"),conv2:s("conv2"),conv3:s("conv3"),conv4:s("conv4"),conv5:s("conv5"),conv6:s("conv6"),conv7:s("conv7"),conv8:r("conv8")};return _n(e,n),{params:o,paramMappings:n}}var ms=class{constructor({inputSize:t,scoreThreshold:n}={}){this._name="TinyYolov2Options";if(this._inputSize=t||416,this._scoreThreshold=n||.5,typeof this._inputSize!="number"||this._inputSize%32!=0)throw new Error(`${this._name} - expected inputSize to be a number divisible by 32`);if(typeof this._scoreThreshold!="number"||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(`${this._name} - expected scoreThreshold to be a number between 0 and 1`)}get inputSize(){return this._inputSize}get scoreThreshold(){return this._scoreThreshold}};var H1=class extends ln{constructor(t){super("TinyYolov2");G1(t),this._config=t}get config(){return this._config}get withClassScores(){return this.config.withClassScores||this.config.classes.length>1}get boxEncodingSize(){return 5+(this.withClassScores?this.config.classes.length:0)}runTinyYolov2(t,n){let r=Ls(t,n.conv0);return r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv1),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv2),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv3),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv4),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv5),r=Pt(r,[2,2],[1,1],"same"),r=Ls(r,n.conv6),r=Ls(r,n.conv7),_i(r,n.conv8,"valid",!1)}runMobilenet(t,n){let r=this.config.isFirstLayerConv2d?Ju(_i(t,n.conv0,"valid",!1)):Bs(t,n.conv0);return r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv1),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv2),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv3),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv4),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv5),r=Pt(r,[2,2],[1,1],"same"),r=n.conv6?Bs(r,n.conv6):r,r=n.conv7?Bs(r,n.conv7):r,_i(r,n.conv8,"valid",!1)}forwardInput(t,n){let{params:r}=this;if(!r)throw new Error("TinyYolov2 - load model before inference");return M(()=>{let s=ce(t.toBatchTensor(n,!1),"float32");return s=this.config.meanRgb?Xr(s,this.config.meanRgb):s,s=s.div(255),this.config.withSeparableConvs?this.runMobilenet(s,r):this.runTinyYolov2(s,r)})}async forward(t,n){return this.forwardInput(await bt(t),n)}async detect(t,n={}){let{inputSize:r,scoreThreshold:s}=new ms(n),a=await bt(t),o=await this.forwardInput(a,r),i=M(()=>ht(o)[0].expandDims()),c={width:a.getInputWidth(0),height:a.getInputHeight(0)},l=await this.extractBoxes(i,a.getReshapedInputDimensions(0),s);o.dispose(),i.dispose();let u=l.map(g=>g.box),d=l.map(g=>g.score),p=l.map(g=>g.classScore),h=l.map(g=>this.config.classes[g.label]);return x1(u.map(g=>g.rescale(r)),d,this.config.iouThreshold,!0).map(g=>new Na(d[g],p[g],h[g],u[g],c))}getDefaultModelName(){return""}extractParamsFromWeightMap(t){return dA(t,this.config)}extractParams(t){let n=this.config.filterSizes||H1.DEFAULT_FILTER_SIZES,r=n?n.length:void 0;if(r!==7&&r!==8&&r!==9)throw new Error(`TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found ${r} filterSizes in config`);return lA(t,this.config,this.boxEncodingSize,n)}async extractBoxes(t,n,r){let{width:s,height:a}=n,o=Math.max(s,a),i=o/s,c=o/a,l=t.shape[1],u=this.config.anchors.length,[d,p,h]=M(()=>{let b=t.reshape([l,l,u,this.boxEncodingSize]),y=b.slice([0,0,0,0],[l,l,u,4]),v=b.slice([0,0,0,4],[l,l,u,1]),x=this.withClassScores?Mr(b.slice([0,0,0,5],[l,l,u,this.config.classes.length]),3):Ie(0);return[y,v,x]}),f=[],m=await p.array(),g=await d.array();for(let b=0;br){let w=(y+tp(g[b][y][v][0]))/l*i,T=(b+tp(g[b][y][v][1]))/l*c,C=Math.exp(g[b][y][v][2])*this.config.anchors[v].x/l*i,D=Math.exp(g[b][y][v][3])*this.config.anchors[v].y/l*c,F=w-C/2,O=T-D/2,$={row:b,col:y,anchor:v},{classScore:R,label:N}=this.withClassScores?await this.extractPredictedClass(h,$):{classScore:1,label:0};f.push({box:new Wu(F,O,F+C,O+D),score:x,classScore:x*R,label:N,...$})}}return d.dispose(),p.dispose(),h.dispose(),f}async extractPredictedClass(t,n){let{row:r,col:s,anchor:a}=n,o=await t.array();return Array(this.config.classes.length).fill(0).map((i,c)=>o[r][s][a][c]).map((i,c)=>({classScore:i,label:c})).reduce((i,c)=>i.classScore>c.classScore?i:c)}},Qu=H1;Qu.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024];var el=class extends Qu{constructor(t=!0){let n={withSeparableConvs:t,iouThreshold:sA,classes:["face"],...t?{anchors:oA,meanRgb:iA}:{anchors:aA,withClassScores:!0}};super(n)}get withSeparableConvs(){return this.config.withSeparableConvs}get anchors(){return this.config.anchors}async locateFaces(t,n){return(await this.detect(t,n)).map(s=>new xt(s.score,s.relativeBox,{width:s.imageWidth,height:s.imageHeight}))}getDefaultModelName(){return this.withSeparableConvs?uA:cA}extractParamsFromWeightMap(t){return super.extractParamsFromWeightMap(t)}};function vue(e,t=!0){let n=new el(t);return n.extractWeights(e),n}var ag=class extends ms{constructor(){super(...arguments);this._name="TinyFaceDetectorOptions"}};var Rr=class{async then(t){return t(await this.run())}async run(){throw new Error("ComposableTask - run is not implemented")}};async function Fi(e,t,n,r,s=({alignedRect:a})=>a){let a=e.map(c=>Ei(c)?s(c):c.detection),o=r||(t instanceof Ee?await Hu(t,a):await Gu(t,a)),i=await n(o);return o.forEach(c=>c instanceof Ee&&c.dispose()),i}async function tl(e,t,n,r,s){return Fi([e],t,async a=>n(a[0]),r,s)}var pA=.4,hA=[new Pe(1.603231,2.094468),new Pe(6.041143,7.080126),new Pe(2.882459,3.518061),new Pe(4.266906,5.178857),new Pe(9.041765,10.66308)],fA=[117.001,114.697,97.404];var nl=class extends Qu{constructor(){let t={withSeparableConvs:!0,iouThreshold:pA,classes:["face"],anchors:hA,meanRgb:fA,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};super(t)}get anchors(){return this.config.anchors}async locateFaces(t,n){return(await this.detect(t,n)).map(s=>new xt(s.score,s.relativeBox,{width:s.imageWidth,height:s.imageHeight}))}getDefaultModelName(){return"tiny_face_detector_model"}extractParamsFromWeightMap(t){return super.extractParamsFromWeightMap(t)}};var nt={ssdMobilenetv1:new Di,tinyFaceDetector:new nl,tinyYolov2:new el,faceLandmark68Net:new Yu,faceLandmark68TinyNet:new Qm,faceRecognitionNet:new Zu,faceExpressionNet:new Ym,ageGenderNet:new Jm},mA=(e,t)=>nt.ssdMobilenetv1.locateFaces(e,t),xue=(e,t)=>nt.tinyFaceDetector.locateFaces(e,t),wue=(e,t)=>nt.tinyYolov2.locateFaces(e,t),gA=e=>nt.faceLandmark68Net.detectLandmarks(e),kue=e=>nt.faceLandmark68TinyNet.detectLandmarks(e),Iue=e=>nt.faceRecognitionNet.computeFaceDescriptor(e),Sue=e=>nt.faceExpressionNet.predictExpressions(e),Tue=e=>nt.ageGenderNet.predictAgeAndGender(e),bA=e=>nt.ssdMobilenetv1.load(e),Cue=e=>nt.tinyFaceDetector.load(e),Nue=e=>nt.tinyYolov2.load(e),_ue=e=>nt.faceLandmark68Net.load(e),Eue=e=>nt.faceLandmark68TinyNet.load(e),Aue=e=>nt.faceRecognitionNet.load(e),Due=e=>nt.faceExpressionNet.load(e),Fue=e=>nt.ageGenderNet.load(e),$ue=bA,Rue=mA,Pue=gA;var j1=class extends Rr{constructor(t,n,r){super();this.parentTask=t;this.input=n;this.extractedFaces=r}},rl=class extends j1{async run(){let t=await this.parentTask,n=await Fi(t,this.input,async r=>Promise.all(r.map(s=>nt.faceExpressionNet.predictExpressions(s))),this.extractedFaces);return t.map((r,s)=>Zm(r,n[s]))}withAgeAndGender(){return new al(this,this.input)}},sl=class extends j1{async run(){let t=await this.parentTask;if(!t)return;let n=await tl(t,this.input,r=>nt.faceExpressionNet.predictExpressions(r),this.extractedFaces);return Zm(t,n)}withAgeAndGender(){return new ol(this,this.input)}},$i=class extends rl{withAgeAndGender(){return new Pi(this,this.input)}withFaceDescriptors(){return new Aa(this,this.input)}},Ri=class extends sl{withAgeAndGender(){return new Oi(this,this.input)}withFaceDescriptor(){return new Da(this,this.input)}};var q1=class extends Rr{constructor(t,n,r){super();this.parentTask=t;this.input=n;this.extractedFaces=r}},al=class extends q1{async run(){let t=await this.parentTask,n=await Fi(t,this.input,async r=>Promise.all(r.map(s=>nt.ageGenderNet.predictAgeAndGender(s))),this.extractedFaces);return t.map((r,s)=>{let{age:a,gender:o,genderProbability:i}=n[s];return ng(rg(r,o,i),a)})}withFaceExpressions(){return new rl(this,this.input)}},ol=class extends q1{async run(){let t=await this.parentTask;if(!t)return;let{age:n,gender:r,genderProbability:s}=await tl(t,this.input,a=>nt.ageGenderNet.predictAgeAndGender(a),this.extractedFaces);return ng(rg(t,r,s),n)}withFaceExpressions(){return new sl(this,this.input)}},Pi=class extends al{withFaceExpressions(){return new $i(this,this.input)}withFaceDescriptors(){return new Aa(this,this.input)}},Oi=class extends ol{withFaceExpressions(){return new Ri(this,this.input)}withFaceDescriptor(){return new Da(this,this.input)}};var og=class extends Rr{constructor(t,n){super();this.parentTask=t;this.input=n}},Aa=class extends og{async run(){let t=await this.parentTask;return(await Fi(t,this.input,r=>Promise.all(r.map(s=>nt.faceRecognitionNet.computeFaceDescriptor(s))),null,r=>r.landmarks.align(null,{useDlibAlignment:!0}))).map((r,s)=>tg(t[s],r))}withFaceExpressions(){return new $i(this,this.input)}withAgeAndGender(){return new Pi(this,this.input)}},Da=class extends og{async run(){let t=await this.parentTask;if(!t)return;let n=await tl(t,this.input,r=>nt.faceRecognitionNet.computeFaceDescriptor(r),null,r=>r.landmarks.align(null,{useDlibAlignment:!0}));return tg(t,n)}withFaceExpressions(){return new Ri(this,this.input)}withAgeAndGender(){return new Oi(this,this.input)}};var ig=class extends Rr{constructor(t,n,r){super();this.parentTask=t;this.input=n;this.useTinyLandmarkNet=r}get landmarkNet(){return this.useTinyLandmarkNet?nt.faceLandmark68TinyNet:nt.faceLandmark68Net}},cg=class extends ig{async run(){let t=await this.parentTask,n=t.map(a=>a.detection),r=this.input instanceof Ee?await Hu(this.input,n):await Gu(this.input,n),s=await Promise.all(r.map(a=>this.landmarkNet.detectLandmarks(a)));return r.forEach(a=>a instanceof Ee&&a.dispose()),t.map((a,o)=>Xu(a,s[o]))}withFaceExpressions(){return new $i(this,this.input)}withAgeAndGender(){return new Pi(this,this.input)}withFaceDescriptors(){return new Aa(this,this.input)}},ug=class extends ig{async run(){let t=await this.parentTask;if(!t)return;let{detection:n}=t,r=this.input instanceof Ee?await Hu(this.input,[n]):await Gu(this.input,[n]),s=await this.landmarkNet.detectLandmarks(r[0]);return r.forEach(a=>a instanceof Ee&&a.dispose()),Xu(t,s)}withFaceExpressions(){return new Ri(this,this.input)}withAgeAndGender(){return new Oi(this,this.input)}withFaceDescriptor(){return new Da(this,this.input)}};var lg=class extends Rr{constructor(t,n=new $r){super();this.input=t;this.options=n}},fp=class extends lg{async run(){let{input:t,options:n}=this,r;if(n instanceof ag)r=nt.tinyFaceDetector.locateFaces(t,n);else if(n instanceof $r)r=nt.ssdMobilenetv1.locateFaces(t,n);else if(n instanceof ms)r=nt.tinyYolov2.locateFaces(t,n);else throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | TinyYolov2Options");return r}runAndExtendWithFaceDetections(){return new Promise((t,n)=>{this.run().then(r=>t(r.map(s=>Si({},s)))).catch(r=>n(r))})}withFaceLandmarks(t=!1){return new cg(this.runAndExtendWithFaceDetections(),this.input,t)}withFaceExpressions(){return new rl(this.runAndExtendWithFaceDetections(),this.input)}withAgeAndGender(){return new al(this.runAndExtendWithFaceDetections(),this.input)}},dg=class extends lg{async run(){let t=await new fp(this.input,this.options),n=t[0];return t.forEach(r=>{r.score>n.score&&(n=r)}),n}runAndExtendWithFaceDetection(){return new Promise(async t=>{let n=await this.run();t(n?Si({},n):void 0)})}withFaceLandmarks(t=!1){return new ug(this.runAndExtendWithFaceDetection(),this.input,t)}withFaceExpressions(){return new sl(this.runAndExtendWithFaceDetection(),this.input)}withAgeAndGender(){return new ol(this.runAndExtendWithFaceDetection(),this.input)}};function Oue(e,t=new $r){return new dg(e,t)}function pg(e,t=new $r){return new fp(e,t)}async function yA(e,t){return pg(e,new $r(t?{minConfidence:t}:{})).withFaceLandmarks().withFaceDescriptors()}async function Mue(e,t={}){return pg(e,new ms(t)).withFaceLandmarks().withFaceDescriptors()}var Lue=yA;function K1(e,t){if(e.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");let n=Array.from(e),r=Array.from(t);return Math.sqrt(n.map((s,a)=>s-r[a]).reduce((s,a)=>s+a**2,0))}var hg=class{constructor(t,n=.6){this._distanceThreshold=n;let r=Array.isArray(t)?t:[t];if(!r.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");let s=1,a=()=>`person ${s++}`;this._labeledDescriptors=r.map(o=>{if(o instanceof Rs)return o;if(o instanceof Float32Array)return new Rs(a(),[o]);if(o.descriptor&&o.descriptor instanceof Float32Array)return new Rs(a(),[o.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor | Float32Array | Array | Float32Array>")})}get labeledDescriptors(){return this._labeledDescriptors}get distanceThreshold(){return this._distanceThreshold}computeMeanDistance(t,n){return n.map(r=>K1(r,t)).reduce((r,s)=>r+s,0)/(n.length||1)}matchDescriptor(t){return this.labeledDescriptors.map(({descriptors:n,label:r})=>new np(r,this.computeMeanDistance(t,n))).reduce((n,r)=>n.distancet.toJSON())}}static fromJSON(t){let n=t.labeledDescriptors.map(r=>Rs.fromJSON(r));return new hg(n,t.distanceThreshold)}};function Bue(e){let t=new nl;return t.extractWeights(e),t}function vA(e,t){let{width:n,height:r}=new Nn(t.width,t.height);if(n<=0||r<=0)throw new Error(`resizeResults - invalid dimensions: ${JSON.stringify({width:n,height:r})}`);if(Array.isArray(e))return e.map(s=>vA(s,{width:n,height:r}));if(Ei(e)){let s=e.detection.forSize(n,r),a=e.unshiftedLandmarks.forSize(s.box.width,s.box.height);return Xu(Si(e,s),a)}return hs(e)?Si(e,e.detection.forSize(n,r)):e instanceof yr||e instanceof xt?e.forSize(n,r):e}var zue=ME;return Wue;})(); + ${s.shape}`);if(a.shape.length!==1)throw new Error(`Target shape should be a vector but received shape ${a.shape}`);let o=t.dataIdMap.get(r.dataId).id,i=t.dataIdMap.get(s.dataId).id,c=t.dataIdMap.get(a.dataId).id,l=r.shape[0],u=k.sizeFromShape(a.shape),d=t.makeOutput([l,u],r.dtype),p=t.dataIdMap.get(d.dataId).id,h=t.makeOutput([u],a.dtype),f=t.dataIdMap.get(h.dataId).id,m=t.makeOutput([3],"int32"),g=t.dataIdMap.get(m.dataId).id;gE(o,i,c,l,p,f,g);let b=t.readSync(m.dataId),y;switch(b[0]){case 0:{y=_.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(b[1],b[2]);break}case 1:{y=_.getSparseReshapeNegativeOutputDimErrorMessage(b[1],b[2]);break}case 2:y=_.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage();break;case 3:{let v=Array.from(t.readSync(s.dataId)),x=Array.from(t.readSync(h.dataId));y=_.getSparseReshapeInputOutputMultipleErrorMessage(v,x);break}case 4:{let v=Array.from(t.readSync(s.dataId)),x=Array.from(t.readSync(h.dataId));y=_.getSparseReshapeInputOutputMismatchErrorMessage(v,x);break}default:y=""}if(t.disposeData(m.dataId),y)throw t.disposeData(d.dataId),t.disposeData(h.dataId),new Error(y);return[d,h]}var Fie={kernelName:Hc,backendName:"wasm",setupFunc:Aie,kernelFunc:Die},bE;function yE(e){bE=e.wasm.cwrap("SparseSegmentReduction",null,["number","number","number","number","number","number","number","number","number"])}function vE(e,t){let{backend:n,inputs:r}=e,{data:s,indices:a,segmentIds:o}=r,i=a.shape[0],c=n.readSync(o.dataId,i-1,i)[0],u=i>0?c+1:0;if(u<0)throw new Error(_.getSparseSegmentReductionNegativeSegmentIdsErrorMessage());let d=s.shape.slice();d[0]=u;let p=n.dataIdMap.get(s.dataId).id,h=n.dataIdMap.get(a.dataId).id,f=n.dataIdMap.get(o.dataId).id,m=n.makeOutput(d,s.dtype),g=n.dataIdMap.get(m.dataId).id,b=n.makeOutput([4],"int32"),y=n.dataIdMap.get(b.dataId).id;bE(p,$t[s.dtype],s.shape[0],h,f,g,y,t,0);let v=n.readSync(b.dataId),x;switch(v[0]){case 0:{x=_.getSparseSegmentReductionNegativeSegmentIdsErrorMessage();break}case 1:{x=_.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage();break}case 2:x=_.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(v[1],v[2]);break;case 3:x=_.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(v[1],v[2],v[3]);break;default:x=""}if(n.disposeData(b.dataId),x)throw n.disposeData(m.dataId),new Error(x);return m}function $ie(e){return vE(e,!0)}var Rie={kernelName:Ml,backendName:"wasm",setupFunc:yE,kernelFunc:$ie};function Pie(e){return vE(e,!1)}var Oie={kernelName:Ll,backendName:"wasm",setupFunc:yE,kernelFunc:Pie};function Mie(e){let{inputs:t,attrs:n,backend:r}=e,{x:s}=t,{numOrSizeSplits:a,axis:o}=n,i=k.parseAxisParam(o,s.shape)[0],c=_.prepareSplitSize(s,a,i),l=new Array(s.shape.length).fill(0),u=s.shape.slice();return c.map(d=>{let p=[...u];p[i]=d;let h=xi({inputs:{x:s},attrs:{begin:l,size:p},backend:r});return l[i]+=d,h})}var Lie={kernelName:Gc,backendName:"wasm",kernelFunc:Mie},Bie=un(_o),zie=un(Bl),Wie=!0,Vie=Cn(Do,Wie),xE;function Uie(e){xE=e.wasm.cwrap(ea,null,["number","number","number","number"])}function Gie(e){let{backend:t,inputs:n,attrs:r}=e,{alpha:s}=r,{x:a}=n,o=t.dataIdMap.get(a.dataId).id,i=t.makeOutput(a.shape,a.dtype),c=t.dataIdMap.get(i.dataId).id;return xE(o,s,$t[a.dtype],c),i}var Hie={kernelName:ea,backendName:"wasm",setupFunc:Uie,kernelFunc:Gie},wE;function jie(e){wE=e.wasm.cwrap(jc,null,["number","array","number","array","array","array","array","array","number","number"])}function qie(e){let{backend:t,inputs:n,attrs:r}=e,{x:s}=n,{begin:a,end:o,strides:i,beginMask:c,endMask:l,ellipsisMask:u,newAxisMask:d,shrinkAxisMask:p}=r,{finalShapeSparse:h,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:b,begin:y,end:v,strides:x}=Gt.sliceInfo(s.shape,a,o,i,c,l,u,d,p),w;if(m)w=Vn({inputs:{x:s},backend:t,attrs:{shape:f}});else if(g||b){k.assert(s.shape.length>=1,()=>`Input must have rank at least 1, got: ${s.shape.length}`);let T=Gt.computeOutShape(y,v,x),C=xi({inputs:{x:s},backend:t,attrs:{begin:y,size:T}});w=Vn({inputs:{x:C},backend:t,attrs:{shape:f}}),t.disposeData(C.dataId)}else{let T=t.makeOutput(h,"float32"),C=t.dataIdMap.get(s.dataId).id,D=new Uint8Array(new Int32Array(k.computeStrides(s.shape)).buffer),F=new Uint8Array(new Int32Array(y).buffer),O=new Uint8Array(new Int32Array(v).buffer),$=new Uint8Array(new Int32Array(x).buffer),R=new Uint8Array(new Int32Array(h).buffer),N=new Uint8Array(new Int32Array(k.computeStrides(h)).buffer),L=t.dataIdMap.get(T.dataId).id;wE(C,D,s.shape.length,F,O,$,R,N,h.length,L),w=Vn({inputs:{x:T},backend:t,attrs:{shape:f}}),t.disposeData(T.dataId)}return w}var Kie={kernelName:jc,backendName:"wasm",setupFunc:jie,kernelFunc:qie},Xie=!0,Yie=Cn(Fo,Xie),kE;function Zie(e){kE=e.wasm.cwrap(Eo,null,["number","number","number","number"])}function Jie(e){let{backend:t,inputs:n,attrs:r}=e,{axis:s,keepDims:a}=r,{x:o}=n,i=t.dataIdMap.get(o.dataId).id,c=i,l=o,{transposed:u,axes:d,originalAxes:p,inputWasTransposed:h}=Ca(o,s,t),f=d;if(h){let v=t.dataIdMap.get(u.dataId).id;v!==i&&(l=u,c=v,f=_.getInnerMostAxes(f.length,l.shape.length))}_.assertAxesAreInnerMostDims("sum",f,l.shape.length);let[m,g]=_.computeOutAndReduceShapes(l.shape,f),b=k.sizeFromShape(g),y=t.makeOutput(m,l.dtype);if(k.sizeFromShape(l.shape)!==0){let v=t.dataIdMap.get(y.dataId).id;kE(c,b,$t[y.dtype],v)}if(h&&t.disposeData(u.dataId),a){let v=_.expandShapeToKeepDim(y.shape,p);y.shape=v}return y}var Qie={kernelName:Eo,backendName:"wasm",setupFunc:Zie,kernelFunc:Jie},ece=un($o),tce=un(Ro),IE;function nce(e){IE=e.wasm.cwrap(Qs,null,["number","array","number","array","number","number"])}function rce(e){let{inputs:t,backend:n,attrs:r}=e,{x:s}=t,a=n.dataIdMap.get(s.dataId).id,{reps:o}=r,i=new Array(s.shape.length);for(let p=0;p{let{x:r}=e,{k:s,sorted:a}=n,o=t.dataIdMap.get(r.dataId).id,i=new Uint8Array(new Int32Array(r.shape).buffer),c=r.shape.slice();c[c.length-1]=s;let l=t.makeOutput(c,r.dtype),u=t.dataIdMap.get(l.dataId).id,d=t.makeOutput(c,"int32"),p=t.dataIdMap.get(d.dataId).id;return SE(o,i,r.shape.length,$t[r.dtype],s,a,u,p),[l,d]},ice={kernelName:qc,backendName:"wasm",setupFunc:ace,kernelFunc:oce},TE;function cce(e){TE=e.wasm.cwrap(Kc,null,["number","number","bool","number","number","number","number","number","number","array","number","number","number","number","number"])}function uce(e){let{backend:t,inputs:n,attrs:r}=e,{image:s,transforms:a}=n,{interpolation:o,fillMode:i,fillValue:c,outputShape:l}=r,[u,d,p,h]=s.shape,[f,m]=l!=null?l:[d,p],g=[u,f,m,h],b=new Uint8Array(new Int32Array(k.computeStrides(s.shape)).buffer),y=t.makeOutput(g,s.dtype),v=t.dataIdMap.get(y.dataId).id,w=t.dataIdMap.get(s.dataId).id,C=t.dataIdMap.get(a.dataId).id,D=o==="nearest"?1:2,F;switch(i){case"constant":F=1;break;case"reflect":F=2;break;case"wrap":F=3;break;case"nearest":F=4;break;default:F=1;break}return TE(w,C,a.shape[0]>1,u,f,m,h,p,d,b,s.shape.length-1,D,F,c,v),y}var lce={kernelName:Kc,backendName:"wasm",setupFunc:cce,kernelFunc:uce};function dce(e){let{inputs:t,backend:n,attrs:r}=e,{value:s}=t,{axis:a}=r;a<0&&(a+=s.shape.length);let o=s.shape[a],i=s.shape.length,c=new Array(i-1),l=0;for(let h=0;h({dataId:h,dtype:f,shape:c}))}var pce={kernelName:Xc,backendName:"wasm",kernelFunc:dce};function hce(e){let{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(0),r}var fce={kernelName:Yc,backendName:"wasm",kernelFunc:hce},mce=[ise,use,pse,xse,Ise,Cse,Ese,$se,Bse,zse,Wse,Gse,Hse,Kse,Zse,Jse,Qse,nae,aae,cae,dae,pae,fae,mae,gae,bae,xae,wae,Iae,ose,Cae,Eae,Fae,Pae,Lae,zae,Vae,hse,Hae,qae,Xae,Yae,Jae,toe,roe,ooe,uoe,poe,foe,boe,voe,xoe,Ioe,Coe,Eoe,Doe,Roe,Ooe,Loe,aE,Voe,Hoe,Koe,Yoe,Joe,Qoe,eie,Ase,rie,oie,uie,die,lie,fie,bie,xie,wie,Mse,Sie,Cie,Eie,Fie,Rie,Oie,Lie,Bie,zie,Vie,Hie,Kie,Yie,Qie,ece,tce,sce,ice,lce,bse,pce,fce];for(let e of mce)Vl(e);var l1=Q();l1.registerFlag("WASM_HAS_SIMD_SUPPORT",async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11])));l1.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",async()=>{if(l1.get("IS_NODE"))return!1;try{return new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch(e){return!1}});var CE=Oa(BD()),gce='var Module={};function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;this.alert=threadAlert;Module["instantiateWasm"]=function(info,receiveInstance){var instance=new WebAssembly.Instance(Module["wasmModule"],info);Module["wasmModule"]=null;receiveInstance(instance);return instance.exports};function moduleLoaded(){}this.onmessage=function(e){try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob==="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module).then(function(instance){Module=instance;moduleLoaded()})}else if(e.data.cmd==="objectTransfer"){Module["PThread"].receiveObjectTransfer(e.data)}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.threadInfoStruct,0,0);var max=e.data.stackBase;var top=e.data.stackBase+e.data.stackSize;Module["establishStackSpace"](top,max);Module["_emscripten_tls_init"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].setThreadStatus(Module["_pthread_self"](),1);try{var result=Module["invokeEntryPoint"](e.data.start_routine,e.data.arg);if(!Module["getNoExitRuntime"]())Module["PThread"].threadExit(result)}catch(ex){if(ex==="Canceled!"){Module["PThread"].threadCancel()}else if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["getNoExitRuntime"]()){}else{Module["PThread"].threadExit(ex.status)}}else{Module["PThread"].threadExit(-2);throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["PThread"].threadCancel()}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processThreadQueue"){if(Module["_pthread_self"]()){Module["_emscripten_current_thread_process_queued_calls"]()}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){err("worker.js onmessage() captured an uncaught exception: "+ex);if(ex&&ex.stack)err(ex.stack);throw ex}};if(typeof process==="object"&&typeof process.versions==="object"&&typeof process.versions.node==="string"){self={location:{href:__filename}};var onmessage=this.onmessage;var nodeWorkerThreads=require("worker_threads");global.Worker=nodeWorkerThreads.Worker;var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",function(data){onmessage({data:data})});var nodeFS=require("fs");var nodeRead=function(filename){return nodeFS.readFileSync(filename,"utf8")};function globalEval(x){global.require=require;global.Module=Module;eval.call(null,x)}importScripts=function(f){globalEval(nodeRead(f))};postMessage=function(msg){parentPort.postMessage(msg)};if(typeof performance==="undefined"){performance={now:function(){return Date.now()}}}}',bce=Oa(zD()),NE=class extends wl{constructor(e){super();this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(EE),p1=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new jp(this,ks())}write(e,t,n){let r={id:this.dataIdNextNumber++};return this.move(r,e,t,n,1),r}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){let t=k.now();return e(),{kernelMs:k.now()-t}}move(e,t,n,r,s){let a=this.dataIdNextNumber++;if(r==="string"){let l=t;this.dataIdMap.set(e,{id:a,stringBytes:l,shape:n,dtype:r,memoryOffset:null,refCount:s});return}let o=k.sizeFromShape(n),i=o*k.bytesPerElement(r),c=this.wasm._malloc(i);this.dataIdMap.set(e,{id:a,memoryOffset:c,shape:n,dtype:r,refCount:s}),this.wasm.tfjs.registerTensor(a,o,c),t!=null&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,i),c)}async read(e){return this.readSync(e)}readSync(e,t,n){let{memoryOffset:r,dtype:s,shape:a,stringBytes:o}=this.dataIdMap.get(e);if(s==="string")return(t==null||t===0)&&(n==null||n>=o.length)?o:o.slice(t,n);t=t||0,n=n||k.sizeFromShape(a);let i=k.bytesPerElement(s),c=this.wasm.HEAPU8.slice(r+t*i,r+n*i);return xce(c.buffer,s)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){let n=this.dataIdMap.get(e);if(n.refCount--,!t&&n.refCount>0)return!1;this.wasm._free(n.memoryOffset),this.wasm.tfjs.disposeData(n.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){let t=this.dataIdMap.get(e);t!=null&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,n){let r;if(n==null)r=this.write(null,e,t);else{let s=this.dataIdNextNumber++;r={id:s},this.dataIdMap.set(r,{id:s,memoryOffset:n,shape:e,dtype:t,refCount:1});let a=k.sizeFromShape(e);this.wasm.tfjs.registerTensor(s,a,n)}return{dataId:r,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){let r=this.wasm.HEAPU8.buffer,{memoryOffset:s}=this.dataIdMap.get(n),a=k.sizeFromShape(e);switch(t){case"float32":return new Float32Array(r,s,a);case"int32":return new Int32Array(r,s,a);case"bool":return new Uint8Array(r,s,a);default:throw new Error(`Unknown dtype ${t}`)}}};function yce(e){return(t,n)=>(k.fetch(e,{credentials:"same-origin"}).then(r=>{r.ok||t.env.a(`failed to load wasm binary file at '${e}'`),r.arrayBuffer().then(s=>{WebAssembly.instantiate(s,t).then(a=>{n(a.instance,a.module)})})}),{})}function _E(e,t,n){if(Om!=null)return Om;let r="tfjs-backend-wasm.wasm";return e&&t?r="tfjs-backend-wasm-threaded-simd.wasm":e&&(r="tfjs-backend-wasm-simd.wasm"),Qd!=null&&Qd[r]!=null?Qd[r]:n+r}async function vce(){let[e,t]=await Promise.all([Q().getAsync("WASM_HAS_SIMD_SUPPORT"),Q().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise((n,r)=>{let s={};s.locateFile=(i,c)=>{if(i.endsWith(".worker.js")){let l=gce,u=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(u)}return i.endsWith(".wasm")?_E(e,t,Jd!=null?Jd:c):c+i},d1&&(s.instantiateWasm=yce(_E(e,t,Jd!=null?Jd:"")));let a=!1;s.onAbort=()=>{if(a||ep)return;ep=!0,r({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"})};let o;t&&e&&Om==null?(s.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+CE.default.toString()],{type:"text/javascript"}),o=(0,CE.default)(s)):o=(0,bce.default)(s),o.then(i=>{a=!0,ep=!1;let c=null;i.tfjs={init:i.cwrap("init",null,[]),initWithThreadsCount:i.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:i.cwrap("get_threads_count","number",[]),registerTensor:i.cwrap("register_tensor",null,["number","number","number"]),disposeData:i.cwrap("dispose_data",c,["number"]),dispose:i.cwrap("dispose",c,[])},n({wasm:i})})})}function xce(e,t){switch(t){case"float32":return new Float32Array(e);case"int32":return new Int32Array(e);case"bool":return new Uint8Array(e);default:throw new Error(`Unknown dtype ${t}`)}}var wce=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"],Om=null,Jd=null,Qd={},ep=!1,d1=!1;function kce(e,t=!1){if(_y("setWasmPath has been deprecated in favor of setWasmPaths and will be removed in a future release."),ep)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPath()` before you call `tf.setBackend()` or `tf.ready()`");Om=e,d1=t}function Ice(e,t=!1){if(ep)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`");if(typeof e=="string")Jd=e;else{Qd=e;let n=wce.filter(r=>Qd[r]==null);if(n.length>0)throw new Error(`There were no entries found for the following binaries: ${n.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`)}d1=t}var EE=-1,p1=-1;function Sce(e){EE=e}function Tce(){if(p1===-1)throw new Error("WASM backend not initialized.");return p1}var Cce="3.12.0",Nce=2;Vh("wasm",async()=>{let{wasm:e}=await vce();return new NE(e)},Nce);var _ce="3.12.0",Ece="3.12.0",Ace="3.12.0",Dce="3.12.0",Fce="3.12.0",$ce="3.12.0",Rce="3.12.0",Pce="3.12.0",Oce={tfjs:_ce,"tfjs-core":Ece,"tfjs-data":Ace,"tfjs-layers":Dce,"tfjs-converter":Fce,"tfjs-backend-cpu":$ce,"tfjs-backend-webgl":Rce,"tfjs-backend-wasm":Pce};var L1={};Up(L1,{AnchorPosition:()=>fs,DrawBox:()=>zm,DrawBoxOptions:()=>N1,DrawFaceLandmarks:()=>M1,DrawFaceLandmarksOptions:()=>O1,DrawTextField:()=>_a,DrawTextFieldOptions:()=>ap,drawContour:()=>Fs,drawDetections:()=>Hce,drawFaceExpressions:()=>Yce,drawFaceLandmarks:()=>Jce});function Fs(e,t,n=!1){if(e.beginPath(),t.slice(1).forEach(({x:r,y:s},a)=>{let o=t[a];e.moveTo(o.x,o.y),e.lineTo(r,s)}),n){let r=t[t.length-1],s=t[0];if(!r||!s)return;e.moveTo(r.x,r.y),e.lineTo(s.x,s.y)}e.stroke()}var b1={};Up(b1,{computeReshapedDimensions:()=>g1,getCenterPoint:()=>Ii,isDimensions:()=>Lm,isEven:()=>Mm,isFloat:()=>m1,isTensor:()=>wi,isTensor1D:()=>Mce,isTensor2D:()=>f1,isTensor3D:()=>$s,isTensor4D:()=>br,isValidNumber:()=>Kr,isValidProbablitiy:()=>zu,range:()=>ps,round:()=>ki});var Nn=class{constructor(t,n){if(!Kr(t)||!Kr(n))throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({width:t,height:n})}`);this._width=t,this._height=n}get width(){return this._width}get height(){return this._height}reverse(){return new Nn(1/this.width,1/this.height)}};function wi(e,t){return e instanceof Ee&&e.shape.length===t}function Mce(e){return wi(e,1)}function f1(e){return wi(e,2)}function $s(e){return wi(e,3)}function br(e){return wi(e,4)}function m1(e){return e%1!=0}function Mm(e){return e%2==0}function ki(e,t=2){let n=10**t;return Math.floor(e*n)/n}function Lm(e){return e&&e.width&&e.height}function g1({width:e,height:t},n){let r=n/Math.max(t,e);return new Nn(Math.round(e*r),Math.round(t*r))}function Ii(e){return e.reduce((t,n)=>t.add(n),new Pe(0,0)).div(new Pe(e.length,e.length))}function ps(e,t,n){return Array(e).fill(0).map((r,s)=>t+s*n)}function Kr(e){return!!e&&e!==1/0&&e!==-1/0&&!Number.isNaN(e)||e===0}function zu(e){return Kr(e)&&e>=0&&e<=1}var Pe=class{constructor(t,n){this._x=t,this._y=n}get x(){return this._x}get y(){return this._y}add(t){return new Pe(this.x+t.x,this.y+t.y)}sub(t){return new Pe(this.x-t.x,this.y-t.y)}mul(t){return new Pe(this.x*t.x,this.y*t.y)}div(t){return new Pe(this.x/t.x,this.y/t.y)}abs(){return new Pe(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new Pe(Math.floor(this.x),Math.floor(this.y))}};var ut=class{static isRect(t){return!!t&&[t.x,t.y,t.width,t.height].every(Kr)}static assertIsValidBox(t,n,r=!1){if(!ut.isRect(t))throw new Error(`${n} - invalid box: ${JSON.stringify(t)}, expected object with properties x, y, width, height`);if(!r&&(t.width<0||t.height<0))throw new Error(`${n} - width (${t.width}) and height (${t.height}) must be positive numbers`)}constructor(t,n=!0){let r=t||{},s=[r.left,r.top,r.right,r.bottom].every(Kr),a=[r.x,r.y,r.width,r.height].every(Kr);if(!a&&!s)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(r)}`);let[o,i,c,l]=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top];ut.assertIsValidBox({x:o,y:i,width:c,height:l},"Box.constructor",n),this._x=o,this._y=i,this._width=c,this._height=l}get x(){return this._x}get y(){return this._y}get width(){return this._width}get height(){return this._height}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get area(){return this.width*this.height}get topLeft(){return new Pe(this.left,this.top)}get topRight(){return new Pe(this.right,this.top)}get bottomLeft(){return new Pe(this.left,this.bottom)}get bottomRight(){return new Pe(this.right,this.bottom)}round(){let[t,n,r,s]=[this.x,this.y,this.width,this.height].map(a=>Math.round(a));return new ut({x:t,y:n,width:r,height:s})}floor(){let[t,n,r,s]=[this.x,this.y,this.width,this.height].map(a=>Math.floor(a));return new ut({x:t,y:n,width:r,height:s})}toSquare(){let{x:t,y:n,width:r,height:s}=this,a=Math.abs(r-s);return rn&&(i=-d+n+r,d=n),p>t&&(c=-p+t+s,p=t),l<1&&(c=2-l,l=1),u<1&&(c=2-u,u=1),{dy:o,edy:c,dx:a,edx:i,y:u,ey:p,x:l,ex:d,w:r,h:s}}calibrate(t){return new ut({left:this.left+t.left*this.width,top:this.top+t.top*this.height,right:this.right+t.right*this.width,bottom:this.bottom+t.bottom*this.height}).toSquare().round()}};var Wu=class extends ut{constructor(t,n,r,s,a=!1){super({left:t,top:n,right:r,bottom:s},a)}};var Na=class{constructor(t,n,r,s,a){this._imageDims=new Nn(a.width,a.height),this._score=t,this._classScore=n,this._className=r,this._box=new ut(s).rescale(this._imageDims)}get score(){return this._score}get classScore(){return this._classScore}get className(){return this._className}get box(){return this._box}get imageDims(){return this._imageDims}get imageWidth(){return this.imageDims.width}get imageHeight(){return this.imageDims.height}get relativeBox(){return new ut(this._box).rescale(this.imageDims.reverse())}forSize(t,n){return new Na(this.score,this.classScore,this.className,this.relativeBox,{width:t,height:n})}};var xt=class extends Na{constructor(t,n,r){super(t,t,"",n,r)}forSize(t,n){let{score:r,relativeBox:s,imageDims:a}=super.forSize(t,n);return new xt(r,s,a)}};function y1(e,t,n=!0){let r=Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left)),s=Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)),a=r*s;return n?a/(e.area+t.area-a):a/Math.min(e.area,t.area)}function v1(e){let t=e.map(i=>i.x),n=e.map(i=>i.y),r=t.reduce((i,c)=>ccii({score:o,boxIndex:i})).sort((o,i)=>o.score-i.score).map(o=>o.boxIndex),a=[];for(;s.length>0;){let o=s.pop();a.push(o);let i=s,c=[];for(let l=0;lc[u]<=n)}return a}function Xr(e,t){return M(()=>{let[n,r,s]=t,a=xn([...e.shape.slice(0,3),1],n,"float32"),o=xn([...e.shape.slice(0,3),1],r,"float32"),i=xn([...e.shape.slice(0,3),1],s,"float32"),c=et([a,o,i],3);return fe(e,c)})}function w1(e,t=!1){return M(()=>{let[n,r]=e.shape.slice(1);if(n===r)return e;let s=Math.abs(n-r),a=Math.round(s*(t?.5:1)),o=n>r?2:1,i=p=>{let h=e.shape.slice();return h[o]=p,xn(h,0,"float32")},c=i(a),l=s-c.shape[o],d=[t&&l?i(l):null,e,c].filter(p=>!!p).map(p=>ce(p,"float32"));return et(d,o)})}function Lce(e){let t=e.slice();for(let n=t.length-1;n>0;n--){let r=Math.floor(Math.random()*(n+1)),s=t[n];t[n]=t[r],t[r]=s}return t}function tp(e){return 1/(1+Math.exp(-e))}function Bce(e){return Math.log(e/(1-e))}var Vu=class extends ut{constructor(t,n,r,s,a=!1){super({x:t,y:n,width:r,height:s},a)}};var zce=.5,Wce=.43,Vce=.45,yr=class{constructor(t,n,r=new Pe(0,0)){let{width:s,height:a}=n;this._imgDims=new Nn(s,a),this._shift=r,this._positions=t.map(o=>o.mul(new Pe(s,a)).add(r))}get shift(){return new Pe(this._shift.x,this._shift.y)}get imageWidth(){return this._imgDims.width}get imageHeight(){return this._imgDims.height}get positions(){return this._positions}get relativePositions(){return this._positions.map(t=>t.sub(this._shift).div(new Pe(this.imageWidth,this.imageHeight)))}forSize(t,n){return new this.constructor(this.relativePositions,{width:t,height:n})}shiftBy(t,n){return new this.constructor(this.relativePositions,this._imgDims,new Pe(t,n))}shiftByPoint(t){return this.shiftBy(t.x,t.y)}align(t,n={}){if(t){let a=t instanceof xt?t.box.floor():new ut(t);return this.shiftBy(a.x,a.y).align(null,n)}let{useDlibAlignment:r,minBoxPadding:s}={useDlibAlignment:!1,minBoxPadding:.2,...n};return r?this.alignDlib():this.alignMinBbox(s)}alignDlib(){let t=this.getRefPointsForAlignment(),[n,r,s]=t,a=d=>s.sub(d).magnitude(),o=(a(n)+a(r))/2,i=Math.floor(o/Vce),c=Ii(t),l=Math.floor(Math.max(0,c.x-zce*i)),u=Math.floor(Math.max(0,c.y-Wce*i));return new Vu(l,u,Math.min(i,this.imageWidth+l),Math.min(i,this.imageHeight+u))}alignMinBbox(t){let n=v1(this.positions);return n.pad(n.width*t,n.height*t)}getRefPointsForAlignment(){throw new Error("getRefPointsForAlignment not implemented by base class")}};var AE=class extends yr{getRefPointsForAlignment(){let t=this.positions;return[t[0],t[1],Ii([t[3],t[4]])]}};var Uu=class extends yr{getJawOutline(){return this.positions.slice(0,17)}getLeftEyeBrow(){return this.positions.slice(17,22)}getRightEyeBrow(){return this.positions.slice(22,27)}getNose(){return this.positions.slice(27,36)}getLeftEye(){return this.positions.slice(36,42)}getRightEye(){return this.positions.slice(42,48)}getMouth(){return this.positions.slice(48,68)}getRefPointsForAlignment(){return[this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Ii)}};var np=class{constructor(t,n){this._label=t,this._distance=n}get label(){return this._label}get distance(){return this._distance}toString(t=!0){return`${this.label}${t?` (${ki(this.distance)})`:""}`}};var rp=class extends ut{static assertIsValidLabeledBox(t,n){if(ut.assertIsValidBox(t,n),!Kr(t.label))throw new Error(`${n} - expected property label (${t.label}) to be a number`)}constructor(t,n){super(t);this._label=n}get label(){return this._label}};var Rs=class{constructor(t,n){if(typeof t!="string")throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(n)||n.some(r=>!(r instanceof Float32Array)))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=n}get label(){return this._label}get descriptors(){return this._descriptors}toJSON(){return{label:this.label,descriptors:this.descriptors.map(t=>Array.from(t))}}static fromJSON(t){let n=t.descriptors.map(r=>new Float32Array(r));return new Rs(t.label,n)}};var DE=class extends rp{static assertIsValidPredictedBox(t,n){if(rp.assertIsValidLabeledBox(t,n),!zu(t.score)||!zu(t.classScore))throw new Error(`${n} - expected properties score (${t.score}) and (${t.classScore}) to be a number between [0, 1]`)}constructor(t,n,r,s){super(t,n);this._score=r,this._classScore=s}get score(){return this._score}get classScore(){return this._classScore}};function hs(e){return e.detection instanceof xt}function Si(e,t){return{...e,...{detection:t}}}function k1(){let e=window.fetch;if(!e)throw new Error("fetch - missing fetch implementation for browser environment");return{Canvas:HTMLCanvasElement,CanvasRenderingContext2D,Image:HTMLImageElement,ImageData,Video:HTMLVideoElement,createCanvasElement:()=>document.createElement("canvas"),createImageElement:()=>document.createElement("img"),createVideoElement:()=>document.createElement("video"),fetch:e,readFile:()=>{throw new Error("readFile - filesystem not available for browser environment")}}}function sp(){return typeof global=="object"&&typeof process!="undefined"&&process.versions!=null&&process.versions.node!=null}function Bm(e){let t="";if(!e&&sp())try{e=pD("fs")}catch(r){t=r.toString()}return{readFile:e?r=>new Promise((s,a)=>{e.readFile(r,(o,i)=>o?a(o):s(i))}):()=>{throw new Error(`readFile - failed to require fs in nodejs environment with error: ${t}`)}}}function I1(){let e=global.Canvas||global.HTMLCanvasElement,t=global.Image||global.HTMLImageElement,n=global.Video||global.HTMLVideoElement,r=()=>{if(e)return new e;throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment")},s=()=>{if(t)return new t;throw new Error("createImageElement - missing Image implementation for nodejs environment")},a=()=>{if(n)return new n;throw new Error("createVideoElement - missing Video implementation for nodejs environment")},o=global.fetch,i=Bm();return{Canvas:e||class{},CanvasRenderingContext2D:global.CanvasRenderingContext2D||class{},Image:t||class{},ImageData:global.ImageData||class{},Video:global.HTMLVideoElement||class{},createCanvasElement:r,createImageElement:s,createVideoElement:a,fetch:o,...i}}function S1(){return typeof window=="object"&&typeof document!="undefined"&&typeof HTMLImageElement!="undefined"&&typeof HTMLCanvasElement!="undefined"&&typeof HTMLVideoElement!="undefined"&&typeof ImageData!="undefined"&&typeof CanvasRenderingContext2D!="undefined"}var nn;function Uce(){if(!nn)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return nn}function T1(e){nn=e}function C1(){return S1()?T1(k1()):sp()?T1(I1()):null}function Gce(e){if(nn||C1(),!nn)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");let{Canvas:t=nn.Canvas,Image:n=nn.Image}=e;nn.Canvas=t,nn.Image=n,nn.createCanvasElement=e.createCanvasElement||(()=>new t),nn.createImageElement=e.createImageElement||(()=>new n),nn.ImageData=e.ImageData||nn.ImageData,nn.Video=e.Video||nn.Video,nn.fetch=e.fetch||nn.fetch,nn.readFile=e.readFile||nn.readFile}var tt={getEnv:Uce,setEnv:T1,initialize:C1,createBrowserEnv:k1,createFileSystem:Bm,createNodejsEnv:I1,monkeyPatch:Gce,isBrowser:S1,isNodejs:sp};C1();function Ti(e){return!tt.isNodejs()&&typeof e=="string"?document.getElementById(e):e}function Un(e){let{Canvas:t,CanvasRenderingContext2D:n}=tt.getEnv();if(e instanceof n)return e;let r=Ti(e);if(!(r instanceof t))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");let s=r.getContext("2d");if(!s)throw new Error("resolveContext2d - canvas 2d context is null");return s}var fs;(function(s){s.TOP_LEFT="TOP_LEFT",s.TOP_RIGHT="TOP_RIGHT",s.BOTTOM_LEFT="BOTTOM_LEFT",s.BOTTOM_RIGHT="BOTTOM_RIGHT"})(fs||(fs={}));var ap=class{constructor(t={}){let{anchorPosition:n,backgroundColor:r,fontColor:s,fontSize:a,fontStyle:o,padding:i}=t;this.anchorPosition=n||fs.TOP_LEFT,this.backgroundColor=r||"rgba(0, 0, 0, 0.5)",this.fontColor=s||"rgba(255, 255, 255, 1)",this.fontSize=a||14,this.fontStyle=o||"Georgia",this.padding=i||4}},_a=class{constructor(t,n,r={}){this.text=typeof t=="string"?[t]:t instanceof _a?t.text:t,this.anchor=n,this.options=new ap(r)}measureWidth(t){let{padding:n}=this.options;return this.text.map(r=>t.measureText(r).width).reduce((r,s)=>r{let f=c+d.x,m=c+d.y+(h+1)*o;r.fillText(p,f,m)})}};var N1=class{constructor(t={}){let{boxColor:n,lineWidth:r,label:s,drawLabelOptions:a}=t;this.boxColor=n||"rgba(0, 0, 255, 1)",this.lineWidth=r||2,this.label=s;let o={anchorPosition:fs.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new ap({...o,...a})}},zm=class{constructor(t,n={}){this.box=new ut(t),this.options=new N1(n)}draw(t){let n=Un(t),{boxColor:r,lineWidth:s}=this.options,{x:a,y:o,width:i,height:c}=this.box;n.strokeStyle=r,n.lineWidth=s,n.strokeRect(a,o,i,c);let{label:l}=this.options;l&&new _a([l],{x:a-s/2,y:o},this.options.drawLabelOptions).draw(t)}};function Hce(e,t){(Array.isArray(t)?t:[t]).forEach(r=>{let s=r instanceof xt?r.score:hs(r)?r.detection.score:void 0,a=r instanceof xt?r.box:hs(r)?r.detection.box:new ut(r),o=s?`${ki(s)}`:void 0;new zm(a,{label:o}).draw(e)})}function op(e){let{Image:t,Video:n}=tt.getEnv();return e instanceof t&&e.complete||e instanceof n&&e.readyState>=3}function _1(e){return new Promise((t,n)=>{(e instanceof tt.getEnv().Canvas||op(e))&&t(null);function r(a){!a.currentTarget||(a.currentTarget.removeEventListener("load",s),a.currentTarget.removeEventListener("error",r),n(a))}function s(a){!a.currentTarget||(a.currentTarget.removeEventListener("load",s),a.currentTarget.removeEventListener("error",r),t(a))}e.addEventListener("load",s),e.addEventListener("error",r)})}function E1(e){return new Promise((t,n)=>{e instanceof Blob||n(new Error("bufferToImage - expected buf to be of type: Blob"));let r=new FileReader;r.onload=()=>{typeof r.result!="string"&&n(new Error("bufferToImage - expected reader.result to be a string, in onload"));let s=tt.getEnv().createImageElement();s.onload=()=>t(s),s.onerror=n,s.src=r.result},r.onerror=n,r.readAsDataURL(e)})}function Ci(e){let{Image:t,Video:n}=tt.getEnv();return e instanceof t?new Nn(e.naturalWidth,e.naturalHeight):e instanceof n?new Nn(e.videoWidth,e.videoHeight):new Nn(e.width,e.height)}function Ni({width:e,height:t}){let{createCanvasElement:n}=tt.getEnv(),r=n();return r.width=e,r.height=t,r}function ip(e,t){let{ImageData:n}=tt.getEnv();if(!(e instanceof n)&&!op(e))throw new Error("createCanvasFromMedia - media has not finished loading yet");let{width:r,height:s}=t||Ci(e),a=Ni({width:r,height:s});return e instanceof n?Un(a).putImageData(e,0,0):Un(a).drawImage(e,0,0,r,s),a}async function A1(e,t){let n=t||tt.getEnv().createCanvasElement(),[r,s,a]=e.shape.slice(br(e)?1:0),o=M(()=>e.as3D(r,s,a).toInt());return await Go.toPixels(o,n),o.dispose(),n}function Wm(e){let{Image:t,Canvas:n,Video:r}=tt.getEnv();return e instanceof t||e instanceof n||e instanceof r}function D1(e,t,n=!1){let{Image:r,Canvas:s}=tt.getEnv();if(!(e instanceof r||e instanceof s))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");if(t<=0)return Ni({width:1,height:1});let a=Ci(e),o=t/Math.max(a.height,a.width),i=o*a.width,c=o*a.height,l=Ni({width:t,height:t}),u=e instanceof s?e:ip(e),d=Math.abs(i-c)/2,p=n&&i0&&u.height>0&&Un(l).drawImage(u,p,h,i,c),l}var Ps=class{constructor(t,n=!1){this._imageTensors=[];this._canvases=[];this._treatAsBatchInput=!1;this._inputDimensions=[];this._inputSize=0;if(!Array.isArray(t))throw new Error(`NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have ${t}`);this._treatAsBatchInput=n,this._batchSize=t.length,t.forEach((r,s)=>{if($s(r)){this._imageTensors[s]=r,this._inputDimensions[s]=r.shape;return}if(br(r)){let o=r.shape[0];if(o!==1)throw new Error(`NetInput - tf.Tensor4D with batchSize ${o} passed, but not supported in input array`);this._imageTensors[s]=r,this._inputDimensions[s]=r.shape.slice(1);return}let a=r instanceof tt.getEnv().Canvas?r:ip(r);this._canvases[s]=a,this._inputDimensions[s]=[a.height,a.width,3]})}get imageTensors(){return this._imageTensors}get canvases(){return this._canvases}get isBatchInput(){return this.batchSize>1||this._treatAsBatchInput}get batchSize(){return this._batchSize}get inputDimensions(){return this._inputDimensions}get inputSize(){return this._inputSize}get reshapedInputDimensions(){return ps(this.batchSize,0,1).map((t,n)=>this.getReshapedInputDimensions(n))}getInput(t){return this.canvases[t]||this.imageTensors[t]}getInputDimensions(t){return this._inputDimensions[t]}getInputHeight(t){return this._inputDimensions[t][0]}getInputWidth(t){return this._inputDimensions[t][1]}getReshapedInputDimensions(t){if(typeof this.inputSize!="number")throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");let n=this.getInputWidth(t),r=this.getInputHeight(t);return g1({width:n,height:r},this.inputSize)}toBatchTensor(t,n=!0){return this._inputSize=t,M(()=>{let r=ps(this.batchSize,0,1).map(a=>{let o=this.getInput(a);if(o instanceof Ee){let i=br(o)?o:mn(o);return i=w1(i,n),(i.shape[1]!==t||i.shape[2]!==t)&&(i=er.resizeBilinear(i,[t,t],!1,!1)),i.as3D(t,t,3)}if(o instanceof tt.getEnv().Canvas)return Go.fromPixels(D1(o,t,n));throw new Error(`toBatchTensor - at batchIdx ${a}, expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have ${o}`)});return Ot(r.map(a=>ce(a,"float32"))).as4D(this.batchSize,t,t,3)})}};async function bt(e){if(e instanceof Ps)return e;let t=Array.isArray(e)?e:[e];if(!t.length)throw new Error("toNetInput - empty array passed as input");let n=s=>Array.isArray(e)?` at input index ${s}:`:"",r=t.map(Ti);return r.forEach((s,a)=>{if(!Wm(s)&&!$s(s)&&!br(s))throw typeof t[a]=="string"?new Error(`toNetInput -${n(a)} string passed, but could not resolve HTMLElement for element id ${t[a]}`):new Error(`toNetInput -${n(a)} expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id`);if(br(s)){let o=s.shape[0];if(o!==1)throw new Error(`toNetInput -${n(a)} tf.Tensor4D with batchSize ${o} passed, but not supported in input array`)}}),await Promise.all(r.map(s=>Wm(s)&&_1(s))),new Ps(r,Array.isArray(e))}async function Gu(e,t){let{Canvas:n}=tt.getEnv(),r=e;if(!(e instanceof n)){let o=await bt(e);if(o.batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");let i=o.getInput(0);r=i instanceof n?i:await A1(i)}let s=Un(r);return t.map(o=>o instanceof xt?o.forSize(r.width,r.height).box.floor():o).map(o=>o.clipAtImageBorders(r.width,r.height)).map(({x:o,y:i,width:c,height:l})=>{let u=Ni({width:c,height:l});return c>0&&l>0&&Un(u).putImageData(s.getImageData(o,i,c,l),0,0),u})}async function Hu(e,t){if(!$s(e)&&!br(e))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(br(e)&&e.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return M(()=>{let[n,r,s]=e.shape.slice(br(e)?1:0);return t.map(i=>i instanceof xt?i.forSize(r,n).box:i).map(i=>i.clipAtImageBorders(r,n)).map(({x:i,y:c,width:l,height:u})=>pu(e.as3D(n,r,s),[c,i,0],[u,l,s]))})}async function Os(e,t){let{fetch:n}=tt.getEnv(),r=await n(e,t);if(!(r.status<400))throw new Error(`failed to fetch: (${r.status}) ${r.statusText}, from url: ${r.url}`);return r}async function jce(e){let t=await Os(e),n=await t.blob();if(!n.type.startsWith("image/"))throw new Error(`fetchImage - expected blob type to be of type image/*, instead have: ${n.type}, for url: ${t.url}`);return E1(n)}async function F1(e){return(await Os(e)).json()}async function qce(e){return new Float32Array(await(await Os(e)).arrayBuffer())}function FE(e){return new Promise((t,n)=>{e instanceof Blob||n(new Error("bufferToVideo - expected buf to be of type: Blob"));let r=tt.getEnv().createVideoElement();r.oncanplay=()=>t(r),r.onerror=n,r.playsInline=!0,r.muted=!0,r.src=URL.createObjectURL(e),r.play()})}async function Kce(e){let t=await Os(e),n=await t.blob();if(!n.type.startsWith("video/"))throw new Error(`fetchVideo - expected blob type to be of type video/*, instead have: ${n.type}, for url: ${t.url}`);return FE(n)}function Vm(e,t){let n=`${t}-weights_manifest.json`;if(!e)return{modelBaseUri:"",manifestUri:n};if(e==="/")return{modelBaseUri:"/",manifestUri:`/${n}`};let r=e.startsWith("http://")?"http://":e.startsWith("https://")?"https://":"";e=e.replace(r,"");let s=e.split("/").filter(i=>i),a=e.endsWith(".json")?s[s.length-1]:n,o=r+(e.endsWith(".json")?s.slice(0,s.length-1):s).join("/");return o=e.startsWith("/")?`/${o}`:o,{modelBaseUri:o,manifestUri:o==="/"?`/${a}`:`${o}/${a}`}}async function $1(e,t){let{manifestUri:n,modelBaseUri:r}=Vm(e,t),s=await F1(n);return Yt.loadWeights(s,r)}function Xce(e,t,n=!1){let{width:r,height:s}=n?Ci(t):t;return e.width=r,e.height=s,{width:r,height:s}}var ln=class{constructor(t){this._params=void 0;this._paramMappings=[];this._name=t}get params(){return this._params}get paramMappings(){return this._paramMappings}get isLoaded(){return!!this.params}getParamFromPath(t){let{obj:n,objProp:r}=this.traversePropertyPath(t);return n[r]}reassignParamFromPath(t,n){let{obj:r,objProp:s}=this.traversePropertyPath(t);r[s].dispose(),r[s]=n}getParamList(){return this._paramMappings.map(({paramPath:t})=>({path:t,tensor:this.getParamFromPath(t)}))}getTrainableParams(){return this.getParamList().filter(t=>t.tensor instanceof ra)}getFrozenParams(){return this.getParamList().filter(t=>!(t.tensor instanceof ra))}variable(){this.getFrozenParams().forEach(({path:t,tensor:n})=>{this.reassignParamFromPath(t,n.variable())})}freeze(){this.getTrainableParams().forEach(({path:t,tensor:n})=>{let r=Kn(n.dataSync());n.dispose(),this.reassignParamFromPath(t,r)})}dispose(t=!0){this.getParamList().forEach(n=>{if(t&&n.tensor.isDisposed)throw new Error(`param tensor has already been disposed for path ${n.path}`);n.tensor.dispose()}),this._params=void 0}serializeParams(){return new Float32Array(this.getParamList().map(({tensor:t})=>Array.from(t.dataSync())).reduce((t,n)=>t.concat(n)))}async load(t){if(t instanceof Float32Array){this.extractWeights(t);return}await this.loadFromUri(t)}async loadFromUri(t){if(t&&typeof t!="string")throw new Error(`${this._name}.loadFromUri - expected model uri`);let n=await $1(t,this.getDefaultModelName());this.loadFromWeightMap(n)}async loadFromDisk(t){if(t&&typeof t!="string")throw new Error(`${this._name}.loadFromDisk - expected model file path`);let{readFile:n}=tt.getEnv(),{manifestUri:r,modelBaseUri:s}=Vm(t,this.getDefaultModelName()),a=l=>Promise.all(l.map(u=>n(u).then(d=>d.buffer))),o=Yt.weightsLoaderFactory(a),i=JSON.parse((await n(r)).toString()),c=await o(i,s);this.loadFromWeightMap(c)}loadFromWeightMap(t){let{paramMappings:n,params:r}=this.extractParamsFromWeightMap(t);this._paramMappings=n,this._params=r}extractWeights(t){let{paramMappings:n,params:r}=this.extractParams(t);this._paramMappings=n,this._params=r}traversePropertyPath(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");let n=t.split("/").reduce((a,o)=>{if(!a.nextObj.hasOwnProperty(o))throw new Error(`traversePropertyPath - object does not have property ${o}, for path ${t}`);return{obj:a.nextObj,objProp:o,nextObj:a.nextObj[o]}},{nextObj:this.params}),{obj:r,objProp:s}=n;if(!r||!s||!(r[s]instanceof Ee))throw new Error(`traversePropertyPath - parameter is not a tensor, for path ${t}`);return{obj:r,objProp:s}}};function Gn(e,t,n){return M(()=>{let r=ei(e,t.depthwise_filter,t.pointwise_filter,n,"same");return r=Y(r,t.bias),r})}function Um(e,t,n=!1){return M(()=>{let r=qe(n?Y(Rt(e,t.conv0.filters,[2,2],"same"),t.conv0.bias):Gn(e,t.conv0,[2,2])),s=Gn(r,t.conv1,[1,1]),a=qe(Y(r,s)),o=Gn(a,t.conv2,[1,1]);return qe(Y(r,Y(s,o)))})}function cp(e,t,n=!1,r=!0){return M(()=>{let s=qe(n?Y(Rt(e,t.conv0.filters,r?[2,2]:[1,1],"same"),t.conv0.bias):Gn(e,t.conv0,r?[2,2]:[1,1])),a=Gn(s,t.conv1,[1,1]),o=qe(Y(s,a)),i=Gn(o,t.conv2,[1,1]),c=qe(Y(s,Y(a,i))),l=Gn(c,t.conv3,[1,1]);return qe(Y(s,Y(a,Y(i,l))))})}function _i(e,t,n="same",r=!1){return M(()=>{let s=Y(Rt(e,t.filters,[1,1],n),t.bias);return r?qe(s):s})}function _n(e,t){Object.keys(e).forEach(n=>{t.some(r=>r.originalPath===n)||e[n].dispose()})}function ju(e,t){return(n,r,s,a)=>{let o=Br(e(n*r*s*s),[s,s,n,r]),i=He(e(r));return t.push({paramPath:`${a}/filters`},{paramPath:`${a}/bias`}),{filters:o,bias:i}}}function Gm(e,t){return(n,r,s)=>{let a=Lr(e(n*r),[n,r]),o=He(e(r));return t.push({paramPath:`${s}/weights`},{paramPath:`${s}/bias`}),{weights:a,bias:o}}}var Hm=class{constructor(t,n,r){this.depthwise_filter=t;this.pointwise_filter=n;this.bias=r}};function qu(e,t){return(n,r,s)=>{let a=Br(e(3*3*n),[3,3,n,1]),o=Br(e(n*r),[1,1,n,r]),i=He(e(r));return t.push({paramPath:`${s}/depthwise_filter`},{paramPath:`${s}/pointwise_filter`},{paramPath:`${s}/bias`}),new Hm(a,o,i)}}function Ku(e){return t=>{let n=e(`${t}/depthwise_filter`,4),r=e(`${t}/pointwise_filter`,4),s=e(`${t}/bias`,1);return new Hm(n,r,s)}}function ar(e,t){return(n,r,s)=>{let a=e[n];if(!wi(a,r))throw new Error(`expected weightMap[${n}] to be a Tensor${r}D, instead have ${a}`);return t.push({originalPath:n,paramPath:s||n}),a}}function En(e){let t=e;function n(s){let a=t.slice(0,s);return t=t.slice(s),a}function r(){return t}return{extractWeights:n,getRemainingWeights:r}}function jm(e,t){let n=ju(e,t),r=qu(e,t);function s(o,i,c,l=!1){let u=l?n(o,i,3,`${c}/conv0`):r(o,i,`${c}/conv0`),d=r(i,i,`${c}/conv1`),p=r(i,i,`${c}/conv2`);return{conv0:u,conv1:d,conv2:p}}function a(o,i,c,l=!1){let{conv0:u,conv1:d,conv2:p}=s(o,i,c,l),h=r(i,i,`${c}/conv3`);return{conv0:u,conv1:d,conv2:p,conv3:h}}return{extractDenseBlock3Params:s,extractDenseBlock4Params:a}}function $E(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),{extractDenseBlock4Params:s}=jm(n,t),a=s(3,32,"dense0",!0),o=s(32,64,"dense1"),i=s(64,128,"dense2"),c=s(128,256,"dense3");if(r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{dense0:a,dense1:o,dense2:i,dense3:c}}}function qm(e){return t=>{let n=e(`${t}/filters`,4),r=e(`${t}/bias`,1);return{filters:n,bias:r}}}function Km(e,t){let n=ar(e,t),r=qm(n),s=Ku(n);function a(i,c=!1){let l=c?r(`${i}/conv0`):s(`${i}/conv0`),u=s(`${i}/conv1`),d=s(`${i}/conv2`);return{conv0:l,conv1:u,conv2:d}}function o(i,c=!1){let l=c?r(`${i}/conv0`):s(`${i}/conv0`),u=s(`${i}/conv1`),d=s(`${i}/conv2`),p=s(`${i}/conv3`);return{conv0:l,conv1:u,conv2:d,conv3:p}}return{extractDenseBlock3Params:a,extractDenseBlock4Params:o}}function RE(e){let t=[],{extractDenseBlock4Params:n}=Km(e,t),r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2"),dense3:n("dense3")};return _n(e,t),{params:r,paramMappings:t}}var up=class extends ln{constructor(){super("FaceFeatureExtractor")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("FaceFeatureExtractor - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(112,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=cp(a,n.dense0,!0);return o=cp(o,n.dense1),o=cp(o,n.dense2),o=cp(o,n.dense3),o=lr(o,[7,7],[2,2],"valid"),o})}async forward(t){return this.forwardInput(await bt(t))}getDefaultModelName(){return"face_feature_extractor_model"}extractParamsFromWeightMap(t){return RE(t)}extractParams(t){return $E(t)}};function lp(e,t){return M(()=>Y(De(e,t.weights),t.bias))}function PE(e,t,n){let r=[],{extractWeights:s,getRemainingWeights:a}=En(e),i=Gm(s,r)(t,n,"fc");if(a().length!==0)throw new Error(`weights remaing after extract: ${a().length}`);return{paramMappings:r,params:{fc:i}}}function OE(e){let t=[],n=ar(e,t);function r(a){let o=n(`${a}/weights`,2),i=n(`${a}/bias`,1);return{weights:o,bias:i}}let s={fc:r("fc")};return _n(e,t),{params:s,paramMappings:t}}function Xm(e){let t={},n={};return Object.keys(e).forEach(r=>{let s=r.startsWith("fc")?n:t;s[r]=e[r]}),{featureExtractorMap:t,classifierMap:n}}var dp=class extends ln{constructor(t,n){super(t);this._faceFeatureExtractor=n}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(t){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return M(()=>{let r=t instanceof Ps?this.faceFeatureExtractor.forwardInput(t):t;return lp(r.as2D(r.shape[0],-1),n.fc)})}dispose(t=!0){this.faceFeatureExtractor.dispose(t),super.dispose(t)}loadClassifierParams(t){let{params:n,paramMappings:r}=this.extractClassifierParams(t);this._params=n,this._paramMappings=r}extractClassifierParams(t){return PE(t,this.getClassifierChannelsIn(),this.getClassifierChannelsOut())}extractParamsFromWeightMap(t){let{featureExtractorMap:n,classifierMap:r}=Xm(t);return this.faceFeatureExtractor.loadFromWeightMap(n),OE(r)}extractParams(t){let n=this.getClassifierChannelsIn(),r=this.getClassifierChannelsOut(),s=r*n+r,a=t.slice(0,t.length-s),o=t.slice(t.length-s);return this.faceFeatureExtractor.extractWeights(a),this.extractClassifierParams(o)}};var R1=["neutral","happy","sad","angry","fearful","disgusted","surprised"],Ea=class{constructor(t){this.neutral=0;this.happy=0;this.sad=0;this.angry=0;this.fearful=0;this.disgusted=0;this.surprised=0;if(t.length!==7)throw new Error(`FaceExpressions.constructor - expected probabilities.length to be 7, have: ${t.length}`);R1.forEach((n,r)=>{this[n]=t[r]})}asSortedArray(){return R1.map(t=>({expression:t,probability:this[t]})).sort((t,n)=>n.probability-t.probability)}};var Ym=class extends dp{constructor(t=new up){super("FaceExpressionNet",t)}forwardInput(t){return M(()=>Mr(this.runNet(t)))}async forward(t){return this.forwardInput(await bt(t))}async predictExpressions(t){let n=await bt(t),r=await this.forwardInput(n),s=await Promise.all(ht(r).map(async o=>{let i=o.dataSync();return o.dispose(),i}));r.dispose();let a=s.map(o=>new Ea(o));return n.isBatchInput?a:a[0]}getDefaultModelName(){return"face_expression_model"}getClassifierChannelsIn(){return 256}getClassifierChannelsOut(){return 7}};function P1(e){return e.expressions instanceof Ea}function Zm(e,t){return{...e,...{expressions:t}}}function Yce(e,t,n=.1,r){(Array.isArray(t)?t:[t]).forEach(a=>{let o=a instanceof Ea?a:P1(a)?a.expressions:void 0;if(!o)throw new Error("drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof");let c=o.asSortedArray().filter(d=>d.probability>n),l=hs(a)?a.detection.box.bottomLeft:r||new Pe(0,0);new _a(c.map(d=>`${d.expression} (${ki(d.probability)})`),l).draw(e)})}function Ei(e){return hs(e)&&e.landmarks instanceof yr&&e.unshiftedLandmarks instanceof yr&&e.alignedRect instanceof xt}function Zce(e){let t=(i,c,l,u)=>Math.atan2(u-c,l-i)%Math.PI,n=i=>i*180/Math.PI,r={roll:void 0,pitch:void 0,yaw:void 0};if(!e||!e._positions||e._positions.length!==68)return r;let s=e._positions;r.roll=-t(s[36]._x,s[36]._y,s[45]._x,s[45]._y),r.pitch=t(0,Math.abs(s[0]._x-s[30]._x)/s[30]._x,Math.PI,Math.abs(s[16]._x-s[30]._x)/s[30]._x);let a=s.reduce((i,c)=>ii>c._y?i:c._y,-1/0);return r.yaw=Math.PI*(e._imgDims._height/(o-a)/1.4-1),r}function Xu(e,t){let{box:n}=e.detection,r=t.shiftBy(n.x,n.y),s=r.align(),{imageDims:a}=e.detection,o=new xt(e.detection.score,s.rescale(a.reverse()),a),i=Zce(t);return{...e,...{landmarks:r,unshiftedLandmarks:t,alignedRect:o,angle:i}}}var O1=class{constructor(t={}){let{drawLines:n=!0,drawPoints:r=!0,lineWidth:s,lineColor:a,pointSize:o,pointColor:i}=t;this.drawLines=n,this.drawPoints=r,this.lineWidth=s||1,this.pointSize=o||2,this.lineColor=a||"rgba(0, 255, 255, 1)",this.pointColor=i||"rgba(255, 0, 255, 1)"}},M1=class{constructor(t,n={}){this.faceLandmarks=t,this.options=new O1(n)}draw(t){let n=Un(t),{drawLines:r,drawPoints:s,lineWidth:a,lineColor:o,pointSize:i,pointColor:c}=this.options;if(r&&this.faceLandmarks instanceof Uu&&(n.strokeStyle=o,n.lineWidth=a,Fs(n,this.faceLandmarks.getJawOutline()),Fs(n,this.faceLandmarks.getLeftEyeBrow()),Fs(n,this.faceLandmarks.getRightEyeBrow()),Fs(n,this.faceLandmarks.getNose()),Fs(n,this.faceLandmarks.getLeftEye(),!0),Fs(n,this.faceLandmarks.getRightEye(),!0),Fs(n,this.faceLandmarks.getMouth(),!0)),s){n.strokeStyle=c,n.fillStyle=c;let l=u=>{n.beginPath(),n.arc(u.x,u.y,i,0,2*Math.PI),n.fill()};this.faceLandmarks.positions.forEach(l)}}};function Jce(e,t){(Array.isArray(t)?t:[t]).forEach(r=>{let s=r instanceof yr?r:Ei(r)?r.landmarks:void 0;if(!s)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks> or array thereof");new M1(s).draw(e)})}var ME="1.6.2";function eue(e,t){let n=ju(e,t),r=qu(e,t);function s(o,i,c){let l=r(o,i,`${c}/separable_conv0`),u=r(i,i,`${c}/separable_conv1`),d=n(o,i,1,`${c}/expansion_conv`);return{separable_conv0:l,separable_conv1:u,expansion_conv:d}}function a(o,i){let c=r(o,o,`${i}/separable_conv0`),l=r(o,o,`${i}/separable_conv1`),u=r(o,o,`${i}/separable_conv2`);return{separable_conv0:c,separable_conv1:l,separable_conv2:u}}return{extractConvParams:n,extractSeparableConvParams:r,extractReductionBlockParams:s,extractMainBlockParams:a}}function LE(e,t){let n=[],{extractWeights:r,getRemainingWeights:s}=En(e),{extractConvParams:a,extractSeparableConvParams:o,extractReductionBlockParams:i,extractMainBlockParams:c}=eue(r,n),l=a(3,32,3,"entry_flow/conv_in"),u=i(32,64,"entry_flow/reduction_block_0"),d=i(64,128,"entry_flow/reduction_block_1"),p={conv_in:l,reduction_block_0:u,reduction_block_1:d},h={};ps(t,0,1).forEach(b=>{h[`main_block_${b}`]=c(128,`middle_flow/main_block_${b}`)});let f=i(128,256,"exit_flow/reduction_block"),m=o(256,512,"exit_flow/separable_conv"),g={reduction_block:f,separable_conv:m};if(s().length!==0)throw new Error(`weights remaing after extract: ${s().length}`);return{paramMappings:n,params:{entry_flow:p,middle_flow:h,exit_flow:g}}}function tue(e,t){let n=ar(e,t),r=qm(n),s=Ku(n);function a(i){let c=s(`${i}/separable_conv0`),l=s(`${i}/separable_conv1`),u=r(`${i}/expansion_conv`);return{separable_conv0:c,separable_conv1:l,expansion_conv:u}}function o(i){let c=s(`${i}/separable_conv0`),l=s(`${i}/separable_conv1`),u=s(`${i}/separable_conv2`);return{separable_conv0:c,separable_conv1:l,separable_conv2:u}}return{extractConvParams:r,extractSeparableConvParams:s,extractReductionBlockParams:a,extractMainBlockParams:o}}function BE(e,t){let n=[],{extractConvParams:r,extractSeparableConvParams:s,extractReductionBlockParams:a,extractMainBlockParams:o}=tue(e,n),i=r("entry_flow/conv_in"),c=a("entry_flow/reduction_block_0"),l=a("entry_flow/reduction_block_1"),u={conv_in:i,reduction_block_0:c,reduction_block_1:l},d={};ps(t,0,1).forEach(m=>{d[`main_block_${m}`]=o(`middle_flow/main_block_${m}`)});let p=a("exit_flow/reduction_block"),h=s("exit_flow/separable_conv"),f={reduction_block:p,separable_conv:h};return _n(e,n),{params:{entry_flow:u,middle_flow:d,exit_flow:f},paramMappings:n}}function zE(e,t,n){return Y(Rt(e,t.filters,n,"same"),t.bias)}function B1(e,t,n=!0){let r=n?qe(e):e;return r=Gn(r,t.separable_conv0,[1,1]),r=Gn(qe(r),t.separable_conv1,[1,1]),r=Pt(r,[3,3],[2,2],"same"),r=Y(r,zE(e,t.expansion_conv,[2,2])),r}function nue(e,t){let n=Gn(qe(e),t.separable_conv0,[1,1]);return n=Gn(qe(n),t.separable_conv1,[1,1]),n=Gn(qe(n),t.separable_conv2,[1,1]),n=Y(n,e),n}var z1=class extends ln{constructor(t){super("TinyXception");this._numMainBlocks=t}forwardInput(t){let{params:n}=this;if(!n)throw new Error("TinyXception - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(112,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=qe(zE(a,n.entry_flow.conv_in,[2,2]));return o=B1(o,n.entry_flow.reduction_block_0,!1),o=B1(o,n.entry_flow.reduction_block_1),ps(this._numMainBlocks,0,1).forEach(i=>{o=nue(o,n.middle_flow[`main_block_${i}`])}),o=B1(o,n.exit_flow.reduction_block),o=qe(Gn(o,n.exit_flow.separable_conv,[1,1])),o})}async forward(t){return this.forwardInput(await bt(t))}getDefaultModelName(){return"tiny_xception_model"}extractParamsFromWeightMap(t){return BE(t,this._numMainBlocks)}extractParams(t){return LE(t,this._numMainBlocks)}};function WE(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),s=Gm(n,t),a=s(512,1,"fc/age"),o=s(512,2,"fc/gender");if(r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{fc:{age:a,gender:o}}}}function VE(e){let t=[],n=ar(e,t);function r(a){let o=n(`${a}/weights`,2),i=n(`${a}/bias`,1);return{weights:o,bias:i}}let s={fc:{age:r("fc/age"),gender:r("fc/gender")}};return _n(e,t),{params:s,paramMappings:t}}var Ms;(function(n){n.FEMALE="female",n.MALE="male"})(Ms||(Ms={}));var Jm=class extends ln{constructor(t=new z1(2)){super("AgeGenderNet");this._faceFeatureExtractor=t}get faceFeatureExtractor(){return this._faceFeatureExtractor}runNet(t){let{params:n}=this;if(!n)throw new Error(`${this._name} - load model before inference`);return M(()=>{let r=t instanceof Ps?this.faceFeatureExtractor.forwardInput(t):t,s=lr(r,[7,7],[2,2],"valid").as2D(r.shape[0],-1),a=lp(s,n.fc.age).as1D(),o=lp(s,n.fc.gender);return{age:a,gender:o}})}forwardInput(t){return M(()=>{let{age:n,gender:r}=this.runNet(t);return{age:n,gender:Mr(r)}})}async forward(t){return this.forwardInput(await bt(t))}async predictAgeAndGender(t){let n=await bt(t),r=await this.forwardInput(n),s=ht(r.age),a=ht(r.gender),o=s.map((c,l)=>({ageTensor:c,genderTensor:a[l]})),i=await Promise.all(o.map(async({ageTensor:c,genderTensor:l})=>{let u=c.dataSync()[0],d=l.dataSync()[0],p=d>.5,h=p?Ms.MALE:Ms.FEMALE,f=p?d:1-d;return c.dispose(),l.dispose(),{age:u,gender:h,genderProbability:f}}));return r.age.dispose(),r.gender.dispose(),n.isBatchInput?i:i[0]}getDefaultModelName(){return"age_gender_model"}dispose(t=!0){this.faceFeatureExtractor.dispose(t),super.dispose(t)}loadClassifierParams(t){let{params:n,paramMappings:r}=this.extractClassifierParams(t);this._params=n,this._paramMappings=r}extractClassifierParams(t){return WE(t)}extractParamsFromWeightMap(t){let{featureExtractorMap:n,classifierMap:r}=Xm(t);return this.faceFeatureExtractor.loadFromWeightMap(n),VE(r)}extractParams(t){let n=512*1+1+(512*2+2),r=t.slice(0,t.length-n),s=t.slice(t.length-n);return this.faceFeatureExtractor.extractWeights(r),this.extractClassifierParams(s)}};var pp=class extends dp{postProcess(t,n,r){let s=r.map(({width:o,height:i})=>{let c=n/Math.max(i,o);return{width:o*c,height:i*c}}),a=s.length;return M(()=>{let o=(d,p)=>Ot([xn([68],d,"float32"),xn([68],p,"float32")],1).as2D(1,136).as1D(),i=(d,p)=>{let{width:h,height:f}=s[d];return p(h,f)?Math.abs(h-f)/2:0},c=d=>i(d,(p,h)=>pi(d,(p,h)=>ho(c(p),l(p))))).div(Ot(Array.from(Array(a),(d,p)=>o(s[p].width,s[p].height))))})}forwardInput(t){return M(()=>{let n=this.runNet(t);return this.postProcess(n,t.inputSize,t.inputDimensions.map(([r,s])=>({height:r,width:s})))})}async forward(t){return this.forwardInput(await bt(t))}async detectLandmarks(t){let n=await bt(t),r=M(()=>ht(this.forwardInput(n))),s=await Promise.all(r.map(async(a,o)=>{let i=Array.from(a.dataSync()),c=i.filter((u,d)=>Mm(d)),l=i.filter((u,d)=>!Mm(d));return new Uu(Array(68).fill(0).map((u,d)=>new Pe(c[d],l[d])),{height:n.getInputHeight(o),width:n.getInputWidth(o)})}));return r.forEach(a=>a.dispose()),n.isBatchInput?s:s[0]}getClassifierChannelsOut(){return 136}};var Yu=class extends pp{constructor(t=new up){super("FaceLandmark68Net",t)}getDefaultModelName(){return"face_landmark_68_model"}getClassifierChannelsIn(){return 256}};function UE(e){let t=[],{extractDenseBlock3Params:n}=Km(e,t),r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2")};return _n(e,t),{params:r,paramMappings:t}}function GE(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),{extractDenseBlock3Params:s}=jm(n,t),a=s(3,32,"dense0",!0),o=s(32,64,"dense1"),i=s(64,128,"dense2");if(r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{paramMappings:t,params:{dense0:a,dense1:o,dense2:i}}}var W1=class extends ln{constructor(){super("TinyFaceFeatureExtractor")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("TinyFaceFeatureExtractor - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(112,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=Um(a,n.dense0,!0);return o=Um(o,n.dense1),o=Um(o,n.dense2),o=lr(o,[14,14],[2,2],"valid"),o})}async forward(t){return this.forwardInput(await bt(t))}getDefaultModelName(){return"face_feature_extractor_tiny_model"}extractParamsFromWeightMap(t){return UE(t)}extractParams(t){return GE(t)}};var Qm=class extends pp{constructor(t=new W1){super("FaceLandmark68TinyNet",t)}getDefaultModelName(){return"face_landmark_68_tiny_model"}getClassifierChannelsIn(){return 128}};var HE=class extends Yu{};function jE(e,t){return Y(V(e,t.weights),t.biases)}function V1(e,t,n,r,s="same"){let{filters:a,bias:o}=t.conv,i=Rt(e,a,n,s);return i=Y(i,o),i=jE(i,t.scale),r?qe(i):i}function qE(e,t){return V1(e,t,[1,1],!0)}function U1(e,t){return V1(e,t,[1,1],!1)}function eg(e,t){return V1(e,t,[2,2],!0,"valid")}function rue(e,t){function n(i,c,l){let u=e(i),d=u.length/(c*l*l);if(m1(d))throw new Error(`depth has to be an integer: ${d}, weights.length: ${u.length}, numFilters: ${c}, filterSize: ${l}`);return M(()=>Re(Br(u,[c,d,l,l]),[2,3,1,0]))}function r(i,c,l,u){let d=n(i,c,l),p=He(e(c));return t.push({paramPath:`${u}/filters`},{paramPath:`${u}/bias`}),{filters:d,bias:p}}function s(i,c){let l=He(e(i)),u=He(e(i));return t.push({paramPath:`${c}/weights`},{paramPath:`${c}/biases`}),{weights:l,biases:u}}function a(i,c,l,u){let d=r(i,c,l,`${u}/conv`),p=s(c,`${u}/scale`);return{conv:d,scale:p}}function o(i,c,l,u,d=!1){let p=a((d?.5:1)*i,c,l,`${u}/conv1`),h=a(i,c,l,`${u}/conv2`);return{conv1:p,conv2:h}}return{extractConvLayerParams:a,extractResidualLayerParams:o}}function KE(e){let{extractWeights:t,getRemainingWeights:n}=En(e),r=[],{extractConvLayerParams:s,extractResidualLayerParams:a}=rue(t,r),o=s(4704,32,7,"conv32_down"),i=a(9216,32,3,"conv32_1"),c=a(9216,32,3,"conv32_2"),l=a(9216,32,3,"conv32_3"),u=a(36864,64,3,"conv64_down",!0),d=a(36864,64,3,"conv64_1"),p=a(36864,64,3,"conv64_2"),h=a(36864,64,3,"conv64_3"),f=a(147456,128,3,"conv128_down",!0),m=a(147456,128,3,"conv128_1"),g=a(147456,128,3,"conv128_2"),b=a(589824,256,3,"conv256_down",!0),y=a(589824,256,3,"conv256_1"),v=a(589824,256,3,"conv256_2"),x=a(589824,256,3,"conv256_down_out"),w=M(()=>Re(Lr(t(256*128),[128,256]),[1,0]));if(r.push({paramPath:"fc"}),n().length!==0)throw new Error(`weights remaing after extract: ${n().length}`);return{params:{conv32_down:o,conv32_1:i,conv32_2:c,conv32_3:l,conv64_down:u,conv64_1:d,conv64_2:p,conv64_3:h,conv128_down:f,conv128_1:m,conv128_2:g,conv256_down:b,conv256_1:y,conv256_2:v,conv256_down_out:x,fc:w},paramMappings:r}}function sue(e,t){let n=ar(e,t);function r(o){let i=n(`${o}/scale/weights`,1),c=n(`${o}/scale/biases`,1);return{weights:i,biases:c}}function s(o){let i=n(`${o}/conv/filters`,4),c=n(`${o}/conv/bias`,1),l=r(o);return{conv:{filters:i,bias:c},scale:l}}function a(o){return{conv1:s(`${o}/conv1`),conv2:s(`${o}/conv2`)}}return{extractConvLayerParams:s,extractResidualLayerParams:a}}function XE(e){let t=[],{extractConvLayerParams:n,extractResidualLayerParams:r}=sue(e,t),s=n("conv32_down"),a=r("conv32_1"),o=r("conv32_2"),i=r("conv32_3"),c=r("conv64_down"),l=r("conv64_1"),u=r("conv64_2"),d=r("conv64_3"),p=r("conv128_down"),h=r("conv128_1"),f=r("conv128_2"),m=r("conv256_down"),g=r("conv256_1"),b=r("conv256_2"),y=r("conv256_down_out"),{fc:v}=e;if(t.push({originalPath:"fc",paramPath:"fc"}),!f1(v))throw new Error(`expected weightMap[fc] to be a Tensor2D, instead have ${v}`);let x={conv32_down:s,conv32_1:a,conv32_2:o,conv32_3:i,conv64_down:c,conv64_1:l,conv64_2:u,conv64_3:d,conv128_down:p,conv128_1:h,conv128_2:f,conv256_down:m,conv256_1:g,conv256_2:b,conv256_down_out:y,fc:v};return _n(e,t),{params:x,paramMappings:t}}function Yr(e,t){let n=qE(e,t.conv1);return n=U1(n,t.conv2),n=Y(n,e),n=qe(n),n}function hp(e,t){let n=eg(e,t.conv1);n=U1(n,t.conv2);let r=lr(e,2,2,"valid"),s=St(r.shape),a=r.shape[3]!==n.shape[3];if(r.shape[1]!==n.shape[1]||r.shape[2]!==n.shape[2]){let i=[...n.shape];i[1]=1;let c=St(i);n=et([n,c],1);let l=[...n.shape];l[2]=1;let u=St(l);n=et([n,u],2)}return r=a?et([r,s],3):r,n=Y(r,n),n=qe(n),n}var Zu=class extends ln{constructor(){super("FaceRecognitionNet")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("FaceRecognitionNet - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(150,!0),"float32"),a=Xr(r,[122.782,117.001,104.298]).div(255),o=eg(a,n.conv32_down);o=Pt(o,3,2,"valid"),o=Yr(o,n.conv32_1),o=Yr(o,n.conv32_2),o=Yr(o,n.conv32_3),o=hp(o,n.conv64_down),o=Yr(o,n.conv64_1),o=Yr(o,n.conv64_2),o=Yr(o,n.conv64_3),o=hp(o,n.conv128_down),o=Yr(o,n.conv128_1),o=Yr(o,n.conv128_2),o=hp(o,n.conv256_down),o=Yr(o,n.conv256_1),o=Yr(o,n.conv256_2),o=hp(o,n.conv256_down_out);let i=o.mean([1,2]);return De(i,n.fc)})}async forward(t){return this.forwardInput(await bt(t))}async computeFaceDescriptor(t){var a;if((a=t==null?void 0:t.shape)==null?void 0:a.some(o=>o<=0))return new Float32Array(128);let n=await bt(t),r=M(()=>ht(this.forwardInput(n))),s=await Promise.all(r.map(o=>o.data()));return r.forEach(o=>o.dispose()),n.isBatchInput?s:s[0]}getDefaultModelName(){return"face_recognition_model"}extractParamsFromWeightMap(t){return XE(t)}extractParams(t){return KE(t)}};function aue(e){let t=new Zu;return t.extractWeights(e),t}function tg(e,t){return{...e,...{descriptor:t}}}function oue(e){return typeof e.age=="number"}function ng(e,t){return{...e,...{age:t}}}function iue(e){return(e.gender===Ms.MALE||e.gender===Ms.FEMALE)&&zu(e.genderProbability)}function rg(e,t,n){return{...e,...{gender:t,genderProbability:n}}}function cue(e,t){function n(c,l){let u=Br(e(3*3*c),[3,3,c,1]),d=He(e(c)),p=He(e(c)),h=He(e(c)),f=He(e(c));return t.push({paramPath:`${l}/filters`},{paramPath:`${l}/batch_norm_scale`},{paramPath:`${l}/batch_norm_offset`},{paramPath:`${l}/batch_norm_mean`},{paramPath:`${l}/batch_norm_variance`}),{filters:u,batch_norm_scale:d,batch_norm_offset:p,batch_norm_mean:h,batch_norm_variance:f}}function r(c,l,u,d,p){let h=Br(e(c*l*u*u),[u,u,c,l]),f=He(e(l));return t.push({paramPath:`${d}/filters`},{paramPath:`${d}/${p?"batch_norm_offset":"bias"}`}),{filters:h,bias:f}}function s(c,l,u,d){let{filters:p,bias:h}=r(c,l,u,d,!0);return{filters:p,batch_norm_offset:h}}function a(c,l,u){let d=n(c,`${u}/depthwise_conv`),p=s(c,l,1,`${u}/pointwise_conv`);return{depthwise_conv:d,pointwise_conv:p}}function o(){let c=s(3,32,3,"mobilenetv1/conv_0"),l=a(32,64,"mobilenetv1/conv_1"),u=a(64,128,"mobilenetv1/conv_2"),d=a(128,128,"mobilenetv1/conv_3"),p=a(128,256,"mobilenetv1/conv_4"),h=a(256,256,"mobilenetv1/conv_5"),f=a(256,512,"mobilenetv1/conv_6"),m=a(512,512,"mobilenetv1/conv_7"),g=a(512,512,"mobilenetv1/conv_8"),b=a(512,512,"mobilenetv1/conv_9"),y=a(512,512,"mobilenetv1/conv_10"),v=a(512,512,"mobilenetv1/conv_11"),x=a(512,1024,"mobilenetv1/conv_12"),w=a(1024,1024,"mobilenetv1/conv_13");return{conv_0:c,conv_1:l,conv_2:u,conv_3:d,conv_4:p,conv_5:h,conv_6:f,conv_7:m,conv_8:g,conv_9:b,conv_10:y,conv_11:v,conv_12:x,conv_13:w}}function i(){let c=s(1024,256,1,"prediction_layer/conv_0"),l=s(256,512,3,"prediction_layer/conv_1"),u=s(512,128,1,"prediction_layer/conv_2"),d=s(128,256,3,"prediction_layer/conv_3"),p=s(256,128,1,"prediction_layer/conv_4"),h=s(128,256,3,"prediction_layer/conv_5"),f=s(256,64,1,"prediction_layer/conv_6"),m=s(64,128,3,"prediction_layer/conv_7"),g=r(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),b=r(512,9,1,"prediction_layer/box_predictor_0/class_predictor"),y=r(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),v=r(1024,18,1,"prediction_layer/box_predictor_1/class_predictor"),x=r(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),w=r(512,18,1,"prediction_layer/box_predictor_2/class_predictor"),T=r(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),C=r(256,18,1,"prediction_layer/box_predictor_3/class_predictor"),D=r(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),F=r(256,18,1,"prediction_layer/box_predictor_4/class_predictor"),O=r(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),$=r(128,18,1,"prediction_layer/box_predictor_5/class_predictor");return{conv_0:c,conv_1:l,conv_2:u,conv_3:d,conv_4:p,conv_5:h,conv_6:f,conv_7:m,box_predictor_0:{box_encoding_predictor:g,class_predictor:b},box_predictor_1:{box_encoding_predictor:y,class_predictor:v},box_predictor_2:{box_encoding_predictor:x,class_predictor:w},box_predictor_3:{box_encoding_predictor:T,class_predictor:C},box_predictor_4:{box_encoding_predictor:D,class_predictor:F},box_predictor_5:{box_encoding_predictor:O,class_predictor:$}}}return{extractMobilenetV1Params:o,extractPredictionLayerParams:i}}function YE(e){let t=[],{extractWeights:n,getRemainingWeights:r}=En(e),{extractMobilenetV1Params:s,extractPredictionLayerParams:a}=cue(n,t),o=s(),i=a(),l={extra_dim:zh(n(5118*4),[1,5118,4])};if(t.push({paramPath:"output_layer/extra_dim"}),r().length!==0)throw new Error(`weights remaing after extract: ${r().length}`);return{params:{mobilenetv1:o,prediction_layer:i,output_layer:l},paramMappings:t}}function uue(e,t){let n=ar(e,t);function r(l,u,d){let p=n(`${l}/Conv2d_${u}_pointwise/weights`,4,`${d}/filters`),h=n(`${l}/Conv2d_${u}_pointwise/convolution_bn_offset`,1,`${d}/batch_norm_offset`);return{filters:p,batch_norm_offset:h}}function s(l){let u=`mobilenetv1/conv_${l}`,d=`MobilenetV1/Conv2d_${l}_depthwise`,p=`${u}/depthwise_conv`,h=`${u}/pointwise_conv`,f=n(`${d}/depthwise_weights`,4,`${p}/filters`),m=n(`${d}/BatchNorm/gamma`,1,`${p}/batch_norm_scale`),g=n(`${d}/BatchNorm/beta`,1,`${p}/batch_norm_offset`),b=n(`${d}/BatchNorm/moving_mean`,1,`${p}/batch_norm_mean`),y=n(`${d}/BatchNorm/moving_variance`,1,`${p}/batch_norm_variance`);return{depthwise_conv:{filters:f,batch_norm_scale:m,batch_norm_offset:g,batch_norm_mean:b,batch_norm_variance:y},pointwise_conv:r("MobilenetV1",l,h)}}function a(){return{conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:s(1),conv_2:s(2),conv_3:s(3),conv_4:s(4),conv_5:s(5),conv_6:s(6),conv_7:s(7),conv_8:s(8),conv_9:s(9),conv_10:s(10),conv_11:s(11),conv_12:s(12),conv_13:s(13)}}function o(l,u){let d=n(`${l}/weights`,4,`${u}/filters`),p=n(`${l}/biases`,1,`${u}/bias`);return{filters:d,bias:p}}function i(l){let u=o(`Prediction/BoxPredictor_${l}/BoxEncodingPredictor`,`prediction_layer/box_predictor_${l}/box_encoding_predictor`),d=o(`Prediction/BoxPredictor_${l}/ClassPredictor`,`prediction_layer/box_predictor_${l}/class_predictor`);return{box_encoding_predictor:u,class_predictor:d}}function c(){return{conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:i(0),box_predictor_1:i(1),box_predictor_2:i(2),box_predictor_3:i(3),box_predictor_4:i(4),box_predictor_5:i(5)}}return{extractMobilenetV1Params:a,extractPredictionLayerParams:c}}function ZE(e){let t=[],{extractMobilenetV1Params:n,extractPredictionLayerParams:r}=uue(e,t),s=e["Output/extra_dim"];if(t.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!$s(s))throw new Error(`expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have ${s}`);let a={mobilenetv1:n(),prediction_layer:r(),output_layer:{extra_dim:s}};return _n(e,t),{params:a,paramMappings:t}}function Fr(e,t,n){return M(()=>{let r=Rt(e,t.filters,n,"same");return r=Y(r,t.batch_norm_offset),Jt(r,0,6)})}var lue=.0010000000474974513;function due(e,t,n){return M(()=>{let r=ua(e,t.filters,n,"same");return r=Is(r,t.batch_norm_mean,t.batch_norm_variance,t.batch_norm_offset,t.batch_norm_scale,lue),Jt(r,0,6)})}function pue(e){return[2,4,6,12].some(t=>t===e)?[2,2]:[1,1]}function JE(e,t){return M(()=>{let n,r=Fr(e,t.conv_0,[2,2]);if([t.conv_1,t.conv_2,t.conv_3,t.conv_4,t.conv_5,t.conv_6,t.conv_7,t.conv_8,t.conv_9,t.conv_10,t.conv_11,t.conv_12,t.conv_13].forEach((a,o)=>{let i=o+1,c=pue(i);r=due(r,a.depthwise_conv,c),r=Fr(r,a.pointwise_conv,[1,1]),i===11&&(n=r)}),n===null)throw new Error("mobileNetV1 - output of conv layer 11 is null");return{out:r,conv11:n}})}function hue(e,t,n){let r=e.arraySync(),s=Math.min(r[t][0],r[t][2]),a=Math.min(r[t][1],r[t][3]),o=Math.max(r[t][0],r[t][2]),i=Math.max(r[t][1],r[t][3]),c=Math.min(r[n][0],r[n][2]),l=Math.min(r[n][1],r[n][3]),u=Math.max(r[n][0],r[n][2]),d=Math.max(r[n][1],r[n][3]),p=(o-s)*(i-a),h=(u-c)*(d-l);if(p<=0||h<=0)return 0;let f=Math.max(s,c),m=Math.max(a,l),g=Math.min(o,u),b=Math.min(i,d),y=Math.max(g-f,0)*Math.max(b-m,0);return y/(p+h-y)}function QE(e,t,n,r,s){let a=e.shape[0],o=Math.min(n,a),i=t.map((u,d)=>({score:u,boxIndex:d})).filter(u=>u.score>s).sort((u,d)=>d.score-u.score),c=u=>u<=r?1:0,l=[];return i.forEach(u=>{if(l.length>=o)return;let d=u.score;for(let p=l.length-1;p>=0;--p){let h=hue(e,u.boxIndex,l[p]);if(h!==0&&(u.score*=c(h),u.score<=s))break}d===u.score&&l.push(u.boxIndex)}),l}function fue(e){let t=ht(Re(e,[1,0])),n=[fe(t[2],t[0]),fe(t[3],t[1])],r=[Y(t[0],me(n[0],2)),Y(t[1],me(n[1],2))];return{sizes:n,centers:r}}function mue(e,t){let{sizes:n,centers:r}=fue(e),s=ht(Re(t,[1,0])),a=me(V(fn(me(s[2],5)),n[0]),2),o=Y(V(me(s[0],10),n[0]),r[0]),i=me(V(fn(me(s[3],5)),n[1]),2),c=Y(V(me(s[1],10),n[1]),r[1]);return Re(Ot([fe(o,a),fe(c,i),Y(o,a),Y(c,i)]),[1,0])}function eA(e,t,n){return M(()=>{let r=e.shape[0],s=mue(U(Pn(n.extra_dim,[r,1,1]),[-1,4]),U(e,[-1,4]));s=U(s,[r,s.shape[0]/r,4]);let a=dr(ze(t,[0,0,1],[-1,-1,-1])),o=ze(a,[0,0,0],[-1,-1,1]);o=U(o,[r,o.shape[1]]);let i=ht(s),c=ht(o);return{boxes:i,scores:c}})}function Ai(e,t){return M(()=>{let n=e.shape[0],r=U(_i(e,t.box_encoding_predictor),[n,-1,1,4]),s=U(_i(e,t.class_predictor),[n,-1,3]);return{boxPredictionEncoding:r,classPrediction:s}})}function tA(e,t,n){return M(()=>{let r=Fr(e,n.conv_0,[1,1]),s=Fr(r,n.conv_1,[2,2]),a=Fr(s,n.conv_2,[1,1]),o=Fr(a,n.conv_3,[2,2]),i=Fr(o,n.conv_4,[1,1]),c=Fr(i,n.conv_5,[2,2]),l=Fr(c,n.conv_6,[1,1]),u=Fr(l,n.conv_7,[2,2]),d=Ai(t,n.box_predictor_0),p=Ai(e,n.box_predictor_1),h=Ai(s,n.box_predictor_2),f=Ai(o,n.box_predictor_3),m=Ai(c,n.box_predictor_4),g=Ai(u,n.box_predictor_5),b=et([d.boxPredictionEncoding,p.boxPredictionEncoding,h.boxPredictionEncoding,f.boxPredictionEncoding,m.boxPredictionEncoding,g.boxPredictionEncoding],1),y=et([d.classPrediction,p.classPrediction,h.classPrediction,f.classPrediction,m.classPrediction,g.classPrediction],1);return{boxPredictions:b,classPredictions:y}})}var $r=class{constructor({minConfidence:t,maxResults:n}={}){this._name="SsdMobilenetv1Options";if(this._minConfidence=t||.5,this._maxResults=n||100,typeof this._minConfidence!="number"||this._minConfidence<=0||this._minConfidence>=1)throw new Error(`${this._name} - expected minConfidence to be a number between 0 and 1`);if(typeof this._maxResults!="number")throw new Error(`${this._name} - expected maxResults to be a number`)}get minConfidence(){return this._minConfidence}get maxResults(){return this._maxResults}};var Di=class extends ln{constructor(){super("SsdMobilenetv1")}forwardInput(t){let{params:n}=this;if(!n)throw new Error("SsdMobilenetv1 - load model before inference");return M(()=>{let r=ce(t.toBatchTensor(512,!1),"float32"),s=fe(me(r,127.5),1),a=JE(s,n.mobilenetv1),{boxPredictions:o,classPredictions:i}=tA(a.out,a.conv11,n.prediction_layer);return eA(o,i,n.output_layer)})}async forward(t){return this.forwardInput(await bt(t))}async locateFaces(t,n={}){let{maxResults:r,minConfidence:s}=new $r(n),a=await bt(t),{boxes:o,scores:i}=this.forwardInput(a),c=o[0],l=i[0];for(let v=1;v{let[x,w]=[Math.max(0,b[v][0]),Math.min(1,b[v][2])].map(D=>D*g),[T,C]=[Math.max(0,b[v][1]),Math.min(1,b[v][3])].map(D=>D*m);return new xt(u[v],new Vu(T,x,C-T,w-x),{height:a.getInputHeight(0),width:a.getInputWidth(0)})});return c.dispose(),l.dispose(),y}getDefaultModelName(){return"ssd_mobilenetv1_model"}extractParamsFromWeightMap(t){return ZE(t)}extractParams(t){return YE(t)}};function nA(e){let t=new Di;return t.extractWeights(e),t}function gue(e){return nA(e)}var rA=class extends Di{};var sA=.4,aA=[new Pe(.738768,.874946),new Pe(2.42204,2.65704),new Pe(4.30971,7.04493),new Pe(10.246,4.59428),new Pe(12.6868,11.8741)],oA=[new Pe(1.603231,2.094468),new Pe(6.041143,7.080126),new Pe(2.882459,3.518061),new Pe(4.266906,5.178857),new Pe(9.041765,10.66308)],iA=[117.001,114.697,97.404],cA="tiny_yolov2_model",uA="tiny_yolov2_separable_conv_model";var sg=e=>typeof e=="number";function G1(e){if(!e)throw new Error(`invalid config: ${e}`);if(typeof e.withSeparableConvs!="boolean")throw new Error(`config.withSeparableConvs has to be a boolean, have: ${e.withSeparableConvs}`);if(!sg(e.iouThreshold)||e.iouThreshold<0||e.iouThreshold>1)throw new Error(`config.iouThreshold has to be a number between [0, 1], have: ${e.iouThreshold}`);if(!Array.isArray(e.classes)||!e.classes.length||!e.classes.every(t=>typeof t=="string"))throw new Error(`config.classes has to be an array class names: string[], have: ${JSON.stringify(e.classes)}`);if(!Array.isArray(e.anchors)||!e.anchors.length||!e.anchors.map(t=>t||{}).every(t=>sg(t.x)&&sg(t.y)))throw new Error(`config.anchors has to be an array of { x: number, y: number }, have: ${JSON.stringify(e.anchors)}`);if(e.meanRgb&&(!Array.isArray(e.meanRgb)||e.meanRgb.length!==3||!e.meanRgb.every(sg)))throw new Error(`config.meanRgb has to be an array of shape [number, number, number], have: ${JSON.stringify(e.meanRgb)}`)}function Ju(e){return M(()=>{let t=V(e,Ie(.10000000149011612));return Y(qe(fe(e,t)),t)})}function Ls(e,t){return M(()=>{let n=pr(e,[[0,0],[1,1],[1,1],[0,0]]);return n=Rt(n,t.conv.filters,[1,1],"valid"),n=fe(n,t.bn.sub),n=V(n,t.bn.truediv),n=Y(n,t.conv.bias),Ju(n)})}function Bs(e,t){return M(()=>{let n=pr(e,[[0,0],[1,1],[1,1],[0,0]]);return n=ei(n,t.depthwise_filter,t.pointwise_filter,[1,1],"valid"),n=Y(n,t.bias),Ju(n)})}function bue(e,t){let n=ju(e,t);function r(o,i){let c=He(e(o)),l=He(e(o));return t.push({paramPath:`${i}/sub`},{paramPath:`${i}/truediv`}),{sub:c,truediv:l}}function s(o,i,c){let l=n(o,i,3,`${c}/conv`),u=r(i,`${c}/bn`);return{conv:l,bn:u}}let a=qu(e,t);return{extractConvParams:n,extractConvWithBatchNormParams:s,extractSeparableConvParams:a}}function lA(e,t,n,r){let{extractWeights:s,getRemainingWeights:a}=En(e),o=[],{extractConvParams:i,extractConvWithBatchNormParams:c,extractSeparableConvParams:l}=bue(s,o),u;if(t.withSeparableConvs){let[d,p,h,f,m,g,b,y,v]=r,x=t.isFirstLayerConv2d?i(d,p,3,"conv0"):l(d,p,"conv0"),w=l(p,h,"conv1"),T=l(h,f,"conv2"),C=l(f,m,"conv3"),D=l(m,g,"conv4"),F=l(g,b,"conv5"),O=y?l(b,y,"conv6"):void 0,$=v?l(y,v,"conv7"):void 0,R=i(v||y||b,5*n,1,"conv8");u={conv0:x,conv1:w,conv2:T,conv3:C,conv4:D,conv5:F,conv6:O,conv7:$,conv8:R}}else{let[d,p,h,f,m,g,b,y,v]=r,x=c(d,p,"conv0"),w=c(p,h,"conv1"),T=c(h,f,"conv2"),C=c(f,m,"conv3"),D=c(m,g,"conv4"),F=c(g,b,"conv5"),O=c(b,y,"conv6"),$=c(y,v,"conv7"),R=i(v,5*n,1,"conv8");u={conv0:x,conv1:w,conv2:T,conv3:C,conv4:D,conv5:F,conv6:O,conv7:$,conv8:R}}if(a().length!==0)throw new Error(`weights remaing after extract: ${a().length}`);return{params:u,paramMappings:o}}function yue(e,t){let n=ar(e,t);function r(i){let c=n(`${i}/sub`,1),l=n(`${i}/truediv`,1);return{sub:c,truediv:l}}function s(i){let c=n(`${i}/filters`,4),l=n(`${i}/bias`,1);return{filters:c,bias:l}}function a(i){let c=s(`${i}/conv`),l=r(`${i}/bn`);return{conv:c,bn:l}}let o=Ku(n);return{extractConvParams:s,extractConvWithBatchNormParams:a,extractSeparableConvParams:o}}function dA(e,t){let n=[],{extractConvParams:r,extractConvWithBatchNormParams:s,extractSeparableConvParams:a}=yue(e,n),o;if(t.withSeparableConvs){let i=t.filterSizes&&t.filterSizes.length||9;o={conv0:t.isFirstLayerConv2d?r("conv0"):a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:i>7?a("conv6"):void 0,conv7:i>8?a("conv7"):void 0,conv8:r("conv8")}}else o={conv0:s("conv0"),conv1:s("conv1"),conv2:s("conv2"),conv3:s("conv3"),conv4:s("conv4"),conv5:s("conv5"),conv6:s("conv6"),conv7:s("conv7"),conv8:r("conv8")};return _n(e,n),{params:o,paramMappings:n}}var ms=class{constructor({inputSize:t,scoreThreshold:n}={}){this._name="TinyYolov2Options";if(this._inputSize=t||416,this._scoreThreshold=n||.5,typeof this._inputSize!="number"||this._inputSize%32!=0)throw new Error(`${this._name} - expected inputSize to be a number divisible by 32`);if(typeof this._scoreThreshold!="number"||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(`${this._name} - expected scoreThreshold to be a number between 0 and 1`)}get inputSize(){return this._inputSize}get scoreThreshold(){return this._scoreThreshold}};var H1=class extends ln{constructor(t){super("TinyYolov2");G1(t),this._config=t}get config(){return this._config}get withClassScores(){return this.config.withClassScores||this.config.classes.length>1}get boxEncodingSize(){return 5+(this.withClassScores?this.config.classes.length:0)}runTinyYolov2(t,n){let r=Ls(t,n.conv0);return r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv1),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv2),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv3),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv4),r=Pt(r,[2,2],[2,2],"same"),r=Ls(r,n.conv5),r=Pt(r,[2,2],[1,1],"same"),r=Ls(r,n.conv6),r=Ls(r,n.conv7),_i(r,n.conv8,"valid",!1)}runMobilenet(t,n){let r=this.config.isFirstLayerConv2d?Ju(_i(t,n.conv0,"valid",!1)):Bs(t,n.conv0);return r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv1),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv2),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv3),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv4),r=Pt(r,[2,2],[2,2],"same"),r=Bs(r,n.conv5),r=Pt(r,[2,2],[1,1],"same"),r=n.conv6?Bs(r,n.conv6):r,r=n.conv7?Bs(r,n.conv7):r,_i(r,n.conv8,"valid",!1)}forwardInput(t,n){let{params:r}=this;if(!r)throw new Error("TinyYolov2 - load model before inference");return M(()=>{let s=ce(t.toBatchTensor(n,!1),"float32");return s=this.config.meanRgb?Xr(s,this.config.meanRgb):s,s=s.div(255),this.config.withSeparableConvs?this.runMobilenet(s,r):this.runTinyYolov2(s,r)})}async forward(t,n){return this.forwardInput(await bt(t),n)}async detect(t,n={}){let{inputSize:r,scoreThreshold:s}=new ms(n),a=await bt(t),o=await this.forwardInput(a,r),i=M(()=>ht(o)[0].expandDims()),c={width:a.getInputWidth(0),height:a.getInputHeight(0)},l=await this.extractBoxes(i,a.getReshapedInputDimensions(0),s);o.dispose(),i.dispose();let u=l.map(g=>g.box),d=l.map(g=>g.score),p=l.map(g=>g.classScore),h=l.map(g=>this.config.classes[g.label]);return x1(u.map(g=>g.rescale(r)),d,this.config.iouThreshold,!0).map(g=>new Na(d[g],p[g],h[g],u[g],c))}getDefaultModelName(){return""}extractParamsFromWeightMap(t){return dA(t,this.config)}extractParams(t){let n=this.config.filterSizes||H1.DEFAULT_FILTER_SIZES,r=n?n.length:void 0;if(r!==7&&r!==8&&r!==9)throw new Error(`TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found ${r} filterSizes in config`);return lA(t,this.config,this.boxEncodingSize,n)}async extractBoxes(t,n,r){let{width:s,height:a}=n,o=Math.max(s,a),i=o/s,c=o/a,l=t.shape[1],u=this.config.anchors.length,[d,p,h]=M(()=>{let b=t.reshape([l,l,u,this.boxEncodingSize]),y=b.slice([0,0,0,0],[l,l,u,4]),v=b.slice([0,0,0,4],[l,l,u,1]),x=this.withClassScores?Mr(b.slice([0,0,0,5],[l,l,u,this.config.classes.length]),3):Ie(0);return[y,v,x]}),f=[],m=await p.array(),g=await d.array();for(let b=0;br){let w=(y+tp(g[b][y][v][0]))/l*i,T=(b+tp(g[b][y][v][1]))/l*c,C=Math.exp(g[b][y][v][2])*this.config.anchors[v].x/l*i,D=Math.exp(g[b][y][v][3])*this.config.anchors[v].y/l*c,F=w-C/2,O=T-D/2,$={row:b,col:y,anchor:v},{classScore:R,label:N}=this.withClassScores?await this.extractPredictedClass(h,$):{classScore:1,label:0};f.push({box:new Wu(F,O,F+C,O+D),score:x,classScore:x*R,label:N,...$})}}return d.dispose(),p.dispose(),h.dispose(),f}async extractPredictedClass(t,n){let{row:r,col:s,anchor:a}=n,o=await t.array();return Array(this.config.classes.length).fill(0).map((i,c)=>o[r][s][a][c]).map((i,c)=>({classScore:i,label:c})).reduce((i,c)=>i.classScore>c.classScore?i:c)}},Qu=H1;Qu.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024];var el=class extends Qu{constructor(t=!0){let n={withSeparableConvs:t,iouThreshold:sA,classes:["face"],...t?{anchors:oA,meanRgb:iA}:{anchors:aA,withClassScores:!0}};super(n)}get withSeparableConvs(){return this.config.withSeparableConvs}get anchors(){return this.config.anchors}async locateFaces(t,n){return(await this.detect(t,n)).map(s=>new xt(s.score,s.relativeBox,{width:s.imageWidth,height:s.imageHeight}))}getDefaultModelName(){return this.withSeparableConvs?uA:cA}extractParamsFromWeightMap(t){return super.extractParamsFromWeightMap(t)}};function vue(e,t=!0){let n=new el(t);return n.extractWeights(e),n}var ag=class extends ms{constructor(){super(...arguments);this._name="TinyFaceDetectorOptions"}};var Rr=class{async then(t){return t(await this.run())}async run(){throw new Error("ComposableTask - run is not implemented")}};async function Fi(e,t,n,r,s=({alignedRect:a})=>a){let a=e.map(c=>Ei(c)?s(c):c.detection),o=r||(t instanceof Ee?await Hu(t,a):await Gu(t,a)),i=await n(o);return o.forEach(c=>c instanceof Ee&&c.dispose()),i}async function tl(e,t,n,r,s){return Fi([e],t,async a=>n(a[0]),r,s)}var pA=.4,hA=[new Pe(1.603231,2.094468),new Pe(6.041143,7.080126),new Pe(2.882459,3.518061),new Pe(4.266906,5.178857),new Pe(9.041765,10.66308)],fA=[117.001,114.697,97.404];var nl=class extends Qu{constructor(){let t={withSeparableConvs:!0,iouThreshold:pA,classes:["face"],anchors:hA,meanRgb:fA,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};super(t)}get anchors(){return this.config.anchors}async locateFaces(t,n){return(await this.detect(t,n)).map(s=>new xt(s.score,s.relativeBox,{width:s.imageWidth,height:s.imageHeight}))}getDefaultModelName(){return"tiny_face_detector_model"}extractParamsFromWeightMap(t){return super.extractParamsFromWeightMap(t)}};var nt={ssdMobilenetv1:new Di,tinyFaceDetector:new nl,tinyYolov2:new el,faceLandmark68Net:new Yu,faceLandmark68TinyNet:new Qm,faceRecognitionNet:new Zu,faceExpressionNet:new Ym,ageGenderNet:new Jm},mA=(e,t)=>nt.ssdMobilenetv1.locateFaces(e,t),xue=(e,t)=>nt.tinyFaceDetector.locateFaces(e,t),wue=(e,t)=>nt.tinyYolov2.locateFaces(e,t),gA=e=>nt.faceLandmark68Net.detectLandmarks(e),kue=e=>nt.faceLandmark68TinyNet.detectLandmarks(e),Iue=e=>nt.faceRecognitionNet.computeFaceDescriptor(e),Sue=e=>nt.faceExpressionNet.predictExpressions(e),Tue=e=>nt.ageGenderNet.predictAgeAndGender(e),bA=e=>nt.ssdMobilenetv1.load(e),Cue=e=>nt.tinyFaceDetector.load(e),Nue=e=>nt.tinyYolov2.load(e),_ue=e=>nt.faceLandmark68Net.load(e),Eue=e=>nt.faceLandmark68TinyNet.load(e),Aue=e=>nt.faceRecognitionNet.load(e),Due=e=>nt.faceExpressionNet.load(e),Fue=e=>nt.ageGenderNet.load(e),$ue=bA,Rue=mA,Pue=gA;var j1=class extends Rr{constructor(t,n,r){super();this.parentTask=t;this.input=n;this.extractedFaces=r}},rl=class extends j1{async run(){let t=await this.parentTask,n=await Fi(t,this.input,async r=>Promise.all(r.map(s=>nt.faceExpressionNet.predictExpressions(s))),this.extractedFaces);return t.map((r,s)=>Zm(r,n[s]))}withAgeAndGender(){return new al(this,this.input)}},sl=class extends j1{async run(){let t=await this.parentTask;if(!t)return;let n=await tl(t,this.input,r=>nt.faceExpressionNet.predictExpressions(r),this.extractedFaces);return Zm(t,n)}withAgeAndGender(){return new ol(this,this.input)}},$i=class extends rl{withAgeAndGender(){return new Pi(this,this.input)}withFaceDescriptors(){return new Aa(this,this.input)}},Ri=class extends sl{withAgeAndGender(){return new Oi(this,this.input)}withFaceDescriptor(){return new Da(this,this.input)}};var q1=class extends Rr{constructor(t,n,r){super();this.parentTask=t;this.input=n;this.extractedFaces=r}},al=class extends q1{async run(){let t=await this.parentTask,n=await Fi(t,this.input,async r=>Promise.all(r.map(s=>nt.ageGenderNet.predictAgeAndGender(s))),this.extractedFaces);return t.map((r,s)=>{let{age:a,gender:o,genderProbability:i}=n[s];return ng(rg(r,o,i),a)})}withFaceExpressions(){return new rl(this,this.input)}},ol=class extends q1{async run(){let t=await this.parentTask;if(!t)return;let{age:n,gender:r,genderProbability:s}=await tl(t,this.input,a=>nt.ageGenderNet.predictAgeAndGender(a),this.extractedFaces);return ng(rg(t,r,s),n)}withFaceExpressions(){return new sl(this,this.input)}},Pi=class extends al{withFaceExpressions(){return new $i(this,this.input)}withFaceDescriptors(){return new Aa(this,this.input)}},Oi=class extends ol{withFaceExpressions(){return new Ri(this,this.input)}withFaceDescriptor(){return new Da(this,this.input)}};var og=class extends Rr{constructor(t,n){super();this.parentTask=t;this.input=n}},Aa=class extends og{async run(){let t=await this.parentTask;return(await Fi(t,this.input,r=>Promise.all(r.map(s=>nt.faceRecognitionNet.computeFaceDescriptor(s))),null,r=>r.landmarks.align(null,{useDlibAlignment:!0}))).map((r,s)=>tg(t[s],r))}withFaceExpressions(){return new $i(this,this.input)}withAgeAndGender(){return new Pi(this,this.input)}},Da=class extends og{async run(){let t=await this.parentTask;if(!t)return;let n=await tl(t,this.input,r=>nt.faceRecognitionNet.computeFaceDescriptor(r),null,r=>r.landmarks.align(null,{useDlibAlignment:!0}));return tg(t,n)}withFaceExpressions(){return new Ri(this,this.input)}withAgeAndGender(){return new Oi(this,this.input)}};var ig=class extends Rr{constructor(t,n,r){super();this.parentTask=t;this.input=n;this.useTinyLandmarkNet=r}get landmarkNet(){return this.useTinyLandmarkNet?nt.faceLandmark68TinyNet:nt.faceLandmark68Net}},cg=class extends ig{async run(){let t=await this.parentTask,n=t.map(a=>a.detection),r=this.input instanceof Ee?await Hu(this.input,n):await Gu(this.input,n),s=await Promise.all(r.map(a=>this.landmarkNet.detectLandmarks(a)));return r.forEach(a=>a instanceof Ee&&a.dispose()),t.map((a,o)=>Xu(a,s[o]))}withFaceExpressions(){return new $i(this,this.input)}withAgeAndGender(){return new Pi(this,this.input)}withFaceDescriptors(){return new Aa(this,this.input)}},ug=class extends ig{async run(){let t=await this.parentTask;if(!t)return;let{detection:n}=t,r=this.input instanceof Ee?await Hu(this.input,[n]):await Gu(this.input,[n]),s=await this.landmarkNet.detectLandmarks(r[0]);return r.forEach(a=>a instanceof Ee&&a.dispose()),Xu(t,s)}withFaceExpressions(){return new Ri(this,this.input)}withAgeAndGender(){return new Oi(this,this.input)}withFaceDescriptor(){return new Da(this,this.input)}};var lg=class extends Rr{constructor(t,n=new $r){super();this.input=t;this.options=n}},fp=class extends lg{async run(){let{input:t,options:n}=this,r;if(n instanceof ag)r=nt.tinyFaceDetector.locateFaces(t,n);else if(n instanceof $r)r=nt.ssdMobilenetv1.locateFaces(t,n);else if(n instanceof ms)r=nt.tinyYolov2.locateFaces(t,n);else throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | TinyYolov2Options");return r}runAndExtendWithFaceDetections(){return new Promise((t,n)=>{this.run().then(r=>t(r.map(s=>Si({},s)))).catch(r=>n(r))})}withFaceLandmarks(t=!1){return new cg(this.runAndExtendWithFaceDetections(),this.input,t)}withFaceExpressions(){return new rl(this.runAndExtendWithFaceDetections(),this.input)}withAgeAndGender(){return new al(this.runAndExtendWithFaceDetections(),this.input)}},dg=class extends lg{async run(){let t=await new fp(this.input,this.options),n=t[0];return t.forEach(r=>{r.score>n.score&&(n=r)}),n}runAndExtendWithFaceDetection(){return new Promise(async t=>{let n=await this.run();t(n?Si({},n):void 0)})}withFaceLandmarks(t=!1){return new ug(this.runAndExtendWithFaceDetection(),this.input,t)}withFaceExpressions(){return new sl(this.runAndExtendWithFaceDetection(),this.input)}withAgeAndGender(){return new ol(this.runAndExtendWithFaceDetection(),this.input)}};function Oue(e,t=new $r){return new dg(e,t)}function pg(e,t=new $r){return new fp(e,t)}async function yA(e,t){return pg(e,new $r(t?{minConfidence:t}:{})).withFaceLandmarks().withFaceDescriptors()}async function Mue(e,t={}){return pg(e,new ms(t)).withFaceLandmarks().withFaceDescriptors()}var Lue=yA;function K1(e,t){if(e.length!==t.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");let n=Array.from(e),r=Array.from(t);return Math.sqrt(n.map((s,a)=>s-r[a]).reduce((s,a)=>s+a**2,0))}var hg=class{constructor(t,n=.6){this._distanceThreshold=n;let r=Array.isArray(t)?t:[t];if(!r.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");let s=1,a=()=>`person ${s++}`;this._labeledDescriptors=r.map(o=>{if(o instanceof Rs)return o;if(o instanceof Float32Array)return new Rs(a(),[o]);if(o.descriptor&&o.descriptor instanceof Float32Array)return new Rs(a(),[o.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor | Float32Array | Array | Float32Array>")})}get labeledDescriptors(){return this._labeledDescriptors}get distanceThreshold(){return this._distanceThreshold}computeMeanDistance(t,n){return n.map(r=>K1(r,t)).reduce((r,s)=>r+s,0)/(n.length||1)}matchDescriptor(t){return this.labeledDescriptors.map(({descriptors:n,label:r})=>new np(r,this.computeMeanDistance(t,n))).reduce((n,r)=>n.distancet.toJSON())}}static fromJSON(t){let n=t.labeledDescriptors.map(r=>Rs.fromJSON(r));return new hg(n,t.distanceThreshold)}};function Bue(e){let t=new nl;return t.extractWeights(e),t}function vA(e,t){let{width:n,height:r}=new Nn(t.width,t.height);if(n<=0||r<=0)throw new Error(`resizeResults - invalid dimensions: ${JSON.stringify({width:n,height:r})}`);if(Array.isArray(e))return e.map(s=>vA(s,{width:n,height:r}));if(Ei(e)){let s=e.detection.forSize(n,r),a=e.unshiftedLandmarks.forSize(s.box.width,s.box.height);return Xu(Si(e,s),a)}return hs(e)?Si(e,e.detection.forSize(n,r)):e instanceof yr||e instanceof xt?e.forSize(n,r):e}var zue=ME;return Wue;})(); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. diff --git a/dist/face-api.node-gpu.js b/dist/face-api.node-gpu.js index 405a82a..77e8375 100644 --- a/dist/face-api.node-gpu.js +++ b/dist/face-api.node-gpu.js @@ -2290,7 +2290,7 @@ function drawFaceLandmarks(canvasArg, faceLandmarks) { } // package.json -var version = "1.6.1"; +var version = "1.6.2"; // src/ageGenderNet/AgeGenderNet.ts var tf20 = __toModule(require_tfjs_esm()); diff --git a/dist/face-api.node.js b/dist/face-api.node.js index 8e4fd85..af42017 100644 --- a/dist/face-api.node.js +++ b/dist/face-api.node.js @@ -2290,7 +2290,7 @@ function drawFaceLandmarks(canvasArg, faceLandmarks) { } // package.json -var version = "1.6.1"; +var version = "1.6.2"; // src/ageGenderNet/AgeGenderNet.ts var tf20 = __toModule(require_tfjs_esm()); diff --git a/typedoc/classes/AgeGenderNet.html b/typedoc/classes/AgeGenderNet.html index e4955d9..05526f6 100644 --- a/typedoc/classes/AgeGenderNet.html +++ b/typedoc/classes/AgeGenderNet.html @@ -1 +1 @@ -AgeGenderNet | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new AgeGenderNet(faceFeatureExtractor?: TinyXception): AgeGenderNet

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): TinyXception

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }

extractWeights

  • extractWeights(weights: Float32Array): void

forward

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void

predictAgeAndGender

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void

runNet

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +AgeGenderNet | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new AgeGenderNet(faceFeatureExtractor?: TinyXception): AgeGenderNet

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): TinyXception

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }

extractWeights

  • extractWeights(weights: Float32Array): void

forward

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void

predictAgeAndGender

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void

runNet

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/BoundingBox.html b/typedoc/classes/BoundingBox.html index da02fbf..e1f7bd9 100644 --- a/typedoc/classes/BoundingBox.html +++ b/typedoc/classes/BoundingBox.html @@ -1 +1 @@ -BoundingBox | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

  • new BoundingBox(left: number, top: number, right: number, bottom: number, allowNegativeDimensions?: boolean): BoundingBox

Accessors

area

  • get area(): number

bottom

  • get bottom(): number

bottomLeft

bottomRight

height

  • get height(): number

left

  • get left(): number

right

  • get right(): number

top

  • get top(): number

topLeft

topRight

width

  • get width(): number

x

  • get x(): number

y

  • get y(): number

Methods

calibrate

  • calibrate(region: Box<any>): Box<any>

clipAtImageBorders

  • clipAtImageBorders(imgWidth: number, imgHeight: number): Box<any>

floor

  • floor(): Box<any>

pad

  • pad(padX: number, padY: number): Box<any>

padAtBorders

  • padAtBorders(imageHeight: number, imageWidth: number): { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }
  • Parameters

    • imageHeight: number
    • imageWidth: number

    Returns { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }

    • dx: number
    • dy: number
    • edx: number
    • edy: number
    • ex: number
    • ey: number
    • h: number
    • w: number
    • x: number
    • y: number

rescale

round

  • round(): Box<any>

shift

  • shift(sx: number, sy: number): Box<any>

toSquare

  • toSquare(): Box<any>

Static assertIsValidBox

  • assertIsValidBox(box: any, callee: string, allowNegativeDimensions?: boolean): void

Static isRect

  • isRect(rect: any): boolean

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +BoundingBox | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

  • new BoundingBox(left: number, top: number, right: number, bottom: number, allowNegativeDimensions?: boolean): BoundingBox

Accessors

area

  • get area(): number

bottom

  • get bottom(): number

bottomLeft

bottomRight

height

  • get height(): number

left

  • get left(): number

right

  • get right(): number

top

  • get top(): number

topLeft

topRight

width

  • get width(): number

x

  • get x(): number

y

  • get y(): number

Methods

calibrate

  • calibrate(region: Box<any>): Box<any>

clipAtImageBorders

  • clipAtImageBorders(imgWidth: number, imgHeight: number): Box<any>

floor

  • floor(): Box<any>

pad

  • pad(padX: number, padY: number): Box<any>

padAtBorders

  • padAtBorders(imageHeight: number, imageWidth: number): { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }
  • Parameters

    • imageHeight: number
    • imageWidth: number

    Returns { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }

    • dx: number
    • dy: number
    • edx: number
    • edy: number
    • ex: number
    • ey: number
    • h: number
    • w: number
    • x: number
    • y: number

rescale

round

  • round(): Box<any>

shift

  • shift(sx: number, sy: number): Box<any>

toSquare

  • toSquare(): Box<any>

Static assertIsValidBox

  • assertIsValidBox(box: any, callee: string, allowNegativeDimensions?: boolean): void

Static isRect

  • isRect(rect: any): boolean

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/Box.html b/typedoc/classes/Box.html index 3cbaa47..521ee53 100644 --- a/typedoc/classes/Box.html +++ b/typedoc/classes/Box.html @@ -1 +1 @@ -Box | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • BoxType = any

Hierarchy

Implements

Index

Constructors

constructor

Accessors

area

  • get area(): number

bottom

  • get bottom(): number

bottomLeft

bottomRight

height

  • get height(): number

left

  • get left(): number

right

  • get right(): number

top

  • get top(): number

topLeft

topRight

width

  • get width(): number

x

  • get x(): number

y

  • get y(): number

Methods

calibrate

  • calibrate(region: Box<any>): Box<any>

clipAtImageBorders

  • clipAtImageBorders(imgWidth: number, imgHeight: number): Box<BoxType>

floor

  • floor(): Box<BoxType>

pad

  • pad(padX: number, padY: number): Box<BoxType>

padAtBorders

  • padAtBorders(imageHeight: number, imageWidth: number): { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }
  • Parameters

    • imageHeight: number
    • imageWidth: number

    Returns { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }

    • dx: number
    • dy: number
    • edx: number
    • edy: number
    • ex: number
    • ey: number
    • h: number
    • w: number
    • x: number
    • y: number

rescale

round

  • round(): Box<BoxType>

shift

  • shift(sx: number, sy: number): Box<BoxType>

toSquare

  • toSquare(): Box<BoxType>

Static assertIsValidBox

  • assertIsValidBox(box: any, callee: string, allowNegativeDimensions?: boolean): void
  • Parameters

    • box: any
    • callee: string
    • allowNegativeDimensions: boolean = false

    Returns void

Static isRect

  • isRect(rect: any): boolean

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +Box | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • BoxType = any

Hierarchy

Implements

Index

Constructors

constructor

Accessors

area

  • get area(): number

bottom

  • get bottom(): number

bottomLeft

bottomRight

height

  • get height(): number

left

  • get left(): number

right

  • get right(): number

top

  • get top(): number

topLeft

topRight

width

  • get width(): number

x

  • get x(): number

y

  • get y(): number

Methods

calibrate

  • calibrate(region: Box<any>): Box<any>

clipAtImageBorders

  • clipAtImageBorders(imgWidth: number, imgHeight: number): Box<BoxType>

floor

  • floor(): Box<BoxType>

pad

  • pad(padX: number, padY: number): Box<BoxType>

padAtBorders

  • padAtBorders(imageHeight: number, imageWidth: number): { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }
  • Parameters

    • imageHeight: number
    • imageWidth: number

    Returns { dx: number; dy: number; edx: number; edy: number; ex: number; ey: number; h: number; w: number; x: number; y: number }

    • dx: number
    • dy: number
    • edx: number
    • edy: number
    • ex: number
    • ey: number
    • h: number
    • w: number
    • x: number
    • y: number

rescale

round

  • round(): Box<BoxType>

shift

  • shift(sx: number, sy: number): Box<BoxType>

toSquare

  • toSquare(): Box<BoxType>

Static assertIsValidBox

  • assertIsValidBox(box: any, callee: string, allowNegativeDimensions?: boolean): void
  • Parameters

    • box: any
    • callee: string
    • allowNegativeDimensions: boolean = false

    Returns void

Static isRect

  • isRect(rect: any): boolean

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/ComposableTask.html b/typedoc/classes/ComposableTask.html index 1d82a30..86cb2da 100644 --- a/typedoc/classes/ComposableTask.html +++ b/typedoc/classes/ComposableTask.html @@ -1 +1 @@ -ComposableTask | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • T

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

run

  • run(): Promise<T>

then

  • then(onfulfilled: (value: T) => T | PromiseLike<T>): Promise<T>
  • Parameters

    • onfulfilled: (value: T) => T | PromiseLike<T>
        • (value: T): T | PromiseLike<T>
        • Parameters

          • value: T

          Returns T | PromiseLike<T>

    Returns Promise<T>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +ComposableTask | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • T

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

run

  • run(): Promise<T>

then

  • then(onfulfilled: (value: T) => T | PromiseLike<T>): Promise<T>
  • Parameters

    • onfulfilled: (value: T) => T | PromiseLike<T>
        • (value: T): T | PromiseLike<T>
        • Parameters

          • value: T

          Returns T | PromiseLike<T>

    Returns Promise<T>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/ComputeAllFaceDescriptorsTask.html b/typedoc/classes/ComputeAllFaceDescriptorsTask.html index fb38421..50d99d4 100644 --- a/typedoc/classes/ComputeAllFaceDescriptorsTask.html +++ b/typedoc/classes/ComputeAllFaceDescriptorsTask.html @@ -1 +1 @@ -ComputeAllFaceDescriptorsTask | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComputeAllFaceDescriptorsTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictAllAgeAndGenderWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

withFaceExpressions

  • withFaceExpressions(): PredictAllFaceExpressionsWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +ComputeAllFaceDescriptorsTask | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComputeAllFaceDescriptorsTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictAllAgeAndGenderWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

withFaceExpressions

  • withFaceExpressions(): PredictAllFaceExpressionsWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/ComputeFaceDescriptorsTaskBase.html b/typedoc/classes/ComputeFaceDescriptorsTaskBase.html index b604efb..e02a67b 100644 --- a/typedoc/classes/ComputeFaceDescriptorsTaskBase.html +++ b/typedoc/classes/ComputeFaceDescriptorsTaskBase.html @@ -1 +1 @@ -ComputeFaceDescriptorsTaskBase | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComputeFaceDescriptorsTaskBase<TReturn, TParentReturn>

Type parameters

  • TReturn

  • TParentReturn

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

run

  • run(): Promise<TReturn>

then

  • then(onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>): Promise<TReturn>
  • Parameters

    • onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>
        • (value: TReturn): TReturn | PromiseLike<TReturn>
        • Parameters

          • value: TReturn

          Returns TReturn | PromiseLike<TReturn>

    Returns Promise<TReturn>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +ComputeFaceDescriptorsTaskBase | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComputeFaceDescriptorsTaskBase<TReturn, TParentReturn>

Type parameters

  • TReturn

  • TParentReturn

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

run

  • run(): Promise<TReturn>

then

  • then(onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>): Promise<TReturn>
  • Parameters

    • onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>
        • (value: TReturn): TReturn | PromiseLike<TReturn>
        • Parameters

          • value: TReturn

          Returns TReturn | PromiseLike<TReturn>

    Returns Promise<TReturn>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/ComputeSingleFaceDescriptorTask.html b/typedoc/classes/ComputeSingleFaceDescriptorTask.html index a569075..4e35f5a 100644 --- a/typedoc/classes/ComputeSingleFaceDescriptorTask.html +++ b/typedoc/classes/ComputeSingleFaceDescriptorTask.html @@ -1 +1 @@ -ComputeSingleFaceDescriptorTask | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComputeSingleFaceDescriptorTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictSingleAgeAndGenderWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

withFaceExpressions

  • withFaceExpressions(): PredictSingleFaceExpressionsWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +ComputeSingleFaceDescriptorTask | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ComputeSingleFaceDescriptorTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictSingleAgeAndGenderWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

withFaceExpressions

  • withFaceExpressions(): PredictSingleFaceExpressionsWithFaceAlignmentTask<WithFaceDescriptor<TSource>>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/DetectAllFaceLandmarksTask.html b/typedoc/classes/DetectAllFaceLandmarksTask.html index d16a3be..8607cfc 100644 --- a/typedoc/classes/DetectAllFaceLandmarksTask.html +++ b/typedoc/classes/DetectAllFaceLandmarksTask.html @@ -1 +1 @@ -DetectAllFaceLandmarksTask | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectAllFaceLandmarksTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

withFaceDescriptors

withFaceExpressions

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +DetectAllFaceLandmarksTask | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectAllFaceLandmarksTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

withFaceDescriptors

withFaceExpressions

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/DetectAllFacesTask.html b/typedoc/classes/DetectAllFacesTask.html index 5f4c003..6aa8aa0 100644 --- a/typedoc/classes/DetectAllFacesTask.html +++ b/typedoc/classes/DetectAllFacesTask.html @@ -1 +1 @@ -DetectAllFacesTask | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictAllAgeAndGenderTask<{ detection: FaceDetection }>

withFaceExpressions

  • withFaceExpressions(): PredictAllFaceExpressionsTask<{ detection: FaceDetection }>

withFaceLandmarks

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +DetectAllFacesTask | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictAllAgeAndGenderTask<{ detection: FaceDetection }>

withFaceExpressions

  • withFaceExpressions(): PredictAllFaceExpressionsTask<{ detection: FaceDetection }>

withFaceLandmarks

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/DetectFaceLandmarksTaskBase.html b/typedoc/classes/DetectFaceLandmarksTaskBase.html index f19ae9f..e120de0 100644 --- a/typedoc/classes/DetectFaceLandmarksTaskBase.html +++ b/typedoc/classes/DetectFaceLandmarksTaskBase.html @@ -1 +1 @@ -DetectFaceLandmarksTaskBase | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectFaceLandmarksTaskBase<TReturn, TParentReturn>

Type parameters

  • TReturn

  • TParentReturn

Hierarchy

Index

Constructors

Methods

Constructors

constructor

  • new DetectFaceLandmarksTaskBase<TReturn, TParentReturn>(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: any, useTinyLandmarkNet: boolean): DetectFaceLandmarksTaskBase<TReturn, TParentReturn>

Methods

run

  • run(): Promise<TReturn>

then

  • then(onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>): Promise<TReturn>
  • Parameters

    • onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>
        • (value: TReturn): TReturn | PromiseLike<TReturn>
        • Parameters

          • value: TReturn

          Returns TReturn | PromiseLike<TReturn>

    Returns Promise<TReturn>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +DetectFaceLandmarksTaskBase | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectFaceLandmarksTaskBase<TReturn, TParentReturn>

Type parameters

  • TReturn

  • TParentReturn

Hierarchy

Index

Constructors

Methods

Constructors

constructor

  • new DetectFaceLandmarksTaskBase<TReturn, TParentReturn>(parentTask: ComposableTask<TParentReturn> | Promise<TParentReturn>, input: any, useTinyLandmarkNet: boolean): DetectFaceLandmarksTaskBase<TReturn, TParentReturn>

Methods

run

  • run(): Promise<TReturn>

then

  • then(onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>): Promise<TReturn>
  • Parameters

    • onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>
        • (value: TReturn): TReturn | PromiseLike<TReturn>
        • Parameters

          • value: TReturn

          Returns TReturn | PromiseLike<TReturn>

    Returns Promise<TReturn>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/DetectFacesTaskBase.html b/typedoc/classes/DetectFacesTaskBase.html index 8225617..6a591d5 100644 --- a/typedoc/classes/DetectFacesTaskBase.html +++ b/typedoc/classes/DetectFacesTaskBase.html @@ -1 +1 @@ -DetectFacesTaskBase | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectFacesTaskBase<TReturn>

Type parameters

  • TReturn

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

run

  • run(): Promise<TReturn>

then

  • then(onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>): Promise<TReturn>
  • Parameters

    • onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>
        • (value: TReturn): TReturn | PromiseLike<TReturn>
        • Parameters

          • value: TReturn

          Returns TReturn | PromiseLike<TReturn>

    Returns Promise<TReturn>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +DetectFacesTaskBase | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectFacesTaskBase<TReturn>

Type parameters

  • TReturn

Hierarchy

Index

Constructors

Methods

Constructors

constructor

Methods

run

  • run(): Promise<TReturn>

then

  • then(onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>): Promise<TReturn>
  • Parameters

    • onfulfilled: (value: TReturn) => TReturn | PromiseLike<TReturn>
        • (value: TReturn): TReturn | PromiseLike<TReturn>
        • Parameters

          • value: TReturn

          Returns TReturn | PromiseLike<TReturn>

    Returns Promise<TReturn>

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/DetectSingleFaceLandmarksTask.html b/typedoc/classes/DetectSingleFaceLandmarksTask.html index 0619251..70c7b08 100644 --- a/typedoc/classes/DetectSingleFaceLandmarksTask.html +++ b/typedoc/classes/DetectSingleFaceLandmarksTask.html @@ -1 +1 @@ -DetectSingleFaceLandmarksTask | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectSingleFaceLandmarksTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

withFaceDescriptor

withFaceExpressions

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +DetectSingleFaceLandmarksTask | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DetectSingleFaceLandmarksTask<TSource>

Type parameters

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

withFaceDescriptor

withFaceExpressions

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/DetectSingleFaceTask.html b/typedoc/classes/DetectSingleFaceTask.html index 29fa59f..5eb4518 100644 --- a/typedoc/classes/DetectSingleFaceTask.html +++ b/typedoc/classes/DetectSingleFaceTask.html @@ -1 +1 @@ -DetectSingleFaceTask | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictSingleAgeAndGenderTask<{ detection: FaceDetection }>

withFaceExpressions

  • withFaceExpressions(): PredictSingleFaceExpressionsTask<{ detection: FaceDetection }>

withFaceLandmarks

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +DetectSingleFaceTask | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Methods

run

then

withAgeAndGender

  • withAgeAndGender(): PredictSingleAgeAndGenderTask<{ detection: FaceDetection }>

withFaceExpressions

  • withFaceExpressions(): PredictSingleFaceExpressionsTask<{ detection: FaceDetection }>

withFaceLandmarks

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/Dimensions.html b/typedoc/classes/Dimensions.html index ec44f77..717abd1 100644 --- a/typedoc/classes/Dimensions.html +++ b/typedoc/classes/Dimensions.html @@ -1 +1 @@ -Dimensions | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Dimensions

Implements

Index

Constructors

Accessors

Methods

Constructors

constructor

  • new Dimensions(width: number, height: number): Dimensions

Accessors

height

  • get height(): number

width

  • get width(): number

Methods

reverse

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +Dimensions | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Dimensions

Implements

Index

Constructors

Accessors

Methods

Constructors

constructor

  • new Dimensions(width: number, height: number): Dimensions

Accessors

height

  • get height(): number

width

  • get width(): number

Methods

reverse

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceDetection.html b/typedoc/classes/FaceDetection.html index b5d3db3..8e49c53 100644 --- a/typedoc/classes/FaceDetection.html +++ b/typedoc/classes/FaceDetection.html @@ -1 +1 @@ -FaceDetection | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

Accessors

box

  • get box(): Box<any>

className

  • get className(): string

classScore

  • get classScore(): number

imageDims

imageHeight

  • get imageHeight(): number

imageWidth

  • get imageWidth(): number

relativeBox

  • get relativeBox(): Box<any>

score

  • get score(): number

Methods

forSize

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +FaceDetection | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

Accessors

box

  • get box(): Box<any>

className

  • get className(): string

classScore

  • get classScore(): number

imageDims

imageHeight

  • get imageHeight(): number

imageWidth

  • get imageWidth(): number

relativeBox

  • get relativeBox(): Box<any>

score

  • get score(): number

Methods

forSize

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceDetectionNet.html b/typedoc/classes/FaceDetectionNet.html index db8460e..3e139f5 100644 --- a/typedoc/classes/FaceDetectionNet.html +++ b/typedoc/classes/FaceDetectionNet.html @@ -1 +1 @@ -FaceDetectionNet | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

_name

_name: any

Accessors

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

dispose

  • dispose(throwOnRedispose?: boolean): void

extractWeights

  • extractWeights(weights: Float32Array): void

forward

  • forward(input: any): Promise<any>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void

locateFaces

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +FaceDetectionNet | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

Properties

_name

_name: any

Accessors

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

dispose

  • dispose(throwOnRedispose?: boolean): void

extractWeights

  • extractWeights(weights: Float32Array): void

forward

  • forward(input: any): Promise<any>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void

locateFaces

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceExpressionNet.html b/typedoc/classes/FaceExpressionNet.html index 0a1b749..6f669e0 100644 --- a/typedoc/classes/FaceExpressionNet.html +++ b/typedoc/classes/FaceExpressionNet.html @@ -1 +1 @@ -FaceExpressionNet | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceProcessor<FaceFeatureExtractorParams>
    • FaceExpressionNet

Index

Constructors

constructor

  • new FaceExpressionNet(faceFeatureExtractor?: FaceFeatureExtractor): FaceExpressionNet

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }
  • Parameters

    • weights: Float32Array

    Returns { paramMappings: ParamMapping[]; params: NetParams }

    • paramMappings: ParamMapping[]
    • params: NetParams

extractWeights

  • extractWeights(weights: Float32Array): void
  • Parameters

    • weights: Float32Array

    Returns void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

  • forwardInput(input: any): Tensor2D

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor
  • Parameters

    • paramPath: string

    Returns Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>
  • Parameters

    • weightsOrUrl: undefined | string | Float32Array

    Returns Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>
  • Parameters

    • filePath: undefined | string

    Returns Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>
  • Parameters

    • uri: undefined | string

    Returns Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void
  • Parameters

    • weightMap: NamedTensorMap

    Returns void

predictExpressions

  • predictExpressions(input: any): Promise<any>

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void
  • Parameters

    • paramPath: string
    • tensor: Tensor

    Returns void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +FaceExpressionNet | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceProcessor<FaceFeatureExtractorParams>
    • FaceExpressionNet

Index

Constructors

constructor

  • new FaceExpressionNet(faceFeatureExtractor?: FaceFeatureExtractor): FaceExpressionNet

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }
  • Parameters

    • weights: Float32Array

    Returns { paramMappings: ParamMapping[]; params: NetParams }

    • paramMappings: ParamMapping[]
    • params: NetParams

extractWeights

  • extractWeights(weights: Float32Array): void
  • Parameters

    • weights: Float32Array

    Returns void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

  • forwardInput(input: any): Tensor2D

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor
  • Parameters

    • paramPath: string

    Returns Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>
  • Parameters

    • weightsOrUrl: undefined | string | Float32Array

    Returns Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>
  • Parameters

    • filePath: undefined | string

    Returns Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>
  • Parameters

    • uri: undefined | string

    Returns Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void
  • Parameters

    • weightMap: NamedTensorMap

    Returns void

predictExpressions

  • predictExpressions(input: any): Promise<any>

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void
  • Parameters

    • paramPath: string
    • tensor: Tensor

    Returns void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceExpressions.html b/typedoc/classes/FaceExpressions.html index b25152d..843e6f9 100644 --- a/typedoc/classes/FaceExpressions.html +++ b/typedoc/classes/FaceExpressions.html @@ -1 +1 @@ -FaceExpressions | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceExpressions

Index

Constructors

constructor

  • new FaceExpressions(probabilities: number[] | Float32Array): FaceExpressions

Properties

angry

angry: number = 0

disgusted

disgusted: number = 0

fearful

fearful: number = 0

happy

happy: number = 0

neutral

neutral: number = 0

sad

sad: number = 0

surprised

surprised: number = 0

Methods

asSortedArray

  • asSortedArray(): { expression: string; probability: number }[]

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +FaceExpressions | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceExpressions

Index

Constructors

constructor

  • new FaceExpressions(probabilities: number[] | Float32Array): FaceExpressions

Properties

angry

angry: number = 0

disgusted

disgusted: number = 0

fearful

fearful: number = 0

happy

happy: number = 0

neutral

neutral: number = 0

sad

sad: number = 0

surprised

surprised: number = 0

Methods

asSortedArray

  • asSortedArray(): { expression: string; probability: number }[]

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceLandmark68Net.html b/typedoc/classes/FaceLandmark68Net.html index 6a74c9a..867e1a4 100644 --- a/typedoc/classes/FaceLandmark68Net.html +++ b/typedoc/classes/FaceLandmark68Net.html @@ -1 +1 @@ -FaceLandmark68Net | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceLandmark68NetBase<FaceFeatureExtractorParams>

Index

Constructors

constructor

  • new FaceLandmark68Net(faceFeatureExtractor?: FaceFeatureExtractor): FaceLandmark68Net

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

detectLandmarks

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }
  • Parameters

    • weights: Float32Array

    Returns { paramMappings: ParamMapping[]; params: NetParams }

    • paramMappings: ParamMapping[]
    • params: NetParams

extractWeights

  • extractWeights(weights: Float32Array): void
  • Parameters

    • weights: Float32Array

    Returns void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor
  • Parameters

    • paramPath: string

    Returns Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>
  • Parameters

    • weightsOrUrl: undefined | string | Float32Array

    Returns Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>
  • Parameters

    • filePath: undefined | string

    Returns Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>
  • Parameters

    • uri: undefined | string

    Returns Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void
  • Parameters

    • weightMap: NamedTensorMap

    Returns void

postProcess

  • postProcess(output: Tensor2D, inputSize: number, originalDimensions: IDimensions[]): Tensor2D

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void
  • Parameters

    • paramPath: string
    • tensor: Tensor

    Returns void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array
  • Returns Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +FaceLandmark68Net | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceLandmark68NetBase<FaceFeatureExtractorParams>

Index

Constructors

constructor

  • new FaceLandmark68Net(faceFeatureExtractor?: FaceFeatureExtractor): FaceLandmark68Net

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

detectLandmarks

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }
  • Parameters

    • weights: Float32Array

    Returns { paramMappings: ParamMapping[]; params: NetParams }

    • paramMappings: ParamMapping[]
    • params: NetParams

extractWeights

  • extractWeights(weights: Float32Array): void
  • Parameters

    • weights: Float32Array

    Returns void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor
  • Parameters

    • paramPath: string

    Returns Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>
  • Parameters

    • weightsOrUrl: undefined | string | Float32Array

    Returns Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>
  • Parameters

    • filePath: undefined | string

    Returns Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>
  • Parameters

    • uri: undefined | string

    Returns Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void
  • Parameters

    • weightMap: NamedTensorMap

    Returns void

postProcess

  • postProcess(output: Tensor2D, inputSize: number, originalDimensions: IDimensions[]): Tensor2D

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void
  • Parameters

    • paramPath: string
    • tensor: Tensor

    Returns void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array
  • Returns Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceLandmark68TinyNet.html b/typedoc/classes/FaceLandmark68TinyNet.html index 72ff643..3f44e4c 100644 --- a/typedoc/classes/FaceLandmark68TinyNet.html +++ b/typedoc/classes/FaceLandmark68TinyNet.html @@ -1 +1 @@ -FaceLandmark68TinyNet | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceLandmark68NetBase<TinyFaceFeatureExtractorParams>
    • FaceLandmark68TinyNet

Index

Constructors

constructor

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

detectLandmarks

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }
  • Parameters

    • weights: Float32Array

    Returns { paramMappings: ParamMapping[]; params: NetParams }

    • paramMappings: ParamMapping[]
    • params: NetParams

extractWeights

  • extractWeights(weights: Float32Array): void
  • Parameters

    • weights: Float32Array

    Returns void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor
  • Parameters

    • paramPath: string

    Returns Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>
  • Parameters

    • weightsOrUrl: undefined | string | Float32Array

    Returns Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>
  • Parameters

    • filePath: undefined | string

    Returns Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>
  • Parameters

    • uri: undefined | string

    Returns Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void
  • Parameters

    • weightMap: NamedTensorMap

    Returns void

postProcess

  • postProcess(output: Tensor2D, inputSize: number, originalDimensions: IDimensions[]): Tensor2D

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void
  • Parameters

    • paramPath: string
    • tensor: Tensor

    Returns void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array
  • Returns Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +FaceLandmark68TinyNet | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • FaceLandmark68NetBase<TinyFaceFeatureExtractorParams>
    • FaceLandmark68TinyNet

Index

Constructors

constructor

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

detectLandmarks

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }
  • Parameters

    • weights: Float32Array

    Returns { paramMappings: ParamMapping[]; params: NetParams }

    • paramMappings: ParamMapping[]
    • params: NetParams

extractWeights

  • extractWeights(weights: Float32Array): void
  • Parameters

    • weights: Float32Array

    Returns void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor
  • Parameters

    • paramPath: string

    Returns Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]
  • Returns { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>
  • Parameters

    • weightsOrUrl: undefined | string | Float32Array

    Returns Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>
  • Parameters

    • filePath: undefined | string

    Returns Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>
  • Parameters

    • uri: undefined | string

    Returns Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void
  • Parameters

    • weightMap: NamedTensorMap

    Returns void

postProcess

  • postProcess(output: Tensor2D, inputSize: number, originalDimensions: IDimensions[]): Tensor2D

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void
  • Parameters

    • paramPath: string
    • tensor: Tensor

    Returns void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array
  • Returns Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceLandmarkNet.html b/typedoc/classes/FaceLandmarkNet.html index e565148..609bd80 100644 --- a/typedoc/classes/FaceLandmarkNet.html +++ b/typedoc/classes/FaceLandmarkNet.html @@ -1 +1 @@ -FaceLandmarkNet | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new FaceLandmarkNet(faceFeatureExtractor?: FaceFeatureExtractor): FaceLandmarkNet

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

detectLandmarks

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }

extractWeights

  • extractWeights(weights: Float32Array): void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void

postProcess

  • postProcess(output: Tensor2D, inputSize: number, originalDimensions: IDimensions[]): Tensor2D

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file +FaceLandmarkNet | @vladmandic/face-api - v1.6.2
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new FaceLandmarkNet(faceFeatureExtractor?: FaceFeatureExtractor): FaceLandmarkNet

Properties

_name

_name: any

Accessors

faceFeatureExtractor

  • get faceFeatureExtractor(): IFaceFeatureExtractor<TExtractorParams>

isLoaded

  • get isLoaded(): boolean

paramMappings

  • get paramMappings(): ParamMapping[]
  • Returns ParamMapping[]

params

  • get params(): undefined | TNetParams
  • Returns undefined | TNetParams

Methods

detectLandmarks

dispose

  • dispose(throwOnRedispose?: boolean): void

extractClassifierParams

  • extractClassifierParams(weights: Float32Array): { paramMappings: ParamMapping[]; params: NetParams }

extractWeights

  • extractWeights(weights: Float32Array): void

forward

  • forward(input: any): Promise<Tensor2D>

forwardInput

freeze

  • freeze(): void

getFrozenParams

  • getFrozenParams(): { path: string; tensor: Tensor }[]

getParamFromPath

  • getParamFromPath(paramPath: string): Tensor

getParamList

  • getParamList(): { path: string; tensor: Tensor }[]

getTrainableParams

  • getTrainableParams(): { path: string; tensor: Tensor }[]

load

  • load(weightsOrUrl: undefined | string | Float32Array): Promise<void>

loadClassifierParams

  • loadClassifierParams(weights: Float32Array): void

loadFromDisk

  • loadFromDisk(filePath: undefined | string): Promise<void>

loadFromUri

  • loadFromUri(uri: undefined | string): Promise<void>

loadFromWeightMap

  • loadFromWeightMap(weightMap: NamedTensorMap): void

postProcess

  • postProcess(output: Tensor2D, inputSize: number, originalDimensions: IDimensions[]): Tensor2D

reassignParamFromPath

  • reassignParamFromPath(paramPath: string, tensor: Tensor): void

runNet

  • runNet(input: any): Tensor2D

serializeParams

  • serializeParams(): Float32Array

variable

  • variable(): void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Static method

Settings

Theme

\ No newline at end of file diff --git a/typedoc/classes/FaceLandmarks.html b/typedoc/classes/FaceLandmarks.html index 3792b93..de1ae03 100644 --- a/typedoc/classes/FaceLandmarks.html +++ b/typedoc/classes/FaceLandmarks.html @@ -1,4 +1,4 @@ -FaceLandmarks | @vladmandic/face-api - v1.6.1
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Implements

Index

Constructors

constructor

Accessors

imageHeight

  • get imageHeight(): number

imageWidth

  • get imageWidth(): number

positions

relativePositions

  • get relativePositions(): Point[]

shift

Methods

align