UNPKG

webgazer4soprabanking

Version:

WebGazer.js is an eye tracking library that uses common webcams to infer the eye-gaze locations of web visitors on a page in real time. The eye tracking model it contains self-calibrates by watching web visitors interact with the web page and trains a map

142 lines 1.92 MB
/*! * * WebGazer.js: Scalable Webcam EyeTracking Using User Interactions * Copyright (c) 2016-2020, Brown HCI Group * Licensed under GPLv3. Companies with a valuation of less than $1M can use WebGazer.js under LGPLv3. * */ var webgazer=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=301)}([function(e,t,n){"use strict";n.r(t),n.d(t,"AdadeltaOptimizer",(function(){return ut})),n.d(t,"AdagradOptimizer",(function(){return lt})),n.d(t,"AdamOptimizer",(function(){return pt})),n.d(t,"AdamaxOptimizer",(function(){return bt})),n.d(t,"MomentumOptimizer",(function(){return yt})),n.d(t,"Optimizer",(function(){return ot})),n.d(t,"RMSPropOptimizer",(function(){return vt})),n.d(t,"SGDOptimizer",(function(){return gt})),n.d(t,"Tensor",(function(){return X.a})),n.d(t,"TensorBuffer",(function(){return X.b})),n.d(t,"Variable",(function(){return X.c})),n.d(t,"Rank",(function(){return xt.a})),n.d(t,"sumOutType",(function(){return xt.b})),n.d(t,"upcastType",(function(){return xt.c})),n.d(t,"abs",(function(){return wt.b})),n.d(t,"acos",(function(){return wt.c})),n.d(t,"acosh",(function(){return wt.d})),n.d(t,"add",(function(){return wt.e})),n.d(t,"addN",(function(){return wt.f})),n.d(t,"all",(function(){return wt.h})),n.d(t,"any",(function(){return wt.i})),n.d(t,"argMax",(function(){return wt.j})),n.d(t,"argMin",(function(){return wt.k})),n.d(t,"asin",(function(){return wt.l})),n.d(t,"asinh",(function(){return wt.m})),n.d(t,"atan",(function(){return wt.n})),n.d(t,"atan2",(function(){return wt.o})),n.d(t,"atanh",(function(){return wt.p})),n.d(t,"avgPool",(function(){return wt.q})),n.d(t,"avgPool3d",(function(){return wt.r})),n.d(t,"basicLSTMCell",(function(){return wt.s})),n.d(t,"batchToSpaceND",(function(){return wt.x})),n.d(t,"batchNorm",(function(){return wt.t})),n.d(t,"batchNorm2d",(function(){return wt.u})),n.d(t,"batchNorm3d",(function(){return wt.v})),n.d(t,"batchNorm4d",(function(){return wt.w})),n.d(t,"bincount",(function(){return wt.y})),n.d(t,"broadcastTo",(function(){return wt.A})),n.d(t,"buffer",(function(){return wt.B})),n.d(t,"cast",(function(){return wt.C})),n.d(t,"ceil",(function(){return wt.D})),n.d(t,"clipByValue",(function(){return wt.E})),n.d(t,"clone",(function(){return wt.F})),n.d(t,"complex",(function(){return wt.G})),n.d(t,"concat",(function(){return wt.H})),n.d(t,"concat1d",(function(){return wt.I})),n.d(t,"concat2d",(function(){return wt.J})),n.d(t,"concat3d",(function(){return wt.K})),n.d(t,"concat4d",(function(){return wt.L})),n.d(t,"conv1d",(function(){return wt.M})),n.d(t,"conv2d",(function(){return wt.N})),n.d(t,"conv2dTranspose",(function(){return wt.O})),n.d(t,"conv3d",(function(){return wt.P})),n.d(t,"conv3dTranspose",(function(){return wt.Q})),n.d(t,"cos",(function(){return wt.R})),n.d(t,"cosh",(function(){return wt.S})),n.d(t,"cumsum",(function(){return wt.U})),n.d(t,"denseBincount",(function(){return wt.V})),n.d(t,"depthToSpace",(function(){return wt.W})),n.d(t,"depthwiseConv2d",(function(){return wt.X})),n.d(t,"diag",(function(){return wt.Y})),n.d(t,"dilation2d",(function(){return wt.Z})),n.d(t,"div",(function(){return wt.ab})),n.d(t,"divNoNan",(function(){return wt.bb})),n.d(t,"dot",(function(){return wt.db})),n.d(t,"elu",(function(){return wt.fb})),n.d(t,"equal",(function(){return wt.hb})),n.d(t,"erf",(function(){return wt.jb})),n.d(t,"exp",(function(){return wt.kb})),n.d(t,"expandDims",(function(){return wt.lb})),n.d(t,"expm1",(function(){return wt.mb})),n.d(t,"eye",(function(){return wt.nb})),n.d(t,"fill",(function(){return wt.pb})),n.d(t,"floor",(function(){return wt.qb})),n.d(t,"floorDiv",(function(){return wt.rb})),n.d(t,"gather",(function(){return wt.tb})),n.d(t,"greater",(function(){return wt.vb})),n.d(t,"greaterEqual",(function(){return wt.wb})),n.d(t,"imag",(function(){return wt.Ab})),n.d(t,"isFinite",(function(){return wt.Eb})),n.d(t,"isInf",(function(){return wt.Fb})),n.d(t,"isNaN",(function(){return wt.Gb})),n.d(t,"leakyRelu",(function(){return wt.Hb})),n.d(t,"less",(function(){return wt.Ib})),n.d(t,"lessEqual",(function(){return wt.Jb})),n.d(t,"linspace",(function(){return wt.Nb})),n.d(t,"localResponseNormalization",(function(){return wt.Ob})),n.d(t,"log",(function(){return wt.Pb})),n.d(t,"log1p",(function(){return wt.Qb})),n.d(t,"logSigmoid",(function(){return wt.Rb})),n.d(t,"logSoftmax",(function(){return wt.Sb})),n.d(t,"logSumExp",(function(){return wt.Tb})),n.d(t,"logicalAnd",(function(){return wt.Ub})),n.d(t,"logicalNot",(function(){return wt.Vb})),n.d(t,"logicalOr",(function(){return wt.Wb})),n.d(t,"logicalXor",(function(){return wt.Xb})),n.d(t,"matMul",(function(){return wt.Zb})),n.d(t,"max",(function(){return wt.ac})),n.d(t,"maxPool",(function(){return wt.bc})),n.d(t,"maxPool3d",(function(){return wt.cc})),n.d(t,"maxPoolWithArgmax",(function(){return wt.dc})),n.d(t,"maximum",(function(){return wt.ec})),n.d(t,"mean",(function(){return wt.gc})),n.d(t,"min",(function(){return wt.hc})),n.d(t,"minimum",(function(){return wt.ic})),n.d(t,"mirrorPad",(function(){return wt.kc})),n.d(t,"mod",(function(){return wt.lc})),n.d(t,"moments",(function(){return wt.nc})),n.d(t,"mul",(function(){return wt.pc})),n.d(t,"multiRNNCell",(function(){return wt.rc})),n.d(t,"multinomial",(function(){return wt.sc})),n.d(t,"neg",(function(){return wt.tc})),n.d(t,"notEqual",(function(){return wt.vc})),n.d(t,"oneHot",(function(){return wt.xc})),n.d(t,"ones",(function(){return wt.yc})),n.d(t,"onesLike",(function(){return wt.zc})),n.d(t,"outerProduct",(function(){return wt.Bc})),n.d(t,"pad",(function(){return wt.Cc})),n.d(t,"pad1d",(function(){return wt.Dc})),n.d(t,"pad2d",(function(){return wt.Ec})),n.d(t,"pad3d",(function(){return wt.Fc})),n.d(t,"pad4d",(function(){return wt.Gc})),n.d(t,"pool",(function(){return wt.Hc})),n.d(t,"pow",(function(){return wt.Ic})),n.d(t,"prelu",(function(){return wt.Kc})),n.d(t,"print",(function(){return wt.Lc})),n.d(t,"prod",(function(){return wt.Mc})),n.d(t,"rand",(function(){return wt.Nc})),n.d(t,"randomGamma",(function(){return wt.Oc})),n.d(t,"randomNormal",(function(){return wt.Pc})),n.d(t,"randomUniform",(function(){return wt.Qc})),n.d(t,"range",(function(){return wt.Rc})),n.d(t,"real",(function(){return wt.Sc})),n.d(t,"reciprocal",(function(){return wt.Tc})),n.d(t,"relu",(function(){return wt.Uc})),n.d(t,"relu6",(function(){return wt.Vc})),n.d(t,"reshape",(function(){return wt.Wc})),n.d(t,"reverse",(function(){return wt.Xc})),n.d(t,"reverse1d",(function(){return wt.Yc})),n.d(t,"reverse2d",(function(){return wt.Zc})),n.d(t,"reverse3d",(function(){return wt.ad})),n.d(t,"reverse4d",(function(){return wt.bd})),n.d(t,"round",(function(){return wt.dd})),n.d(t,"rsqrt",(function(){return wt.ed})),n.d(t,"scalar",(function(){return wt.fd})),n.d(t,"selu",(function(){return wt.hd})),n.d(t,"separableConv2d",(function(){return wt.id})),n.d(t,"setdiff1dAsync",(function(){return wt.jd})),n.d(t,"sigmoid",(function(){return wt.kd})),n.d(t,"sign",(function(){return wt.ld})),n.d(t,"sin",(function(){return wt.nd})),n.d(t,"sinh",(function(){return wt.od})),n.d(t,"slice",(function(){return wt.pd})),n.d(t,"slice1d",(function(){return wt.qd})),n.d(t,"slice2d",(function(){return wt.rd})),n.d(t,"slice3d",(function(){return wt.sd})),n.d(t,"slice4d",(function(){return wt.td})),n.d(t,"softmax",(function(){return wt.ud})),n.d(t,"softplus",(function(){return wt.vd})),n.d(t,"spaceToBatchND",(function(){return wt.wd})),n.d(t,"fft",(function(){return wt.ob})),n.d(t,"ifft",(function(){return wt.zb})),n.d(t,"irfft",(function(){return wt.Db})),n.d(t,"rfft",(function(){return wt.cd})),n.d(t,"split",(function(){return wt.zd})),n.d(t,"sqrt",(function(){return wt.Ad})),n.d(t,"square",(function(){return wt.Bd})),n.d(t,"squaredDifference",(function(){return wt.Cd})),n.d(t,"squeeze",(function(){return wt.Ed})),n.d(t,"stack",(function(){return wt.Fd})),n.d(t,"step",(function(){return wt.Gd})),n.d(t,"stridedSlice",(function(){return wt.Hd})),n.d(t,"sub",(function(){return wt.Id})),n.d(t,"sum",(function(){return wt.Kd})),n.d(t,"tan",(function(){return wt.Ld})),n.d(t,"tanh",(function(){return wt.Md})),n.d(t,"tensor",(function(){return wt.Nd})),n.d(t,"tensor1d",(function(){return wt.Od})),n.d(t,"tensor2d",(function(){return wt.Pd})),n.d(t,"tensor3d",(function(){return wt.Qd})),n.d(t,"tensor4d",(function(){return wt.Rd})),n.d(t,"tensor5d",(function(){return wt.Sd})),n.d(t,"tensor6d",(function(){return wt.Td})),n.d(t,"tile",(function(){return wt.Ud})),n.d(t,"topk",(function(){return wt.Vd})),n.d(t,"truncatedNormal",(function(){return wt.Xd})),n.d(t,"unique",(function(){return wt.Yd})),n.d(t,"unsortedSegmentSum",(function(){return wt.Zd})),n.d(t,"unstack",(function(){return wt.ae})),n.d(t,"variable",(function(){return wt.be})),n.d(t,"where",(function(){return wt.ce})),n.d(t,"whereAsync",(function(){return wt.de})),n.d(t,"zeros",(function(){return wt.ee})),n.d(t,"zerosLike",(function(){return wt.fe})),n.d(t,"booleanMaskAsync",(function(){return wt.z})),n.d(t,"equalStrict",(function(){return wt.ib})),n.d(t,"greaterEqualStrict",(function(){return wt.xb})),n.d(t,"greaterStrict",(function(){return wt.yb})),n.d(t,"lessEqualStrict",(function(){return wt.Kb})),n.d(t,"lessStrict",(function(){return wt.Lb})),n.d(t,"notEqualStrict",(function(){return wt.wc})),n.d(t,"addStrict",(function(){return wt.g})),n.d(t,"divStrict",(function(){return wt.cb})),n.d(t,"maximumStrict",(function(){return wt.fc})),n.d(t,"minimumStrict",(function(){return wt.jc})),n.d(t,"modStrict",(function(){return wt.mc})),n.d(t,"mulStrict",(function(){return wt.qc})),n.d(t,"powStrict",(function(){return wt.Jc})),n.d(t,"squaredDifferenceStrict",(function(){return wt.Dd})),n.d(t,"subStrict",(function(){return wt.Jd})),n.d(t,"transpose",(function(){return wt.Wd})),n.d(t,"norm",(function(){return wt.uc})),n.d(t,"movingAverage",(function(){return wt.oc})),n.d(t,"scatterND",(function(){return wt.gd})),n.d(t,"sparseToDense",(function(){return wt.xd})),n.d(t,"gatherND",(function(){return wt.ub})),n.d(t,"dropout",(function(){return wt.eb})),n.d(t,"enclosingPowerOfTwo",(function(){return wt.gb})),n.d(t,"cosineWindow",(function(){return wt.T})),n.d(t,"inTopKAsync",(function(){return wt.Cb})),n.d(t,"op",(function(){return wt.Ac})),n.d(t,"OP_SCOPE_SUFFIX",(function(){return wt.a})),n.d(t,"image",(function(){return wt.Bb})),n.d(t,"linalg",(function(){return wt.Mb})),n.d(t,"losses",(function(){return wt.Yb})),n.d(t,"spectral",(function(){return wt.yd})),n.d(t,"fused",(function(){return wt.sb})),n.d(t,"signal",(function(){return wt.md})),n.d(t,"Reduction",(function(){return Ot.a})),n.d(t,"train",(function(){return jt})),n.d(t,"enableProdMode",(function(){return Qe.g})),n.d(t,"enableDebugMode",(function(){return Qe.f})),n.d(t,"disableDeprecationWarnings",(function(){return Qe.c})),n.d(t,"deprecationWarn",(function(){return Qe.b})),n.d(t,"disposeVariables",(function(){return Qe.e})),n.d(t,"engine",(function(){return Qe.h})),n.d(t,"memory",(function(){return Qe.m})),n.d(t,"profile",(function(){return Qe.n})),n.d(t,"tidy",(function(){return Qe.t})),n.d(t,"dispose",(function(){return Qe.d})),n.d(t,"keep",(function(){return Qe.l})),n.d(t,"time",(function(){return Qe.u})),n.d(t,"setBackend",(function(){return Qe.r})),n.d(t,"ready",(function(){return Qe.o})),n.d(t,"getBackend",(function(){return Qe.k})),n.d(t,"removeBackend",(function(){return Qe.q})),n.d(t,"findBackend",(function(){return Qe.i})),n.d(t,"findBackendFactory",(function(){return Qe.j})),n.d(t,"registerBackend",(function(){return Qe.p})),n.d(t,"backend",(function(){return Qe.a})),n.d(t,"setPlatform",(function(){return Qe.s})),n.d(t,"getKernel",(function(){return Oe.c})),n.d(t,"getGradient",(function(){return Oe.b})),n.d(t,"getKernelsForBackend",(function(){return Oe.d})),n.d(t,"registerKernel",(function(){return Oe.f})),n.d(t,"registerGradient",(function(){return Oe.e})),n.d(t,"unregisterKernel",(function(){return Oe.h})),n.d(t,"unregisterGradient",(function(){return Oe.g})),n.d(t,"copyRegisteredKernels",(function(){return Oe.a})),n.d(t,"customGrad",(function(){return st.a})),n.d(t,"grad",(function(){return st.b})),n.d(t,"grads",(function(){return st.c})),n.d(t,"valueAndGrad",(function(){return st.d})),n.d(t,"valueAndGrads",(function(){return st.e})),n.d(t,"variableGrads",(function(){return st.f})),n.d(t,"Environment",(function(){return p.b})),n.d(t,"env",(function(){return p.c})),n.d(t,"ENV",(function(){return p.a})),n.d(t,"version_core",(function(){return Ze})),n.d(t,"nextFrame",(function(){return It.a})),n.d(t,"browser",(function(){return s})),n.d(t,"io",(function(){return r})),n.d(t,"math",(function(){return a})),n.d(t,"serialization",(function(){return u})),n.d(t,"test_util",(function(){return Xe})),n.d(t,"util",(function(){return Ye})),n.d(t,"backend_util",(function(){return l})),n.d(t,"tensor_util",(function(){return Ke})),n.d(t,"slice_util",(function(){return o})),n.d(t,"gather_util",(function(){return i})),n.d(t,"scatter_util",(function(){return Te})),n.d(t,"device_util",(function(){return fn})),n.d(t,"kernel_impls",(function(){return d})),n.d(t,"KernelBackend",(function(){return gn.b})),n.d(t,"DataStorage",(function(){return gn.a})),n.d(t,"Abs",(function(){return we.a})),n.d(t,"Acos",(function(){return we.b})),n.d(t,"Acosh",(function(){return we.c})),n.d(t,"Add",(function(){return we.d})),n.d(t,"AddN",(function(){return we.e})),n.d(t,"All",(function(){return we.f})),n.d(t,"Any",(function(){return we.g})),n.d(t,"ArgMax",(function(){return we.h})),n.d(t,"ArgMin",(function(){return we.i})),n.d(t,"Asin",(function(){return we.j})),n.d(t,"Asinh",(function(){return we.k})),n.d(t,"Atan",(function(){return we.l})),n.d(t,"Atanh",(function(){return we.n})),n.d(t,"Atan2",(function(){return we.m})),n.d(t,"AvgPool",(function(){return we.o})),n.d(t,"AvgPoolGrad",(function(){return we.r})),n.d(t,"AvgPool3D",(function(){return we.p})),n.d(t,"AvgPool3DGrad",(function(){return we.q})),n.d(t,"BatchMatMul",(function(){return we.s})),n.d(t,"BatchToSpaceND",(function(){return we.t})),n.d(t,"Bincount",(function(){return we.u})),n.d(t,"BroadcastTo",(function(){return we.v})),n.d(t,"Cast",(function(){return we.w})),n.d(t,"Ceil",(function(){return we.x})),n.d(t,"ClipByValue",(function(){return we.y})),n.d(t,"Complex",(function(){return we.z})),n.d(t,"ComplexAbs",(function(){return we.A})),n.d(t,"Concat",(function(){return we.B})),n.d(t,"Conv2D",(function(){return we.C})),n.d(t,"Conv2DBackpropFilter",(function(){return we.D})),n.d(t,"Conv2DBackpropInput",(function(){return we.E})),n.d(t,"Conv3D",(function(){return we.F})),n.d(t,"Conv3DBackpropFilterV2",(function(){return we.G})),n.d(t,"Conv3DBackpropInputV2",(function(){return we.H})),n.d(t,"Cos",(function(){return we.I})),n.d(t,"Cosh",(function(){return we.J})),n.d(t,"Cumsum",(function(){return we.L})),n.d(t,"CropAndResize",(function(){return we.K})),n.d(t,"DenseBincount",(function(){return we.M})),n.d(t,"DepthToSpace",(function(){return we.N})),n.d(t,"DepthwiseConv2dNative",(function(){return we.O})),n.d(t,"DepthwiseConv2dNativeBackpropFilter",(function(){return we.P})),n.d(t,"DepthwiseConv2dNativeBackpropInput",(function(){return we.Q})),n.d(t,"Diag",(function(){return we.R})),n.d(t,"Dilation2D",(function(){return we.S})),n.d(t,"Dilation2DBackpropInput",(function(){return we.U})),n.d(t,"Dilation2DBackpropFilter",(function(){return we.T})),n.d(t,"RealDiv",(function(){return we.kc})),n.d(t,"Elu",(function(){return we.V})),n.d(t,"EluGrad",(function(){return we.W})),n.d(t,"Erf",(function(){return we.Y})),n.d(t,"Equal",(function(){return we.X})),n.d(t,"Exp",(function(){return we.Z})),n.d(t,"ExpandDims",(function(){return we.ab})),n.d(t,"Expm1",(function(){return we.bb})),n.d(t,"FFT",(function(){return we.cb})),n.d(t,"Fill",(function(){return we.db})),n.d(t,"FlipLeftRight",(function(){return we.eb})),n.d(t,"Floor",(function(){return we.fb})),n.d(t,"FloorDiv",(function(){return we.gb})),n.d(t,"FusedBatchNorm",(function(){return we.ib})),n.d(t,"GatherV2",(function(){return we.mb})),n.d(t,"GatherNd",(function(){return we.lb})),n.d(t,"Greater",(function(){return we.nb})),n.d(t,"GreaterEqual",(function(){return we.ob})),n.d(t,"Identity",(function(){return we.qb})),n.d(t,"IFFT",(function(){return we.pb})),n.d(t,"Imag",(function(){return we.rb})),n.d(t,"IsFinite",(function(){return we.sb})),n.d(t,"IsInf",(function(){return we.tb})),n.d(t,"IsNan",(function(){return we.ub})),n.d(t,"LeakyRelu",(function(){return we.xb})),n.d(t,"Less",(function(){return we.yb})),n.d(t,"LessEqual",(function(){return we.zb})),n.d(t,"LinSpace",(function(){return we.Ab})),n.d(t,"Log",(function(){return we.Bb})),n.d(t,"Log1p",(function(){return we.Cb})),n.d(t,"LogicalAnd",(function(){return we.Eb})),n.d(t,"LogicalNot",(function(){return we.Fb})),n.d(t,"LogicalOr",(function(){return we.Gb})),n.d(t,"LogSoftmax",(function(){return we.Db})),n.d(t,"LRN",(function(){return we.vb})),n.d(t,"LRNGrad",(function(){return we.wb})),n.d(t,"Max",(function(){return we.Hb})),n.d(t,"Maximum",(function(){return we.Nb})),n.d(t,"MaxPool",(function(){return we.Ib})),n.d(t,"MaxPoolGrad",(function(){return we.Lb})),n.d(t,"MaxPool3D",(function(){return we.Jb})),n.d(t,"MaxPool3DGrad",(function(){return we.Kb})),n.d(t,"MaxPoolWithArgmax",(function(){return we.Mb})),n.d(t,"Mean",(function(){return we.Ob})),n.d(t,"Min",(function(){return we.Pb})),n.d(t,"Minimum",(function(){return we.Qb})),n.d(t,"MirrorPad",(function(){return we.Rb})),n.d(t,"Mod",(function(){return we.Sb})),n.d(t,"Multinomial",(function(){return we.Tb})),n.d(t,"Multiply",(function(){return we.Ub})),n.d(t,"Neg",(function(){return we.Vb})),n.d(t,"NotEqual",(function(){return we.Zb})),n.d(t,"NonMaxSuppressionV3",(function(){return we.Wb})),n.d(t,"NonMaxSuppressionV4",(function(){return we.Xb})),n.d(t,"NonMaxSuppressionV5",(function(){return we.Yb})),n.d(t,"OnesLike",(function(){return we.bc})),n.d(t,"OneHot",(function(){return we.ac})),n.d(t,"Pack",(function(){return we.cc})),n.d(t,"PadV2",(function(){return we.dc})),n.d(t,"Pool",(function(){return we.ec})),n.d(t,"Pow",(function(){return we.fc})),n.d(t,"Prelu",(function(){return we.gc})),n.d(t,"Prod",(function(){return we.hc})),n.d(t,"Range",(function(){return we.ic})),n.d(t,"Real",(function(){return we.jc})),n.d(t,"Reciprocal",(function(){return we.lc})),n.d(t,"Relu",(function(){return we.mc})),n.d(t,"Reshape",(function(){return we.oc})),n.d(t,"ResizeNearestNeighbor",(function(){return we.rc})),n.d(t,"ResizeNearestNeighborGrad",(function(){return we.sc})),n.d(t,"ResizeBilinear",(function(){return we.pc})),n.d(t,"ResizeBilinearGrad",(function(){return we.qc})),n.d(t,"Relu6",(function(){return we.nc})),n.d(t,"Reverse",(function(){return we.tc})),n.d(t,"Round",(function(){return we.vc})),n.d(t,"Rsqrt",(function(){return we.wc})),n.d(t,"ScatterNd",(function(){return we.xc})),n.d(t,"Select",(function(){return we.yc})),n.d(t,"Selu",(function(){return we.zc})),n.d(t,"Slice",(function(){return we.Ec})),n.d(t,"Sin",(function(){return we.Cc})),n.d(t,"Sinh",(function(){return we.Dc})),n.d(t,"Sign",(function(){return we.Bc})),n.d(t,"Sigmoid",(function(){return we.Ac})),n.d(t,"Softplus",(function(){return we.Gc})),n.d(t,"Sqrt",(function(){return we.Kc})),n.d(t,"Sum",(function(){return we.Qc})),n.d(t,"SpaceToBatchND",(function(){return we.Hc})),n.d(t,"SplitV",(function(){return we.Jc})),n.d(t,"Softmax",(function(){return we.Fc})),n.d(t,"SquaredDifference",(function(){return we.Mc})),n.d(t,"Square",(function(){return we.Lc})),n.d(t,"Sub",(function(){return we.Pc})),n.d(t,"SparseToDense",(function(){return we.Ic})),n.d(t,"StridedSlice",(function(){return we.Oc})),n.d(t,"Tan",(function(){return we.Rc})),n.d(t,"Tanh",(function(){return we.Sc})),n.d(t,"Tile",(function(){return we.Tc})),n.d(t,"TopK",(function(){return we.Uc})),n.d(t,"Transpose",(function(){return we.Vc})),n.d(t,"Unique",(function(){return we.Wc})),n.d(t,"Unpack",(function(){return we.Xc})),n.d(t,"UnsortedSegmentSum",(function(){return we.Yc})),n.d(t,"ZerosLike",(function(){return we.Zc})),n.d(t,"Step",(function(){return we.Nc})),n.d(t,"FromPixels",(function(){return we.hb})),n.d(t,"RotateWithOffset",(function(){return we.uc})),n.d(t,"_FusedMatMul",(function(){return we.ad})),n.d(t,"FusedConv2D",(function(){return we.jb})),n.d(t,"FusedDepthwiseConv2D",(function(){return we.kb}));var r={};n.r(r),n.d(r,"copyModel",(function(){return W})),n.d(r,"listModels",(function(){return P})),n.d(r,"moveModel",(function(){return V})),n.d(r,"removeModel",(function(){return B})),n.d(r,"browserFiles",(function(){return ee})),n.d(r,"browserHTTPRequest",(function(){return le})),n.d(r,"concatenateArrayBuffers",(function(){return f.d})),n.d(r,"decodeWeights",(function(){return f.e})),n.d(r,"encodeWeights",(function(){return f.f})),n.d(r,"fromMemory",(function(){return pe})),n.d(r,"getLoadHandlers",(function(){return v})),n.d(r,"getModelArtifactsInfoForJSON",(function(){return f.g})),n.d(r,"getSaveHandlers",(function(){return y})),n.d(r,"http",(function(){return ce})),n.d(r,"isHTTPScheme",(function(){return oe})),n.d(r,"loadWeights",(function(){return ae})),n.d(r,"registerLoadRouter",(function(){return g})),n.d(r,"registerSaveRouter",(function(){return b})),n.d(r,"weightsLoaderFactory",(function(){return se})),n.d(r,"withSaveHandler",(function(){return fe}));var a={};n.r(a),n.d(a,"confusionMatrix",(function(){return xe}));var s={};n.r(s),n.d(s,"toPixels",(function(){return Ie})),n.d(s,"fromPixels",(function(){return Ne}));var i={};n.r(i),n.d(i,"prepareAndValidate",(function(){return Se}));var o={};n.r(o),n.d(o,"assertParamsValid",(function(){return Ce})),n.d(o,"maskToAxes",(function(){return Ae})),n.d(o,"computeOutShape",(function(){return Ee})),n.d(o,"stridesWithElidedDims",(function(){return Re})),n.d(o,"getNormalizedAxes",(function(){return Fe})),n.d(o,"startIndicesWithElidedDims",(function(){return De})),n.d(o,"stopIndicesWithElidedDims",(function(){return Me})),n.d(o,"stridesForAxis",(function(){return ze})),n.d(o,"startForAxis",(function(){return Le})),n.d(o,"stopForAxis",(function(){return Pe})),n.d(o,"isSliceContinous",(function(){return Be})),n.d(o,"computeFlatOffset",(function(){return We})),n.d(o,"parseSliceParams",(function(){return Ve})),n.d(o,"sliceInfo",(function(){return Ue}));var u={};n.r(u),n.d(u,"Serializable",(function(){return Ge})),n.d(u,"SerializationMap",(function(){return He})),n.d(u,"registerClass",(function(){return qe}));var c={};n.r(c),n.d(c,"segOpComputeOptimalWindowSize",(function(){return on})),n.d(c,"computeOutShape",(function(){return un})),n.d(c,"collectGatherOpShapeInfo",(function(){return cn}));var l={};n.r(l),n.d(l,"axesAreInnerMostDims",(function(){return St.b})),n.d(l,"combineLocations",(function(){return St.c})),n.d(l,"computeOutAndReduceShapes",(function(){return St.d})),n.d(l,"expandShapeToKeepDim",(function(){return St.e})),n.d(l,"assertAxesAreInnerMostDims",(function(){return St.a})),n.d(l,"getAxesPermutation",(function(){return St.f})),n.d(l,"getUndoAxesPermutation",(function(){return St.h})),n.d(l,"getInnerMostAxes",(function(){return St.g})),n.d(l,"getBroadcastDims",(function(){return Tt.b})),n.d(l,"getReductionAxes",(function(){return Tt.c})),n.d(l,"assertAndGetBroadcastShape",(function(){return Tt.a})),n.d(l,"assertParamsConsistent",(function(){return Ct})),n.d(l,"computeOutShape",(function(){return At})),n.d(l,"computeDilation2DInfo",(function(){return Et.d})),n.d(l,"computePool2DInfo",(function(){return Et.e})),n.d(l,"computePool3DInfo",(function(){return Et.f})),n.d(l,"computeConv2DInfo",(function(){return Et.a})),n.d(l,"computeConv3DInfo",(function(){return Et.b})),n.d(l,"computeDefaultPad",(function(){return Et.c})),n.d(l,"tupleValuesAreOne",(function(){return Et.i})),n.d(l,"eitherStridesOrDilationsAreOne",(function(){return Et.h})),n.d(l,"convertConv2DDataFormat",(function(){return Et.g})),n.d(l,"getFusedDyActivation",(function(){return Rt.c})),n.d(l,"getFusedBiasGradient",(function(){return Rt.b})),n.d(l,"applyActivation",(function(){return Rt.a})),n.d(l,"shouldFuse",(function(){return Rt.d})),n.d(l,"PARALLELIZE_THRESHOLD",(function(){return $t})),n.d(l,"computeOptimalWindowSize",(function(){return _t})),n.d(l,"slice_util",(function(){return o})),n.d(l,"upcastType",(function(){return xt.c})),n.d(l,"getImageCenter",(function(){return Ft})),n.d(l,"getReshaped",(function(){return Dt})),n.d(l,"getPermuted",(function(){return Mt})),n.d(l,"getReshapedPermuted",(function(){return zt})),n.d(l,"getSliceBeginCoords",(function(){return Lt})),n.d(l,"getSliceSize",(function(){return Pt})),n.d(l,"prepareAndValidate",(function(){return Se})),n.d(l,"validateUpdateShape",(function(){return Te.validateUpdateShape})),n.d(l,"validateInput",(function(){return Te.validateInput})),n.d(l,"calculateShapes",(function(){return Te.calculateShapes})),n.d(l,"SELU_SCALEALPHA",(function(){return Bt})),n.d(l,"SELU_SCALE",(function(){return Wt})),n.d(l,"ERF_P",(function(){return Vt})),n.d(l,"ERF_A1",(function(){return Ut})),n.d(l,"ERF_A2",(function(){return Gt})),n.d(l,"ERF_A3",(function(){return Ht})),n.d(l,"ERF_A4",(function(){return qt})),n.d(l,"ERF_A5",(function(){return Kt})),n.d(l,"warn",(function(){return Xt})),n.d(l,"log",(function(){return Yt})),n.d(l,"mergeRealAndImagArrays",(function(){return Zt})),n.d(l,"splitRealAndImagArrays",(function(){return Qt})),n.d(l,"complexWithEvenIndex",(function(){return Jt})),n.d(l,"complexWithOddIndex",(function(){return en})),n.d(l,"getComplexWithIndex",(function(){return tn})),n.d(l,"assignToTypedArray",(function(){return nn})),n.d(l,"exponents",(function(){return rn})),n.d(l,"exponent",(function(){return an})),n.d(l,"prepareSplitSize",(function(){return sn})),n.d(l,"segment_util",(function(){return c})),n.d(l,"castTensor",(function(){return ln})),n.d(l,"reshapeTensor",(function(){return dn})),n.d(l,"fromUint8ToStringArray",(function(){return hn})),n.d(l,"fromStringArrayToUint8",(function(){return pn}));var d={};n.r(d),n.d(d,"nonMaxSuppressionV3Impl",(function(){return mn.a})),n.d(d,"nonMaxSuppressionV4Impl",(function(){return mn.b})),n.d(d,"nonMaxSuppressionV5Impl",(function(){return mn.c})),n.d(d,"whereImpl",(function(){return bn.a}));var h=n(5),p=(n(141),n(24)),f=n(41); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class m{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==m.instance&&(m.instance=new m),m.instance}static registerSaveRouter(e){m.getInstance().saveRouters.push(e)}static registerLoadRouter(e){m.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return m.getHandlers(e,"save")}static getLoadHandlers(e,t){return m.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?m.getInstance().loadRouters:m.getInstance().saveRouters).forEach(t=>{const a=t(e,n);null!==a&&r.push(a)}),r}}const b=e=>m.registerSaveRouter(e),g=e=>m.registerLoadRouter(e),y=e=>m.getSaveHandlers(e),v=(e,t)=>m.getLoadHandlers(e,t) /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */;function x(){if(!Object(p.c)().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function w(e){const t=e.result;t.createObjectStore("models_store",{keyPath:"modelPath"}),t.createObjectStore("model_info_store",{keyPath:"modelPath"})}class O{constructor(e){if(this.indexedDB=x(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise((e,n)=>{const r=this.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=()=>w(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction("models_store","readonly"),r=t.objectStore("models_store").get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=Object(f.g)(t),s=a.transaction("model_info_store","readwrite");let i=s.objectStore("model_info_store");const o=i.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;o.onsuccess=()=>{u=a.transaction("models_store","readwrite");const o=u.objectStore("models_store").put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});o.onsuccess=()=>e({modelArtifactsInfo:r}),o.onerror=e=>{i=s.objectStore("model_info_store");const t=i.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(o.error)),t.onerror=e=>(a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),s.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)})}}O.URL_SCHEME="indexeddb://";const k=e=>{return Object(p.c)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(O.URL_SCHEME)?(t=e.slice(O.URL_SCHEME.length),new O(t)):null;var t};m.registerSaveRouter(k),m.registerLoadRouter(k);class j{constructor(){this.indexedDB=x()}async listModels(){return new Promise((e,t)=>{const n=this.indexedDB.open("tensorflowjs",1);n.onupgradeneeded=()=>w(n),n.onsuccess=()=>{const r=n.result,a=r.transaction("model_info_store","readonly"),s=a.objectStore("model_info_store").getAll();s.onsuccess=()=>{const t={};for(const e of s.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},s.onerror=e=>(r.close(),t(s.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)})}async removeModel(e){var t;return e=(t=e).startsWith(O.URL_SCHEME)?t.slice(O.URL_SCHEME.length):t,new Promise((t,n)=>{const r=this.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=()=>w(r),r.onsuccess=()=>{const a=r.result,s=a.transaction("model_info_store","readwrite"),i=s.objectStore("model_info_store"),o=i.get(e);let u;o.onsuccess=()=>{if(null==o.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=i.delete(e),s=()=>{u=a.transaction("models_store","readwrite");const r=u.objectStore("models_store").delete(e);r.onsuccess=()=>t(o.result.modelArtifactsInfo),r.onerror=e=>n(o.error)};r.onsuccess=s,r.onerror=e=>(s(),a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),s.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)})}}var I=n(7); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */const N="tensorflowjs_models",S="info",T="model_topology",C="weight_specs",A="weight_data",E="model_metadata";function R(e){return{info:[N,e,S].join("/"),topology:[N,e,T].join("/"),weightSpecs:[N,e,C].join("/"),weightData:[N,e,A].join("/"),modelMetadata:[N,e,E].join("/")}}function $(e){const t=e.split("/");if(t.length<3)throw new Error("Invalid key format: "+e);return t.slice(1,t.length-1).join("/")}class _{constructor(e){if(!Object(p.c)().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=R(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=Object(f.g)(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,Object(f.a)(e.weightData));const a={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};return null!=e.signature&&(a.signature=e.signature),null!=e.userDefinedMetadata&&(a.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(a.modelInitializer=e.modelInitializer),this.LS.setItem(this.keys.modelMetadata,JSON.stringify(a)),{modelArtifactsInfo:r}}catch(e){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==r)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;const a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){const e=JSON.parse(a);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer)}const s=this.LS.getItem(this.keys.weightData);if(null==s)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=Object(f.b)(s),t}}_.URL_SCHEME="localstorage://";const F=e=>{return Object(p.c)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(_.URL_SCHEME)?(t=e.slice(_.URL_SCHEME.length),new _(t)):null;var t};m.registerSaveRouter(F),m.registerLoadRouter(F);class D{constructor(){Object(I.b)(Object(p.c)().getBool("IS_BROWSER"),()=>"Current environment is not a web browser"),Object(I.b)("undefined"==typeof window||void 0!==window.localStorage,()=>"Current browser does not appear to support localStorage"),this.LS=window.localStorage}async listModels(){const e={},t=N+"/",n="/"+S;for(let r=0;r<this.LS.length;++r){const a=this.LS.key(r);if(a.startsWith(t)&&a.endsWith(n)){e[$(a)]=JSON.parse(this.LS.getItem(a))}}return e}async removeModel(e){var t;const n=R(e=(t=e).startsWith(_.URL_SCHEME)?t.slice(_.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(n.info));return this.LS.removeItem(n.info),this.LS.removeItem(n.topology),this.LS.removeItem(n.weightSpecs),this.LS.removeItem(n.weightData),r}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class M{constructor(){this.managers={}}static getInstance(){return null==M.instance&&(M.instance=new M),M.instance}static registerManager(e,t){Object(I.b)(null!=e,()=>"scheme must not be undefined or null."),e.endsWith("://")&&(e=e.slice(0,e.indexOf("://"))),Object(I.b)(e.length>0,()=>"scheme must not be an empty string.");const n=M.getInstance();Object(I.b)(null==n.managers[e],()=>`A model store manager is already registered for scheme '${e}'.`),n.managers[e]=t}static getManager(e){const t=this.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(this.getInstance().managers)}}function z(e){if(-1===e.indexOf("://"))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+M.getSchemes().join(","));return{scheme:e.split("://")[0],path:e.split("://")[1]}}async function L(e,t,n=!1){Object(I.b)(e!==t,()=>`Old path and new path are the same: '${e}'`);const r=m.getLoadHandlers(e);Object(I.b)(r.length>0,()=>`Copying failed because no load handler is found for source URL ${e}.`),Object(I.b)(r.length<2,()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`);const a=r[0],s=m.getSaveHandlers(t);Object(I.b)(s.length>0,()=>`Copying failed because no save handler is found for destination URL ${t}.`),Object(I.b)(s.length<2,()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`);const i=s[0],o=z(e).scheme,u=z(e).path,c=o===z(e).scheme,l=await a.load();n&&c&&await M.getManager(o).removeModel(u);const d=await i.save(l);return n&&!c&&await M.getManager(o).removeModel(u),d.modelArtifactsInfo}async function P(){const e=M.getSchemes(),t={};for(const n of e){const e=await M.getManager(n).listModels();for(const r in e){t[n+"://"+r]=e[r]}}return t}async function B(e){const t=z(e);return M.getManager(t.scheme).removeModel(t.path)}async function W(e,t){return L(e,t,!1)}async function V(e,t){return L(e,t,!0)} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */class U{fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error("Browser's encoder only supports utf-8, but got "+t);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}}if(Object(p.c)().get("IS_BROWSER")){Object(p.c)().setPlatform("browser",new U);try{M.registerManager(_.URL_SCHEME,new D)}catch(e){}try{M.registerManager(O.URL_SCHEME,new j)}catch(e){}}n(276);var G=n(48),H=n(12),q=n(68),K=n(149),X=n(6); /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ Object(h.b)();const Y={buffer:G.a,cast:H.a,clone:q.a,print:K.a};Object(X.e)(Y);function Z(e){return new Promise(e=>setTimeout(e)).then(e)}class Q{constructor(e){if(!Object(p.c)().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(Q.URL_SCHEME)&&(e=e.slice(Q.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelTopologyFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}],r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:n};null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer);const a=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),s=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor;if(s.download=this.modelTopologyFileName,s.href=a,await Z(()=>s.dispatchEvent(new MouseEvent("click"))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await Z(()=>e.dispatchEvent(new MouseEvent("click")))}return{modelArtifactsInfo:Object(f.g)(e)}}}}Q.URL_SCHEME="downloads://";class J{constructor(e){if(null==e||e.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+e);this.files=e}async load(){const e=this.files[0],t=this.files.slice(1);return new Promise((n,r)=>{const a=new FileReader;a.onload=a=>{const s=JSON.parse(a.target.result),i=s.modelTopology;if(null==i)return void r(new Error("modelTopology field is missing from file "+e.name));0===t.length&&n({modelTopology:i});const o=s.weightsManifest;if(null==o)return void r(new Error("weightManifest field is missing from file "+e.name));let u;try{u=this.checkManifestAndWeightFiles(o,t)}catch(e){return void r(e)}const c=[],l=[],d=[];o.forEach(e=>{e.paths.forEach(e=>{l.push(e),d.push(null)}),c.push(...e.weights)}),o.forEach(e=>{e.paths.forEach(e=>{const t=new FileReader;t.onload=t=>{const r=t.target.result,a=l.indexOf(e);if(d[a]=r,-1===d.indexOf(null)){const e={modelTopology:i,weightSpecs:c,weightData:Object(f.d)(d),format:s.format,generatedBy:s.generatedBy,convertedBy:s.convertedBy};null!=s.signature&&(e.signature=s.signature),null!=s.userDefinedMetadata&&(e.userDefinedMetadata=s.userDefinedMetadata),null!=s.modelInitializer&&(e.modelInitializer=s.modelInitializer),n(e)}},t.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),t.readAsArrayBuffer(u[e])})})},a.onerror=t=>r(`Failed to read model topology and weights manifest JSON from file '${e.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),a.readAsText(e)})}checkManifestAndWeightFiles(e,t){const n=[],r=t.map(e=>Object(f.c)(e.name)),a={};for(const s of e)s.paths.forEach(e=>{const s=Object(f.c)(e);if(-1!==n.indexOf(s))throw new Error(`Duplicate file basename found in weights manifest: '${s}'`);if(n.push(s),-1===r.indexOf(s))throw new Error(`Weight file with basename '${s}' is not provided.`);a[e]=t[r.indexOf(s)]});if(n.length!==t.length)throw new Error(`Mismatch in the number of files in weights manifest (${n.length}) and the number of weight files provided (${t.length}).`);return a}}function ee(e){return new J(e)} /** * @license * Copyright 2019 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */function te(e,t,n,r){!function(e){Object(I.b)(null!=e&&Array.isArray(e)&&e.length>0,()=>"promises must be a none empty array")}(e),function(e,t){Object(I.b)(e>=0&&e<=1,()=>"Progress fraction must be in range [0, 1], but got startFraction "+e),Object(I.b)(t>=0&&t<=1,()=>"Progress fraction must be in range [0, 1], but got endFraction "+t),Object(I.b)(t>=e,()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction `+t)}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map(s=>(s.then(s=>{const i=n+ ++a/e.length*(r-n);return t(i),s}),s)))}m.registerSaveRouter(e=>Object(p.c)().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Q.URL_SCHEME)?function(e="model"){return new Q(e)}(e.slice(Q.URL_SCHEME.length)):null);var ne=n(146); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */async function re(e,t){null==t&&(t={});const n=null==t.fetchFunc?Object(p.c)().platform.fetch:t.fetchFunc,r=e.map(e=>n(e,t.requestInit,{isBinary:!0})),a=(null==t.onProgress?await Promise.all(r):await te(r,t.onProgress,0,.5)).map(e=>e.arrayBuffer());return null==t.onProgress?await Promise.all(a):await te(a,t.onProgress,.5,1)}async function ae(e,t="",n,r){return se(e=>re(e,{requestInit:r}))(e,t,n)}function se(e){return async(t,n="",r)=>{const a=t.map(()=>!1),s={},i=null!=r?r.map(()=>!1):[],o=[];if(t.forEach((e,t)=>{let n=0;e.weights.forEach(e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,c=ne.a[u]*I.N(e.shape),l=()=>{a[t]=!0,null==s[t]&&(s[t]=[]),s[t].push({manifestEntry:e,groupOffset:n,sizeBytes:c})};null!=r?r.forEach((t,n)=>{t===e.name&&(l(),i[n]=!0)}):l(),o.push(e.name),n+=c})}),!i.every(e=>e)){const e=r.filter((e,t)=>!i[t]);throw new Error("Could not find weights in manifest with names: "+e.join(", ")+". \nManifest JSON has weights with names: "+o.join(", ")+".")}const u=a.reduce((e,t,n)=>(t&&e.push(n),e),[]),c=[];u.forEach(e=>{t[e].paths.forEach(e=>{const t=n+(n.endsWith("/")?"":"/")+e;c.push(t)})});const l=await e(c),d={};let h=0;return u.forEach(e=>{const n=t[e].paths.length;let r=0;for(let e=0;e<n;e++)r+=l[h+e].byteLength;const a=new ArrayBuffer(r),i=new Uint8Array(a);let o=0;for(let e=0;e<n;e++){const t=new Uint8Array(l[h+e]);i.set(t,o),o+=t.byteLength}s[e].forEach(e=>{const t=a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),n=Object(f.e)(t,[e.manifestEntry]);for(const e in n)d[e]=n[e]}),h+=n}),d}} /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * L