longpipe 0.0.11 → 0.0.13

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/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>;
@@ -194,7 +252,7 @@ interface RendererStats {
194
252
  inputPath: string;
195
253
  outputPath: string;
196
254
  }
197
- type ErrorSource = 'backend-lost' | 'worker' | 'adaptive' | 'background' | 'unknown';
255
+ type ErrorSource = 'backend-lost' | 'worker' | 'adaptive' | 'background' | 'audio' | 'unknown';
198
256
  interface PipelineError {
199
257
  message: string;
200
258
  source: ErrorSource;
@@ -202,23 +260,65 @@ interface PipelineError {
202
260
  cause?: unknown;
203
261
  }
204
262
 
263
+ type DenoiseModel = 'rnnoise' | 'dfn' | 'dfnint8';
264
+ type DenoiseTier = 'high' | 'mid' | 'low';
265
+ type DenoiseModelOption = 'auto' | DenoiseTier | DenoiseModel;
266
+
267
+ interface DenoiseOptions {
268
+ model?: DenoiseModelOption;
269
+ postFilterBeta?: number;
270
+ gruLeak?: number;
271
+ enabled?: boolean;
272
+ }
273
+ type AudioInput = 'passthrough' | 'drop' | 'denoise' | {
274
+ denoise: DenoiseOptions;
275
+ };
205
276
  type AudioMode = 'passthrough' | 'drop';
206
277
 
278
+ interface AudioStats {
279
+ model: DenoiseModel;
280
+ p50Ms: number | null;
281
+ p95Ms: number | null;
282
+ latencyMs: number;
283
+ active: boolean;
284
+ sampleRate: number;
285
+ }
286
+
207
287
  interface PipelineOptions {
208
288
  background?: BackgroundInput;
209
289
  preset?: PresetName | ManualPreset;
210
290
  weightsBaseUrl?: string;
211
- audio?: AudioMode;
291
+ dtype?: Dtype;
292
+ audio?: AudioInput;
212
293
  enabled?: boolean;
213
294
  outputResolution?: {
214
295
  w: number;
215
296
  h: number;
216
297
  };
217
298
  adaptive?: boolean;
299
+ touchup?: TouchupOptions;
300
+ reframe?: ReframeConfig;
218
301
  onReady?: () => void;
219
302
  onError?: (err: PipelineError) => void;
220
303
  debug?: boolean;
221
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
+ }
222
322
  declare class Pipeline implements PromiseLike<Pipeline> {
223
323
  readonly stream: MediaStream;
224
324
  readonly ready: Promise<void>;
@@ -227,12 +327,19 @@ declare class Pipeline implements PromiseLike<Pipeline> {
227
327
  private inputCleanup;
228
328
  private outputCleanup;
229
329
  private adaptive;
330
+ private denoiser;
331
+ private touchupAssets;
332
+ private weightsBaseUrl;
333
+ private resolvedDtype;
230
334
  private bgCleanup;
231
335
  private previewBgCleanup;
232
336
  constructor(inputStream: MediaStream, options: PipelineOptions);
233
337
  private bootstrap;
234
338
  then<T1 = this, T2 = never>(onFulfilled?: ((value: this) => T1 | PromiseLike<T1>) | null, onRejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): PromiseLike<T1 | T2>;
235
339
  setBackground(input: BackgroundInput): Promise<void>;
340
+ setTouchup(opts: TouchupOptions | null): Promise<void>;
341
+ setReframe(cfg: ReframeConfig | null): Promise<void>;
342
+ reframe(): Promise<void>;
236
343
  setPreset(p: PresetName | ManualPreset, weights?: ArrayBuffer): void;
237
344
  attachPreview(canvas: HTMLCanvasElement): void;
238
345
  setPreview(input: {
@@ -242,6 +349,8 @@ declare class Pipeline implements PromiseLike<Pipeline> {
242
349
  clearPreview(): void;
243
350
  setEnabled(on: boolean): void;
244
351
  getStats(): Promise<RendererStats>;
352
+ setDenoise(input: boolean | DenoiseOptions): void;
353
+ getAudioStats(): AudioStats | null;
245
354
  destroy(): void;
246
355
  }
247
356
 
@@ -283,4 +392,4 @@ declare class WebGPUBackend implements Backend {
283
392
  destroy(): void;
284
393
  }
285
394
 
286
- export { type Activation, type AudioMode, type Backend, type Background, type BackgroundInput, type BlurInput, type ColorInput, type Conv2dParams, 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>;
@@ -194,7 +252,7 @@ interface RendererStats {
194
252
  inputPath: string;
195
253
  outputPath: string;
196
254
  }
197
- type ErrorSource = 'backend-lost' | 'worker' | 'adaptive' | 'background' | 'unknown';
255
+ type ErrorSource = 'backend-lost' | 'worker' | 'adaptive' | 'background' | 'audio' | 'unknown';
198
256
  interface PipelineError {
199
257
  message: string;
200
258
  source: ErrorSource;
@@ -202,23 +260,65 @@ interface PipelineError {
202
260
  cause?: unknown;
203
261
  }
204
262
 
263
+ type DenoiseModel = 'rnnoise' | 'dfn' | 'dfnint8';
264
+ type DenoiseTier = 'high' | 'mid' | 'low';
265
+ type DenoiseModelOption = 'auto' | DenoiseTier | DenoiseModel;
266
+
267
+ interface DenoiseOptions {
268
+ model?: DenoiseModelOption;
269
+ postFilterBeta?: number;
270
+ gruLeak?: number;
271
+ enabled?: boolean;
272
+ }
273
+ type AudioInput = 'passthrough' | 'drop' | 'denoise' | {
274
+ denoise: DenoiseOptions;
275
+ };
205
276
  type AudioMode = 'passthrough' | 'drop';
206
277
 
278
+ interface AudioStats {
279
+ model: DenoiseModel;
280
+ p50Ms: number | null;
281
+ p95Ms: number | null;
282
+ latencyMs: number;
283
+ active: boolean;
284
+ sampleRate: number;
285
+ }
286
+
207
287
  interface PipelineOptions {
208
288
  background?: BackgroundInput;
209
289
  preset?: PresetName | ManualPreset;
210
290
  weightsBaseUrl?: string;
211
- audio?: AudioMode;
291
+ dtype?: Dtype;
292
+ audio?: AudioInput;
212
293
  enabled?: boolean;
213
294
  outputResolution?: {
214
295
  w: number;
215
296
  h: number;
216
297
  };
217
298
  adaptive?: boolean;
299
+ touchup?: TouchupOptions;
300
+ reframe?: ReframeConfig;
218
301
  onReady?: () => void;
219
302
  onError?: (err: PipelineError) => void;
220
303
  debug?: boolean;
221
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
+ }
222
322
  declare class Pipeline implements PromiseLike<Pipeline> {
223
323
  readonly stream: MediaStream;
224
324
  readonly ready: Promise<void>;
@@ -227,12 +327,19 @@ declare class Pipeline implements PromiseLike<Pipeline> {
227
327
  private inputCleanup;
228
328
  private outputCleanup;
229
329
  private adaptive;
330
+ private denoiser;
331
+ private touchupAssets;
332
+ private weightsBaseUrl;
333
+ private resolvedDtype;
230
334
  private bgCleanup;
231
335
  private previewBgCleanup;
232
336
  constructor(inputStream: MediaStream, options: PipelineOptions);
233
337
  private bootstrap;
234
338
  then<T1 = this, T2 = never>(onFulfilled?: ((value: this) => T1 | PromiseLike<T1>) | null, onRejected?: ((reason: unknown) => T2 | PromiseLike<T2>) | null): PromiseLike<T1 | T2>;
235
339
  setBackground(input: BackgroundInput): Promise<void>;
340
+ setTouchup(opts: TouchupOptions | null): Promise<void>;
341
+ setReframe(cfg: ReframeConfig | null): Promise<void>;
342
+ reframe(): Promise<void>;
236
343
  setPreset(p: PresetName | ManualPreset, weights?: ArrayBuffer): void;
237
344
  attachPreview(canvas: HTMLCanvasElement): void;
238
345
  setPreview(input: {
@@ -242,6 +349,8 @@ declare class Pipeline implements PromiseLike<Pipeline> {
242
349
  clearPreview(): void;
243
350
  setEnabled(on: boolean): void;
244
351
  getStats(): Promise<RendererStats>;
352
+ setDenoise(input: boolean | DenoiseOptions): void;
353
+ getAudioStats(): AudioStats | null;
245
354
  destroy(): void;
246
355
  }
247
356
 
@@ -283,4 +392,4 @@ declare class WebGPUBackend implements Backend {
283
392
  destroy(): void;
284
393
  }
285
394
 
286
- export { type Activation, type AudioMode, type Backend, type Background, type BackgroundInput, type BlurInput, type ColorInput, type Conv2dParams, 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 };