mirror of https://github.com/vladmandic/human
10 lines
79 KiB
JavaScript
10 lines
79 KiB
JavaScript
var $e=Object.defineProperty;var v=(e,t)=>()=>(t||(t={exports:{}},e(t.exports,t)),t.exports),A0=e=>$e(e,"__esModule",{value:!0}),Je=(e,t)=>{A0(e);for(var o in t)$e(e,o,{get:t[o],enumerable:!0})};var st=v(ue=>{const E=require("@tensorflow/tfjs"),et=6;function F0(e){const t={strides:[e/16,e/8],anchors:[2,6]},o=[];for(let n=0;n<t.strides.length;n++){const s=t.strides[n],i=Math.floor((e+s-1)/s),a=Math.floor((e+s-1)/s),c=t.anchors[n];for(let d=0;d<i;d++){const l=s*(d+.5);for(let h=0;h<a;h++){const p=s*(h+.5);for(let u=0;u<c;u++)o.push([p,l])}}}return o}const tt=e=>{e.startEndTensor.dispose(),e.startPoint.dispose(),e.endPoint.dispose()},ot=e=>({startEndTensor:e,startPoint:E.slice(e,[0,0],[-1,2]),endPoint:E.slice(e,[0,2],[-1,2])}),B0=(e,t)=>{const o=E.mul(e.startPoint,t),n=E.mul(e.endPoint,t),s=E.concat2d([o,n],1);return ot(s)};function D0(e,t,o){const n=E.slice(e,[0,1],[-1,2]),s=E.add(n,t),i=E.slice(e,[0,3],[-1,2]),a=E.div(i,o),c=E.div(s,o),d=E.div(a,2),l=E.sub(c,d),h=E.add(c,d),p=E.mul(l,o),u=E.mul(h,o),r=1;return E.concat2d([p,u],r)}function k0(e,t){return E.tidy(()=>{const o=e.box?e.box:e;return B0(o,t).startEndTensor.squeeze()})}class nt{constructor(e,t){this.blazeFaceModel=e,this.width=t.detector.inputSize,this.height=t.detector.inputSize,this.maxFaces=t.detector.maxFaces,this.anchorsData=F0(t.detector.inputSize),this.anchors=E.tensor2d(this.anchorsData),this.inputSize=E.tensor1d([this.width,this.height]),this.iouThreshold=t.detector.iouThreshold,this.scaleFaces=.8,this.scoreThreshold=t.detector.scoreThreshold}async getBoundingBoxes(e){if(!e||e.isDisposedInternal||e.shape.length!==4||e.shape[1]<1||e.shape[2]<1)return null;const[t,o,n]=E.tidy(()=>{const l=e.resizeBilinear([this.width,this.height]),h=E.mul(E.sub(l.div(255),.5),2),p=this.blazeFaceModel.predict(h);let u;if(Array.isArray(p)){const M=p.sort((N,f)=>N.size-f.size),P=E.concat([M[0],M[2]],2),w=E.concat([M[1],M[3]],2),k=E.concat([w,P],1);u=k.squeeze(0)}else u=p.squeeze();const r=D0(u,this.anchors,this.inputSize),x=E.slice(u,[0,0],[-1,1]),T=E.sigmoid(x).squeeze();return[u,r,T]}),s=await E.image.nonMaxSuppressionAsync(o,n,this.maxFaces,this.iouThreshold,this.scoreThreshold),i=await s.array();s.dispose();const a=i.map(l=>E.slice(o,[l,0],[1,-1])),c=await Promise.all(a.map(async l=>{const h=await l.array();return l.dispose(),h})),d=[];for(let l=0;l<c.length;l++){const h=c[l],p=ot(h),u=i[l],r=this.anchorsData[u],x=E.slice(t,[u,et-1],[1,-1]),T=x.squeeze(),M=T.reshape([et,-1]),P=E.slice(n,[u],[1]),w={box:p,landmarks:M,probability:P,anchor:r};d.push(w),x.dispose(),T.dispose()}return t.dispose(),o.dispose(),n.dispose(),t.dispose(),{boxes:d,scaleFactor:[e.shape[2]/this.width,e.shape[1]/this.height]}}async estimateFaces(e){const{boxes:t,scaleFactor:o}=await this.getBoundingBoxes(e);return Promise.all(t.map(async n=>{const s=k0(n,o),[i,a,c]=await Promise.all([n.landmarks,s,n.probability].map(async r=>r.array())),d=n.anchor,[l,h]=o,p=i.map(r=>[(r[0]+d[0])*l,(r[1]+d[1])*h]),u={topLeft:a.slice(0,2),bottomRight:a.slice(2),landmarks:p,probability:c};return tt(n.box),n.landmarks.dispose(),n.probability.dispose(),s.dispose(),u}))}}async function N0(e){const t=await E.loadGraphModel(e.detector.modelPath,{fromTFHub:e.detector.modelPath.includes("tfhub.dev")}),o=new nt(t,e);return o}ue.load=N0;ue.BlazeFaceModel=nt;ue.disposeBox=tt});var we=v(ye=>{ye.MESH_ANNOTATIONS={silhouette:[10,338,297,332,284,251,389,356,454,323,361,288,397,365,379,378,400,377,152,148,176,149,150,136,172,58,132,93,234,127,162,21,54,103,67,109],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],rightEyeIris:[473,474,475,476,477],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],leftEyeIris:[468,469,470,471,472],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]};ye.MESH_TO_IRIS_INDICES_MAP=[{key:"EyeUpper0",indices:[9,10,11,12,13,14,15]},{key:"EyeUpper1",indices:[25,26,27,28,29,30,31]},{key:"EyeUpper2",indices:[41,42,43,44,45,46,47]},{key:"EyeLower0",indices:[0,1,2,3,4,5,6,7,8]},{key:"EyeLower1",indices:[16,17,18,19,20,21,22,23,24]},{key:"EyeLower2",indices:[32,33,34,35,36,37,38,39,40]},{key:"EyeLower3",indices:[54,55,56,57,58,59,60,61,62]},{key:"EyebrowUpper",indices:[63,64,65,66,67,68,69,70]},{key:"EyebrowLower",indices:[48,49,50,51,52,53]}]});var it=v(oe=>{const C0=require("@tensorflow/tfjs");function z0(e,t){const o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]];return{startPoint:o,endPoint:n}}oe.scaleBoxCoordinates=z0;function Ee(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}oe.getBoxSize=Ee;function ve(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}oe.getBoxCenter=ve;function O0(e,t,o){const n=t.shape[1],s=t.shape[2],i=[[e.startPoint[1]/n,e.startPoint[0]/s,e.endPoint[1]/n,e.endPoint[0]/s]];return C0.image.cropAndResize(t,i,[0],o)}oe.cutBoxFromImageAndResize=O0;function L0(e,t=1.5){const o=ve(e),n=Ee(e),s=[t*n[0]/2,t*n[1]/2],i=[o[0]-s[0],o[1]-s[1]],a=[o[0]+s[0],o[1]+s[1]];return{startPoint:i,endPoint:a,landmarks:e.landmarks}}oe.enlargeBox=L0;function H0(e){const t=ve(e),o=Ee(e),n=Math.max(...o),s=n/2,i=[t[0]-s,t[1]-s],a=[t[0]+s,t[1]+s];return{startPoint:i,endPoint:a,landmarks:e.landmarks}}oe.squarifyBox=H0});var lt=v(O=>{O.IDENTITY_MATRIX=[[1,0,0],[0,1,0],[0,0,1]];function rt(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}O.normalizeRadians=rt;function U0(e,t){const o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return rt(o)}O.computeRotation=U0;function j0(e){return e*180/Math.PI}O.radToDegrees=j0;function at(e,t){return[[1,0,e],[0,1,t],[0,0,1]]}function ne(e,t){let o=0;for(let n=0;n<e.length;n++)o+=e[n]*t[n];return o}O.dot=ne;function ct(e,t){const o=[];for(let n=0;n<e.length;n++)o.push(e[n][t]);return o}O.getColumnFrom2DArr=ct;function dt(e,t){const o=[],n=e.length;for(let s=0;s<n;s++){o.push([]);for(let i=0;i<n;i++)o[s].push(ne(e[s],ct(t,i)))}return o}function q0(e,t){const o=Math.cos(e),n=Math.sin(e),s=[[o,-n,0],[n,o,0],[0,0,1]],i=at(t[0],t[1]),a=dt(i,s),c=at(-t[0],-t[1]);return dt(a,c)}O.buildRotationMatrix=q0;function X0(e){const t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-ne(t[0],o),-ne(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]}O.invertTransformMatrix=X0;function W0(e,t){return[ne(e,t[0]),ne(e,t[1])]}O.rotatePoint=W0;function G0(e,t){return Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2)}O.xyDistanceBetweenPoints=G0});var ht=v(ut=>{const X=require("@tensorflow/tfjs"),j=it(),G=we(),Y=lt(),Y0=468,K0=.25,V0=13,Q0=[V0,G.MESH_ANNOTATIONS.midwayBetweenEyes[0]],Z0=3,$0=2,J0=[Z0,$0],Pe=G.MESH_ANNOTATIONS.leftEyeLower0,Te=[Pe[0],Pe[Pe.length-1]],_e=G.MESH_ANNOTATIONS.rightEyeLower0,Me=[_e[0],_e[_e.length-1]],eo=3,to=4,oo=71,Ie=76;function he(e,t,o,n){for(let s=0;s<G.MESH_TO_IRIS_INDICES_MAP.length;s++){const{key:i,indices:a}=G.MESH_TO_IRIS_INDICES_MAP[s],c=G.MESH_ANNOTATIONS[`${o}${i}`],d=n==null;if(d||n.includes(i))for(let l=0;l<a.length;l++){const h=a[l];e[c[l]]=[t[h][0],t[h][1],(t[h][2]+e[c[l]][2])/2]}}}class no{constructor(e,t,o,n){this.regionsOfInterest=[],this.runsWithoutFaceDetector=0,this.boundingBoxDetector=e,this.meshDetector=t,this.irisModel=o,this.meshWidth=n.mesh.inputSize,this.meshHeight=n.mesh.inputSize,this.irisSize=n.iris.inputSize,this.irisEnlarge=n.iris.enlargeFactor}transformRawCoords(e,t,o,n){const s=j.getBoxSize({startPoint:t.startPoint,endPoint:t.endPoint}),i=[s[0]/this.meshWidth,s[1]/this.meshHeight],a=e.map(u=>[i[0]*(u[0]-this.meshWidth/2),i[1]*(u[1]-this.meshHeight/2),u[2]]),c=Y.buildRotationMatrix(o,[0,0]),d=a.map(u=>[...Y.rotatePoint(u,c),u[2]]),l=Y.invertTransformMatrix(n),h=[...j.getBoxCenter({startPoint:t.startPoint,endPoint:t.endPoint}),1],p=[Y.dot(h,l[0]),Y.dot(h,l[1])];return d.map(u=>[u[0]+p[0],u[1]+p[1],u[2]])}getLeftToRightEyeDepthDifference(e){const t=e[Te[0]][2],o=e[Me[0]][2];return t-o}getEyeBox(e,t,o,n,s=!1){const i=j.squarifyBox(j.enlargeBox(this.calculateLandmarksBoundingBox([e[o],e[n]]),this.irisEnlarge)),a=j.getBoxSize(i);let c=X.image.cropAndResize(t,[[i.startPoint[1]/this.meshHeight,i.startPoint[0]/this.meshWidth,i.endPoint[1]/this.meshHeight,i.endPoint[0]/this.meshWidth]],[0],[this.irisSize,this.irisSize]);return s&&(c=X.image.flipLeftRight(c)),{box:i,boxSize:a,crop:c}}getEyeCoords(e,t,o,n=!1){const s=[];for(let i=0;i<Ie;i++){const a=e[i*3],c=e[i*3+1],d=e[i*3+2];s.push([(n?1-a/this.irisSize:a/this.irisSize)*o[0]+t.startPoint[0],c/this.irisSize*o[1]+t.startPoint[1],d])}return{rawCoords:s,iris:s.slice(oo)}}getAdjustedIrisCoords(e,t,o){const n=e[G.MESH_ANNOTATIONS[`${o}EyeUpper0`][eo]][2],s=e[G.MESH_ANNOTATIONS[`${o}EyeLower0`][to]][2],i=(n+s)/2;return t.map((a,c)=>{let d=i;return c===2?d=n:c===4&&(d=s),[a[0],a[1],d]})}async predict(e,t){if(this.skipFrames=t.detector.skipFrames,this.maxFaces=t.detector.maxFaces,this.runsWithoutFaceDetector++,this.shouldUpdateRegionsOfInterest()){const n=await this.boundingBoxDetector.getBoundingBoxes(e);if(n.boxes.length===0)return this.regionsOfInterest=[],null;const s=n.boxes.map(i=>{const a=i.box.startPoint.squeeze(),c=i.box.endPoint.squeeze(),d={startPoint:a.arraySync(),endPoint:c.arraySync()};a.dispose(),c.dispose();const l=j.scaleBoxCoordinates(d,n.scaleFactor),h=j.enlargeBox(l),p=i.landmarks.arraySync();return i.box.startPoint.dispose(),i.box.endPoint.dispose(),i.landmarks.dispose(),i.probability.dispose(),{...h,landmarks:p}});this.updateRegionsOfInterest(s),this.runsWithoutFaceDetector=0}const o=X.tidy(()=>this.regionsOfInterest.map((n,s)=>{let i=0;const a=n.landmarks.length>=Y0;let[c,d]=Q0;a===!1&&([c,d]=J0),i=Y.computeRotation(n.landmarks[c],n.landmarks[d]);const l=j.getBoxCenter({startPoint:n.startPoint,endPoint:n.endPoint}),h=[l[0]/e.shape[2],l[1]/e.shape[1]];let p=e,u=Y.IDENTITY_MATRIX;i!==0&&(p=X.image.rotateWithOffset(e,i,0,h),u=Y.buildRotationMatrix(-i,l));const r={startPoint:n.startPoint,endPoint:n.endPoint},x=j.cutBoxFromImageAndResize(r,p,[this.meshHeight,this.meshWidth]).div(255),[,T,M]=this.meshDetector.predict(x),P=X.reshape(M,[-1,3]);let w=P.arraySync();if(t.iris.enabled){const{box:m,boxSize:y,crop:I}=this.getEyeBox(w,x,Te[0],Te[1],!0),{box:A,boxSize:U,crop:P0}=this.getEyeBox(w,x,Me[0],Me[1]),Ye=this.irisModel.predict(X.concat([I,P0])),Ke=Ye.dataSync();Ye.dispose();const T0=Ke.slice(0,Ie*3),{rawCoords:Ve,iris:_0}=this.getEyeCoords(T0,m,y,!0),M0=Ke.slice(Ie*3),{rawCoords:Qe,iris:I0}=this.getEyeCoords(M0,A,U),Ze=this.getLeftToRightEyeDepthDifference(w);Math.abs(Ze)<30?(he(w,Ve,"left"),he(w,Qe,"right")):Ze<1?he(w,Ve,"left",["EyeUpper0","EyeLower0"]):he(w,Qe,"right",["EyeUpper0","EyeLower0"]);const S0=this.getAdjustedIrisCoords(w,_0,"left"),R0=this.getAdjustedIrisCoords(w,I0,"right");w=w.concat(S0).concat(R0)}const k=this.transformRawCoords(w,n,i,u);X.dispose(w);const N=j.enlargeBox(this.calculateLandmarksBoundingBox(k)),f=T.squeeze();if(X.dispose(T),t.mesh.enabled){const m=X.tensor2d(k);this.regionsOfInterest[s]={...N,landmarks:m.arraySync()};const y={coords:m,box:N,confidence:f,image:x};return y}const b={coords:null,box:N,confidence:f,image:x};return b}));return o}updateRegionsOfInterest(e){for(let t=0;t<e.length;t++){const o=e[t],n=this.regionsOfInterest[t];let s=0;if(n&&n.startPoint){const[i,a]=o.startPoint,[c,d]=o.endPoint,[l,h]=n.startPoint,[p,u]=n.endPoint,r=Math.max(i,l),x=Math.max(a,h),T=Math.min(c,p),M=Math.min(d,u),P=(T-r)*(M-x),w=(c-i)*(d-a),k=(p-l)*(u-a);s=P/(w+k-P)}s<K0&&(this.regionsOfInterest[t]=o)}this.regionsOfInterest=this.regionsOfInterest.slice(0,e.length)}clearRegionOfInterest(e){this.regionsOfInterest[e]!=null&&(this.regionsOfInterest=[...this.regionsOfInterest.slice(0,e),...this.regionsOfInterest.slice(e+1)])}shouldUpdateRegionsOfInterest(){return this.regionsOfInterest.length===0?!0:this.regionsOfInterest.length!==this.maxFaces&&this.runsWithoutFaceDetector>=this.skipFrames}calculateLandmarksBoundingBox(e){const t=e.map(i=>i[0]),o=e.map(i=>i[1]),n=[Math.min(...t),Math.min(...o)],s=[Math.max(...t),Math.max(...o)];return{startPoint:n,endPoint:s,landmarks:e}}}ut.Pipeline=no});var pt=v(mt=>{mt.UV_COORDS=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]]});var ft=v(so=>{Je(so,{default:()=>io});var io=[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,118,50,101,73,39,40,9,151,108,48,115,131,194,204,211,74,40,185,80,42,183,40,92,186,230,229,118,202,212,214,83,18,17,76,61,146,160,29,30,56,157,173,106,204,194,135,214,192,203,165,98,21,71,68,51,45,4,144,24,23,77,146,91,205,50,187,201,200,18,91,106,182,90,91,181,85,84,17,206,203,36,148,171,140,92,40,39,193,189,244,159,158,28,247,246,161,236,3,196,54,68,104,193,168,8,117,228,31,189,193,55,98,97,99,126,47,100,166,79,218,155,154,26,209,49,131,135,136,150,47,126,217,223,52,53,45,51,134,211,170,140,67,69,108,43,106,91,230,119,120,226,130,247,63,53,52,238,20,242,46,70,156,78,62,96,46,53,63,143,34,227,173,155,133,123,117,111,44,125,19,236,134,51,216,206,205,154,153,22,39,37,167,200,201,208,36,142,100,57,212,202,20,60,99,28,158,157,35,226,113,160,159,27,204,202,210,113,225,46,43,202,204,62,76,77,137,123,116,41,38,72,203,129,142,64,98,240,49,102,64,41,73,74,212,216,207,42,74,184,169,170,211,170,149,176,105,66,69,122,6,168,123,147,187,96,77,90,65,55,107,89,90,180,101,100,120,63,105,104,93,137,227,15,86,85,129,102,49,14,87,86,55,8,9,100,47,121,145,23,22,88,89,179,6,122,196,88,95,96,138,172,136,215,58,172,115,48,219,42,80,81,195,3,51,43,146,61,171,175,199,81,82,38,53,46,225,144,163,110,246,33,7,52,65,66,229,228,117,34,127,234,107,108,69,109,108,151,48,64,235,62,78,191,129,209,126,111,35,143,163,161,246,117,123,50,222,65,52,19,125,141,221,55,65,3,195,197,25,7,33,220,237,44,70,71,139,122,193,245,247,130,33,71,21,162,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,101,50,205,206,92,165,209,198,217,165,167,97,220,115,218,133,112,243,239,238,241,214,135,169,190,173,133,171,208,32,125,44,237,86,87,178,85,86,179,84,85,180,83,84,181,201,83,182,137,93,132,76,62,183,61,76,184,57,61,185,212,57,186,214,207,187,34,143,156,79,239,237,123,137,177,44,1,4,201,194,32,64,102,129,213,215,138,59,166,219,242,99,97,2,94,141,75,59,235,24,110,228,25,130,226,23,24,229,22,23,230,26,22,231,112,26,232,189,190,243,221,56,190,28,56,221,27,28,222,29,27,223,30,29,224,247,30,225,238,79,20,166,59,75,60,75,240,147,177,215,20,79,166,187,147,213,112,233,244,233,128,245,128,114,188,114,217,174,131,115,220,217,198,236,198,131,134,177,132,58,143,35,124,110,163,7,228,110,25,356,389,368,11,302,267,452,350,349,302,303,269,357,343,277,452,453,357,333,332,297,175,152,377,384,398,382,347,348,330,303,304,270,9,336,337,278,279,360,418,262,431,304,408,409,310,415,407,270,409,410,450,348,347,422,430,434,313,314,17,306,307,375,387,388,260,286,414,398,335,406,418,364,367,416,423,358,327,251,284,298,281,5,4,373,374,253,307,320,321,425,427,411,421,313,18,321,405,406,320,404,405,315,16,17,426,425,266,377,400,369,322,391,269,417,465,464,386,257,258,466,260,388,456,399,419,284,332,333,417,285,8,346,340,261,413,441,285,327,460,328,355,371,329,392,439,438,382,341,256,429,420,360,364,394,379,277,343,437,443,444,283,275,440,363,431,262,369,297,338,337,273,375,321,450,451,349,446,342,467,293,334,282,458,461,462,276,353,383,308,324,325,276,300,293,372,345,447,382,398,362,352,345,340,274,1,19,456,248,281,436,427,425,381,256,252,269,391,393,200,199,428,266,330,329,287,273,422,250,462,328,258,286,384,265,353,342,387,259,257,424,431,430,342,353,276,273,335,424,292,325,307,366,447,345,271,303,302,423,266,371,294,455,460,279,278,294,271,272,304,432,434,427,272,407,408,394,430,431,395,369,400,334,333,299,351,417,168,352,280,411,325,319,320,295,296,336,319,403,404,330,348,349,293,298,333,323,454,447,15,16,315,358,429,279,14,15,316,285,336,9,329,349,350,374,380,252,318,402,403,6,197,419,318,319,325,367,364,365,435,367,397,344,438,439,272,271,311,195,5,281,273,287,291,396,428,199,311,271,268,283,444,445,373,254,339,263,466,249,282,334,296,449,347,346,264,447,454,336,296,299,338,10,151,278,439,455,292,407,415,358,371,355,340,345,372,390,249,466,346,347,280,442,443,282,19,94,370,441,442,295,248,419,197,263,255,359,440,275,274,300,383,368,351,412,465,263,467,466,301,368,389,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,330,266,425,426,423,391,429,355,437,391,327,326,440,457,438,341,382,362,459,457,461,434,430,394,414,463,362,396,369,262,354,461,457,316,403,402,315,404,403,314,405,404,313,406,405,421,418,406,366,401,361,306,408,407,291,409,408,287,410,409,432,436,410,434,416,411,264,368,383,309,438,457,352,376,401,274,275,4,421,428,262,294,327,358,433,416,367,289,455,439,462,370,326,2,326,370,305,460,455,254,449,448,255,261,446,253,450,449,252,451,450,256,452,451,341,453,452,413,464,463,441,413,414,258,442,441,257,443,442,259,444,443,260,445,444,467,342,445,459,458,250,289,392,290,290,328,460,376,433,435,250,290,392,411,416,433,341,463,464,453,464,465,357,465,412,343,412,399,360,363,440,437,399,456,420,456,363,401,435,288,372,383,353,339,255,249,448,261,255,133,243,190,133,155,112,33,246,247,33,130,25,398,384,286,362,398,414,362,463,341,263,359,467,263,249,255,466,467,260,75,60,166,238,239,79,162,127,139,72,11,37,121,232,120,73,72,39,114,128,47,233,232,128,103,104,67,152,175,148,173,157,155,119,118,101,74,73,40,107,9,108,49,48,131,32,194,211,184,74,185,191,80,183,185,40,186,119,230,118,210,202,214,84,83,17,77,76,146,161,160,30,190,56,173,182,106,194,138,135,192,129,203,98,54,21,68,5,51,4,145,144,23,90,77,91,207,205,187,83,201,18,181,91,182,180,90,181,16,85,17,205,206,36,176,148,140,165,92,39,245,193,244,27,159,28,30,247,161,174,236,196,103,54,104,55,193,8,111,117,31,221,189,55,240,98,99,142,126,100,219,166,218,112,155,26,198,209,131,169,135,150,114,47,217,224,223,53,220,45,134,32,211,140,109,67,108,146,43,91,231,230,120,113,226,247,105,63,52,241,238,242,124,46,156,95,78,96,70,46,63,116,143,227,116,123,111,1,44,19,3,236,51,207,216,205,26,154,22,165,39,167,199,200,208,101,36,100,43,57,202,242,20,99,56,28,157,124,35,113,29,160,27,211,204,210,124,113,46,106,43,204,96,62,77,227,137,116,73,41,72,36,203,142,235,64,240,48,49,64,42,41,74,214,212,207,183,42,184,210,169,211,140,170,176,104,105,69,193,122,168,50,123,187,89,96,90,66,65,107,179,89,180,119,101,120,68,63,104,234,93,227,16,15,85,209,129,49,15,14,86,107,55,9,120,100,121,153,145,22,178,88,179,197,6,196,89,88,96,135,138,136,138,215,172,218,115,219,41,42,81,5,195,51,57,43,61,208,171,199,41,81,38,224,53,225,24,144,110,105,52,66,118,229,117,227,34,234,66,107,69,10,109,151,219,48,235,183,62,191,142,129,126,116,111,143,7,163,246,118,117,50,223,222,52,94,19,141,222,221,65,196,3,197,45,220,44,156,70,139,188,122,245,139,71,162,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,36,101,205,203,206,165,126,209,217,98,165,97,237,220,218,237,239,241,210,214,169,140,171,32,241,125,237,179,86,178,180,85,179,181,84,180,182,83,181,194,201,182,177,137,132,184,76,183,185,61,184,186,57,185,216,212,186,192,214,187,139,34,156,218,79,237,147,123,177,45,44,4,208,201,32,98,64,129,192,213,138,235,59,219,141,242,97,97,2,141,240,75,235,229,24,228,31,25,226,230,23,229,231,22,230,232,26,231,233,112,232,244,189,243,189,221,190,222,28,221,223,27,222,224,29,223,225,30,224,113,247,225,99,60,240,213,147,215,60,20,166,192,187,213,243,112,244,244,233,245,245,128,188,188,114,174,134,131,220,174,217,236,236,198,134,215,177,58,156,143,124,25,110,7,31,228,25,264,356,368,0,11,267,451,452,349,267,302,269,350,357,277,350,452,357,299,333,297,396,175,377,381,384,382,280,347,330,269,303,270,151,9,337,344,278,360,424,418,431,270,304,409,272,310,407,322,270,410,449,450,347,432,422,434,18,313,17,291,306,375,259,387,260,424,335,418,434,364,416,391,423,327,301,251,298,275,281,4,254,373,253,375,307,321,280,425,411,200,421,18,335,321,406,321,320,405,314,315,17,423,426,266,396,377,369,270,322,269,413,417,464,385,386,258,248,456,419,298,284,333,168,417,8,448,346,261,417,413,285,326,327,328,277,355,329,309,392,438,381,382,256,279,429,360,365,364,379,355,277,437,282,443,283,281,275,363,395,431,369,299,297,337,335,273,321,348,450,349,359,446,467,283,293,282,250,458,462,300,276,383,292,308,325,283,276,293,264,372,447,346,352,340,354,274,19,363,456,281,426,436,425,380,381,252,267,269,393,421,200,428,371,266,329,432,287,422,290,250,328,385,258,384,446,265,342,386,387,257,422,424,430,445,342,276,422,273,424,306,292,307,352,366,345,268,271,302,358,423,371,327,294,460,331,279,294,303,271,304,436,432,427,304,272,408,395,394,431,378,395,400,296,334,299,6,351,168,376,352,411,307,325,320,285,295,336,320,319,404,329,330,349,334,293,333,366,323,447,316,15,315,331,358,279,317,14,316,8,285,9,277,329,350,253,374,252,319,318,403,351,6,419,324,318,325,397,367,365,288,435,397,278,344,439,310,272,311,248,195,281,375,273,291,175,396,199,312,311,268,276,283,445,390,373,339,295,282,296,448,449,346,356,264,454,337,336,299,337,338,151,294,278,455,308,292,415,429,358,355,265,340,372,388,390,466,352,346,280,295,442,282,354,19,370,285,441,295,195,248,197,457,440,274,301,300,368,417,351,465,251,301,389,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,280,330,425,322,426,391,420,429,437,393,391,326,344,440,438,458,459,461,364,434,394,428,396,262,274,354,457,317,316,402,316,315,403,315,314,404,314,313,405,313,421,406,323,366,361,292,306,407,306,291,408,291,287,409,287,432,410,427,434,411,372,264,383,459,309,457,366,352,401,1,274,4,418,421,262,331,294,358,435,433,367,392,289,439,328,462,326,94,2,370,289,305,455,339,254,448,359,255,446,254,253,449,253,252,450,252,256,451,256,341,452,414,413,463,286,441,414,286,258,441,258,257,442,257,259,443,259,260,444,260,467,445,309,459,250,305,289,290,305,290,460,401,376,435,309,250,392,376,411,433,453,341,464,357,453,465,343,357,412,437,343,399,344,360,440,420,437,456,360,420,363,361,401,288,265,372,353,390,339,249,339,448,255]});var bt=v(ae=>{const Se=require("@tensorflow/tfjs"),ro=st(),gt=we(),ao=ht(),co=pt(),lo=ft().default;class xt{constructor(e,t,o,n){this.pipeline=new ao.Pipeline(e,t,o,n),n&&(this.config=n)}async estimateFaces(e,t){t&&(this.config=t);const o=await this.pipeline.predict(e,t),n=[];for(const s of o||[]){if(s.isDisposedInternal)continue;const i=s.confidence.arraySync();if(i>=this.config.detector.minConfidence){const a=s.coords?s.coords.arraySync():null,c={};if(a&&a.length>0)for(const d in gt.MESH_ANNOTATIONS)(this.config.iris.enabled||d.includes("Iris")===!1)&&(c[d]=gt.MESH_ANNOTATIONS[d].map(l=>a[l]));n.push({confidence:i||0,box:s.box?[s.box.startPoint[0],s.box.startPoint[1],s.box.endPoint[0]-s.box.startPoint[0],s.box.endPoint[1]-s.box.startPoint[1]]:0,mesh:a,annotations:c,image:s.image?Se.clone(s.image):null})}s.confidence&&s.confidence.dispose(),s.coords&&s.coords.dispose(),s.image&&s.image.dispose()}return n}}async function uo(e){const t=await Promise.all([ro.load(e),Se.loadGraphModel(e.mesh.modelPath,{fromTFHub:e.mesh.modelPath.includes("tfhub.dev")}),Se.loadGraphModel(e.iris.modelPath,{fromTFHub:e.iris.modelPath.includes("tfhub.dev")})]),o=new xt(t[0],t[1],t[2],e);return o}ae.load=uo;ae.MediaPipeFaceMesh=xt;ae.uv_coords=co;ae.triangulation=lo});var wt=v(me=>{const K=require("@tensorflow/tfjs"),V={};let yt={age:0,gender:""},Re=0;async function ho(e){return V.age||(V.age=await K.loadGraphModel(e.face.age.modelPath)),V.age}async function mo(e){return V.gender||(V.gender=await K.loadGraphModel(e.face.gender.modelPath)),V.gender}async function po(e,t){if(Re<t.face.age.skipFrames)return Re+=1,yt;Re=0;const o=K.image.resizeBilinear(e,[t.face.age.inputSize,t.face.age.inputSize],!1),n=K.mul(o,[255]);K.dispose(o);const s=[];let i,a;t.face.age.enabled&&s.push(i=V.age.predict(n)),t.face.gender.enabled&&s.push(a=V.gender.predict(n)),await Promise.all(s);const c={};if(i){const d=await i.data();c.age=Math.trunc(10*d[0])/10,K.dispose(i)}if(a){const d=await a.data(),l=Math.trunc(Math.abs(1.9*100*(d[0]-.5)))/100;l>t.face.gender.minConfidence&&(c.gender=d[0]<=.5?"female":"male",c.confidence=l),K.dispose(a)}return K.dispose(n),yt=c,c}me.predict=po;me.loadAge=ho;me.loadGender=mo});var Pt=v(Ae=>{const W=require("@tensorflow/tfjs"),fo=["angry","discust","fear","happy","sad","surpise","neutral"],pe={};let Et=[],Fe=0;const vt=1.5;async function go(e){return pe.emotion||(pe.emotion=await W.loadGraphModel(e.face.emotion.modelPath)),pe.emotion}async function xo(e,t){if(Fe<t.face.emotion.skipFrames)return Fe+=1,Et;Fe=0;const o=W.image.resizeBilinear(e,[t.face.emotion.inputSize,t.face.emotion.inputSize],!1),[n,s,i]=W.split(o,3,3);o.dispose();const a=W.mul(n,[.2989]),c=W.mul(s,[.587]),d=W.mul(i,[.114]);n.dispose(),s.dispose(),i.dispose();const l=W.addN([a,c,d]);a.dispose(),c.dispose(),d.dispose();const h=[];if(t.face.emotion.enabled){const p=await pe.emotion.predict(l),u=await p.data();for(let r=0;r<u.length;r++)vt*u[r]>t.face.emotion.minConfidence&&h.push({score:Math.min(.99,Math.trunc(100*vt*u[r])/100),emotion:fo[r]});h.sort((r,x)=>x.score-r.score),W.dispose(p)}return W.dispose(l),Et=h,h}Ae.predict=xo;Ae.load=go});var Mt=v(Tt=>{const _t=require("@tensorflow/tfjs");class bo{constructor(e,t){this.model=e,this.outputStride=t;const o=this.model.inputs[0].shape;_t.util.assert(o[1]===-1&&o[2]===-1,()=>`Input shape [${o[1]}, ${o[2]}] must both be equal to or -1`)}predict(e){return _t.tidy(()=>{const t=this.preprocessInput(e.toFloat()),o=t.expandDims(0),n=this.model.predict(o),s=n.map(a=>a.squeeze([0])),i=this.nameOutputResults(s);return{heatmapScores:i.heatmap.sigmoid(),offsets:i.offsets,displacementFwd:i.displacementFwd,displacementBwd:i.displacementBwd}})}dispose(){this.model.dispose()}}Tt.BaseModel=bo});var Be=v(It=>{const St=require("@tensorflow/tfjs"),yo=Mt();class wo extends yo.BaseModel{preprocessInput(e){return St.tidy(()=>St.div(e,127.5).sub(1))}nameOutputResults(e){const[t,o,n,s]=e;return{offsets:t,heatmap:o,displacementFwd:n,displacementBwd:s}}}It.MobileNet=wo});var At=v(Rt=>{function De(e){return Math.floor(e/2)}class Eo{constructor(e,t){this.priorityQueue=new Array(e),this.numberOfElements=-1,this.getElementValue=t}enqueue(e){this.priorityQueue[++this.numberOfElements]=e,this.swim(this.numberOfElements)}dequeue(){const e=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,e}empty(){return this.numberOfElements===-1}size(){return this.numberOfElements+1}all(){return this.priorityQueue.slice(0,this.numberOfElements+1)}max(){return this.priorityQueue[0]}swim(e){for(;e>0&&this.less(De(e),e);)this.exchange(e,De(e)),e=De(e)}sink(e){for(;2*e<=this.numberOfElements;){let t=2*e;if(t<this.numberOfElements&&this.less(t,t+1)&&t++,!this.less(e,t))break;this.exchange(e,t),e=t}}getValueAt(e){return this.getElementValue(this.priorityQueue[e])}less(e,t){return this.getValueAt(e)<this.getValueAt(t)}exchange(e,t){const o=this.priorityQueue[e];this.priorityQueue[e]=this.priorityQueue[t],this.priorityQueue[t]=o}}Rt.MaxHeap=Eo});var Bt=v(Ft=>{const vo=At();function Po(e,t,o,n,s,i){const[a,c]=i.shape;let d=!0;const l=Math.max(o-s,0),h=Math.min(o+s+1,a);for(let p=l;p<h;++p){const u=Math.max(n-s,0),r=Math.min(n+s+1,c);for(let x=u;x<r;++x)if(i.get(p,x,e)>t){d=!1;break}if(!d)break}return d}function To(e,t,o){const[n,s,i]=o.shape,a=new vo.MaxHeap(n*s*i,({score:c})=>c);for(let c=0;c<n;++c)for(let d=0;d<s;++d)for(let l=0;l<i;++l){const h=o.get(c,d,l);if(h<e)continue;Po(l,h,c,d,t,o)&&a.enqueue({score:h,part:{heatmapY:c,heatmapX:d,id:l}})}return a}Ft.buildPartWithScoreQueue=To});var ce=v(L=>{L.partNames=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"];L.NUM_KEYPOINTS=L.partNames.length;L.partIds=L.partNames.reduce((e,t,o)=>(e[t]=o,e),{});const _o=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]];L.poseChain=[["nose","leftEye"],["leftEye","leftEar"],["nose","rightEye"],["rightEye","rightEar"],["nose","leftShoulder"],["leftShoulder","leftElbow"],["leftElbow","leftWrist"],["leftShoulder","leftHip"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["nose","rightShoulder"],["rightShoulder","rightElbow"],["rightElbow","rightWrist"],["rightShoulder","rightHip"],["rightHip","rightKnee"],["rightKnee","rightAnkle"]];L.connectedPartIndices=_o.map(([e,t])=>[L.partIds[e],L.partIds[t]]);L.partChannels=["left_face","right_face","right_upper_leg_front","right_lower_leg_back","right_upper_leg_back","left_lower_leg_front","left_upper_leg_front","left_upper_leg_back","left_lower_leg_back","right_feet","right_lower_leg_front","left_feet","torso_front","torso_back","right_upper_arm_front","right_upper_arm_back","right_lower_arm_back","left_lower_arm_front","left_upper_arm_front","left_upper_arm_back","left_lower_arm_back","right_hand","right_lower_arm_front","left_hand"]});var Ne=v(Q=>{const Mo=ce();function Dt(e,t,o,n){return{y:n.get(e,t,o),x:n.get(e,t,o+Mo.NUM_KEYPOINTS)}}Q.getOffsetPoint=Dt;function Io(e,t,o){const{heatmapY:n,heatmapX:s,id:i}=e,{y:a,x:c}=Dt(n,s,i,o);return{x:e.heatmapX*t+c,y:e.heatmapY*t+a}}Q.getImageCoords=Io;function So(e,t){const o=new Array(t);for(let n=0;n<t;n++)o[n]=e;return o}Q.fillArray=So;function ke(e,t,o){return e<t?t:e>o?o:e}Q.clamp=ke;function Ro(e,t,o,n){const s=o-e,i=n-t;return s*s+i*i}Q.squaredDistance=Ro;function Ao(e,t){return{x:e.x+t.x,y:e.y+t.y}}Q.addVectors=Ao;function Fo(e,t,o){return{y:ke(e.y,t,o),x:ke(e.x,t,o)}}Q.clampVector=Fo});var Ot=v(kt=>{const de=ce(),se=Ne(),Nt=de.poseChain.map(([e,t])=>[de.partIds[e],de.partIds[t]]),Ce=Nt.map(([,e])=>e),Ct=Nt.map(([e])=>e);function Bo(e,t,o){const n=o.shape[2]/2;return{y:o.get(t.y,t.x,e),x:o.get(t.y,t.x,n+e)}}function ze(e,t,o,n){return{y:se.clamp(Math.round(e.y/t),0,o-1),x:se.clamp(Math.round(e.x/t),0,n-1)}}function zt(e,t,o,n,s,i,a,c=2){const[d,l]=n.shape,h=ze(t.position,i,d,l),p=Bo(e,h,a),u=se.addVectors(t.position,p);let r=u;for(let M=0;M<c;M++){const P=ze(r,i,d,l),w=se.getOffsetPoint(P.y,P.x,o,s);r=se.addVectors({x:P.x*i,y:P.y*i},{x:w.x,y:w.y})}const x=ze(r,i,d,l),T=n.get(x.y,x.x,o);return{position:r,part:de.partNames[o],score:T}}function Do(e,t,o,n,s,i){const a=t.shape[2],c=Ce.length,d=new Array(a),{part:l,score:h}=e,p=se.getImageCoords(l,n,o);d[l.id]={score:h,part:de.partNames[l.id],position:p};for(let u=c-1;u>=0;--u){const r=Ce[u],x=Ct[u];d[r]&&!d[x]&&(d[x]=zt(u,d[r],x,t,o,n,i))}for(let u=0;u<c;++u){const r=Ct[u],x=Ce[u];d[r]&&!d[x]&&(d[x]=zt(u,d[r],x,t,o,n,s))}return d}kt.decodePose=Do});var Oe=v(Lt=>{const ko=Bt(),No=Ot(),Ht=Ne();function Ut(e,t,{x:o,y:n},s){return e.some(({keypoints:i})=>{const a=i[s].position;return Ht.squaredDistance(n,o,a.y,a.x)<=t})}function Co(e,t,o){const n=o.reduce((s,{position:i,score:a},c)=>(Ut(e,t,i,c)||(s+=a),s),0);return n/o.length}const zo=1;function Oo(e,t,o,n,s,i,a=.5,c=20){const d=[],l=ko.buildPartWithScoreQueue(a,zo,e),h=c*c;for(;d.length<i&&!l.empty();){const p=l.dequeue(),u=Ht.getImageCoords(p.part,s,t);if(Ut(d,h,u,p.part.id))continue;const r=No.decodePose(p,e,t,s,o,n),x=Co(d,h,r);d.push({keypoints:r,score:x})}return d}Lt.decodeMultiplePoses=Oo});var Le=v(Z=>{const Lo=ce();function Ho(e,t,o){return e<o||t<o}function Uo(e,t){return Lo.connectedPartIndices.reduce((o,[n,s])=>(Ho(e[n].score,e[s].score,t)||o.push([e[n],e[s]]),o),[])}Z.getAdjacentKeyPoints=Uo;const{NEGATIVE_INFINITY:jt,POSITIVE_INFINITY:qt}=Number;function Xt(e){return e.reduce(({maxX:t,maxY:o,minX:n,minY:s},{position:{x:i,y:a}})=>({maxX:Math.max(t,i),maxY:Math.max(o,a),minX:Math.min(n,i),minY:Math.min(s,a)}),{maxX:jt,maxY:jt,minX:qt,minY:qt})}Z.getBoundingBox=Xt;function jo(e){const{minX:t,minY:o,maxX:n,maxY:s}=Xt(e);return[{x:t,y:o},{x:n,y:o},{x:n,y:s},{x:t,y:s}]}Z.getBoundingBoxPoints=jo;async function qo(e){return Promise.all(e.map(t=>t.buffer()))}Z.toTensorBuffers3D=qo;function Wt(e,t,o){return{score:e.score,keypoints:e.keypoints.map(({score:n,part:s,position:i})=>({score:n,part:s,position:{x:i.x*o,y:i.y*t}}))}}Z.scalePose=Wt;function Xo(e,[t,o]){const n=e.squeeze(0),s=n.resizeBilinear([t,o]);return n.dispose(),s}Z.resizeTo=Xo;function Wo(e,[t,o],[n,s]){const i=e.map(a=>Wt(a,t/n,o/s));return i}Z.scaleAndFlipPoses=Wo});var Yt=v(He=>{const Go=require("@tensorflow/tfjs"),Yo=Be(),Ko=Oe(),Ue=Le();class Gt{constructor(e){this.baseModel=e}async estimatePoses(e,t){const o=t.outputStride,n=e.shape[1],s=e.shape[2],i=Ue.resizeTo(e,[t.inputResolution,t.inputResolution]),{heatmapScores:a,offsets:c,displacementFwd:d,displacementBwd:l}=this.baseModel.predict(i),h=await Ue.toTensorBuffers3D([a,c,d,l]),p=h[0],u=h[1],r=h[2],x=h[3],T=await Ko.decodeMultiplePoses(p,u,r,x,o,t.maxDetections,t.scoreThreshold,t.nmsRadius),M=Ue.scaleAndFlipPoses(T,[n,s],[t.inputResolution,t.inputResolution]);return a.dispose(),c.dispose(),d.dispose(),l.dispose(),i.dispose(),M}dispose(){this.baseModel.dispose()}}He.PoseNet=Gt;async function Vo(e){const t=await Go.loadGraphModel(e.modelPath),o=new Yo.MobileNet(t,e.outputStride);return new Gt(o)}async function Qo(e){return Vo(e)}He.load=Qo});var Vt=v(D=>{const Zo=Be(),Kt=Yt(),$o=Oe(),fe=ce(),le=Le();D.load=Kt.load;D.PoseNet=Kt.PoseNet;D.MobileNet=Zo.MobileNet;D.decodeMultiplePoses=$o.decodeMultiplePoses;D.partChannels=fe.partChannels;D.partIds=fe.partIds;D.partNames=fe.partNames;D.poseChain=fe.poseChain;D.getAdjacentKeyPoints=le.getAdjacentKeyPoints;D.getBoundingBox=le.getBoundingBox;D.getBoundingBoxPoints=le.getBoundingBoxPoints;D.scaleAndFlipPoses=le.scaleAndFlipPoses;D.scalePose=le.scalePose});var Xe=v($=>{const Jo=require("@tensorflow/tfjs");function je(e){return[Math.abs(e.endPoint[0]-e.startPoint[0]),Math.abs(e.endPoint[1]-e.startPoint[1])]}$.getBoxSize=je;function qe(e){return[e.startPoint[0]+(e.endPoint[0]-e.startPoint[0])/2,e.startPoint[1]+(e.endPoint[1]-e.startPoint[1])/2]}$.getBoxCenter=qe;function en(e,t,o){const n=t.shape[1],s=t.shape[2],i=[[e.startPoint[1]/n,e.startPoint[0]/s,e.endPoint[1]/n,e.endPoint[0]/s]];return Jo.image.cropAndResize(t,i,[0],o)}$.cutBoxFromImageAndResize=en;function tn(e,t){const o=[e.startPoint[0]*t[0],e.startPoint[1]*t[1]],n=[e.endPoint[0]*t[0],e.endPoint[1]*t[1]],s=e.palmLandmarks.map(i=>{const a=[i[0]*t[0],i[1]*t[1]];return a});return{startPoint:o,endPoint:n,palmLandmarks:s}}$.scaleBoxCoordinates=tn;function on(e,t=1.5){const o=qe(e),n=je(e),s=[t*n[0]/2,t*n[1]/2],i=[o[0]-s[0],o[1]-s[1]],a=[o[0]+s[0],o[1]+s[1]];return{startPoint:i,endPoint:a,palmLandmarks:e.palmLandmarks}}$.enlargeBox=on;function nn(e){const t=qe(e),o=je(e),n=Math.max(...o),s=n/2,i=[t[0]-s,t[1]-s],a=[t[0]+s,t[1]+s];return{startPoint:i,endPoint:a,palmLandmarks:e.palmLandmarks}}$.squarifyBox=nn;function sn(e,t){const o=[e.endPoint[0]-e.startPoint[0],e.endPoint[1]-e.startPoint[1]],n=[o[0]*t[0],o[1]*t[1]],s=[e.startPoint[0]+n[0],e.startPoint[1]+n[1]],i=[e.endPoint[0]+n[0],e.endPoint[1]+n[1]];return{startPoint:s,endPoint:i,palmLandmarks:e.palmLandmarks}}$.shiftBox=sn});var Zt=v(Qt=>{const _=require("@tensorflow/tfjs"),rn=Xe();class an{constructor(e,t,o){this.model=e,this.width=o.inputSize,this.height=o.inputSize,this.anchors=t.map(n=>[n.x_center,n.y_center]),this.anchorsTensor=_.tensor2d(this.anchors),this.inputSizeTensor=_.tensor1d([o.inputSize,o.inputSize]),this.doubleInputSizeTensor=_.tensor1d([o.inputSize*2,o.inputSize*2])}normalizeBoxes(e){return _.tidy(()=>{const t=_.slice(e,[0,0],[-1,2]),o=_.slice(e,[0,2],[-1,2]),n=_.add(_.div(t,this.inputSizeTensor),this.anchorsTensor),s=_.div(o,this.doubleInputSizeTensor),i=_.mul(_.sub(n,s),this.inputSizeTensor),a=_.mul(_.add(n,s),this.inputSizeTensor);return _.concat2d([i,a],1)})}normalizeLandmarks(e,t){return _.tidy(()=>{const o=_.add(_.div(e.reshape([-1,7,2]),this.inputSizeTensor),this.anchors[t]);return _.mul(o,this.inputSizeTensor)})}async getBoundingBoxes(e){const t=this.model.predict(e),o=t.squeeze(),n=_.tidy(()=>_.sigmoid(_.slice(o,[0,0],[-1,1])).squeeze()),s=_.slice(o,[0,1],[-1,4]),i=this.normalizeBoxes(s),a=await _.image.nonMaxSuppressionAsync(i,n,this.maxHands,this.iouThreshold,this.scoreThreshold),c=await a.array(),d=[t,a,o,i,s,n],l=_.tidy(()=>{const h=[];for(const p in c){const u=c[p],r=_.slice(i,[u,0],[1,-1]),x=_.slice(o,[u,5],[1,14]),T=_.tidy(()=>this.normalizeLandmarks(x,u).reshape([-1,2]));h.push({boxes:r,palmLandmarks:T})}return h});return d.forEach(h=>h.dispose()),l}async estimateHandBounds(e,t){this.iouThreshold=t.iouThreshold,this.scoreThreshold=t.scoreThreshold,this.maxHands=t.maxHands;const o=e.resizeBilinear([this.width,this.height]),n=o.div(255),s=n.sub(.5),i=s.mul(2);o.dispose(),n.dispose(),s.dispose();const a=await this.getBoundingBoxes(i);if(i.dispose(),!a||a.length===0)return null;const c=[];for(const d in a){const l=a[d],h=await l.boxes.array(),p=h[0].slice(0,2),u=h[0].slice(2,4),r=await l.palmLandmarks.array();l.boxes.dispose(),l.palmLandmarks.dispose(),c.push(rn.scaleBoxCoordinates({startPoint:p,endPoint:u,palmLandmarks:r},[e.shape[2]/this.width,e.shape[1]/this.height]))}return c}}Qt.HandDetector=an});var Jt=v($t=>{$t.MESH_ANNOTATIONS={thumb:[1,2,3,4],indexFinger:[5,6,7,8],middleFinger:[9,10,11,12],ringFinger:[13,14,15,16],pinky:[17,18,19,20],palmBase:[0]}});var s0=v(J=>{function e0(e){return e-2*Math.PI*Math.floor((e+Math.PI)/(2*Math.PI))}J.normalizeRadians=e0;function cn(e,t){const o=Math.PI/2-Math.atan2(-(t[1]-e[1]),t[0]-e[0]);return e0(o)}J.computeRotation=cn;const t0=(e,t)=>[[1,0,e],[0,1,t],[0,0,1]];function ie(e,t){let o=0;for(let n=0;n<e.length;n++)o+=e[n]*t[n];return o}J.dot=ie;function o0(e,t){const o=[];for(let n=0;n<e.length;n++)o.push(e[n][t]);return o}J.getColumnFrom2DArr=o0;function n0(e,t){const o=[],n=e.length;for(let s=0;s<n;s++){o.push([]);for(let i=0;i<n;i++)o[s].push(ie(e[s],o0(t,i)))}return o}function dn(e,t){const o=Math.cos(e),n=Math.sin(e),s=[[o,-n,0],[n,o,0],[0,0,1]],i=t0(t[0],t[1]),a=n0(i,s),c=t0(-t[0],-t[1]);return n0(a,c)}J.buildRotationMatrix=dn;function ln(e){const t=[[e[0][0],e[1][0]],[e[0][1],e[1][1]]],o=[e[0][2],e[1][2]],n=[-ie(t[0],o),-ie(t[1],o)];return[t[0].concat(n[0]),t[1].concat(n[1]),[0,0,1]]}J.invertTransformMatrix=ln;function un(e,t){return[ie(e,t[0]),ie(e,t[1])]}J.rotatePoint=un});var c0=v(i0=>{const r0=require("@tensorflow/tfjs"),q=Xe(),ee=s0(),hn=.8,mn=[0,-.4],pn=[0,-.1],fn=1.65,a0=[0,5,9,13,17,1,2],gn=0,xn=2;class bn{constructor(e,t,o){this.regionsOfInterest=[],this.runsWithoutHandDetector=0,this.boundingBoxDetector=e,this.meshDetector=t,this.meshWidth=o.inputSize,this.meshHeight=o.inputSize,this.enlargeFactor=o.enlargeFactor}getBoxForPalmLandmarks(e,t){const o=e.map(s=>{const i=[...s,1];return ee.rotatePoint(i,t)}),n=this.calculateLandmarksBoundingBox(o);return q.enlargeBox(q.squarifyBox(q.shiftBox(n,mn)),this.enlargeFactor)}getBoxForHandLandmarks(e){const t=this.calculateLandmarksBoundingBox(e),o=q.enlargeBox(q.squarifyBox(q.shiftBox(t,pn)),fn),n=[];for(let s=0;s<a0.length;s++)n.push(e[a0[s]].slice(0,2));return o.palmLandmarks=n,o}transformRawCoords(e,t,o,n){const s=q.getBoxSize(t),i=[s[0]/this.meshWidth,s[1]/this.meshHeight],a=e.map(u=>[i[0]*(u[0]-this.meshWidth/2),i[1]*(u[1]-this.meshHeight/2),u[2]]),c=ee.buildRotationMatrix(o,[0,0]),d=a.map(u=>{const r=ee.rotatePoint(u,c);return[...r,u[2]]}),l=ee.invertTransformMatrix(n),h=[...q.getBoxCenter(t),1],p=[ee.dot(h,l[0]),ee.dot(h,l[1])];return d.map(u=>[u[0]+p[0],u[1]+p[1],u[2]])}async estimateHands(e,t){this.skipFrames=t.skipFrames,this.detectionConfidence=t.minConfidence,this.maxHands=t.maxHands,this.runsWithoutHandDetector++;const o=this.shouldUpdateRegionsOfInterest();if(o===!0){const s=await this.boundingBoxDetector.estimateHandBounds(e,t);this.regionsOfInterest=[];for(const i in s)this.updateRegionsOfInterest(s[i],!0,i);this.runsWithoutHandDetector=0}const n=[];if(!this.regionsOfInterest)return n;for(const s in this.regionsOfInterest){const i=this.regionsOfInterest[s][0];if(!i)return n;const a=ee.computeRotation(i.palmLandmarks[gn],i.palmLandmarks[xn]),c=q.getBoxCenter(i),d=[c[0]/e.shape[2],c[1]/e.shape[1]],l=r0.image.rotateWithOffset(e,a,0,d),h=ee.buildRotationMatrix(-a,c),p=o?this.getBoxForPalmLandmarks(i.palmLandmarks,h):i,u=q.cutBoxFromImageAndResize(p,l,[this.meshWidth,this.meshHeight]),r=u.div(255);u.dispose(),l.dispose();const x=this.meshDetector.predict(r),[T,M]=x;r.dispose();const P=T.dataSync()[0];if(T.dispose(),P<t.minConfidence)return M.dispose(),this.regionsOfInterest[s]=[],n;const w=r0.reshape(M,[-1,3]),k=await w.array();M.dispose(),w.dispose();const N=this.transformRawCoords(k,p,a,h),f=this.getBoxForHandLandmarks(N);this.updateRegionsOfInterest(f,!1,s);const b={landmarks:N,confidence:P,box:{topLeft:f.startPoint,bottomRight:f.endPoint}};n.push(b)}return n}calculateLandmarksBoundingBox(e){const t=e.map(i=>i[0]),o=e.map(i=>i[1]),n=[Math.min(...t),Math.min(...o)],s=[Math.max(...t),Math.max(...o)];return{startPoint:n,endPoint:s}}updateRegionsOfInterest(e,t,o){if(t)this.regionsOfInterest[o]=[e];else{const n=this.regionsOfInterest[o][0];let s=0;if(n!=null&&n.startPoint!=null){const[i,a]=e.startPoint,[c,d]=e.endPoint,[l,h]=n.startPoint,[p,u]=n.endPoint,r=Math.max(i,l),x=Math.max(a,h),T=Math.min(c,p),M=Math.min(d,u),P=(T-r)*(M-x),w=(c-i)*(d-a),k=(p-l)*(u-a);s=P/(w+k-P)}this.regionsOfInterest[o][0]=s>hn?n:e}}shouldUpdateRegionsOfInterest(){return!this.regionsOfInterest||this.regionsOfInterest.length===0||this.runsWithoutHandDetector>=this.skipFrames}}i0.HandPipeline=bn});var u0=v(We=>{const ge=require("@tensorflow/tfjs"),yn=Zt(),d0=Jt(),wn=c0();class l0{constructor(e){this.pipeline=e}async estimateHands(e,t){this.skipFrames=t.skipFrames,this.detectionConfidence=t.minConfidence,this.maxHands=t.maxHands;const o=await this.pipeline.estimateHands(e,t),n=[];if(!o)return n;for(const s of o){if(!s)return[];const i={};for(const a of Object.keys(d0.MESH_ANNOTATIONS))i[a]=d0.MESH_ANNOTATIONS[a].map(c=>s.landmarks[c]);n.push({confidence:s.confidence||0,box:s.box?[s.box.topLeft[0],s.box.topLeft[1],s.box.bottomRight[0]-s.box.topLeft[0],s.box.bottomRight[1]-s.box.topLeft[1]]:0,landmarks:s.landmarks,annotations:i})}return n}}We.HandPose=l0;async function En(e){if(ge.env().features.IS_NODE){const t=require("fs"),o=await t.readFileSync(e.replace("file://",""));return JSON.parse(o)}return ge.util.fetch(e).then(t=>t.json())}async function vn(e){const[t,o,n]=await Promise.all([En(e.detector.anchors),ge.loadGraphModel(e.detector.modelPath,{fromTFHub:e.detector.modelPath.includes("tfhub.dev")}),ge.loadGraphModel(e.skeleton.modelPath,{fromTFHub:e.skeleton.modelPath.includes("tfhub.dev")})]),s=new yn.HandDetector(o,t,e),i=new wn.HandPipeline(s,n,e),a=new l0(i);return a}We.load=vn});var m0=v(h0=>{const Pn=function(e,t,o){const n=function(c,d,l){const h=new RegExp("\\b"+d+" \\w+ (\\w+)","ig");c.replace(h,(p,u)=>(l[u]=0,p))},s=function(c,d,l){const h=c.createShader(l);if(c.shaderSource(h,d),c.compileShader(h),!c.getShaderParameter(h,c.COMPILE_STATUS))throw new Error("Filter: GL compile failed",c.getShaderInfoLog(h));return h};this.uniform={},this.attribute={};const i=s(e,t,e.VERTEX_SHADER),a=s(e,o,e.FRAGMENT_SHADER);if(this.id=e.createProgram(),e.attachShader(this.id,i),e.attachShader(this.id,a),e.linkProgram(this.id),!e.getProgramParameter(this.id,e.LINK_STATUS))throw new Error("Filter: GL link failed",e.getProgramInfoLog(this.id));e.useProgram(this.id),n(t,"attribute",this.attribute);for(const c in this.attribute)this.attribute[c]=e.getAttribLocation(this.id,c);n(t,"uniform",this.uniform),n(o,"uniform",this.uniform);for(const c in this.uniform)this.uniform[c]=e.getUniformLocation(this.id,c)},Tn=function(e){e||(e={});let t=0,o=null,n=!1,s=-1,i=[null,null],a=[],c=-1,d=-1,l=null,h=null;const p=e.canvas||document.createElement("canvas"),u={},r=p.getContext("webgl")||p.getContext("experimental-webgl");if(!r)throw new Error("Filter: getContext() failed");this.addFilter=function(b){const m=Array.prototype.slice.call(arguments,1),y=f[b];a.push({func:y,args:m})},this.reset=function(){a=[]},this.apply=function(b){if(x(b.width,b.height),t=0,o||(o=r.createTexture()),r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,b),a.length===0){const m=w(N.FRAGMENT_IDENTITY);return P(),p}for(let m=0;m<a.length;m++){n=m===a.length-1;const y=a[m];y.func.apply(this,y.args||[])}return p};const x=function(b,m){if(b===c&&m===d)return;if(p.width=c=b,p.height=d=m,!l){const y=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,-1,1,0,0,1,-1,1,1,1,1,1,0]);l=r.createBuffer(),r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,y,r.STATIC_DRAW),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0)}r.viewport(0,0,c,d),i=[null,null]},T=function(b){return i[b]=i[b]||M(c,d),i[b]},M=function(b,m){const y=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,y);const I=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,I);const A=r.createTexture();return r.bindTexture(r.TEXTURE_2D,A),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,b,m,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,A,0),r.bindTexture(r.TEXTURE_2D,null),r.bindFramebuffer(r.FRAMEBUFFER,null),{fbo:y,texture:A}},P=function(b){let m=null,y=null,I=!1;t===0?m=o:m=T(s).texture,t++,n&&!(b&k.INTERMEDIATE)?(y=null,I=t%2===0):(s=(s+1)%2,y=T(s).fbo),r.bindTexture(r.TEXTURE_2D,m),r.bindFramebuffer(r.FRAMEBUFFER,y),r.uniform1f(h.uniform.flipY,I?-1:1),r.drawArrays(r.TRIANGLES,0,6)},w=function(b){if(u[b])return h=u[b],r.useProgram(h.id),h;h=new Pn(r,N.VERTEX_IDENTITY,b);const m=Float32Array.BYTES_PER_ELEMENT,y=4*m;return r.enableVertexAttribArray(h.attribute.pos),r.vertexAttribPointer(h.attribute.pos,2,r.FLOAT,!1,y,0*m),r.enableVertexAttribArray(h.attribute.uv),r.vertexAttribPointer(h.attribute.uv,2,r.FLOAT,!1,y,2*m),u[b]=h,h};let k={INTERMEDIATE:1},N={};N.VERTEX_IDENTITY=["precision highp float;","attribute vec2 pos;","attribute vec2 uv;","varying vec2 vUv;","uniform float flipY;","void main(void) {","vUv = uv;","gl_Position = vec4(pos.x, pos.y*flipY, 0.0, 1.);","}"].join(`
|
|
`),N.FRAGMENT_IDENTITY=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","void main(void) {","gl_FragColor = texture2D(texture, vUv);","}"].join(`
|
|
`);let f={};f.colorMatrix=function(b){const m=new Float32Array(b);m[4]/=255,m[9]/=255,m[14]/=255,m[19]/=255;const y=m[18]===1&&m[3]===0&&m[8]===0&&m[13]===0&&m[15]===0&&m[16]===0&&m[17]===0&&m[19]===0?f.colorMatrix.SHADER.WITHOUT_ALPHA:f.colorMatrix.SHADER.WITH_ALPHA,I=w(y);r.uniform1fv(I.uniform.m,m),P()},f.colorMatrix.SHADER={},f.colorMatrix.SHADER.WITH_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[3] * c.a + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[8] * c.a + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[13] * c.a + m[14];","gl_FragColor.a = m[15] * c.r + m[16] * c.g + m[17] * c.b + m[18] * c.a + m[19];","}"].join(`
|
|
`),f.colorMatrix.SHADER.WITHOUT_ALPHA=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform float m[20];","void main(void) {","vec4 c = texture2D(texture, vUv);","gl_FragColor.r = m[0] * c.r + m[1] * c.g + m[2] * c.b + m[4];","gl_FragColor.g = m[5] * c.r + m[6] * c.g + m[7] * c.b + m[9];","gl_FragColor.b = m[10] * c.r + m[11] * c.g + m[12] * c.b + m[14];","gl_FragColor.a = c.a;","}"].join(`
|
|
`),f.brightness=function(b){const m=(b||0)+1;f.colorMatrix([m,0,0,0,0,0,m,0,0,0,0,0,m,0,0,0,0,0,1,0])},f.saturation=function(b){const m=(b||0)*2/3+1,y=(m-1)*-.5;f.colorMatrix([m,y,y,0,0,y,m,y,0,0,y,y,m,0,0,0,0,0,1,0])},f.desaturate=function(){f.saturation(-1)},f.contrast=function(b){const m=(b||0)+1,y=-128*(m-1);f.colorMatrix([m,0,0,0,y,0,m,0,0,y,0,0,m,0,y,0,0,0,1,0])},f.negative=function(){f.contrast(-2)},f.hue=function(b){b=(b||0)/180*Math.PI;const m=Math.cos(b),y=Math.sin(b),I=.213,A=.715,U=.072;f.colorMatrix([I+m*(1-I)+y*-I,A+m*-A+y*-A,U+m*-U+y*(1-U),0,0,I+m*-I+y*.143,A+m*(1-A)+y*.14,U+m*-U+y*-.283,0,0,I+m*-I+y*-(1-I),A+m*-A+y*A,U+m*(1-U)+y*U,0,0,0,0,0,1,0])},f.desaturateLuminance=function(){f.colorMatrix([.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,.2764723,.929708,.0938197,0,-37.1,0,0,0,1,0])},f.sepia=function(){f.colorMatrix([.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0])},f.brownie=function(){f.colorMatrix([.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0])},f.vintagePinhole=function(){f.colorMatrix([.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0])},f.kodachrome=function(){f.colorMatrix([1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0])},f.technicolor=function(){f.colorMatrix([1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0])},f.polaroid=function(){f.colorMatrix([1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0])},f.shiftToBGR=function(){f.colorMatrix([0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0])},f.convolution=function(b){const m=new Float32Array(b),y=1/c,I=1/d,A=w(f.convolution.SHADER);r.uniform1fv(A.uniform.m,m),r.uniform2f(A.uniform.px,y,I),P()},f.convolution.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","uniform float m[9];","void main(void) {","vec4 c11 = texture2D(texture, vUv - px);","vec4 c12 = texture2D(texture, vec2(vUv.x, vUv.y - px.y));","vec4 c13 = texture2D(texture, vec2(vUv.x + px.x, vUv.y - px.y));","vec4 c21 = texture2D(texture, vec2(vUv.x - px.x, vUv.y) );","vec4 c22 = texture2D(texture, vUv);","vec4 c23 = texture2D(texture, vec2(vUv.x + px.x, vUv.y) );","vec4 c31 = texture2D(texture, vec2(vUv.x - px.x, vUv.y + px.y) );","vec4 c32 = texture2D(texture, vec2(vUv.x, vUv.y + px.y) );","vec4 c33 = texture2D(texture, vUv + px );","gl_FragColor = ","c11 * m[0] + c12 * m[1] + c22 * m[2] +","c21 * m[3] + c22 * m[4] + c23 * m[5] +","c31 * m[6] + c32 * m[7] + c33 * m[8];","gl_FragColor.a = c22.a;","}"].join(`
|
|
`),f.detectEdges=function(){f.convolution.call(this,[0,1,0,1,-4,1,0,1,0])},f.sobelX=function(){f.convolution.call(this,[-1,0,1,-2,0,2,-1,0,1])},f.sobelY=function(){f.convolution.call(this,[-1,-2,-1,0,0,0,1,2,1])},f.sharpen=function(b){const m=b||1;f.convolution.call(this,[0,-1*m,0,-1*m,1+4*m,-1*m,0,-1*m,0])},f.emboss=function(b){const m=b||1;f.convolution.call(this,[-2*m,-1*m,0,-1*m,1,1*m,0,1*m,2*m])},f.blur=function(b){const m=b/7/c,y=b/7/d,I=w(f.blur.SHADER);r.uniform2f(I.uniform.px,0,y),P(k.INTERMEDIATE),r.uniform2f(I.uniform.px,m,0),P()},f.blur.SHADER=["precision highp float;","varying vec2 vUv;","uniform sampler2D texture;","uniform vec2 px;","void main(void) {","gl_FragColor = vec4(0.0);","gl_FragColor += texture2D(texture, vUv + vec2(-7.0*px.x, -7.0*px.y))*0.0044299121055113265;","gl_FragColor += texture2D(texture, vUv + vec2(-6.0*px.x, -6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2(-5.0*px.x, -5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2(-4.0*px.x, -4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2(-3.0*px.x, -3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2(-2.0*px.x, -2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2(-1.0*px.x, -1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv )*0.159576912161;","gl_FragColor += texture2D(texture, vUv + vec2( 1.0*px.x, 1.0*px.y))*0.147308056121;","gl_FragColor += texture2D(texture, vUv + vec2( 2.0*px.x, 2.0*px.y))*0.115876621105;","gl_FragColor += texture2D(texture, vUv + vec2( 3.0*px.x, 3.0*px.y))*0.0776744219933;","gl_FragColor += texture2D(texture, vUv + vec2( 4.0*px.x, 4.0*px.y))*0.0443683338718;","gl_FragColor += texture2D(texture, vUv + vec2( 5.0*px.x, 5.0*px.y))*0.0215963866053;","gl_FragColor += texture2D(texture, vUv + vec2( 6.0*px.x, 6.0*px.y))*0.00895781211794;","gl_FragColor += texture2D(texture, vUv + vec2( 7.0*px.x, 7.0*px.y))*0.0044299121055113265;","}"].join(`
|
|
`),f.pixelate=function(b){const m=b/c,y=b/d,I=w(f.pixelate.SHADER);r.uniform2f(I.uniform.size,m,y),P()},f.pixelate.SHADER=["precision highp float;","varying vec2 vUv;","uniform vec2 size;","uniform sampler2D texture;","vec2 pixelate(vec2 coord, vec2 size) {","return floor( coord / size ) * size;","}","void main(void) {","gl_FragColor = vec4(0.0);","vec2 coord = pixelate(vUv, size);","gl_FragColor += texture2D(texture, coord);","}"].join(`
|
|
`)};h0.Canvas=Tn});var p0=v(_n=>{Je(_n,{default:()=>Mn});var Mn={backend:"webgl",console:!0,scoped:!1,videoOptimized:!0,filter:{enabled:!0,return:!0,brightness:0,contrast:0,sharpness:0,blur:0,saturation:0,hue:0,negative:!1,sepia:!1,vintage:!1,kodachrome:!1,technicolor:!1,polaroid:!1,pixelate:0},face:{enabled:!0,detector:{modelPath:"../models/blazeface/back/model.json",inputSize:256,maxFaces:10,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.7},mesh:{enabled:!0,modelPath:"../models/facemesh/model.json",inputSize:192},iris:{enabled:!0,modelPath:"../models/iris/model.json",enlargeFactor:2.3,inputSize:64},age:{enabled:!0,modelPath:"../models/ssrnet-age/imdb/model.json",inputSize:64,skipFrames:10},gender:{enabled:!0,minConfidence:.8,modelPath:"../models/ssrnet-gender/imdb/model.json"},emotion:{enabled:!0,inputSize:64,minConfidence:.5,skipFrames:10,modelPath:"../models/emotion/model.json"}},body:{enabled:!0,modelPath:"../models/posenet/model.json",inputResolution:257,outputStride:16,maxDetections:10,scoreThreshold:.7,nmsRadius:20},hand:{enabled:!0,inputSize:256,skipFrames:10,minConfidence:.5,iouThreshold:.3,scoreThreshold:.7,enlargeFactor:1.65,maxHands:10,detector:{anchors:"../models/handdetect/anchors.json",modelPath:"../models/handdetect/model.json"},skeleton:{modelPath:"../models/handskeleton/model.json"}}}});var g0=v((us,f0)=>{f0.exports={name:"@vladmandic/human",version:"0.3.9",description:"human: 3D Face Detection, Iris Tracking and Age & Gender Prediction",sideEffects:!1,main:"dist/human.cjs",module:"dist/human.esm.js",browser:"dist/human.esm.js",author:"Vladimir Mandic <mandic00@live.com>",bugs:{url:"https://github.com/vladmandic/human/issues"},homepage:"https://github.com/vladmandic/human#readme",license:"MIT",engines:{node:">=14.0.0"},repository:{type:"git",url:"git+https://github.com/vladmandic/human.git"},dependencies:{},peerDependencies:{},devDependencies:{"@vladmandic/pilogger":"^0.2.6",dayjs:"^1.9.3","simple-git":"^2.21.0","@tensorflow/tfjs":"^2.6.0","@tensorflow/tfjs-node":"^2.6.0",esbuild:"^0.7.15",eslint:"^7.10.0","eslint-config-airbnb-base":"^14.2.0","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.2","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.2.1",rimraf:"^3.0.2"},scripts:{start:"node --trace-warnings --unhandled-rejections=strict --trace-uncaught --no-deprecation src/node.js",lint:"eslint src/*.js demo/*.js","build-iife":"esbuild --bundle --platform=browser --sourcemap --target=esnext --format=iife --minify --external:fs --global-name=human --metafile=dist/human.json --outfile=dist/human.js src/human.js","build-esm-bundle":"esbuild --bundle --platform=browser --sourcemap --target=esnext --format=esm --minify --external:fs --metafile=dist/human.esm.json --outfile=dist/human.esm.js src/human.js","build-esm-nobundle":"esbuild --bundle --platform=browser --sourcemap --target=esnext --format=esm --minify --external:@tensorflow --external:fs --metafile=dist/human.esm-nobundle.json --outfile=dist/human.esm-nobundle.js src/human.js","build-node":"esbuild --bundle --platform=node --sourcemap --target=esnext --format=cjs --external:@tensorflow --metafile=dist/human.cjs.json --outfile=dist/human.cjs src/human.js",build:"rimraf dist/* && npm run build-iife && npm run build-esm-bundle && npm run build-esm-nobundle && npm run build-node && ls -l dist/",update:"npm update --depth 20 && npm dedupe && npm prune && npm audit",changelog:"node changelog.js"},keywords:["tensorflowjs","face-detection","face-geometry","body-tracking","hand-tracking","iris-tracking","age-estimation","emotion-detection","gender-prediction","gesture-recognition"]}});var v0=v(z=>{const B=require("@tensorflow/tfjs"),x0=bt(),xe=wt(),b0=Pt(),y0=Vt(),w0=u0(),In=m0(),Ge=p0().default,Sn=g0();let g,R,H="idle",re;const F={facemesh:null,posenet:null,handpose:null,iris:null,age:null,gender:null,emotion:null},Rn={face:{detector:{skipFrames:0},age:{skipFrames:0},emotion:{skipFrames:0}},hand:{skipFrames:0}},S=()=>typeof performance!="undefined"?performance.now():parseInt(Number(process.hrtime.bigint())/1e3/1e3),C=(...e)=>{e&&g.console&&console.log(...e)};let E0=0;const An=!1,te=(...e)=>{if(!An)return;const t=B.engine().state.numTensors,o=E0;E0=t;const n=t-o;n!==0&&C(...e,n)};function be(...e){const t=o=>o&&typeof o=="object";return e.reduce((o,n)=>(Object.keys(n||{}).forEach(s=>{const i=o[s],a=n[s];Array.isArray(i)&&Array.isArray(a)?o[s]=i.concat(...a):t(i)&&t(a)?o[s]=be(i,a):o[s]=a}),o),{})}function Fn(e){if(!e)return"input is not defined";if(B.ENV.flags.IS_NODE&&!(e instanceof B.Tensor))return"input must be a tensor";try{B.getBackend()}catch{return"backend not loaded"}return null}async function Bn(e){e&&(g=be(Ge,e)),g.face.enabled&&!F.facemesh&&(C("Load model: Face"),F.facemesh=await x0.load(g.face)),g.body.enabled&&!F.posenet&&(C("Load model: Body"),F.posenet=await y0.load(g.body)),g.hand.enabled&&!F.handpose&&(C("Load model: Hand"),F.handpose=await w0.load(g.hand)),g.face.enabled&&g.face.age.enabled&&!F.age&&(C("Load model: Age"),F.age=await xe.loadAge(g)),g.face.enabled&&g.face.gender.enabled&&!F.gender&&(C("Load model: Gender"),F.gender=await xe.loadGender(g)),g.face.enabled&&g.face.emotion.enabled&&!F.emotion&&(C("Load model: Emotion"),F.emotion=await b0.load(g))}function Dn(e){let t;if(B.ENV.flags.IS_BROWSER&&g.filter.enabled&&!(e instanceof B.Tensor)){const n=e.naturalWidth||e.videoWidth||e.width||e.shape&&e.shape[1]>0,s=e.naturalHeight||e.videoHeight||e.height||e.shape&&e.shape[2]>0;re||(re=new OffscreenCanvas(n,s));const i=re.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,n,s,0,0,re.width,re.height),R?R.reset():R=new In.Canvas,R.addFilter("brightness",g.filter.brightness),g.filter.contrast!==0&&R.addFilter("contrast",g.filter.contrast),g.filter.sharpness!==0&&R.addFilter("sharpen",g.filter.sharpness),g.filter.blur!==0&&R.addFilter("blur",g.filter.blur),g.filter.saturation!==0&&R.addFilter("saturation",g.filter.saturation),g.filter.hue!==0&&R.addFilter("hue",g.filter.hue),g.filter.negative&&R.addFilter("negative"),g.filter.sepia&&R.addFilter("sepia"),g.filter.vintage&&R.addFilter("brownie"),g.filter.sepia&&R.addFilter("sepia"),g.filter.kodachrome&&R.addFilter("kodachrome"),g.filter.technicolor&&R.addFilter("technicolor"),g.filter.polaroid&&R.addFilter("polaroid"),g.filter.pixelate!==0&&R.addFilter("pixelate",g.filter.pixelate),t=R.apply(re)}let o;if(e instanceof B.Tensor)o=B.clone(e);else{const n=B.browser.fromPixels(t||e),s=n.toFloat();o=s.expandDims(0),n.dispose(),s.dispose()}return{tensor:o,canvas:g.filter.return?t:null}}async function kn(e,t={}){H="config";const o={};let n;n=S(),g=be(Ge,t),g.videoOptimized||(g=be(g,Rn)),o.config=Math.trunc(S()-n),n=S(),H="check";const s=Fn(e);return s?(C(s,e),{error:s}):(o.sanity=Math.trunc(S()-n),new Promise(async i=>{const a=S();n=S(),B.getBackend()!==g.backend&&(H="backend",C("Human library setting backend:",g.backend),await B.setBackend(g.backend),await B.ready()),o.backend=Math.trunc(S()-n);const c=Object.values(F).filter(r=>r).length;c===0&&(C("Human library starting"),C("Configuration:",g),C("Flags:",B.ENV.flags)),n=S(),H="load",await Bn(),o.load=Math.trunc(S()-n),g.scoped&&B.engine().startScope(),te("Start Detect:"),n=S();const d=Dn(e);o.image=Math.trunc(S()-n);const l=d.tensor;H="run:body",n=S(),te("Start PoseNet");const h=g.body.enabled?await F.posenet.estimatePoses(l,g.body):[];te("End PoseNet:"),o.body=Math.trunc(S()-n),H="run:hand",n=S(),te("Start HandPose:");const p=g.hand.enabled?await F.handpose.estimateHands(l,g.hand):[];te("End HandPose:"),o.hand=Math.trunc(S()-n);const u=[];if(g.face.enabled){H="run:face",n=S(),te("Start FaceMesh:");const r=await F.facemesh.estimateFaces(l,g.face);o.face=Math.trunc(S()-n);for(const x of r){if(!x.image||x.image.isDisposedInternal){C("face object is disposed:",x.image);continue}H="run:agegender",n=S();const T=g.face.age.enabled||g.face.gender.enabled?await xe.predict(x.image,g):{};o.agegender=Math.trunc(S()-n),H="run:emotion",n=S();const M=g.face.emotion.enabled?await b0.predict(x.image,g):{};o.emotion=Math.trunc(S()-n),x.image.dispose();const P=x.annotations.leftEyeIris&&x.annotations.rightEyeIris?Math.max(x.annotations.leftEyeIris[3][0]-x.annotations.leftEyeIris[1][0],x.annotations.rightEyeIris[3][0]-x.annotations.rightEyeIris[1][0]):0;u.push({confidence:x.confidence,box:x.box,mesh:x.mesh,annotations:x.annotations,age:T.age,gender:T.gender,agConfidence:T.confidence,emotion:M,iris:P!==0?Math.trunc(100*11.7/P)/100:0}),te("End FaceMesh:")}}l.dispose(),H="idle",g.scoped&&B.engine().endScope(),te("End Scope:"),o.total=Math.trunc(S()-a),i({face:u,body:h,hand:p,performance:o,canvas:d.canvas})}))}z.detect=kn;z.defaults=Ge;z.config=g;z.models=F;z.facemesh=x0;z.ssrnet=xe;z.posenet=y0;z.handpose=w0;z.tf=B;z.version=Sn.version;z.state=H});export default v0();
|
|
//# sourceMappingURL=human.esm-nobundle.js.map
|