UNPKG

@magenta/music

Version:

Make music with machine learning, in the browser.

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