longpipe 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -270
- package/dist/audio.cjs +33 -0
- package/dist/audio.d.cts +37 -0
- package/dist/audio.d.ts +37 -0
- package/dist/audio.js +1 -0
- package/dist/chunk-JM6V2XLC.js +33 -0
- package/dist/chunk-NYCCJS3G.js +4924 -0
- package/dist/chunk-O4OF2WRO.js +33 -0
- package/dist/index-BctoEDhZ.d.cts +288 -0
- package/dist/index-BctoEDhZ.d.ts +288 -0
- package/dist/index.cjs +42 -42
- package/dist/index.d.cts +5 -242
- package/dist/index.d.ts +5 -242
- package/dist/index.js +2 -4956
- package/dist/messages-DjW-szBq.d.cts +14 -0
- package/dist/messages-DjW-szBq.d.ts +14 -0
- package/dist/model.cjs +7008 -0
- package/dist/model.d.cts +155 -0
- package/dist/model.d.ts +155 -0
- package/dist/model.js +2085 -0
- package/package.json +12 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var a={rnnoise:{wasm:"rnnoise.wasm",weights:null,scaleIn:32768,scaleOut:30517578125e-15,needsSimd:false,exports:{malloc:"malloc",create:"rn_create",process:"rn_process"}},dfn:{wasm:"dfn.wasm",weights:"dfn_weights.pack",scaleIn:1,scaleOut:1,needsSimd:true,exports:{malloc:"df_lite_malloc",create:"df_lite_create",process:"df_lite_process",setBeta:"df_lite_set_beta",setGruLeak:"df_lite_set_gru_leak"}},dfnint8:{wasm:"dfn.wasm",weights:"dfn_weights_int8.pack",scaleIn:1,scaleOut:1,needsSimd:true,exports:{malloc:"df_lite_malloc",create:"df_lite_create_i8",process:"df_lite_process",setBeta:"df_lite_set_beta",setGruLeak:"df_lite_set_gru_leak"}}},_={high:"dfn",mid:"dfnint8",low:"rnnoise"},b=["high","mid","low"];function M(t){return b.includes(t)}function c(t){return M(t)?_[t]:t}function m(t,e){return `${t.replace(/\/$/,"")}/${e}`}async function p(t){let e=await fetch(t);if(!e.ok)throw new Error(`audio asset fetch failed: ${e.status} ${t}`);return e.arrayBuffer()}async function f(t,e){let r=a[t],[s,o]=await Promise.all([p(m(e,r.wasm)),r.weights?p(m(e,r.weights)):Promise.resolve(null)]);return {wasmBytes:s,weights:o}}function l(){try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,22,1,20,0,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11]))}catch{return false}}var k=1.3,x=64,S=3,R=`
|
|
2
|
+
self.onmessage = async (e) => {
|
|
3
|
+
const { wasmUrl, iters, rounds, budget } = e.data
|
|
4
|
+
try {
|
|
5
|
+
const res = await fetch(wasmUrl)
|
|
6
|
+
if (!res.ok) throw new Error(res.status + ' ' + wasmUrl)
|
|
7
|
+
const module = await WebAssembly.compile(await res.arrayBuffer())
|
|
8
|
+
const imports = {}
|
|
9
|
+
for (const im of WebAssembly.Module.imports(module)) {
|
|
10
|
+
;(imports[im.module] = imports[im.module] || {})
|
|
11
|
+
if (im.kind === 'function') imports[im.module][im.name] = () => 0
|
|
12
|
+
}
|
|
13
|
+
const ex = new WebAssembly.Instance(module, imports).exports
|
|
14
|
+
const best = (fn) => {
|
|
15
|
+
fn(iters) // warm up
|
|
16
|
+
let b = Infinity
|
|
17
|
+
for (let r = 0; r < rounds; r++) {
|
|
18
|
+
const t = performance.now()
|
|
19
|
+
fn(iters)
|
|
20
|
+
b = Math.min(b, (performance.now() - t) / iters)
|
|
21
|
+
}
|
|
22
|
+
return b
|
|
23
|
+
}
|
|
24
|
+
const dfnMs = best(ex.calibrate_f32)
|
|
25
|
+
const int8Ms = ex.calibrate_i8 ? best(ex.calibrate_i8) : Infinity
|
|
26
|
+
const model = dfnMs <= budget ? 'dfn' : int8Ms <= budget ? 'dfnint8' : 'rnnoise'
|
|
27
|
+
self.postMessage({ model, dfnMs, int8Ms })
|
|
28
|
+
} catch (err) {
|
|
29
|
+
self.postMessage({ error: (err && err.message) || String(err) })
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;async function g(t,e){if(!l())return "rnnoise";let r=`${t.replace(/\/$/,"")}/${a.dfn.wasm}`,s=null,o=null;try{s=URL.createObjectURL(new Blob([R],{type:"application/javascript"})),o=new Worker(s);let i=await new Promise((h,n)=>{o.onmessage=u=>h(u.data),o.onerror=u=>n(new Error(u.message||"probe worker error")),o.postMessage({wasmUrl:r,iters:x,rounds:S,budget:k});});if(i.error)throw new Error(i.error);return i.model??"rnnoise"}catch(i){return e?.(`audio tier probe failed (${i.message??String(i)}); using rnnoise`),"rnnoise"}finally{o?.terminate(),s&&URL.revokeObjectURL(s);}}var d='var b=Object.defineProperty;var y=(u,a,i)=>a in u?b(u,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[a]=i;var r=(u,a,i)=>y(u,typeof a!="symbol"?a+"":a,i);var f={rnnoise:{wasm:"rnnoise.wasm",weights:null,scaleIn:32768,scaleOut:30517578125e-15,needsSimd:!1,exports:{malloc:"malloc",create:"rn_create",process:"rn_process"}},dfn:{wasm:"dfn.wasm",weights:"dfn_weights.pack",scaleIn:1,scaleOut:1,needsSimd:!0,exports:{malloc:"df_lite_malloc",create:"df_lite_create",process:"df_lite_process",setBeta:"df_lite_set_beta",setGruLeak:"df_lite_set_gru_leak"}},dfnint8:{wasm:"dfn.wasm",weights:"dfn_weights_int8.pack",scaleIn:1,scaleOut:1,needsSimd:!0,exports:{malloc:"df_lite_malloc",create:"df_lite_create_i8",process:"df_lite_process",setBeta:"df_lite_set_beta",setGruLeak:"df_lite_set_gru_leak"}}};var c=4096,m=class extends AudioWorkletProcessor{constructor(i){super();r(this,"cfg");r(this,"mem");r(this,"run");r(this,"state",0);r(this,"inPtr",0);r(this,"outPtr",0);r(this,"setBeta",null);r(this,"setGruLeak",null);r(this,"resample",!1);r(this,"rsPush",null);r(this,"inRs",0);r(this,"outRs",0);r(this,"rsDevInPtr",0);r(this,"rsOutPtr",0);r(this,"enabled");r(this,"model");r(this,"inAcc",new Float32Array(480));r(this,"inFill",0);r(this,"outRing",new Float32Array(4096));r(this,"outRead",0);r(this,"outWrite",0);r(this,"outCount",0);r(this,"primed",!1);r(this,"now");r(this,"times",new Float32Array(256));r(this,"tIdx",0);r(this,"hops",0);r(this,"_f32",null);let o=i.processorOptions;this.model=o.model,this.enabled=o.enabled,this.cfg=f[o.model];try{let t=this.instantiate(o.wasmBytes),e=n=>n?t[n]:void 0;this.mem=t.memory;let s=t[this.cfg.exports.malloc];if(this.run=t[this.cfg.exports.process],this.inPtr=s(480*4),this.outPtr=s(480*4),o.weights?this.state=t[this.cfg.exports.create](this.upload(s,o.weights),o.weights.byteLength):this.state=t[this.cfg.exports.create](),this.setBeta=e(this.cfg.exports.setBeta)??null,this.setGruLeak=e(this.cfg.exports.setGruLeak)??null,this.setBeta&&(o.postFilterBeta??0)>0&&this.setBeta(this.state,o.postFilterBeta),this.setGruLeak&&(o.gruLeak??1)<1&&this.setGruLeak(this.state,o.gruLeak),sampleRate!==48e3){let n=t.df_resampler_create;this.rsPush=t.df_resampler_push??null,n&&this.rsPush?(this.resample=!0,this.inRs=n(sampleRate,48e3),this.outRs=n(48e3,sampleRate),this.rsDevInPtr=s(256*4),this.rsOutPtr=s(c*4)):this.post({type:"error",message:`${o.model} can\'t resample ${sampleRate}\\u219248000 Hz; needs a 48 kHz AudioContext`})}}catch(t){let e=t;this.post({type:"error",message:`denoise init failed: ${e.message??String(t)}${e.stack?`\n`+e.stack:""}`})}this.now=typeof performance<"u"&&performance.now?()=>performance.now():null,this.port.onmessage=t=>{let e=t.data;e.type==="enabled"?this.enabled=e.value:e.type==="config"&&(this.setBeta&&e.postFilterBeta!=null&&this.setBeta(this.state,e.postFilterBeta),this.setGruLeak&&e.gruLeak!=null&&this.setGruLeak(this.state,e.gruLeak))},this.post({type:"ready"})}instantiate(i){var e;let o=new WebAssembly.Module(i),t={};for(let s of WebAssembly.Module.imports(o))t[e=s.module]??(t[e]={}),s.kind==="function"?t[s.module][s.name]=()=>0:s.kind==="memory"?t[s.module][s.name]=new WebAssembly.Memory({initial:256}):s.kind==="table"?t[s.module][s.name]=new WebAssembly.Table({initial:0,element:"anyfunc"}):s.kind==="global"&&(t[s.module][s.name]=new WebAssembly.Global({value:"i32",mutable:!1},0));return new WebAssembly.Instance(o,t).exports}upload(i,o){let t=new Uint8Array(o),e=i(t.length);return new Uint8Array(this.mem.buffer).set(t,e),e}heap(){return(!this._f32||this._f32.buffer!==this.mem.buffer)&&(this._f32=new Float32Array(this.mem.buffer)),this._f32}post(i){this.port.postMessage(i)}pushOut(i){this.outRing[this.outWrite]=i,this.outWrite=(this.outWrite+1)%this.outRing.length,this.outCount++}feed48k(i,o){for(let t=0;t<o;t++)this.inAcc[this.inFill++]=i[t],this.inFill===480&&(this.runHop(),this.inFill=0)}runHop(){let i=this.heap(),o=this.inPtr>>2;for(let e=0;e<480;e++)i[o+e]=this.inAcc[e]*this.cfg.scaleIn;let t=this.now?this.now():0;if(this.run(this.state,this.inPtr,this.outPtr),this.now&&(this.times[this.tIdx=this.tIdx+1&255]=this.now()-t),this.resample&&this.rsPush){let e=this.rsPush(this.outRs,this.outPtr,480,this.rsOutPtr,c);i=this.heap();let s=this.rsOutPtr>>2;for(let n=0;n<e;n++)this.pushOut(i[s+n])}else{let e=this.outPtr>>2;for(let s=0;s<480;s++)this.pushOut(i[e+s]*this.cfg.scaleOut)}++this.hops>=50&&(this.reportStats(),this.hops=0)}reportStats(){let i=Array.from(this.times).filter(e=>e>0).sort((e,s)=>e-s),o=e=>i.length?i[Math.min(i.length-1,Math.floor(e*i.length))]:null,t={model:this.model,p50Ms:this.now?o(.5):null,p95Ms:this.now?o(.95):null,latencyMs:this.outCount/sampleRate*1e3,active:this.enabled&&this.state!==0,sampleRate};this.post({type:"stats",stats:t})}process(i,o){let t=i[0]?.[0],e=o[0]?.[0];if(!e)return!0;let s=e.length;if(!t||!this.enabled||this.state===0)return t&&!this.enabled?e.set(t):e.fill(0),!0;if(this.resample&&this.rsPush){let n=this.heap(),g=this.rsDevInPtr>>2;for(let h=0;h<s;h++)n[g+h]=t[h];let d=this.rsPush(this.inRs,this.rsDevInPtr,s,this.rsOutPtr,c);n=this.heap(),this.feed48k(n.subarray(this.rsOutPtr>>2,(this.rsOutPtr>>2)+d),d)}else this.feed48k(t,s);if(!this.primed)if(this.outCount>=480)this.primed=!0;else return e.fill(0),!0;if(this.outCount>=s)for(let n=0;n<s;n++)e[n]=this.outRing[this.outRead],this.outRead=(this.outRead+1)%this.outRing.length,this.outCount--;else e.fill(0);return!0}};registerProcessor("denoise",m);\n';var w="https://cdn.longpipe.dev/models/v/0.0.5/";var E=.03,v=.995,y=class{constructor(e,r={}){this.opts=r;this.ctx=new AudioContext({sampleRate:48e3}),this.source=this.ctx.createMediaStreamSource(new MediaStream([e])),this.dest=this.ctx.createMediaStreamDestination(),this.outputTrack=this.dest.stream.getAudioTracks()[0],this.resume().catch(()=>{}),this.source.connect(this.dest),this.ready=this.init().then(()=>this.node!==null,s=>(this.opts.onError?.(`audio denoise init failed: ${s.message??String(s)}`),false));}opts;outputTrack;ready;ctx;source;dest;node=null;model=null;latestStats=null;destroyed=false;resolveExplicit(){let e=c(this.opts.model);return a[e].needsSimd&&!l()?(this.opts.onError?.(`${e} needs wasm SIMD; falling back to rnnoise`),"rnnoise"):e}async init(){let e=this.opts.weightsBaseUrl??w,r=(this.opts.model??"auto")==="auto"?await g(e,this.opts.onError):this.resolveExplicit();this.model=r;let s=await f(r,e);if(await this.ctx.audioWorklet.addModule(L()),this.destroyed)return;let o={model:r,wasmBytes:s.wasmBytes,weights:s.weights,enabled:this.opts.enabled??true,postFilterBeta:this.opts.postFilterBeta??E,gruLeak:this.opts.gruLeak??v},i=new AudioWorkletNode(this.ctx,"denoise",{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:o});i.port.onmessage=h=>{let n=h.data;n.type==="stats"?this.latestStats=n.stats:n.type==="error"?this.opts.onError?.(n.message):n.type==="ready"&&this.opts.onReady?.();},this.node=i,this.source.disconnect(this.dest),this.source.connect(i).connect(this.dest);}setEnabled(e){this.node?.port.postMessage({type:"enabled",value:e});}setConfig(e){this.node?.port.postMessage({type:"config",...e});}getStats(){return this.latestStats}async resume(){this.destroyed||this.ctx.state!=="suspended"||await this.ctx.resume();}destroy(){this.destroyed=true;try{this.node?.disconnect();}catch{}try{this.source.disconnect();}catch{}this.ctx.close();}};function L(){return URL.createObjectURL(new Blob([d],{type:"application/javascript"}))}
|
|
33
|
+
export{w as a,y as b};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
interface Conv2DWeights {
|
|
2
|
+
weights: ArrayLike<number>;
|
|
3
|
+
bias: ArrayLike<number>;
|
|
4
|
+
}
|
|
5
|
+
interface DepthwiseWeights {
|
|
6
|
+
weights: ArrayLike<number>;
|
|
7
|
+
bias: ArrayLike<number>;
|
|
8
|
+
}
|
|
9
|
+
interface DepthwiseSeparableWeights {
|
|
10
|
+
dw: DepthwiseWeights;
|
|
11
|
+
pw: Conv2DWeights;
|
|
12
|
+
}
|
|
13
|
+
interface MBConvWeights {
|
|
14
|
+
expand: Conv2DWeights;
|
|
15
|
+
dw: DepthwiseWeights;
|
|
16
|
+
proj: Conv2DWeights;
|
|
17
|
+
}
|
|
18
|
+
interface DecoderBlockWeights {
|
|
19
|
+
conv1: Conv2DWeights;
|
|
20
|
+
conv2: Conv2DWeights;
|
|
21
|
+
}
|
|
22
|
+
interface UNetWrapperWeights {
|
|
23
|
+
down1: Conv2DWeights;
|
|
24
|
+
down2?: Conv2DWeights;
|
|
25
|
+
adapter: Conv2DWeights;
|
|
26
|
+
expandFeat: Conv2DWeights;
|
|
27
|
+
up1Combine?: Conv2DWeights;
|
|
28
|
+
upCombine: Conv2DWeights;
|
|
29
|
+
}
|
|
30
|
+
interface FlowWeights {
|
|
31
|
+
stem: Conv2DWeights;
|
|
32
|
+
stages: Conv2DWeights[];
|
|
33
|
+
predictBot: Conv2DWeights;
|
|
34
|
+
deconv: Conv2DWeights[];
|
|
35
|
+
predict: Conv2DWeights[];
|
|
36
|
+
}
|
|
37
|
+
interface FaceWeights {
|
|
38
|
+
proj: Conv2DWeights;
|
|
39
|
+
block1: DecoderBlockWeights;
|
|
40
|
+
block2: DecoderBlockWeights;
|
|
41
|
+
out: Conv2DWeights;
|
|
42
|
+
}
|
|
43
|
+
interface LandmarkWeights {
|
|
44
|
+
stem: Conv2DWeights;
|
|
45
|
+
blocks: Conv2DWeights[];
|
|
46
|
+
headConv: Conv2DWeights;
|
|
47
|
+
fc: Conv2DWeights;
|
|
48
|
+
}
|
|
49
|
+
interface ModelWeights {
|
|
50
|
+
encoder: {
|
|
51
|
+
stem: Conv2DWeights;
|
|
52
|
+
s0: DepthwiseSeparableWeights;
|
|
53
|
+
s1: MBConvWeights[];
|
|
54
|
+
s2: MBConvWeights[];
|
|
55
|
+
s3: MBConvWeights[];
|
|
56
|
+
s4: MBConvWeights[];
|
|
57
|
+
s5?: MBConvWeights[];
|
|
58
|
+
s6?: MBConvWeights[];
|
|
59
|
+
};
|
|
60
|
+
bottleneck: Conv2DWeights;
|
|
61
|
+
decoder: {
|
|
62
|
+
blocks: DecoderBlockWeights[];
|
|
63
|
+
finalUpsample: Conv2DWeights;
|
|
64
|
+
outputConv: Conv2DWeights;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type Dtype = 'f32' | 'f16';
|
|
69
|
+
interface Tensor {
|
|
70
|
+
readonly h: number;
|
|
71
|
+
readonly w: number;
|
|
72
|
+
readonly c: number;
|
|
73
|
+
}
|
|
74
|
+
interface MLBuffer {
|
|
75
|
+
}
|
|
76
|
+
interface Op {
|
|
77
|
+
readonly inputs: Tensor[];
|
|
78
|
+
readonly output: Tensor;
|
|
79
|
+
run(): void;
|
|
80
|
+
}
|
|
81
|
+
interface Presenter {
|
|
82
|
+
run(): void;
|
|
83
|
+
}
|
|
84
|
+
type RenderTarget = "main" | "preview";
|
|
85
|
+
type Activation = "none" | "relu6" | "relu" | "leaky";
|
|
86
|
+
interface Conv2dParams {
|
|
87
|
+
outChannels: number;
|
|
88
|
+
kernel: number;
|
|
89
|
+
stride: number;
|
|
90
|
+
padding: number | "same" | "valid";
|
|
91
|
+
activation: Activation;
|
|
92
|
+
}
|
|
93
|
+
interface DepthwiseParams {
|
|
94
|
+
kernel: number;
|
|
95
|
+
stride: number;
|
|
96
|
+
padding: number | "same" | "valid";
|
|
97
|
+
activation: Activation;
|
|
98
|
+
}
|
|
99
|
+
interface ConvTranspose2dParams {
|
|
100
|
+
outChannels: number;
|
|
101
|
+
kernel: number;
|
|
102
|
+
stride: number;
|
|
103
|
+
padding: number;
|
|
104
|
+
activation: Activation;
|
|
105
|
+
}
|
|
106
|
+
interface WarpParams {
|
|
107
|
+
flowScale: number;
|
|
108
|
+
}
|
|
109
|
+
interface StabilizeParams {
|
|
110
|
+
tLo: number;
|
|
111
|
+
tHi: number;
|
|
112
|
+
leak: number;
|
|
113
|
+
release: number;
|
|
114
|
+
tDiv: number;
|
|
115
|
+
divScale: number;
|
|
116
|
+
stepX: number;
|
|
117
|
+
stepY: number;
|
|
118
|
+
}
|
|
119
|
+
interface UpsampleParams {
|
|
120
|
+
outH: number;
|
|
121
|
+
outW: number;
|
|
122
|
+
}
|
|
123
|
+
interface FaceBoxParams {
|
|
124
|
+
win: number;
|
|
125
|
+
thresh: number;
|
|
126
|
+
boxScale: number;
|
|
127
|
+
}
|
|
128
|
+
interface FaceBoxesParams extends FaceBoxParams {
|
|
129
|
+
maxFaces: number;
|
|
130
|
+
tol: number;
|
|
131
|
+
}
|
|
132
|
+
interface CropResampleParams {
|
|
133
|
+
outH: number;
|
|
134
|
+
outW: number;
|
|
135
|
+
mean: [number, number, number];
|
|
136
|
+
std: [number, number, number];
|
|
137
|
+
slot?: number;
|
|
138
|
+
}
|
|
139
|
+
interface LandmarkOverlayParams {
|
|
140
|
+
count: number;
|
|
141
|
+
thresh: number;
|
|
142
|
+
pointSize: number;
|
|
143
|
+
color: [number, number, number];
|
|
144
|
+
slot?: number;
|
|
145
|
+
drawImage?: boolean;
|
|
146
|
+
}
|
|
147
|
+
interface ReframeStateParams {
|
|
148
|
+
zoom: number;
|
|
149
|
+
gravity: number;
|
|
150
|
+
margin: number;
|
|
151
|
+
deadband: number;
|
|
152
|
+
ease: number;
|
|
153
|
+
aspect: number;
|
|
154
|
+
}
|
|
155
|
+
interface FaceTouchupStageOp extends Op {
|
|
156
|
+
setActiveSlots(n: number): void;
|
|
157
|
+
}
|
|
158
|
+
interface FaceTopology {
|
|
159
|
+
count: number;
|
|
160
|
+
uv: Float32Array;
|
|
161
|
+
idx: Float32Array;
|
|
162
|
+
weightMask: ImageBitmap;
|
|
163
|
+
}
|
|
164
|
+
type FaceTouchupStyle = "freq-sep" | "bilateral";
|
|
165
|
+
interface FaceTouchupParams {
|
|
166
|
+
strength: number;
|
|
167
|
+
amount: number;
|
|
168
|
+
detail: number;
|
|
169
|
+
thresh: number;
|
|
170
|
+
style?: FaceTouchupStyle;
|
|
171
|
+
slots?: number;
|
|
172
|
+
}
|
|
173
|
+
interface UpsampleConv1x1Params {
|
|
174
|
+
outH: number;
|
|
175
|
+
outW: number;
|
|
176
|
+
outChannels: number;
|
|
177
|
+
activation: Activation;
|
|
178
|
+
}
|
|
179
|
+
interface ProjResidualParams {
|
|
180
|
+
outChannels: number;
|
|
181
|
+
}
|
|
182
|
+
interface ConcatConv2dParams {
|
|
183
|
+
outChannels: number;
|
|
184
|
+
}
|
|
185
|
+
interface DownAdapterParams {
|
|
186
|
+
stride: number;
|
|
187
|
+
}
|
|
188
|
+
type ImageSource = ImageBitmap | VideoFrame;
|
|
189
|
+
interface InputOp {
|
|
190
|
+
readonly output: Tensor;
|
|
191
|
+
setSource(src: ImageSource): void;
|
|
192
|
+
run(): void;
|
|
193
|
+
}
|
|
194
|
+
type DataView_ = Float32Array | Uint16Array;
|
|
195
|
+
interface Backend {
|
|
196
|
+
readonly dtype: Dtype;
|
|
197
|
+
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
198
|
+
tensor(h: number, w: number, c: number, data?: DataView_): Tensor;
|
|
199
|
+
upload(data: DataView_): MLBuffer;
|
|
200
|
+
ops: {
|
|
201
|
+
Conv2d: (input: Tensor, weights: Conv2DWeights, params: Conv2dParams) => Op;
|
|
202
|
+
ConvTranspose2d: (input: Tensor, weights: Conv2DWeights, params: ConvTranspose2dParams) => Op;
|
|
203
|
+
DepthwiseConv2d: (input: Tensor, weights: DepthwiseWeights, params: DepthwiseParams) => Op;
|
|
204
|
+
Add: (a: Tensor, b: Tensor) => Op;
|
|
205
|
+
Sigmoid: (input: Tensor) => Op;
|
|
206
|
+
BilinearUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
207
|
+
Crop: (input: Tensor, params: UpsampleParams) => Op;
|
|
208
|
+
BicubicUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
209
|
+
ChannelConcat: (a: Tensor, b: Tensor) => Op;
|
|
210
|
+
Tanh: (input: Tensor) => Op;
|
|
211
|
+
ElementwiseMul: (a: Tensor, b: Tensor) => Op;
|
|
212
|
+
Warp: (source: Tensor, flow: Tensor, params: WarpParams) => Op;
|
|
213
|
+
FaceBoxFromHeatmaps: (heatmaps: Tensor, params: FaceBoxParams) => Op;
|
|
214
|
+
FaceBoxesFromHeatmaps: (heatmaps: Tensor, params: FaceBoxesParams) => Op;
|
|
215
|
+
ReframeState: (boxes: Tensor, prev: Tensor, cmd: Tensor, params: ReframeStateParams) => Op;
|
|
216
|
+
Reframe: (src: Tensor, rect: Tensor) => Op;
|
|
217
|
+
FaceTouchupStage: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams) => FaceTouchupStageOp;
|
|
218
|
+
CropResample: (frame: Tensor, box: Tensor, params: CropResampleParams) => Op;
|
|
219
|
+
Stabilize: (flow: Tensor, pred: Tensor, ref: Tensor, envPrev: Tensor, params: StabilizeParams) => Op;
|
|
220
|
+
GatesFused: (uIn: Tensor, hPrev: Tensor, weights: Conv2DWeights) => Op;
|
|
221
|
+
CandUpdateFused: (uIn: Tensor, hPrev: Tensor, gatesOut: Tensor, weights: Conv2DWeights, gamma: ArrayLike<number>) => Op;
|
|
222
|
+
ConvExpand: (input: Tensor, weights: Conv2DWeights) => Op;
|
|
223
|
+
CatConv6to2: (u: Tensor, d: Tensor, weights: Conv2DWeights) => Op;
|
|
224
|
+
DownAdapter: (input: Tensor, downWeights: Conv2DWeights, adaptWeights: Conv2DWeights, params: DownAdapterParams) => Op;
|
|
225
|
+
UpFinal: (u: Tensor, rgb: Tensor, weights: Conv2DWeights) => Op;
|
|
226
|
+
UpFinalSkip: (u: Tensor, dFull: Tensor, rgb: Tensor, weights: Conv2DWeights) => Op;
|
|
227
|
+
Conv2dAdd: (input: Tensor, skip: Tensor, weights: Conv2DWeights, params: Conv2dParams) => Op;
|
|
228
|
+
ProjResidual: (input: Tensor, skip: Tensor, weights: Conv2DWeights, params: ProjResidualParams) => Op;
|
|
229
|
+
ConcatConv2d: (a: Tensor, b: Tensor, weights: Conv2DWeights, params: ConcatConv2dParams) => Op;
|
|
230
|
+
UpsampleConcat: (a: Tensor, b: Tensor, params: UpsampleParams) => Op;
|
|
231
|
+
UpsampleConv1x1: (input: Tensor, weights: Conv2DWeights, params: UpsampleConv1x1Params) => Op;
|
|
232
|
+
UpsampleSigmoid: (input: Tensor, params: UpsampleParams) => Op;
|
|
233
|
+
Input: (h: number, w: number) => InputOp;
|
|
234
|
+
};
|
|
235
|
+
presenters: {
|
|
236
|
+
CompositeSolid: (image: Tensor, alpha: Tensor, bgColor: [number, number, number], target?: RenderTarget) => Presenter;
|
|
237
|
+
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
238
|
+
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
239
|
+
CompositePassthrough: (image: Tensor, target?: RenderTarget) => Presenter;
|
|
240
|
+
LandmarkOverlay: (image: Tensor, landmarks: Tensor, box: Tensor, params: LandmarkOverlayParams, target?: RenderTarget) => Presenter;
|
|
241
|
+
FaceTouchup: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams, target?: RenderTarget) => Presenter;
|
|
242
|
+
};
|
|
243
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
244
|
+
readback(tensor: Tensor): Promise<Float32Array>;
|
|
245
|
+
copyTensor(src: Tensor, dst: Tensor): void;
|
|
246
|
+
sync(): Promise<void>;
|
|
247
|
+
destroy(): void;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
interface WebGPUTensor extends Tensor {
|
|
251
|
+
readonly buffer: GPUBuffer;
|
|
252
|
+
}
|
|
253
|
+
interface WebGPUMLBuffer extends MLBuffer {
|
|
254
|
+
readonly buffer: GPUBuffer;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface WebGPUBackendOptions {
|
|
258
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
259
|
+
device?: GPUDevice;
|
|
260
|
+
dtype?: Dtype;
|
|
261
|
+
}
|
|
262
|
+
declare class WebGPUBackend implements Backend {
|
|
263
|
+
readonly device: GPUDevice;
|
|
264
|
+
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
265
|
+
readonly dtype: Dtype;
|
|
266
|
+
readonly ops: Backend["ops"];
|
|
267
|
+
readonly presenters: Backend["presenters"];
|
|
268
|
+
readonly canvasContext: GPUCanvasContext;
|
|
269
|
+
readonly canvasFormat: GPUTextureFormat;
|
|
270
|
+
readonly bytesPerElement: 2 | 4;
|
|
271
|
+
private readonly contexts;
|
|
272
|
+
private constructor();
|
|
273
|
+
private configureContext;
|
|
274
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
275
|
+
static isAvailable(): Promise<boolean>;
|
|
276
|
+
static hasF16Support(): Promise<boolean>;
|
|
277
|
+
static create(opts: WebGPUBackendOptions): Promise<WebGPUBackend>;
|
|
278
|
+
getCurrentDisplayTexture(target?: RenderTarget): GPUTexture;
|
|
279
|
+
tensor(h: number, w: number, c: number, data?: DataView_): WebGPUTensor;
|
|
280
|
+
upload(data: DataView_): WebGPUMLBuffer;
|
|
281
|
+
private writeView;
|
|
282
|
+
readback(tensor: WebGPUTensor): Promise<Float32Array>;
|
|
283
|
+
copyTensor(src: WebGPUTensor, dst: WebGPUTensor): void;
|
|
284
|
+
sync(): Promise<void>;
|
|
285
|
+
destroy(): void;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export { type Activation as A, type Backend as B, type Conv2dParams as C, type Dtype as D, type FaceTouchupStyle as F, type InputOp as I, type LandmarkWeights as L, type MLBuffer as M, type Op as O, type Presenter as P, type RenderTarget as R, type Tensor as T, type UNetWrapperWeights as U, WebGPUBackend as W, type DepthwiseParams as a, type DataView_ as b, type ModelWeights as c, type ImageSource as d, type Conv2DWeights as e, type DecoderBlockWeights as f, type DepthwiseWeights as g, type FaceWeights as h, type FlowWeights as i, type MBConvWeights as j, type UpsampleParams as k };
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
interface Conv2DWeights {
|
|
2
|
+
weights: ArrayLike<number>;
|
|
3
|
+
bias: ArrayLike<number>;
|
|
4
|
+
}
|
|
5
|
+
interface DepthwiseWeights {
|
|
6
|
+
weights: ArrayLike<number>;
|
|
7
|
+
bias: ArrayLike<number>;
|
|
8
|
+
}
|
|
9
|
+
interface DepthwiseSeparableWeights {
|
|
10
|
+
dw: DepthwiseWeights;
|
|
11
|
+
pw: Conv2DWeights;
|
|
12
|
+
}
|
|
13
|
+
interface MBConvWeights {
|
|
14
|
+
expand: Conv2DWeights;
|
|
15
|
+
dw: DepthwiseWeights;
|
|
16
|
+
proj: Conv2DWeights;
|
|
17
|
+
}
|
|
18
|
+
interface DecoderBlockWeights {
|
|
19
|
+
conv1: Conv2DWeights;
|
|
20
|
+
conv2: Conv2DWeights;
|
|
21
|
+
}
|
|
22
|
+
interface UNetWrapperWeights {
|
|
23
|
+
down1: Conv2DWeights;
|
|
24
|
+
down2?: Conv2DWeights;
|
|
25
|
+
adapter: Conv2DWeights;
|
|
26
|
+
expandFeat: Conv2DWeights;
|
|
27
|
+
up1Combine?: Conv2DWeights;
|
|
28
|
+
upCombine: Conv2DWeights;
|
|
29
|
+
}
|
|
30
|
+
interface FlowWeights {
|
|
31
|
+
stem: Conv2DWeights;
|
|
32
|
+
stages: Conv2DWeights[];
|
|
33
|
+
predictBot: Conv2DWeights;
|
|
34
|
+
deconv: Conv2DWeights[];
|
|
35
|
+
predict: Conv2DWeights[];
|
|
36
|
+
}
|
|
37
|
+
interface FaceWeights {
|
|
38
|
+
proj: Conv2DWeights;
|
|
39
|
+
block1: DecoderBlockWeights;
|
|
40
|
+
block2: DecoderBlockWeights;
|
|
41
|
+
out: Conv2DWeights;
|
|
42
|
+
}
|
|
43
|
+
interface LandmarkWeights {
|
|
44
|
+
stem: Conv2DWeights;
|
|
45
|
+
blocks: Conv2DWeights[];
|
|
46
|
+
headConv: Conv2DWeights;
|
|
47
|
+
fc: Conv2DWeights;
|
|
48
|
+
}
|
|
49
|
+
interface ModelWeights {
|
|
50
|
+
encoder: {
|
|
51
|
+
stem: Conv2DWeights;
|
|
52
|
+
s0: DepthwiseSeparableWeights;
|
|
53
|
+
s1: MBConvWeights[];
|
|
54
|
+
s2: MBConvWeights[];
|
|
55
|
+
s3: MBConvWeights[];
|
|
56
|
+
s4: MBConvWeights[];
|
|
57
|
+
s5?: MBConvWeights[];
|
|
58
|
+
s6?: MBConvWeights[];
|
|
59
|
+
};
|
|
60
|
+
bottleneck: Conv2DWeights;
|
|
61
|
+
decoder: {
|
|
62
|
+
blocks: DecoderBlockWeights[];
|
|
63
|
+
finalUpsample: Conv2DWeights;
|
|
64
|
+
outputConv: Conv2DWeights;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type Dtype = 'f32' | 'f16';
|
|
69
|
+
interface Tensor {
|
|
70
|
+
readonly h: number;
|
|
71
|
+
readonly w: number;
|
|
72
|
+
readonly c: number;
|
|
73
|
+
}
|
|
74
|
+
interface MLBuffer {
|
|
75
|
+
}
|
|
76
|
+
interface Op {
|
|
77
|
+
readonly inputs: Tensor[];
|
|
78
|
+
readonly output: Tensor;
|
|
79
|
+
run(): void;
|
|
80
|
+
}
|
|
81
|
+
interface Presenter {
|
|
82
|
+
run(): void;
|
|
83
|
+
}
|
|
84
|
+
type RenderTarget = "main" | "preview";
|
|
85
|
+
type Activation = "none" | "relu6" | "relu" | "leaky";
|
|
86
|
+
interface Conv2dParams {
|
|
87
|
+
outChannels: number;
|
|
88
|
+
kernel: number;
|
|
89
|
+
stride: number;
|
|
90
|
+
padding: number | "same" | "valid";
|
|
91
|
+
activation: Activation;
|
|
92
|
+
}
|
|
93
|
+
interface DepthwiseParams {
|
|
94
|
+
kernel: number;
|
|
95
|
+
stride: number;
|
|
96
|
+
padding: number | "same" | "valid";
|
|
97
|
+
activation: Activation;
|
|
98
|
+
}
|
|
99
|
+
interface ConvTranspose2dParams {
|
|
100
|
+
outChannels: number;
|
|
101
|
+
kernel: number;
|
|
102
|
+
stride: number;
|
|
103
|
+
padding: number;
|
|
104
|
+
activation: Activation;
|
|
105
|
+
}
|
|
106
|
+
interface WarpParams {
|
|
107
|
+
flowScale: number;
|
|
108
|
+
}
|
|
109
|
+
interface StabilizeParams {
|
|
110
|
+
tLo: number;
|
|
111
|
+
tHi: number;
|
|
112
|
+
leak: number;
|
|
113
|
+
release: number;
|
|
114
|
+
tDiv: number;
|
|
115
|
+
divScale: number;
|
|
116
|
+
stepX: number;
|
|
117
|
+
stepY: number;
|
|
118
|
+
}
|
|
119
|
+
interface UpsampleParams {
|
|
120
|
+
outH: number;
|
|
121
|
+
outW: number;
|
|
122
|
+
}
|
|
123
|
+
interface FaceBoxParams {
|
|
124
|
+
win: number;
|
|
125
|
+
thresh: number;
|
|
126
|
+
boxScale: number;
|
|
127
|
+
}
|
|
128
|
+
interface FaceBoxesParams extends FaceBoxParams {
|
|
129
|
+
maxFaces: number;
|
|
130
|
+
tol: number;
|
|
131
|
+
}
|
|
132
|
+
interface CropResampleParams {
|
|
133
|
+
outH: number;
|
|
134
|
+
outW: number;
|
|
135
|
+
mean: [number, number, number];
|
|
136
|
+
std: [number, number, number];
|
|
137
|
+
slot?: number;
|
|
138
|
+
}
|
|
139
|
+
interface LandmarkOverlayParams {
|
|
140
|
+
count: number;
|
|
141
|
+
thresh: number;
|
|
142
|
+
pointSize: number;
|
|
143
|
+
color: [number, number, number];
|
|
144
|
+
slot?: number;
|
|
145
|
+
drawImage?: boolean;
|
|
146
|
+
}
|
|
147
|
+
interface ReframeStateParams {
|
|
148
|
+
zoom: number;
|
|
149
|
+
gravity: number;
|
|
150
|
+
margin: number;
|
|
151
|
+
deadband: number;
|
|
152
|
+
ease: number;
|
|
153
|
+
aspect: number;
|
|
154
|
+
}
|
|
155
|
+
interface FaceTouchupStageOp extends Op {
|
|
156
|
+
setActiveSlots(n: number): void;
|
|
157
|
+
}
|
|
158
|
+
interface FaceTopology {
|
|
159
|
+
count: number;
|
|
160
|
+
uv: Float32Array;
|
|
161
|
+
idx: Float32Array;
|
|
162
|
+
weightMask: ImageBitmap;
|
|
163
|
+
}
|
|
164
|
+
type FaceTouchupStyle = "freq-sep" | "bilateral";
|
|
165
|
+
interface FaceTouchupParams {
|
|
166
|
+
strength: number;
|
|
167
|
+
amount: number;
|
|
168
|
+
detail: number;
|
|
169
|
+
thresh: number;
|
|
170
|
+
style?: FaceTouchupStyle;
|
|
171
|
+
slots?: number;
|
|
172
|
+
}
|
|
173
|
+
interface UpsampleConv1x1Params {
|
|
174
|
+
outH: number;
|
|
175
|
+
outW: number;
|
|
176
|
+
outChannels: number;
|
|
177
|
+
activation: Activation;
|
|
178
|
+
}
|
|
179
|
+
interface ProjResidualParams {
|
|
180
|
+
outChannels: number;
|
|
181
|
+
}
|
|
182
|
+
interface ConcatConv2dParams {
|
|
183
|
+
outChannels: number;
|
|
184
|
+
}
|
|
185
|
+
interface DownAdapterParams {
|
|
186
|
+
stride: number;
|
|
187
|
+
}
|
|
188
|
+
type ImageSource = ImageBitmap | VideoFrame;
|
|
189
|
+
interface InputOp {
|
|
190
|
+
readonly output: Tensor;
|
|
191
|
+
setSource(src: ImageSource): void;
|
|
192
|
+
run(): void;
|
|
193
|
+
}
|
|
194
|
+
type DataView_ = Float32Array | Uint16Array;
|
|
195
|
+
interface Backend {
|
|
196
|
+
readonly dtype: Dtype;
|
|
197
|
+
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
198
|
+
tensor(h: number, w: number, c: number, data?: DataView_): Tensor;
|
|
199
|
+
upload(data: DataView_): MLBuffer;
|
|
200
|
+
ops: {
|
|
201
|
+
Conv2d: (input: Tensor, weights: Conv2DWeights, params: Conv2dParams) => Op;
|
|
202
|
+
ConvTranspose2d: (input: Tensor, weights: Conv2DWeights, params: ConvTranspose2dParams) => Op;
|
|
203
|
+
DepthwiseConv2d: (input: Tensor, weights: DepthwiseWeights, params: DepthwiseParams) => Op;
|
|
204
|
+
Add: (a: Tensor, b: Tensor) => Op;
|
|
205
|
+
Sigmoid: (input: Tensor) => Op;
|
|
206
|
+
BilinearUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
207
|
+
Crop: (input: Tensor, params: UpsampleParams) => Op;
|
|
208
|
+
BicubicUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
209
|
+
ChannelConcat: (a: Tensor, b: Tensor) => Op;
|
|
210
|
+
Tanh: (input: Tensor) => Op;
|
|
211
|
+
ElementwiseMul: (a: Tensor, b: Tensor) => Op;
|
|
212
|
+
Warp: (source: Tensor, flow: Tensor, params: WarpParams) => Op;
|
|
213
|
+
FaceBoxFromHeatmaps: (heatmaps: Tensor, params: FaceBoxParams) => Op;
|
|
214
|
+
FaceBoxesFromHeatmaps: (heatmaps: Tensor, params: FaceBoxesParams) => Op;
|
|
215
|
+
ReframeState: (boxes: Tensor, prev: Tensor, cmd: Tensor, params: ReframeStateParams) => Op;
|
|
216
|
+
Reframe: (src: Tensor, rect: Tensor) => Op;
|
|
217
|
+
FaceTouchupStage: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams) => FaceTouchupStageOp;
|
|
218
|
+
CropResample: (frame: Tensor, box: Tensor, params: CropResampleParams) => Op;
|
|
219
|
+
Stabilize: (flow: Tensor, pred: Tensor, ref: Tensor, envPrev: Tensor, params: StabilizeParams) => Op;
|
|
220
|
+
GatesFused: (uIn: Tensor, hPrev: Tensor, weights: Conv2DWeights) => Op;
|
|
221
|
+
CandUpdateFused: (uIn: Tensor, hPrev: Tensor, gatesOut: Tensor, weights: Conv2DWeights, gamma: ArrayLike<number>) => Op;
|
|
222
|
+
ConvExpand: (input: Tensor, weights: Conv2DWeights) => Op;
|
|
223
|
+
CatConv6to2: (u: Tensor, d: Tensor, weights: Conv2DWeights) => Op;
|
|
224
|
+
DownAdapter: (input: Tensor, downWeights: Conv2DWeights, adaptWeights: Conv2DWeights, params: DownAdapterParams) => Op;
|
|
225
|
+
UpFinal: (u: Tensor, rgb: Tensor, weights: Conv2DWeights) => Op;
|
|
226
|
+
UpFinalSkip: (u: Tensor, dFull: Tensor, rgb: Tensor, weights: Conv2DWeights) => Op;
|
|
227
|
+
Conv2dAdd: (input: Tensor, skip: Tensor, weights: Conv2DWeights, params: Conv2dParams) => Op;
|
|
228
|
+
ProjResidual: (input: Tensor, skip: Tensor, weights: Conv2DWeights, params: ProjResidualParams) => Op;
|
|
229
|
+
ConcatConv2d: (a: Tensor, b: Tensor, weights: Conv2DWeights, params: ConcatConv2dParams) => Op;
|
|
230
|
+
UpsampleConcat: (a: Tensor, b: Tensor, params: UpsampleParams) => Op;
|
|
231
|
+
UpsampleConv1x1: (input: Tensor, weights: Conv2DWeights, params: UpsampleConv1x1Params) => Op;
|
|
232
|
+
UpsampleSigmoid: (input: Tensor, params: UpsampleParams) => Op;
|
|
233
|
+
Input: (h: number, w: number) => InputOp;
|
|
234
|
+
};
|
|
235
|
+
presenters: {
|
|
236
|
+
CompositeSolid: (image: Tensor, alpha: Tensor, bgColor: [number, number, number], target?: RenderTarget) => Presenter;
|
|
237
|
+
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
238
|
+
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
239
|
+
CompositePassthrough: (image: Tensor, target?: RenderTarget) => Presenter;
|
|
240
|
+
LandmarkOverlay: (image: Tensor, landmarks: Tensor, box: Tensor, params: LandmarkOverlayParams, target?: RenderTarget) => Presenter;
|
|
241
|
+
FaceTouchup: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams, target?: RenderTarget) => Presenter;
|
|
242
|
+
};
|
|
243
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
244
|
+
readback(tensor: Tensor): Promise<Float32Array>;
|
|
245
|
+
copyTensor(src: Tensor, dst: Tensor): void;
|
|
246
|
+
sync(): Promise<void>;
|
|
247
|
+
destroy(): void;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
interface WebGPUTensor extends Tensor {
|
|
251
|
+
readonly buffer: GPUBuffer;
|
|
252
|
+
}
|
|
253
|
+
interface WebGPUMLBuffer extends MLBuffer {
|
|
254
|
+
readonly buffer: GPUBuffer;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
interface WebGPUBackendOptions {
|
|
258
|
+
canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
259
|
+
device?: GPUDevice;
|
|
260
|
+
dtype?: Dtype;
|
|
261
|
+
}
|
|
262
|
+
declare class WebGPUBackend implements Backend {
|
|
263
|
+
readonly device: GPUDevice;
|
|
264
|
+
readonly canvas: HTMLCanvasElement | OffscreenCanvas;
|
|
265
|
+
readonly dtype: Dtype;
|
|
266
|
+
readonly ops: Backend["ops"];
|
|
267
|
+
readonly presenters: Backend["presenters"];
|
|
268
|
+
readonly canvasContext: GPUCanvasContext;
|
|
269
|
+
readonly canvasFormat: GPUTextureFormat;
|
|
270
|
+
readonly bytesPerElement: 2 | 4;
|
|
271
|
+
private readonly contexts;
|
|
272
|
+
private constructor();
|
|
273
|
+
private configureContext;
|
|
274
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
275
|
+
static isAvailable(): Promise<boolean>;
|
|
276
|
+
static hasF16Support(): Promise<boolean>;
|
|
277
|
+
static create(opts: WebGPUBackendOptions): Promise<WebGPUBackend>;
|
|
278
|
+
getCurrentDisplayTexture(target?: RenderTarget): GPUTexture;
|
|
279
|
+
tensor(h: number, w: number, c: number, data?: DataView_): WebGPUTensor;
|
|
280
|
+
upload(data: DataView_): WebGPUMLBuffer;
|
|
281
|
+
private writeView;
|
|
282
|
+
readback(tensor: WebGPUTensor): Promise<Float32Array>;
|
|
283
|
+
copyTensor(src: WebGPUTensor, dst: WebGPUTensor): void;
|
|
284
|
+
sync(): Promise<void>;
|
|
285
|
+
destroy(): void;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export { type Activation as A, type Backend as B, type Conv2dParams as C, type Dtype as D, type FaceTouchupStyle as F, type InputOp as I, type LandmarkWeights as L, type MLBuffer as M, type Op as O, type Presenter as P, type RenderTarget as R, type Tensor as T, type UNetWrapperWeights as U, WebGPUBackend as W, type DepthwiseParams as a, type DataView_ as b, type ModelWeights as c, type ImageSource as d, type Conv2DWeights as e, type DecoderBlockWeights as f, type DepthwiseWeights as g, type FaceWeights as h, type FlowWeights as i, type MBConvWeights as j, type UpsampleParams as k };
|