longpipe 0.0.9 → 0.0.11
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 +4 -3
- package/dist/index.cjs +1160 -239
- package/dist/index.d.cts +42 -6
- package/dist/index.d.ts +42 -6
- package/dist/index.js +1160 -239
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -23,7 +23,8 @@ interface Op {
|
|
|
23
23
|
interface Presenter {
|
|
24
24
|
run(): void;
|
|
25
25
|
}
|
|
26
|
-
type
|
|
26
|
+
type RenderTarget = "main" | "preview";
|
|
27
|
+
type Activation = "none" | "relu6" | "relu" | "leaky";
|
|
27
28
|
interface Conv2dParams {
|
|
28
29
|
outChannels: number;
|
|
29
30
|
kernel: number;
|
|
@@ -37,6 +38,26 @@ interface DepthwiseParams {
|
|
|
37
38
|
padding: number | "same" | "valid";
|
|
38
39
|
activation: Activation;
|
|
39
40
|
}
|
|
41
|
+
interface ConvTranspose2dParams {
|
|
42
|
+
outChannels: number;
|
|
43
|
+
kernel: number;
|
|
44
|
+
stride: number;
|
|
45
|
+
padding: number;
|
|
46
|
+
activation: Activation;
|
|
47
|
+
}
|
|
48
|
+
interface WarpParams {
|
|
49
|
+
flowScale: number;
|
|
50
|
+
}
|
|
51
|
+
interface StabilizeParams {
|
|
52
|
+
tLo: number;
|
|
53
|
+
tHi: number;
|
|
54
|
+
leak: number;
|
|
55
|
+
release: number;
|
|
56
|
+
tDiv: number;
|
|
57
|
+
divScale: number;
|
|
58
|
+
stepX: number;
|
|
59
|
+
stepY: number;
|
|
60
|
+
}
|
|
40
61
|
interface UpsampleParams {
|
|
41
62
|
outH: number;
|
|
42
63
|
outW: number;
|
|
@@ -70,14 +91,18 @@ interface Backend {
|
|
|
70
91
|
upload(data: DataView_): MLBuffer;
|
|
71
92
|
ops: {
|
|
72
93
|
Conv2d: (input: Tensor, weights: Conv2DWeights, params: Conv2dParams) => Op;
|
|
94
|
+
ConvTranspose2d: (input: Tensor, weights: Conv2DWeights, params: ConvTranspose2dParams) => Op;
|
|
73
95
|
DepthwiseConv2d: (input: Tensor, weights: DepthwiseWeights, params: DepthwiseParams) => Op;
|
|
74
96
|
Add: (a: Tensor, b: Tensor) => Op;
|
|
75
97
|
Sigmoid: (input: Tensor) => Op;
|
|
76
98
|
BilinearUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
99
|
+
Crop: (input: Tensor, params: UpsampleParams) => Op;
|
|
77
100
|
BicubicUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
78
101
|
ChannelConcat: (a: Tensor, b: Tensor) => Op;
|
|
79
102
|
Tanh: (input: Tensor) => Op;
|
|
80
103
|
ElementwiseMul: (a: Tensor, b: Tensor) => Op;
|
|
104
|
+
Warp: (source: Tensor, flow: Tensor, params: WarpParams) => Op;
|
|
105
|
+
Stabilize: (flow: Tensor, pred: Tensor, ref: Tensor, envPrev: Tensor, params: StabilizeParams) => Op;
|
|
81
106
|
GatesFused: (uIn: Tensor, hPrev: Tensor, weights: Conv2DWeights) => Op;
|
|
82
107
|
CandUpdateFused: (uIn: Tensor, hPrev: Tensor, gatesOut: Tensor, weights: Conv2DWeights, gamma: ArrayLike<number>) => Op;
|
|
83
108
|
ConvExpand: (input: Tensor, weights: Conv2DWeights) => Op;
|
|
@@ -94,11 +119,12 @@ interface Backend {
|
|
|
94
119
|
Input: (h: number, w: number) => InputOp;
|
|
95
120
|
};
|
|
96
121
|
presenters: {
|
|
97
|
-
CompositeSolid: (image: Tensor, alpha: Tensor, bgColor: [number, number, number]) => Presenter;
|
|
98
|
-
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor) => Presenter;
|
|
99
|
-
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor) => Presenter;
|
|
100
|
-
CompositePassthrough: (image: Tensor) => Presenter;
|
|
122
|
+
CompositeSolid: (image: Tensor, alpha: Tensor, bgColor: [number, number, number], target?: RenderTarget) => Presenter;
|
|
123
|
+
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
124
|
+
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
125
|
+
CompositePassthrough: (image: Tensor, target?: RenderTarget) => Presenter;
|
|
101
126
|
};
|
|
127
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
102
128
|
readback(tensor: Tensor): Promise<Float32Array>;
|
|
103
129
|
copyTensor(src: Tensor, dst: Tensor): void;
|
|
104
130
|
sync(): Promise<void>;
|
|
@@ -202,11 +228,18 @@ declare class Pipeline implements PromiseLike<Pipeline> {
|
|
|
202
228
|
private outputCleanup;
|
|
203
229
|
private adaptive;
|
|
204
230
|
private bgCleanup;
|
|
231
|
+
private previewBgCleanup;
|
|
205
232
|
constructor(inputStream: MediaStream, options: PipelineOptions);
|
|
206
233
|
private bootstrap;
|
|
207
234
|
then<T1 = this, T2 = never>(onFulfilled?: ((value: this) => T1 | PromiseLike<T1>) | null, onRejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): PromiseLike<T1 | T2>;
|
|
208
235
|
setBackground(input: BackgroundInput): Promise<void>;
|
|
209
236
|
setPreset(p: PresetName | ManualPreset, weights?: ArrayBuffer): void;
|
|
237
|
+
attachPreview(canvas: HTMLCanvasElement): void;
|
|
238
|
+
setPreview(input: {
|
|
239
|
+
background: BackgroundInput;
|
|
240
|
+
fps?: number;
|
|
241
|
+
}): Promise<void>;
|
|
242
|
+
clearPreview(): void;
|
|
210
243
|
setEnabled(on: boolean): void;
|
|
211
244
|
getStats(): Promise<RendererStats>;
|
|
212
245
|
destroy(): void;
|
|
@@ -233,11 +266,14 @@ declare class WebGPUBackend implements Backend {
|
|
|
233
266
|
readonly canvasContext: GPUCanvasContext;
|
|
234
267
|
readonly canvasFormat: GPUTextureFormat;
|
|
235
268
|
readonly bytesPerElement: 2 | 4;
|
|
269
|
+
private readonly contexts;
|
|
236
270
|
private constructor();
|
|
271
|
+
private configureContext;
|
|
272
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
237
273
|
static isAvailable(): Promise<boolean>;
|
|
238
274
|
static hasF16Support(): Promise<boolean>;
|
|
239
275
|
static create(opts: WebGPUBackendOptions): Promise<WebGPUBackend>;
|
|
240
|
-
getCurrentDisplayTexture(): GPUTexture;
|
|
276
|
+
getCurrentDisplayTexture(target?: RenderTarget): GPUTexture;
|
|
241
277
|
tensor(h: number, w: number, c: number, data?: DataView_): WebGPUTensor;
|
|
242
278
|
upload(data: DataView_): WebGPUMLBuffer;
|
|
243
279
|
private writeView;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,8 @@ interface Op {
|
|
|
23
23
|
interface Presenter {
|
|
24
24
|
run(): void;
|
|
25
25
|
}
|
|
26
|
-
type
|
|
26
|
+
type RenderTarget = "main" | "preview";
|
|
27
|
+
type Activation = "none" | "relu6" | "relu" | "leaky";
|
|
27
28
|
interface Conv2dParams {
|
|
28
29
|
outChannels: number;
|
|
29
30
|
kernel: number;
|
|
@@ -37,6 +38,26 @@ interface DepthwiseParams {
|
|
|
37
38
|
padding: number | "same" | "valid";
|
|
38
39
|
activation: Activation;
|
|
39
40
|
}
|
|
41
|
+
interface ConvTranspose2dParams {
|
|
42
|
+
outChannels: number;
|
|
43
|
+
kernel: number;
|
|
44
|
+
stride: number;
|
|
45
|
+
padding: number;
|
|
46
|
+
activation: Activation;
|
|
47
|
+
}
|
|
48
|
+
interface WarpParams {
|
|
49
|
+
flowScale: number;
|
|
50
|
+
}
|
|
51
|
+
interface StabilizeParams {
|
|
52
|
+
tLo: number;
|
|
53
|
+
tHi: number;
|
|
54
|
+
leak: number;
|
|
55
|
+
release: number;
|
|
56
|
+
tDiv: number;
|
|
57
|
+
divScale: number;
|
|
58
|
+
stepX: number;
|
|
59
|
+
stepY: number;
|
|
60
|
+
}
|
|
40
61
|
interface UpsampleParams {
|
|
41
62
|
outH: number;
|
|
42
63
|
outW: number;
|
|
@@ -70,14 +91,18 @@ interface Backend {
|
|
|
70
91
|
upload(data: DataView_): MLBuffer;
|
|
71
92
|
ops: {
|
|
72
93
|
Conv2d: (input: Tensor, weights: Conv2DWeights, params: Conv2dParams) => Op;
|
|
94
|
+
ConvTranspose2d: (input: Tensor, weights: Conv2DWeights, params: ConvTranspose2dParams) => Op;
|
|
73
95
|
DepthwiseConv2d: (input: Tensor, weights: DepthwiseWeights, params: DepthwiseParams) => Op;
|
|
74
96
|
Add: (a: Tensor, b: Tensor) => Op;
|
|
75
97
|
Sigmoid: (input: Tensor) => Op;
|
|
76
98
|
BilinearUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
99
|
+
Crop: (input: Tensor, params: UpsampleParams) => Op;
|
|
77
100
|
BicubicUpsample: (input: Tensor, params: UpsampleParams) => Op;
|
|
78
101
|
ChannelConcat: (a: Tensor, b: Tensor) => Op;
|
|
79
102
|
Tanh: (input: Tensor) => Op;
|
|
80
103
|
ElementwiseMul: (a: Tensor, b: Tensor) => Op;
|
|
104
|
+
Warp: (source: Tensor, flow: Tensor, params: WarpParams) => Op;
|
|
105
|
+
Stabilize: (flow: Tensor, pred: Tensor, ref: Tensor, envPrev: Tensor, params: StabilizeParams) => Op;
|
|
81
106
|
GatesFused: (uIn: Tensor, hPrev: Tensor, weights: Conv2DWeights) => Op;
|
|
82
107
|
CandUpdateFused: (uIn: Tensor, hPrev: Tensor, gatesOut: Tensor, weights: Conv2DWeights, gamma: ArrayLike<number>) => Op;
|
|
83
108
|
ConvExpand: (input: Tensor, weights: Conv2DWeights) => Op;
|
|
@@ -94,11 +119,12 @@ interface Backend {
|
|
|
94
119
|
Input: (h: number, w: number) => InputOp;
|
|
95
120
|
};
|
|
96
121
|
presenters: {
|
|
97
|
-
CompositeSolid: (image: Tensor, alpha: Tensor, bgColor: [number, number, number]) => Presenter;
|
|
98
|
-
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor) => Presenter;
|
|
99
|
-
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor) => Presenter;
|
|
100
|
-
CompositePassthrough: (image: Tensor) => Presenter;
|
|
122
|
+
CompositeSolid: (image: Tensor, alpha: Tensor, bgColor: [number, number, number], target?: RenderTarget) => Presenter;
|
|
123
|
+
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
124
|
+
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
125
|
+
CompositePassthrough: (image: Tensor, target?: RenderTarget) => Presenter;
|
|
101
126
|
};
|
|
127
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
102
128
|
readback(tensor: Tensor): Promise<Float32Array>;
|
|
103
129
|
copyTensor(src: Tensor, dst: Tensor): void;
|
|
104
130
|
sync(): Promise<void>;
|
|
@@ -202,11 +228,18 @@ declare class Pipeline implements PromiseLike<Pipeline> {
|
|
|
202
228
|
private outputCleanup;
|
|
203
229
|
private adaptive;
|
|
204
230
|
private bgCleanup;
|
|
231
|
+
private previewBgCleanup;
|
|
205
232
|
constructor(inputStream: MediaStream, options: PipelineOptions);
|
|
206
233
|
private bootstrap;
|
|
207
234
|
then<T1 = this, T2 = never>(onFulfilled?: ((value: this) => T1 | PromiseLike<T1>) | null, onRejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): PromiseLike<T1 | T2>;
|
|
208
235
|
setBackground(input: BackgroundInput): Promise<void>;
|
|
209
236
|
setPreset(p: PresetName | ManualPreset, weights?: ArrayBuffer): void;
|
|
237
|
+
attachPreview(canvas: HTMLCanvasElement): void;
|
|
238
|
+
setPreview(input: {
|
|
239
|
+
background: BackgroundInput;
|
|
240
|
+
fps?: number;
|
|
241
|
+
}): Promise<void>;
|
|
242
|
+
clearPreview(): void;
|
|
210
243
|
setEnabled(on: boolean): void;
|
|
211
244
|
getStats(): Promise<RendererStats>;
|
|
212
245
|
destroy(): void;
|
|
@@ -233,11 +266,14 @@ declare class WebGPUBackend implements Backend {
|
|
|
233
266
|
readonly canvasContext: GPUCanvasContext;
|
|
234
267
|
readonly canvasFormat: GPUTextureFormat;
|
|
235
268
|
readonly bytesPerElement: 2 | 4;
|
|
269
|
+
private readonly contexts;
|
|
236
270
|
private constructor();
|
|
271
|
+
private configureContext;
|
|
272
|
+
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
237
273
|
static isAvailable(): Promise<boolean>;
|
|
238
274
|
static hasF16Support(): Promise<boolean>;
|
|
239
275
|
static create(opts: WebGPUBackendOptions): Promise<WebGPUBackend>;
|
|
240
|
-
getCurrentDisplayTexture(): GPUTexture;
|
|
276
|
+
getCurrentDisplayTexture(target?: RenderTarget): GPUTexture;
|
|
241
277
|
tensor(h: number, w: number, c: number, data?: DataView_): WebGPUTensor;
|
|
242
278
|
upload(data: DataView_): WebGPUMLBuffer;
|
|
243
279
|
private writeView;
|