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.
@@ -0,0 +1,155 @@
1
+ import { T as Tensor, M as MLBuffer, b as DataView_, B as Backend, D as Dtype, R as RenderTarget, c as ModelWeights, O as Op, U as UNetWrapperWeights, I as InputOp, d as ImageSource } from './index-BctoEDhZ.cjs';
2
+ export { A as Activation, e as Conv2DWeights, C as Conv2dParams, f as DecoderBlockWeights, a as DepthwiseParams, g as DepthwiseWeights, F as FaceTouchupStyle, h as FaceWeights, i as FlowWeights, L as LandmarkWeights, j as MBConvWeights, P as Presenter, k as UpsampleParams, W as WebGPUBackend } from './index-BctoEDhZ.cjs';
3
+
4
+ interface WebGLTensor extends Tensor {
5
+ readonly texture: WebGLTexture;
6
+ readonly texW: number;
7
+ readonly texH: number;
8
+ }
9
+ interface WebGLMLBuffer extends MLBuffer {
10
+ readonly data: DataView_;
11
+ }
12
+
13
+ interface WebGLBackendOptions {
14
+ canvas: HTMLCanvasElement | OffscreenCanvas;
15
+ dtype?: Dtype;
16
+ }
17
+ interface TextureFormat {
18
+ internalFormat: GLenum;
19
+ format: GLenum;
20
+ type: GLenum;
21
+ bytesPerElement: 2 | 4;
22
+ }
23
+ declare class WebGLBackend implements Backend {
24
+ readonly gl: WebGL2RenderingContext;
25
+ readonly canvas: HTMLCanvasElement | OffscreenCanvas;
26
+ readonly dtype: Dtype;
27
+ readonly ops: Backend['ops'];
28
+ readonly presenters: Backend['presenters'];
29
+ readonly fbo: WebGLFramebuffer;
30
+ readonly textureFormat: TextureFormat;
31
+ private constructor();
32
+ static isAvailable(): boolean;
33
+ static create(opts: WebGLBackendOptions): WebGLBackend;
34
+ attachCanvas(name: RenderTarget): void;
35
+ bindDisplayFramebuffer(): void;
36
+ toTextureView(data: DataView_ | null): Float32Array | Uint16Array | null;
37
+ tensor(h: number, w: number, c: number, data?: DataView_): WebGLTensor;
38
+ upload(data: DataView_): WebGLMLBuffer;
39
+ readback(tensor: WebGLTensor): Promise<Float32Array>;
40
+ copyTensor(src: WebGLTensor, dst: WebGLTensor): void;
41
+ sync(): Promise<void>;
42
+ destroy(): void;
43
+ }
44
+
45
+ type UNetVariant = 'A' | 'B' | 'E' | 'D';
46
+ interface UNetWrapperParams {
47
+ variant: UNetVariant;
48
+ cHigh: number;
49
+ cLow: number;
50
+ cUp: number;
51
+ }
52
+
53
+ interface BaseNetwork {
54
+ readonly featLowRes: Tensor;
55
+ readonly encoderTaps: Tensor[];
56
+ readonly halfTap?: Tensor;
57
+ run(): void;
58
+ }
59
+ type BaseNetworkCtor = new (backend: Backend, input: Tensor, w: ModelWeights) => BaseNetwork;
60
+ declare class TierModel implements Op {
61
+ readonly inputs: Tensor[];
62
+ readonly output: Tensor;
63
+ readonly encoderTaps: Tensor[];
64
+ readonly halfTap?: Tensor;
65
+ private readonly steps;
66
+ constructor(backend: Backend, x_hr: Tensor, baseWeights: ModelWeights, wrapperWeights: UNetWrapperWeights, params: UNetWrapperParams, BaseCtor: BaseNetworkCtor);
67
+ run(): void;
68
+ }
69
+
70
+ interface Res {
71
+ w: number;
72
+ h: number;
73
+ }
74
+ interface TierConfig {
75
+ base: BaseNetworkCtor;
76
+ wrapper: UNetWrapperParams;
77
+ canvasRes: Res;
78
+ baseRes: Res;
79
+ flowFuseStem?: boolean;
80
+ }
81
+ declare const TIER_CONFIG: Record<string, TierConfig>;
82
+
83
+ declare function loadWeightsFromBinary(buf: ArrayBuffer): ModelWeights;
84
+
85
+ type UpscalerMode = 'bilinear' | 'bicubic';
86
+ type BackgroundConfig = {
87
+ mode: 'solid';
88
+ color: [number, number, number];
89
+ } | {
90
+ mode: 'image';
91
+ image: Tensor;
92
+ } | {
93
+ mode: 'blur';
94
+ sigma: number;
95
+ };
96
+ type CompositeSpec = BackgroundConfig | {
97
+ mode: 'passthrough';
98
+ } | {
99
+ mode: 'fg-passthrough';
100
+ };
101
+ interface NetworkLike {
102
+ readonly output: Tensor;
103
+ run(): void;
104
+ }
105
+ interface EffectStage {
106
+ readonly output: Tensor;
107
+ run(): void;
108
+ }
109
+ interface RenderOptions {
110
+ upscaler: UpscalerMode;
111
+ background: BackgroundConfig;
112
+ }
113
+ declare class RenderOp<N extends NetworkLike = NetworkLike> {
114
+ private readonly backend;
115
+ private readonly displayInput;
116
+ private readonly image;
117
+ private network;
118
+ private networkInput;
119
+ private upscaler;
120
+ private upscalerMode;
121
+ private bgConfig;
122
+ private effectChain;
123
+ private viewRect;
124
+ private viewFg;
125
+ private viewAlpha;
126
+ private displayDirty;
127
+ private compositors;
128
+ constructor(backend: Backend);
129
+ attachNetwork(network: N, networkInput: InputOp, options: RenderOptions): void;
130
+ hasNetwork(): boolean;
131
+ setSource(src: ImageSource): void;
132
+ setUpscaler(mode: UpscalerMode): void;
133
+ setBackground(config: BackgroundConfig): void;
134
+ get displayImage(): Tensor;
135
+ private fgImage;
136
+ private chainTail;
137
+ private alphaImage;
138
+ setViewTransform(rect: Tensor | null): void;
139
+ private rebuildView;
140
+ setEffectChain(stages: EffectStage[]): void;
141
+ runEffects(): void;
142
+ run(): void;
143
+ runDisplay(): void;
144
+ runFgPassthrough(): void;
145
+ runPassthrough(): void;
146
+ compositeMain(mode: 'effect' | 'fg' | 'raw'): void;
147
+ refreshDisplayInput(): void;
148
+ compositeTo(target: RenderTarget, spec: CompositeSpec): void;
149
+ applyAlpha(alpha: Tensor): void;
150
+ runModel(): void;
151
+ private makeUpscaler;
152
+ private buildCompositor;
153
+ }
154
+
155
+ export { Backend, type BackgroundConfig, type BaseNetwork, type BaseNetworkCtor, type CompositeSpec, Dtype, ImageSource, InputOp, ModelWeights, Op, RenderOp, type RenderOptions, RenderTarget, type Res, TIER_CONFIG, Tensor, type TierConfig, TierModel, UNetWrapperWeights, type UpscalerMode, WebGLBackend, loadWeightsFromBinary };
@@ -0,0 +1,155 @@
1
+ import { T as Tensor, M as MLBuffer, b as DataView_, B as Backend, D as Dtype, R as RenderTarget, c as ModelWeights, O as Op, U as UNetWrapperWeights, I as InputOp, d as ImageSource } from './index-BctoEDhZ.js';
2
+ export { A as Activation, e as Conv2DWeights, C as Conv2dParams, f as DecoderBlockWeights, a as DepthwiseParams, g as DepthwiseWeights, F as FaceTouchupStyle, h as FaceWeights, i as FlowWeights, L as LandmarkWeights, j as MBConvWeights, P as Presenter, k as UpsampleParams, W as WebGPUBackend } from './index-BctoEDhZ.js';
3
+
4
+ interface WebGLTensor extends Tensor {
5
+ readonly texture: WebGLTexture;
6
+ readonly texW: number;
7
+ readonly texH: number;
8
+ }
9
+ interface WebGLMLBuffer extends MLBuffer {
10
+ readonly data: DataView_;
11
+ }
12
+
13
+ interface WebGLBackendOptions {
14
+ canvas: HTMLCanvasElement | OffscreenCanvas;
15
+ dtype?: Dtype;
16
+ }
17
+ interface TextureFormat {
18
+ internalFormat: GLenum;
19
+ format: GLenum;
20
+ type: GLenum;
21
+ bytesPerElement: 2 | 4;
22
+ }
23
+ declare class WebGLBackend implements Backend {
24
+ readonly gl: WebGL2RenderingContext;
25
+ readonly canvas: HTMLCanvasElement | OffscreenCanvas;
26
+ readonly dtype: Dtype;
27
+ readonly ops: Backend['ops'];
28
+ readonly presenters: Backend['presenters'];
29
+ readonly fbo: WebGLFramebuffer;
30
+ readonly textureFormat: TextureFormat;
31
+ private constructor();
32
+ static isAvailable(): boolean;
33
+ static create(opts: WebGLBackendOptions): WebGLBackend;
34
+ attachCanvas(name: RenderTarget): void;
35
+ bindDisplayFramebuffer(): void;
36
+ toTextureView(data: DataView_ | null): Float32Array | Uint16Array | null;
37
+ tensor(h: number, w: number, c: number, data?: DataView_): WebGLTensor;
38
+ upload(data: DataView_): WebGLMLBuffer;
39
+ readback(tensor: WebGLTensor): Promise<Float32Array>;
40
+ copyTensor(src: WebGLTensor, dst: WebGLTensor): void;
41
+ sync(): Promise<void>;
42
+ destroy(): void;
43
+ }
44
+
45
+ type UNetVariant = 'A' | 'B' | 'E' | 'D';
46
+ interface UNetWrapperParams {
47
+ variant: UNetVariant;
48
+ cHigh: number;
49
+ cLow: number;
50
+ cUp: number;
51
+ }
52
+
53
+ interface BaseNetwork {
54
+ readonly featLowRes: Tensor;
55
+ readonly encoderTaps: Tensor[];
56
+ readonly halfTap?: Tensor;
57
+ run(): void;
58
+ }
59
+ type BaseNetworkCtor = new (backend: Backend, input: Tensor, w: ModelWeights) => BaseNetwork;
60
+ declare class TierModel implements Op {
61
+ readonly inputs: Tensor[];
62
+ readonly output: Tensor;
63
+ readonly encoderTaps: Tensor[];
64
+ readonly halfTap?: Tensor;
65
+ private readonly steps;
66
+ constructor(backend: Backend, x_hr: Tensor, baseWeights: ModelWeights, wrapperWeights: UNetWrapperWeights, params: UNetWrapperParams, BaseCtor: BaseNetworkCtor);
67
+ run(): void;
68
+ }
69
+
70
+ interface Res {
71
+ w: number;
72
+ h: number;
73
+ }
74
+ interface TierConfig {
75
+ base: BaseNetworkCtor;
76
+ wrapper: UNetWrapperParams;
77
+ canvasRes: Res;
78
+ baseRes: Res;
79
+ flowFuseStem?: boolean;
80
+ }
81
+ declare const TIER_CONFIG: Record<string, TierConfig>;
82
+
83
+ declare function loadWeightsFromBinary(buf: ArrayBuffer): ModelWeights;
84
+
85
+ type UpscalerMode = 'bilinear' | 'bicubic';
86
+ type BackgroundConfig = {
87
+ mode: 'solid';
88
+ color: [number, number, number];
89
+ } | {
90
+ mode: 'image';
91
+ image: Tensor;
92
+ } | {
93
+ mode: 'blur';
94
+ sigma: number;
95
+ };
96
+ type CompositeSpec = BackgroundConfig | {
97
+ mode: 'passthrough';
98
+ } | {
99
+ mode: 'fg-passthrough';
100
+ };
101
+ interface NetworkLike {
102
+ readonly output: Tensor;
103
+ run(): void;
104
+ }
105
+ interface EffectStage {
106
+ readonly output: Tensor;
107
+ run(): void;
108
+ }
109
+ interface RenderOptions {
110
+ upscaler: UpscalerMode;
111
+ background: BackgroundConfig;
112
+ }
113
+ declare class RenderOp<N extends NetworkLike = NetworkLike> {
114
+ private readonly backend;
115
+ private readonly displayInput;
116
+ private readonly image;
117
+ private network;
118
+ private networkInput;
119
+ private upscaler;
120
+ private upscalerMode;
121
+ private bgConfig;
122
+ private effectChain;
123
+ private viewRect;
124
+ private viewFg;
125
+ private viewAlpha;
126
+ private displayDirty;
127
+ private compositors;
128
+ constructor(backend: Backend);
129
+ attachNetwork(network: N, networkInput: InputOp, options: RenderOptions): void;
130
+ hasNetwork(): boolean;
131
+ setSource(src: ImageSource): void;
132
+ setUpscaler(mode: UpscalerMode): void;
133
+ setBackground(config: BackgroundConfig): void;
134
+ get displayImage(): Tensor;
135
+ private fgImage;
136
+ private chainTail;
137
+ private alphaImage;
138
+ setViewTransform(rect: Tensor | null): void;
139
+ private rebuildView;
140
+ setEffectChain(stages: EffectStage[]): void;
141
+ runEffects(): void;
142
+ run(): void;
143
+ runDisplay(): void;
144
+ runFgPassthrough(): void;
145
+ runPassthrough(): void;
146
+ compositeMain(mode: 'effect' | 'fg' | 'raw'): void;
147
+ refreshDisplayInput(): void;
148
+ compositeTo(target: RenderTarget, spec: CompositeSpec): void;
149
+ applyAlpha(alpha: Tensor): void;
150
+ runModel(): void;
151
+ private makeUpscaler;
152
+ private buildCompositor;
153
+ }
154
+
155
+ export { Backend, type BackgroundConfig, type BaseNetwork, type BaseNetworkCtor, type CompositeSpec, Dtype, ImageSource, InputOp, ModelWeights, Op, RenderOp, type RenderOptions, RenderTarget, type Res, TIER_CONFIG, Tensor, type TierConfig, TierModel, UNetWrapperWeights, type UpscalerMode, WebGLBackend, loadWeightsFromBinary };