longpipe 0.0.12 → 0.0.14
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 +78 -10
- package/dist/index.cjs +6942 -2363
- package/dist/index.d.cts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +6942 -2363
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -62,6 +62,56 @@ interface UpsampleParams {
|
|
|
62
62
|
outH: number;
|
|
63
63
|
outW: number;
|
|
64
64
|
}
|
|
65
|
+
interface FaceBoxParams {
|
|
66
|
+
win: number;
|
|
67
|
+
thresh: number;
|
|
68
|
+
boxScale: number;
|
|
69
|
+
}
|
|
70
|
+
interface FaceBoxesParams extends FaceBoxParams {
|
|
71
|
+
maxFaces: number;
|
|
72
|
+
tol: number;
|
|
73
|
+
}
|
|
74
|
+
interface CropResampleParams {
|
|
75
|
+
outH: number;
|
|
76
|
+
outW: number;
|
|
77
|
+
mean: [number, number, number];
|
|
78
|
+
std: [number, number, number];
|
|
79
|
+
slot?: number;
|
|
80
|
+
}
|
|
81
|
+
interface LandmarkOverlayParams {
|
|
82
|
+
count: number;
|
|
83
|
+
thresh: number;
|
|
84
|
+
pointSize: number;
|
|
85
|
+
color: [number, number, number];
|
|
86
|
+
slot?: number;
|
|
87
|
+
drawImage?: boolean;
|
|
88
|
+
}
|
|
89
|
+
interface ReframeStateParams {
|
|
90
|
+
zoom: number;
|
|
91
|
+
gravity: number;
|
|
92
|
+
margin: number;
|
|
93
|
+
deadband: number;
|
|
94
|
+
ease: number;
|
|
95
|
+
aspect: number;
|
|
96
|
+
}
|
|
97
|
+
interface FaceTouchupStageOp extends Op {
|
|
98
|
+
setActiveSlots(n: number): void;
|
|
99
|
+
}
|
|
100
|
+
interface FaceTopology {
|
|
101
|
+
count: number;
|
|
102
|
+
uv: Float32Array;
|
|
103
|
+
idx: Float32Array;
|
|
104
|
+
weightMask: ImageBitmap;
|
|
105
|
+
}
|
|
106
|
+
type FaceTouchupStyle = "freq-sep" | "bilateral";
|
|
107
|
+
interface FaceTouchupParams {
|
|
108
|
+
strength: number;
|
|
109
|
+
amount: number;
|
|
110
|
+
detail: number;
|
|
111
|
+
thresh: number;
|
|
112
|
+
style?: FaceTouchupStyle;
|
|
113
|
+
slots?: number;
|
|
114
|
+
}
|
|
65
115
|
interface UpsampleConv1x1Params {
|
|
66
116
|
outH: number;
|
|
67
117
|
outW: number;
|
|
@@ -102,6 +152,12 @@ interface Backend {
|
|
|
102
152
|
Tanh: (input: Tensor) => Op;
|
|
103
153
|
ElementwiseMul: (a: Tensor, b: Tensor) => Op;
|
|
104
154
|
Warp: (source: Tensor, flow: Tensor, params: WarpParams) => Op;
|
|
155
|
+
FaceBoxFromHeatmaps: (heatmaps: Tensor, params: FaceBoxParams) => Op;
|
|
156
|
+
FaceBoxesFromHeatmaps: (heatmaps: Tensor, params: FaceBoxesParams) => Op;
|
|
157
|
+
ReframeState: (boxes: Tensor, prev: Tensor, cmd: Tensor, params: ReframeStateParams) => Op;
|
|
158
|
+
Reframe: (src: Tensor, rect: Tensor) => Op;
|
|
159
|
+
FaceTouchupStage: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams) => FaceTouchupStageOp;
|
|
160
|
+
CropResample: (frame: Tensor, box: Tensor, params: CropResampleParams) => Op;
|
|
105
161
|
Stabilize: (flow: Tensor, pred: Tensor, ref: Tensor, envPrev: Tensor, params: StabilizeParams) => Op;
|
|
106
162
|
GatesFused: (uIn: Tensor, hPrev: Tensor, weights: Conv2DWeights) => Op;
|
|
107
163
|
CandUpdateFused: (uIn: Tensor, hPrev: Tensor, gatesOut: Tensor, weights: Conv2DWeights, gamma: ArrayLike<number>) => Op;
|
|
@@ -123,6 +179,8 @@ interface Backend {
|
|
|
123
179
|
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
124
180
|
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
125
181
|
CompositePassthrough: (image: Tensor, target?: RenderTarget) => Presenter;
|
|
182
|
+
LandmarkOverlay: (image: Tensor, landmarks: Tensor, box: Tensor, params: LandmarkOverlayParams, target?: RenderTarget) => Presenter;
|
|
183
|
+
FaceTouchup: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams, target?: RenderTarget) => Presenter;
|
|
126
184
|
};
|
|
127
185
|
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
128
186
|
readback(tensor: Tensor): Promise<Float32Array>;
|
|
@@ -230,6 +288,7 @@ interface PipelineOptions {
|
|
|
230
288
|
background?: BackgroundInput;
|
|
231
289
|
preset?: PresetName | ManualPreset;
|
|
232
290
|
weightsBaseUrl?: string;
|
|
291
|
+
dtype?: Dtype;
|
|
233
292
|
audio?: AudioInput;
|
|
234
293
|
enabled?: boolean;
|
|
235
294
|
outputResolution?: {
|
|
@@ -237,10 +296,29 @@ interface PipelineOptions {
|
|
|
237
296
|
h: number;
|
|
238
297
|
};
|
|
239
298
|
adaptive?: boolean;
|
|
299
|
+
touchup?: TouchupOptions;
|
|
300
|
+
reframe?: ReframeConfig;
|
|
240
301
|
onReady?: () => void;
|
|
241
302
|
onError?: (err: PipelineError) => void;
|
|
242
303
|
debug?: boolean;
|
|
243
304
|
}
|
|
305
|
+
interface TouchupOptions {
|
|
306
|
+
strength?: number;
|
|
307
|
+
amount?: number;
|
|
308
|
+
detail?: number;
|
|
309
|
+
style?: FaceTouchupStyle;
|
|
310
|
+
}
|
|
311
|
+
type ReframeConfig = boolean | ReframeOptions;
|
|
312
|
+
interface ReframeOptions {
|
|
313
|
+
zoom?: number;
|
|
314
|
+
gravity?: number;
|
|
315
|
+
margin?: number;
|
|
316
|
+
auto?: boolean | ReframeAutoOptions;
|
|
317
|
+
}
|
|
318
|
+
interface ReframeAutoOptions {
|
|
319
|
+
deadband?: number;
|
|
320
|
+
ease?: number;
|
|
321
|
+
}
|
|
244
322
|
declare class Pipeline implements PromiseLike<Pipeline> {
|
|
245
323
|
readonly stream: MediaStream;
|
|
246
324
|
readonly ready: Promise<void>;
|
|
@@ -250,12 +328,18 @@ declare class Pipeline implements PromiseLike<Pipeline> {
|
|
|
250
328
|
private outputCleanup;
|
|
251
329
|
private adaptive;
|
|
252
330
|
private denoiser;
|
|
331
|
+
private touchupAssets;
|
|
332
|
+
private weightsBaseUrl;
|
|
333
|
+
private resolvedDtype;
|
|
253
334
|
private bgCleanup;
|
|
254
335
|
private previewBgCleanup;
|
|
255
336
|
constructor(inputStream: MediaStream, options: PipelineOptions);
|
|
256
337
|
private bootstrap;
|
|
257
338
|
then<T1 = this, T2 = never>(onFulfilled?: ((value: this) => T1 | PromiseLike<T1>) | null, onRejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): PromiseLike<T1 | T2>;
|
|
258
339
|
setBackground(input: BackgroundInput): Promise<void>;
|
|
340
|
+
setTouchup(opts: TouchupOptions | null): Promise<void>;
|
|
341
|
+
setReframe(cfg: ReframeConfig | null): Promise<void>;
|
|
342
|
+
reframe(): Promise<void>;
|
|
259
343
|
setPreset(p: PresetName | ManualPreset, weights?: ArrayBuffer): void;
|
|
260
344
|
attachPreview(canvas: HTMLCanvasElement): void;
|
|
261
345
|
setPreview(input: {
|
|
@@ -308,4 +392,4 @@ declare class WebGPUBackend implements Backend {
|
|
|
308
392
|
destroy(): void;
|
|
309
393
|
}
|
|
310
394
|
|
|
311
|
-
export { type Activation, type AudioInput, type AudioMode, type AudioStats, type Backend, type Background, type BackgroundInput, type BlurInput, type ColorInput, type Conv2dParams, type DenoiseModel, type DenoiseModelOption, type DenoiseOptions, type DenoiseTier, type DepthwiseParams, Pipeline as EffectsPipeline, type ErrorSource, type ImageInput, type ManualPreset, type ModelName, type Op, type PipelineError, type PipelineOptions, type PresetName, type Tensor, type VideoInput, WebGPUBackend };
|
|
395
|
+
export { type Activation, type AudioInput, type AudioMode, type AudioStats, type Backend, type Background, type BackgroundInput, type BlurInput, type ColorInput, type Conv2dParams, type DenoiseModel, type DenoiseModelOption, type DenoiseOptions, type DenoiseTier, type DepthwiseParams, Pipeline as EffectsPipeline, type ErrorSource, type FaceTouchupStyle, type ImageInput, type ManualPreset, type ModelName, type Op, type PipelineError, type PipelineOptions, type PresetName, type Tensor, type TouchupOptions, type VideoInput, WebGPUBackend };
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,56 @@ interface UpsampleParams {
|
|
|
62
62
|
outH: number;
|
|
63
63
|
outW: number;
|
|
64
64
|
}
|
|
65
|
+
interface FaceBoxParams {
|
|
66
|
+
win: number;
|
|
67
|
+
thresh: number;
|
|
68
|
+
boxScale: number;
|
|
69
|
+
}
|
|
70
|
+
interface FaceBoxesParams extends FaceBoxParams {
|
|
71
|
+
maxFaces: number;
|
|
72
|
+
tol: number;
|
|
73
|
+
}
|
|
74
|
+
interface CropResampleParams {
|
|
75
|
+
outH: number;
|
|
76
|
+
outW: number;
|
|
77
|
+
mean: [number, number, number];
|
|
78
|
+
std: [number, number, number];
|
|
79
|
+
slot?: number;
|
|
80
|
+
}
|
|
81
|
+
interface LandmarkOverlayParams {
|
|
82
|
+
count: number;
|
|
83
|
+
thresh: number;
|
|
84
|
+
pointSize: number;
|
|
85
|
+
color: [number, number, number];
|
|
86
|
+
slot?: number;
|
|
87
|
+
drawImage?: boolean;
|
|
88
|
+
}
|
|
89
|
+
interface ReframeStateParams {
|
|
90
|
+
zoom: number;
|
|
91
|
+
gravity: number;
|
|
92
|
+
margin: number;
|
|
93
|
+
deadband: number;
|
|
94
|
+
ease: number;
|
|
95
|
+
aspect: number;
|
|
96
|
+
}
|
|
97
|
+
interface FaceTouchupStageOp extends Op {
|
|
98
|
+
setActiveSlots(n: number): void;
|
|
99
|
+
}
|
|
100
|
+
interface FaceTopology {
|
|
101
|
+
count: number;
|
|
102
|
+
uv: Float32Array;
|
|
103
|
+
idx: Float32Array;
|
|
104
|
+
weightMask: ImageBitmap;
|
|
105
|
+
}
|
|
106
|
+
type FaceTouchupStyle = "freq-sep" | "bilateral";
|
|
107
|
+
interface FaceTouchupParams {
|
|
108
|
+
strength: number;
|
|
109
|
+
amount: number;
|
|
110
|
+
detail: number;
|
|
111
|
+
thresh: number;
|
|
112
|
+
style?: FaceTouchupStyle;
|
|
113
|
+
slots?: number;
|
|
114
|
+
}
|
|
65
115
|
interface UpsampleConv1x1Params {
|
|
66
116
|
outH: number;
|
|
67
117
|
outW: number;
|
|
@@ -102,6 +152,12 @@ interface Backend {
|
|
|
102
152
|
Tanh: (input: Tensor) => Op;
|
|
103
153
|
ElementwiseMul: (a: Tensor, b: Tensor) => Op;
|
|
104
154
|
Warp: (source: Tensor, flow: Tensor, params: WarpParams) => Op;
|
|
155
|
+
FaceBoxFromHeatmaps: (heatmaps: Tensor, params: FaceBoxParams) => Op;
|
|
156
|
+
FaceBoxesFromHeatmaps: (heatmaps: Tensor, params: FaceBoxesParams) => Op;
|
|
157
|
+
ReframeState: (boxes: Tensor, prev: Tensor, cmd: Tensor, params: ReframeStateParams) => Op;
|
|
158
|
+
Reframe: (src: Tensor, rect: Tensor) => Op;
|
|
159
|
+
FaceTouchupStage: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams) => FaceTouchupStageOp;
|
|
160
|
+
CropResample: (frame: Tensor, box: Tensor, params: CropResampleParams) => Op;
|
|
105
161
|
Stabilize: (flow: Tensor, pred: Tensor, ref: Tensor, envPrev: Tensor, params: StabilizeParams) => Op;
|
|
106
162
|
GatesFused: (uIn: Tensor, hPrev: Tensor, weights: Conv2DWeights) => Op;
|
|
107
163
|
CandUpdateFused: (uIn: Tensor, hPrev: Tensor, gatesOut: Tensor, weights: Conv2DWeights, gamma: ArrayLike<number>) => Op;
|
|
@@ -123,6 +179,8 @@ interface Backend {
|
|
|
123
179
|
CompositeImage: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
124
180
|
CompositeImageBilinear: (image: Tensor, alpha: Tensor, bg: Tensor, target?: RenderTarget) => Presenter;
|
|
125
181
|
CompositePassthrough: (image: Tensor, target?: RenderTarget) => Presenter;
|
|
182
|
+
LandmarkOverlay: (image: Tensor, landmarks: Tensor, box: Tensor, params: LandmarkOverlayParams, target?: RenderTarget) => Presenter;
|
|
183
|
+
FaceTouchup: (frame: Tensor, landmarks: Tensor, box: Tensor, topo: FaceTopology, params: FaceTouchupParams, target?: RenderTarget) => Presenter;
|
|
126
184
|
};
|
|
127
185
|
attachCanvas(name: RenderTarget, canvas: HTMLCanvasElement | OffscreenCanvas): void;
|
|
128
186
|
readback(tensor: Tensor): Promise<Float32Array>;
|
|
@@ -230,6 +288,7 @@ interface PipelineOptions {
|
|
|
230
288
|
background?: BackgroundInput;
|
|
231
289
|
preset?: PresetName | ManualPreset;
|
|
232
290
|
weightsBaseUrl?: string;
|
|
291
|
+
dtype?: Dtype;
|
|
233
292
|
audio?: AudioInput;
|
|
234
293
|
enabled?: boolean;
|
|
235
294
|
outputResolution?: {
|
|
@@ -237,10 +296,29 @@ interface PipelineOptions {
|
|
|
237
296
|
h: number;
|
|
238
297
|
};
|
|
239
298
|
adaptive?: boolean;
|
|
299
|
+
touchup?: TouchupOptions;
|
|
300
|
+
reframe?: ReframeConfig;
|
|
240
301
|
onReady?: () => void;
|
|
241
302
|
onError?: (err: PipelineError) => void;
|
|
242
303
|
debug?: boolean;
|
|
243
304
|
}
|
|
305
|
+
interface TouchupOptions {
|
|
306
|
+
strength?: number;
|
|
307
|
+
amount?: number;
|
|
308
|
+
detail?: number;
|
|
309
|
+
style?: FaceTouchupStyle;
|
|
310
|
+
}
|
|
311
|
+
type ReframeConfig = boolean | ReframeOptions;
|
|
312
|
+
interface ReframeOptions {
|
|
313
|
+
zoom?: number;
|
|
314
|
+
gravity?: number;
|
|
315
|
+
margin?: number;
|
|
316
|
+
auto?: boolean | ReframeAutoOptions;
|
|
317
|
+
}
|
|
318
|
+
interface ReframeAutoOptions {
|
|
319
|
+
deadband?: number;
|
|
320
|
+
ease?: number;
|
|
321
|
+
}
|
|
244
322
|
declare class Pipeline implements PromiseLike<Pipeline> {
|
|
245
323
|
readonly stream: MediaStream;
|
|
246
324
|
readonly ready: Promise<void>;
|
|
@@ -250,12 +328,18 @@ declare class Pipeline implements PromiseLike<Pipeline> {
|
|
|
250
328
|
private outputCleanup;
|
|
251
329
|
private adaptive;
|
|
252
330
|
private denoiser;
|
|
331
|
+
private touchupAssets;
|
|
332
|
+
private weightsBaseUrl;
|
|
333
|
+
private resolvedDtype;
|
|
253
334
|
private bgCleanup;
|
|
254
335
|
private previewBgCleanup;
|
|
255
336
|
constructor(inputStream: MediaStream, options: PipelineOptions);
|
|
256
337
|
private bootstrap;
|
|
257
338
|
then<T1 = this, T2 = never>(onFulfilled?: ((value: this) => T1 | PromiseLike<T1>) | null, onRejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): PromiseLike<T1 | T2>;
|
|
258
339
|
setBackground(input: BackgroundInput): Promise<void>;
|
|
340
|
+
setTouchup(opts: TouchupOptions | null): Promise<void>;
|
|
341
|
+
setReframe(cfg: ReframeConfig | null): Promise<void>;
|
|
342
|
+
reframe(): Promise<void>;
|
|
259
343
|
setPreset(p: PresetName | ManualPreset, weights?: ArrayBuffer): void;
|
|
260
344
|
attachPreview(canvas: HTMLCanvasElement): void;
|
|
261
345
|
setPreview(input: {
|
|
@@ -308,4 +392,4 @@ declare class WebGPUBackend implements Backend {
|
|
|
308
392
|
destroy(): void;
|
|
309
393
|
}
|
|
310
394
|
|
|
311
|
-
export { type Activation, type AudioInput, type AudioMode, type AudioStats, type Backend, type Background, type BackgroundInput, type BlurInput, type ColorInput, type Conv2dParams, type DenoiseModel, type DenoiseModelOption, type DenoiseOptions, type DenoiseTier, type DepthwiseParams, Pipeline as EffectsPipeline, type ErrorSource, type ImageInput, type ManualPreset, type ModelName, type Op, type PipelineError, type PipelineOptions, type PresetName, type Tensor, type VideoInput, WebGPUBackend };
|
|
395
|
+
export { type Activation, type AudioInput, type AudioMode, type AudioStats, type Backend, type Background, type BackgroundInput, type BlurInput, type ColorInput, type Conv2dParams, type DenoiseModel, type DenoiseModelOption, type DenoiseOptions, type DenoiseTier, type DepthwiseParams, Pipeline as EffectsPipeline, type ErrorSource, type FaceTouchupStyle, type ImageInput, type ManualPreset, type ModelName, type Op, type PipelineError, type PipelineOptions, type PresetName, type Tensor, type TouchupOptions, type VideoInput, WebGPUBackend };
|