face-api/dist/face-api.esm-nobundle.js

10 lines
80 KiB
JavaScript
Raw Normal View History

/*
Face-API
homepage: <https://github.com/vladmandic/face-api>
author: <https://github.com/vladmandic>'
*/
2021-02-06 16:18:46 +01:00
var dn=Object.create,Ge=Object.defineProperty,un=Object.getPrototypeOf,fn=Object.prototype.hasOwnProperty,ln=Object.getOwnPropertyNames,hn=Object.getOwnPropertyDescriptor;var lo=o=>Ge(o,"__esModule",{value:!0});var ho=(o,t)=>()=>(t||(t={exports:{}},o(t.exports,t)),t.exports),Er=(o,t)=>{lo(o);for(var e in t)Ge(o,e,{get:t[e],enumerable:!0})},Bt=(o,t,e)=>{if(lo(o),t&&typeof t=="object"||typeof t=="function")for(let r of ln(t))!fn.call(o,r)&&r!=="default"&&Ge(o,r,{get:()=>t[r],enumerable:!(e=hn(t,r))||e.enumerable});return o},b=o=>o&&o.__esModule?o:Bt(Ge(o!=null?dn(un(o)):{},"default",{value:o,enumerable:!0}),o);import*as Ma from"@tensorflow/tfjs/dist/index.js";import*as Ca from"@tensorflow/tfjs-backend-wasm";var g=ho(xn=>{Bt(xn,Ma);Bt(xn,Ca)});var yo=ho((Pn,vo)=>{Er(Pn,{isNodejs:()=>_n});function _n(){return typeof global=="object"&&!0&&typeof vo!="undefined"&&typeof process!="undefined"&&!!process.version}});var va=b(g());var Qr={};Er(Qr,{AnchorPosition:()=>dt,DrawBox:()=>Xe,DrawBoxOptions:()=>Hr,DrawFaceLandmarks:()=>Kr,DrawFaceLandmarksOptions:()=>Zr,DrawTextField:()=>Mt,DrawTextFieldOptions:()=>Ne,drawContour:()=>lt,drawDetections:()=>En,drawFaceExpressions:()=>In,drawFaceLandmarks:()=>Ln});function lt(o,t,e=!1){if(o.beginPath(),t.slice(1).forEach(({x:r,y:n},a)=>{let s=t[a];o.moveTo(s.x,s.y),o.lineTo(r,n)}),e){let r=t[t.length-1],n=t[0];if(!r||!n)return;o.moveTo(r.x,r.y),o.lineTo(n.x,n.y)}o.stroke()}var Mr={};Er(Mr,{computeReshapedDimensions:()=>Ir,getCenterPoint:()=>Ot,isDimensions:()=>Ve,isEven:()=>ze,isFloat:()=>Nr,isTensor:()=>Rt,isTensor1D:()=>bn,isTensor2D:()=>Cr,isTensor3D:()=>ht,isTensor4D:()=>z,isValidNumber:()=>rt,isValidProbablitiy:()=>ee,range:()=>ct,round:()=>$t});var xo=b(g());var A=class{constructor(t,e){if(!rt(t)||!rt(e))throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({width:t,height:e})}`);this._width=t,this._height=e}get width(){return this._width}get height(){return this._height}reverse(){return new A(1/this.width,1/this.height)}};function Rt(o,t){return o instanceof xo.Tensor&&o.shape.length===t}function bn(o){return Rt(o,1)}function Cr(o){return Rt(o,2)}function ht(o){return Rt(o,3)}function z(o){return Rt(o,4)}function Nr(o){return o%1!=0}function ze(o){return o%2==0}function $t(o,t=2){let e=10**t;return Math.floor(o*e)/e}function Ve(o){return o&&o.width&&o.height}function Ir({width:o,height:t},e){let r=e/Math.max(t,o);return new A(Math.round(o*r),Math.round(t*r))}function Ot(o){return o.reduce((t,e)=>t.add(e),new x(0,0)).div(new x(o.length,o.length))}function ct(o,t,e){return Array(o).fill(0).map((r,n)=>t+n*e)}function rt(o){return!!o&&o!==Infinity&&o!==-Infinity&&!Number.isNaN(o)||o===0}function ee(o){return rt(o)&&o>=0&&o<=1}var x=class{constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}add(t){return new x(this.x+t.x,this.y+t.y)}sub(t){return new x(this.x-t.x,this.y-t.y)}mul(t){return new x(this.x*t.x,this.y*t.y)}div(t){return new x(this.x/t.x,this.y/t.y)}abs(){return new x(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new x(Math.floor(this.x),Math.floor(this.y))}};var D=class{static isRect(t){return!!t&&[t.x,t.y,t.width,t.height].every(rt)}static assertIsValidBox(t,e,r=!1){if(!D.isRect(t))throw new Error(`${e} - invalid box: ${JSON.stringify(t)}, expected object with properties x, y, width, height`);if(!r&&(t.width<0||t.height<0))throw new Error(`${e} - width (${t.width}) and height (${t.height}) must be positive numbers`)}constructor(t,e=!0){let r=t||{},n=[r.left,r.top,r.right,r.bottom].every(rt),a=[r.x,r.y,r.width,r.height].every(rt);if(!a&&!n)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(r)}`);let[s,i,c,m]=a?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top];D.assertIsValidBox({x:s,y:i,width:c,height:m},"Box.constructor",e),this._x=s,this._y=i,this._width=c,this._height=m}get x(){return this._x}get y(){return this._y}get width(){return this._width}get heigh
//# sourceMappingURL=face-api.esm-nobundle.js.map