UNPKG

tfjs-yolo-tiny

Version:

YOLO Object detection right in the browser via Tensorflow.js

1 lines 31.3 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@tensorflow/tfjs")):"function"==typeof define&&define.amd?define(["@tensorflow/tfjs"],e):"object"==typeof exports?exports.remoteRequire=e(require("@tensorflow/tfjs")):t.remoteRequire=e(t["@tensorflow/tfjs"])}(window,function(t){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=85)}([function(t,e,r){var n=r(33)("wks"),o=r(32),i=r(1).Symbol,u="function"==typeof i;(t.exports=function(t){return n[t]||(n[t]=u&&i[t]||(u?i:o)("Symbol."+t))}).store=n},function(t,e){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,e,r){var n=r(7);t.exports=function(t){if(!n(t))throw TypeError(t+" is not an object!");return t}},function(t,e){var r=t.exports={version:"2.5.4"};"number"==typeof __e&&(__e=r)},function(t,e,r){var n=r(9),o=r(35);t.exports=r(6)?function(t,e,r){return n.f(t,e,o(1,r))}:function(t,e,r){return t[e]=r,t}},function(t,e){t.exports={}},function(t,e,r){t.exports=!r(36)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e){var r={}.hasOwnProperty;t.exports=function(t,e){return r.call(t,e)}},function(t,e,r){var n=r(2),o=r(76),i=r(75),u=Object.defineProperty;e.f=r(6)?Object.defineProperty:function(t,e,r){if(n(t),e=i(e,!0),n(r),o)try{return u(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[e]=r.value),t}},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,e,r){var n=r(10);t.exports=function(t,e,r){if(n(t),void 0===e)return t;switch(r){case 1:return function(r){return t.call(e,r)};case 2:return function(r,n){return t.call(e,r,n)};case 3:return function(r,n,o){return t.call(e,r,n,o)}}return function(){return t.apply(e,arguments)}}},function(t,e,r){var n=r(1),o=r(3),i=r(11),u=r(4),a=r(8),c=function(t,e,r){var s,f,l,p=t&c.F,h=t&c.G,v=t&c.S,d=t&c.P,y=t&c.B,m=t&c.W,g=h?o:o[e]||(o[e]={}),x=g.prototype,_=h?n:v?n[e]:(n[e]||{}).prototype;for(s in h&&(r=e),r)(f=!p&&_&&void 0!==_[s])&&a(g,s)||(l=f?_[s]:r[s],g[s]=h&&"function"!=typeof _[s]?r[s]:y&&f?i(l,n):m&&_[s]==l?function(t){var e=function(e,r,n){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,r)}return new t(e,r,n)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(l):d&&"function"==typeof l?i(Function.call,l):l,d&&((g.virtual||(g.virtual={}))[s]=l,t&c.R&&x&&!x[s]&&u(x,s,l)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,e){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,e,r){"use strict";var n=r(10);t.exports.f=function(t){return new function(t){var e,r;this.promise=new t(function(t,n){if(void 0!==e||void 0!==r)throw TypeError("Bad Promise constructor");e=t,r=n}),this.resolve=n(e),this.reject=n(r)}(t)}},function(t,e,r){var n=r(13),o=r(0)("toStringTag"),i="Arguments"==n(function(){return arguments}());t.exports=function(t){var e,r,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),o))?r:i?n(e):"Object"==(u=n(e))&&"function"==typeof e.callee?"Arguments":u}},function(t,e,r){"use strict";var n=r(64)(!0);r(38)(String,"String",function(t){this._t=String(t),this._i=0},function(){var t,e=this._t,r=this._i;return r>=e.length?{value:void 0,done:!0}:(t=n(e,r),this._i+=t.length,{value:t,done:!1})})},function(t,e,r){var n=r(9).f,o=r(8),i=r(0)("toStringTag");t.exports=function(t,e,r){t&&!o(t=r?t:t.prototype,i)&&n(t,i,{configurable:!0,value:e})}},function(t,e,r){var n=r(33)("keys"),o=r(32);t.exports=function(t){return n[t]||(n[t]=o(t))}},function(t,e){var r=Math.ceil,n=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?n:r)(t)}},function(t,e,r){var n=r(7),o=r(1).document,i=n(o)&&n(o.createElement);t.exports=function(t){return i?o.createElement(t):{}}},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,r){var n=r(77),o=r(21);t.exports=function(t){return n(o(t))}},function(t,e,r){r(80);for(var n=r(1),o=r(4),i=r(5),u=r(0)("toStringTag"),a="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),c=0;c<a.length;c++){var s=a[c],f=n[s],l=f&&f.prototype;l&&!l[u]&&o(l,u,s),i[s]=i.Array}},function(e,r){e.exports=t},function(t,e,r){var n=r(2),o=r(7),i=r(14);t.exports=function(t,e){if(n(t),o(e)&&e.constructor===t)return e;var r=i.f(t);return(0,r.resolve)(e),r.promise}},function(t,e){t.exports=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}}},function(t,e,r){var n,o,i,u=r(11),a=r(47),c=r(30),s=r(20),f=r(1),l=f.process,p=f.setImmediate,h=f.clearImmediate,v=f.MessageChannel,d=f.Dispatch,y=0,m={},g=function(){var t=+this;if(m.hasOwnProperty(t)){var e=m[t];delete m[t],e()}},x=function(t){g.call(t.data)};p&&h||(p=function(t){for(var e=[],r=1;arguments.length>r;)e.push(arguments[r++]);return m[++y]=function(){a("function"==typeof t?t:Function(t),e)},n(y),y},h=function(t){delete m[t]},"process"==r(13)(l)?n=function(t){l.nextTick(u(g,t,1))}:d&&d.now?n=function(t){d.now(u(g,t,1))}:v?(i=(o=new v).port2,o.port1.onmessage=x,n=u(i.postMessage,i,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(n=function(t){f.postMessage(t+"","*")},f.addEventListener("message",x,!1)):n="onreadystatechange"in s("script")?function(t){c.appendChild(s("script")).onreadystatechange=function(){c.removeChild(this),g.call(t)}}:function(t){setTimeout(u(g,t,1),0)}),t.exports={set:p,clear:h}},function(t,e,r){var n=r(2),o=r(10),i=r(0)("species");t.exports=function(t,e){var r,u=n(t).constructor;return void 0===u||void 0==(r=n(u)[i])?e:o(r)}},function(t,e,r){var n=r(15),o=r(0)("iterator"),i=r(5);t.exports=r(3).getIteratorMethod=function(t){if(void 0!=t)return t[o]||t["@@iterator"]||i[n(t)]}},function(t,e,r){var n=r(1).document;t.exports=n&&n.documentElement},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,e){var r=0,n=Math.random();t.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+n).toString(36))}},function(t,e,r){var n=r(1),o=n["__core-js_shared__"]||(n["__core-js_shared__"]={});t.exports=function(t){return o[t]||(o[t]={})}},function(t,e,r){var n=r(19),o=Math.min;t.exports=function(t){return t>0?o(n(t),9007199254740991):0}},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){t.exports=!0},function(t,e,r){"use strict";var n=r(37),o=r(12),i=r(74),u=r(4),a=r(5),c=r(73),s=r(17),f=r(66),l=r(0)("iterator"),p=!([].keys&&"next"in[].keys()),h=function(){return this};t.exports=function(t,e,r,v,d,y,m){c(r,e,v);var g,x,_,w=function(t){if(!p&&t in L)return L[t];switch(t){case"keys":case"values":return function(){return new r(this,t)}}return function(){return new r(this,t)}},b=e+" Iterator",O="values"==d,j=!1,L=t.prototype,P=L[l]||L["@@iterator"]||d&&L[d],M=P||w(d),S=d?O?w("entries"):M:void 0,E="Array"==e&&L.entries||P;if(E&&(_=f(E.call(new t)))!==Object.prototype&&_.next&&(s(_,b,!0),n||"function"==typeof _[l]||u(_,l,h)),O&&P&&"values"!==P.name&&(j=!0,M=function(){return P.call(this)}),n&&!m||!p&&!j&&L[l]||u(L,l,M),a[e]=M,a[b]=h,d)if(g={values:O?M:w("values"),keys:y?M:w("keys"),entries:S},m)for(x in g)x in L||i(L,x,g[x]);else o(o.P+o.F*(p||j),e,g);return g}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=["person","bicycle","car","motorbike","aeroplane","bus","train","truck","boat","traffic light","fire hydrant","stop sign","parking meter","bench","bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","backpack","umbrella","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket","bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair","sofa","pottedplant","bed","diningtable","toilet","tvmonitor","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","book","clock","vase","scissors","teddy bear","hair drier","toothbrush"]},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.YOLO_ANCHORS=void 0,e.yolo_filter_boxes=function(t,e,r,o){var i=n.mul(e,r),u=n.argMax(i,-1),a=n.max(i,-1),c=n.greaterEqual(a,n.scalar(o)).as1D(),s=c.size,f=n.linspace(0,s-1,s).toInt(),l=n.zeros([s],"int32"),p=n.where(c,f,l);return[n.gather(t.reshape([s,4]),p),n.gather(a.flatten(),p),n.gather(u.flatten(),p)]},e.yolo_boxes_to_corners=function(t,e){var r=n.tensor1d([2]),o=n.sub(t,n.div(e,r)),i=n.add(t,n.div(e,r)),u=o.shape[0],a=o.shape[1],c=o.shape[2],s=[u,a,c,1];return n.concat([o.slice([0,0,0,1],s),o.slice([0,0,0,0],s),i.slice([0,0,0,1],s),i.slice([0,0,0,0],s)],3)},e.yolo_head=function(t,e,r){var o=e.shape[0],i=n.reshape(e,[1,1,o,2]),u=t.shape.slice(1,3),a=u[0],c=u[1],s=n.range(0,u[0]),f=n.range(0,u[1]);s=n.tile(s,[u[1]]),f=n.tile(n.expandDims(f,0),[u[0],1]),f=n.transpose(f).flatten();var l=n.transpose(n.stack([s,f]));l=n.reshape(l,[u[0],u[1],1,2]),l=n.cast(l,t.dtype),t=n.reshape(t,[u[0],u[1],o,r+5]),u=n.cast(n.reshape(n.tensor1d(u),[1,1,1,2]),t.dtype);var p=n.sigmoid(t.slice([0,0,0,0],[a,c,o,2])),h=n.exp(t.slice([0,0,0,2],[a,c,o,2])),v=n.sigmoid(t.slice([0,0,0,4],[a,c,o,1])),d=n.softmax(t.slice([0,0,0,5],[a,c,o,r]));return p=n.div(n.add(p,l),u),h=n.div(n.mul(h,i),u),[p,h,v,d]},e.box_intersection=o,e.box_union=i,e.box_iou=function(t,e){return o(t,e)/i(t,e)};var n=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(r(24));e.YOLO_ANCHORS=n.tensor2d([[.57273,.677385],[1.87446,2.06253],[3.33843,5.47434],[7.88282,3.52778],[9.77052,9.16828]]);function o(t,e){var r=Math.min(t[3],e[3])-Math.max(t[1],e[1]),n=Math.min(t[2],e[2])-Math.max(t[0],e[0]);return r<0||n<0?0:r*n}function i(t,e){var r=o(t,e);return(t[3]-t[1])*(t[2]-t[0])+(e[3]-e[1])*(e[2]-e[0])-r}},function(t,e,r){"use strict";var n=r(12),o=r(14),i=r(26);n(n.S,"Promise",{try:function(t){var e=o.f(this),r=i(t);return(r.e?e.reject:e.resolve)(r.v),e.promise}})},function(t,e,r){"use strict";var n=r(12),o=r(3),i=r(1),u=r(28),a=r(25);n(n.P+n.R,"Promise",{finally:function(t){var e=u(this,o.Promise||i.Promise),r="function"==typeof t;return this.then(r?function(r){return a(e,t()).then(function(){return r})}:t,r?function(r){return a(e,t()).then(function(){throw r})}:t)}})},function(t,e,r){var n=r(0)("iterator"),o=!1;try{var i=[7][n]();i.return=function(){o=!0},Array.from(i,function(){throw 2})}catch(t){}t.exports=function(t,e){if(!e&&!o)return!1;var r=!1;try{var i=[7],u=i[n]();u.next=function(){return{done:r=!0}},i[n]=function(){return u},t(i)}catch(t){}return r}},function(t,e,r){"use strict";var n=r(1),o=r(3),i=r(9),u=r(6),a=r(0)("species");t.exports=function(t){var e="function"==typeof o[t]?o[t]:n[t];u&&e&&!e[a]&&i.f(e,a,{configurable:!0,get:function(){return this}})}},function(t,e,r){var n=r(4);t.exports=function(t,e,r){for(var o in e)r&&t[o]?t[o]=e[o]:n(t,o,e[o]);return t}},function(t,e,r){var n=r(1),o=r(27).set,i=n.MutationObserver||n.WebKitMutationObserver,u=n.process,a=n.Promise,c="process"==r(13)(u);t.exports=function(){var t,e,r,s=function(){var n,o;for(c&&(n=u.domain)&&n.exit();t;){o=t.fn,t=t.next;try{o()}catch(n){throw t?r():e=void 0,n}}e=void 0,n&&n.enter()};if(c)r=function(){u.nextTick(s)};else if(!i||n.navigator&&n.navigator.standalone)if(a&&a.resolve){var f=a.resolve();r=function(){f.then(s)}}else r=function(){o.call(n,s)};else{var l=!0,p=document.createTextNode("");new i(s).observe(p,{characterData:!0}),r=function(){p.data=l=!l}}return function(n){var o={fn:n,next:void 0};e&&(e.next=o),t||(t=o,r()),e=o}}},function(t,e){t.exports=function(t,e,r){var n=void 0===r;switch(e.length){case 0:return n?t():t.call(r);case 1:return n?t(e[0]):t.call(r,e[0]);case 2:return n?t(e[0],e[1]):t.call(r,e[0],e[1]);case 3:return n?t(e[0],e[1],e[2]):t.call(r,e[0],e[1],e[2]);case 4:return n?t(e[0],e[1],e[2],e[3]):t.call(r,e[0],e[1],e[2],e[3])}return t.apply(r,e)}},function(t,e,r){var n=r(5),o=r(0)("iterator"),i=Array.prototype;t.exports=function(t){return void 0!==t&&(n.Array===t||i[o]===t)}},function(t,e,r){var n=r(2);t.exports=function(t,e,r,o){try{return o?e(n(r)[0],r[1]):e(r)}catch(e){var i=t.return;throw void 0!==i&&n(i.call(t)),e}}},function(t,e,r){var n=r(11),o=r(49),i=r(48),u=r(2),a=r(34),c=r(29),s={},f={};(e=t.exports=function(t,e,r,l,p){var h,v,d,y,m=p?function(){return t}:c(t),g=n(r,l,e?2:1),x=0;if("function"!=typeof m)throw TypeError(t+" is not iterable!");if(i(m)){for(h=a(t.length);h>x;x++)if((y=e?g(u(v=t[x])[0],v[1]):g(t[x]))===s||y===f)return y}else for(d=m.call(t);!(v=d.next()).done;)if((y=o(d,g,v.value,e))===s||y===f)return y}).BREAK=s,e.RETURN=f},function(t,e){t.exports=function(t,e,r,n){if(!(t instanceof e)||void 0!==n&&n in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,e,r){"use strict";var n,o,i,u,a=r(37),c=r(1),s=r(11),f=r(15),l=r(12),p=r(7),h=r(10),v=r(51),d=r(50),y=r(28),m=r(27).set,g=r(46)(),x=r(14),_=r(26),w=r(25),b=c.TypeError,O=c.process,j=c.Promise,L="process"==f(O),P=function(){},M=o=x.f,S=!!function(){try{var t=j.resolve(1),e=(t.constructor={})[r(0)("species")]=function(t){t(P,P)};return(L||"function"==typeof PromiseRejectionEvent)&&t.then(P)instanceof e}catch(t){}}(),E=function(t){var e;return!(!p(t)||"function"!=typeof(e=t.then))&&e},k=function(t,e){if(!t._n){t._n=!0;var r=t._c;g(function(){for(var n=t._v,o=1==t._s,i=0,u=function(e){var r,i,u,a=o?e.ok:e.fail,c=e.resolve,s=e.reject,f=e.domain;try{a?(o||(2==t._h&&A(t),t._h=1),!0===a?r=n:(f&&f.enter(),r=a(n),f&&(f.exit(),u=!0)),r===e.promise?s(b("Promise-chain cycle")):(i=E(r))?i.call(r,c,s):c(r)):s(n)}catch(t){f&&!u&&f.exit(),s(t)}};r.length>i;)u(r[i++]);t._c=[],t._n=!1,e&&!t._h&&T(t)})}},T=function(t){m.call(c,function(){var e,r,n,o=t._v,i=R(t);if(i&&(e=_(function(){L?O.emit("unhandledRejection",o,t):(r=c.onunhandledrejection)?r({promise:t,reason:o}):(n=c.console)&&n.error&&n.error("Unhandled promise rejection",o)}),t._h=L||R(t)?2:1),t._a=void 0,i&&e.e)throw e.v})},R=function(t){return 1!==t._h&&0===(t._a||t._c).length},A=function(t){m.call(c,function(){var e;L?O.emit("rejectionHandled",t):(e=c.onrejectionhandled)&&e({promise:t,reason:t._v})})},N=function(t){var e=this;e._d||(e._d=!0,(e=e._w||e)._v=t,e._s=2,e._a||(e._a=e._c.slice()),k(e,!0))},F=function(t){var e,r=this;if(!r._d){r._d=!0,r=r._w||r;try{if(r===t)throw b("Promise can't be resolved itself");(e=E(t))?g(function(){var n={_w:r,_d:!1};try{e.call(t,s(F,n,1),s(N,n,1))}catch(t){N.call(n,t)}}):(r._v=t,r._s=1,k(r,!1))}catch(t){N.call({_w:r,_d:!1},t)}}};S||(j=function(t){v(this,j,"Promise","_h"),h(t),n.call(this);try{t(s(F,this,1),s(N,this,1))}catch(t){N.call(this,t)}},(n=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=r(45)(j.prototype,{then:function(t,e){var r=M(y(this,j));return r.ok="function"!=typeof t||t,r.fail="function"==typeof e&&e,r.domain=L?O.domain:void 0,this._c.push(r),this._a&&this._a.push(r),this._s&&k(this,!1),r.promise},catch:function(t){return this.then(void 0,t)}}),i=function(){var t=new n;this.promise=t,this.resolve=s(F,t,1),this.reject=s(N,t,1)},x.f=M=function(t){return t===j||t===u?new i(t):o(t)}),l(l.G+l.W+l.F*!S,{Promise:j}),r(17)(j,"Promise"),r(44)("Promise"),u=r(3).Promise,l(l.S+l.F*!S,"Promise",{reject:function(t){var e=M(this);return(0,e.reject)(t),e.promise}}),l(l.S+l.F*(a||!S),"Promise",{resolve:function(t){return w(a&&this===u?j:this,t)}}),l(l.S+l.F*!(S&&r(43)(function(t){j.all(t).catch(P)})),"Promise",{all:function(t){var e=this,r=M(e),n=r.resolve,o=r.reject,i=_(function(){var r=[],i=0,u=1;d(t,!1,function(t){var a=i++,c=!1;r.push(void 0),u++,e.resolve(t).then(function(t){c||(c=!0,r[a]=t,--u||n(r))},o)}),--u||n(r)});return i.e&&o(i.v),r.promise},race:function(t){var e=this,r=M(e),n=r.reject,o=_(function(){d(t,!1,function(t){e.resolve(t).then(r.resolve,n)})});return o.e&&n(o.v),r.promise}})},function(t,e){},function(t,e,r){r(53),r(16),r(23),r(52),r(42),r(41),t.exports=r(3).Promise},function(t,e,r){t.exports={default:r(54),__esModule:!0}},function(t,e,r){"use strict";e.__esModule=!0;var n,o=r(55),i=(n=o)&&n.__esModule?n:{default:n};e.default=function(t){return function(){var e=t.apply(this,arguments);return new i.default(function(t,r){return function n(o,u){try{var a=e[o](u),c=a.value}catch(t){return void r(t)}if(!a.done)return i.default.resolve(c).then(function(t){n("next",t)},function(t){n("throw",t)});t(c)}("next")})}}},function(t,e){!function(e){"use strict";var r,n=Object.prototype,o=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag",s="object"==typeof t,f=e.regeneratorRuntime;if(f)s&&(t.exports=f);else{(f=e.regeneratorRuntime=s?t.exports:{}).wrap=_;var l="suspendedStart",p="suspendedYield",h="executing",v="completed",d={},y={};y[u]=function(){return this};var m=Object.getPrototypeOf,g=m&&m(m(T([])));g&&g!==n&&o.call(g,u)&&(y=g);var x=j.prototype=b.prototype=Object.create(y);O.prototype=x.constructor=j,j.constructor=O,j[c]=O.displayName="GeneratorFunction",f.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===O||"GeneratorFunction"===(e.displayName||e.name))},f.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,j):(t.__proto__=j,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(x),t},f.awrap=function(t){return{__await:t}},L(P.prototype),P.prototype[a]=function(){return this},f.AsyncIterator=P,f.async=function(t,e,r,n){var o=new P(_(t,e,r,n));return f.isGeneratorFunction(e)?o:o.next().then(function(t){return t.done?t.value:o.next()})},L(x),x[c]="Generator",x[u]=function(){return this},x.toString=function(){return"[object Generator]"},f.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},f.values=T,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(E),!t)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(n,o){return a.type="throw",a.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i],a=u.completion;if("root"===u.tryLoc)return n("end");if(u.tryLoc<=this.prev){var c=o.call(u,"catchLoc"),s=o.call(u,"finallyLoc");if(c&&s){if(this.prev<u.catchLoc)return n(u.catchLoc,!0);if(this.prev<u.finallyLoc)return n(u.finallyLoc)}else if(c){if(this.prev<u.catchLoc)return n(u.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return n(u.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),E(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:T(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),d}}}function _(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,i=Object.create(o.prototype),u=new k(n||[]);return i._invoke=function(t,e,r){var n=l;return function(o,i){if(n===h)throw new Error("Generator is already running");if(n===v){if("throw"===o)throw i;return R()}for(r.method=o,r.arg=i;;){var u=r.delegate;if(u){var a=M(u,r);if(a){if(a===d)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var c=w(t,e,r);if("normal"===c.type){if(n=r.done?v:p,c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=v,r.method="throw",r.arg=c.arg)}}}(t,r,u),i}function w(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function b(){}function O(){}function j(){}function L(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function P(t){var e;this._invoke=function(r,n){function i(){return new Promise(function(e,i){!function e(r,n,i,u){var a=w(t[r],t,n);if("throw"!==a.type){var c=a.arg,s=c.value;return s&&"object"==typeof s&&o.call(s,"__await")?Promise.resolve(s.__await).then(function(t){e("next",t,i,u)},function(t){e("throw",t,i,u)}):Promise.resolve(s).then(function(t){c.value=t,i(c)},u)}u(a.arg)}(r,n,e,i)})}return e=e?e.then(i,i):i()}}function M(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,M(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=w(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function T(t){if(t){var e=t[u];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(o.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}return{next:R}}function R(){return{value:r,done:!0}}}(function(){return this}()||Function("return this")())},function(t,e,r){var n=function(){return this}()||Function("return this")(),o=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,i=o&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=r(57),o)n.regeneratorRuntime=i;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},function(t,e,r){t.exports=r(58)},function(t,e,r){var n=r(2),o=r(29);t.exports=r(3).getIterator=function(t){var e=o(t);if("function"!=typeof e)throw TypeError(t+" is not iterable!");return n(e.call(t))}},function(t,e,r){r(23),r(16),t.exports=r(60)},function(t,e,r){t.exports={default:r(61),__esModule:!0}},function(t,e,r){var n=r(15),o=r(0)("iterator"),i=r(5);t.exports=r(3).isIterable=function(t){var e=Object(t);return void 0!==e[o]||"@@iterator"in e||i.hasOwnProperty(n(e))}},function(t,e,r){var n=r(19),o=r(21);t.exports=function(t){return function(e,r){var i,u,a=String(o(e)),c=n(r),s=a.length;return c<0||c>=s?t?"":void 0:(i=a.charCodeAt(c))<55296||i>56319||c+1===s||(u=a.charCodeAt(c+1))<56320||u>57343?t?a.charAt(c):i:t?a.slice(c,c+2):u-56320+(i-55296<<10)+65536}}},function(t,e,r){var n=r(21);t.exports=function(t){return Object(n(t))}},function(t,e,r){var n=r(8),o=r(65),i=r(18)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=o(t),n(t,i)?t[i]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,e,r){var n=r(19),o=Math.max,i=Math.min;t.exports=function(t,e){return(t=n(t))<0?o(t+e,0):i(t,e)}},function(t,e,r){var n=r(22),o=r(34),i=r(67);t.exports=function(t){return function(e,r,u){var a,c=n(e),s=o(c.length),f=i(u,s);if(t&&r!=r){for(;s>f;)if((a=c[f++])!=a)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===r)return t||f||0;return!t&&-1}}},function(t,e,r){var n=r(8),o=r(22),i=r(68)(!1),u=r(18)("IE_PROTO");t.exports=function(t,e){var r,a=o(t),c=0,s=[];for(r in a)r!=u&&n(a,r)&&s.push(r);for(;e.length>c;)n(a,r=e[c++])&&(~i(s,r)||s.push(r));return s}},function(t,e,r){var n=r(69),o=r(31);t.exports=Object.keys||function(t){return n(t,o)}},function(t,e,r){var n=r(9),o=r(2),i=r(70);t.exports=r(6)?Object.defineProperties:function(t,e){o(t);for(var r,u=i(e),a=u.length,c=0;a>c;)n.f(t,r=u[c++],e[r]);return t}},function(t,e,r){var n=r(2),o=r(71),i=r(31),u=r(18)("IE_PROTO"),a=function(){},c=function(){var t,e=r(20)("iframe"),n=i.length;for(e.style.display="none",r(30).appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),c=t.F;n--;)delete c.prototype[i[n]];return c()};t.exports=Object.create||function(t,e){var r;return null!==t?(a.prototype=n(t),r=new a,a.prototype=null,r[u]=t):r=c(),void 0===e?r:o(r,e)}},function(t,e,r){"use strict";var n=r(72),o=r(35),i=r(17),u={};r(4)(u,r(0)("iterator"),function(){return this}),t.exports=function(t,e,r){t.prototype=n(u,{next:o(1,r)}),i(t,e+" Iterator")}},function(t,e,r){t.exports=r(4)},function(t,e,r){var n=r(7);t.exports=function(t,e){if(!n(t))return t;var r,o;if(e&&"function"==typeof(r=t.toString)&&!n(o=r.call(t)))return o;if("function"==typeof(r=t.valueOf)&&!n(o=r.call(t)))return o;if(!e&&"function"==typeof(r=t.toString)&&!n(o=r.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e,r){t.exports=!r(6)&&!r(36)(function(){return 7!=Object.defineProperty(r(20)("div"),"a",{get:function(){return 7}}).a})},function(t,e,r){var n=r(13);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==n(t)?t.split(""):Object(t)}},function(t,e){t.exports=function(t,e){return{value:e,done:!!t}}},function(t,e){t.exports=function(){}},function(t,e,r){"use strict";var n=r(79),o=r(78),i=r(5),u=r(22);t.exports=r(38)(Array,"Array",function(t,e){this._t=u(t),this._i=0,this._k=e},function(){var t=this._t,e=this._k,r=this._i++;return!t||r>=t.length?(this._t=void 0,o(1)):o(0,"keys"==e?r:"values"==e?t[r]:[r,t[r]])},"values"),i.Arguments=i.Array,n("keys"),n("values"),n("entries")},function(t,e,r){r(23),r(16),t.exports=r(63)},function(t,e,r){t.exports={default:r(81),__esModule:!0}},function(t,e,r){"use strict";e.__esModule=!0;var n=i(r(82)),o=i(r(62));function i(t){return t&&t.__esModule?t:{default:t}}e.default=function(){return function(t,e){if(Array.isArray(t))return t;if((0,n.default)(Object(t)))return function(t,e){var r=[],n=!0,i=!1,u=void 0;try{for(var a,c=(0,o.default)(t);!(n=(a=c.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,u=t}finally{try{!n&&c.return&&c.return()}finally{if(i)throw u}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}()},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.downloadModel=void 0;var n,o,i=p(r(83)),u=p(r(59)),a=p(r(56)),c=(e.downloadModel=(n=(0,a.default)(u.default.mark(function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:g;return u.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,s.loadModel(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t,this)})),function(){return n.apply(this,arguments)}),o=(0,a.default)(u.default.mark(function t(e,r){var n,o,a,c,p,g,x,_,w,b,O=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},j=O.classProbThreshold,L=void 0===j?m:j,P=O.iouThreshold,M=void 0===P?y:P,S=O.filterBoxesThreshold,E=void 0===S?d:S,k=O.yoloAnchors,T=void 0===k?f.YOLO_ANCHORS:k,R=O.maxBoxes,A=void 0===R?v:R,N=O.width,F=void 0===N?h:N,C=O.height,I=void 0===C?h:C,G=O.numClasses,D=void 0===G?80:G,H=O.classNames,B=void 0===H?l.default:H;return u.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(null!==(n=s.tidy(function(){var t=r.predict(e),n=(0,f.yolo_head)(t,T,D),o=(0,i.default)(n,4),u=o[0],a=o[1],c=o[2],l=o[3],p=(0,f.yolo_boxes_to_corners)(u,a),h=(0,f.yolo_filter_boxes)(p,c,l,E),v=(0,i.default)(h,3),d=v[0],y=v[1],m=v[2];if(null==d)return null;var g=s.scalar(F),x=s.scalar(I),_=s.stack([x,g,x,g]).reshape([1,4]);return[d=s.mul(d,_),y,m]}))){t.next=3;break}return t.abrupt("return",[]);case 3:return o=(0,i.default)(n,3),a=o[0],c=o[1],p=o[2],t.next=6,s.image.nonMaxSuppressionAsync(a,c,A,M);case 6:return g=t.sent,t.next=9,p.gather(g).data();case 9:return x=t.sent,t.next=12,c.gather(g).data();case 12:return _=t.sent,t.next=15,a.gather(g).data();case 15:return w=t.sent,s.dispose(n),g.dispose(),b=[],x.forEach(function(t,e){var r=_[e];if(!(r<L)){var n=B[t],o=[w[4*e],w[4*e+1],w[4*e+2],w[4*e+3]],i=o[0],u=o[1],a=o[2],c=o[3];i=Math.max(0,i),u=Math.max(0,u);var s={className:n,classProb:r,bottom:a=Math.min(I,a),top:i,left:u,right:c=Math.min(F,c)};b.push(s)}}),t.abrupt("return",b);case 21:case"end":return t.stop()}},t,this)})),function(t,e){return o.apply(this,arguments)}),s=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}(r(24)),f=r(40),l=p(r(39));function p(t){return t&&t.__esModule?t:{default:t}}var h=416,v=2048,d=.01,y=.4,m=.4,g="https://raw.githubusercontent.com/MikeShi42/yolo-tiny-tfjs/master/model2.json";e.default=c},function(t,e,r){t.exports=r(84)}])});