longpipe 0.0.7 → 0.0.9
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 +34 -15
- package/dist/index.cjs +4168 -1929
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +4168 -1929
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Fast, high quality virtual effects in the browser
|
|
|
9
9
|
|
|
10
10
|
Try the live demo: [longpipe.dev/demo](https://longpipe.dev/demo)
|
|
11
11
|
|
|
12
|
-
> **Warning** — This project is very new
|
|
12
|
+
> **Warning** — This project is very new and still under active development. Expect API changes between versions and bugs.
|
|
13
13
|
|
|
14
14
|
## Features
|
|
15
15
|
|
|
@@ -44,7 +44,7 @@ await pipeline.ready // optional — resolves once the effect i
|
|
|
44
44
|
|
|
45
45
|
## Performance
|
|
46
46
|
|
|
47
|
-
Longpipe uses custom-trained models built with an
|
|
47
|
+
Longpipe uses custom-trained models built with an EfficientNet-Lite encoder and a U-Net style decoder, broken into five performance presets (`xs` through `xl`) that vary in encoder size, decoder width, and input resolution. Across all variants Longpipe has much higher segmentation accuracy than alternative open-source models like MediaPipe and BodyPix, while also delivering much better real-world performance — the model runs as pure WebGPU/WebGL shaders in a zero-copy, fully-GPU pipeline.
|
|
48
48
|
|
|
49
49
|
### Quality
|
|
50
50
|
Using average alpha pixel error on the P3M-10K valdation dataset (499 landscape images), all variants of Longpipe surpassed mediapipe in both MAE and IoU.
|
|
@@ -104,7 +104,7 @@ You can also pass a manual config:
|
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
106
|
new EffectsPipeline(stream, {
|
|
107
|
-
preset: { model: 'large', dtype: '
|
|
107
|
+
preset: { model: 'large', dtype: 'f32', resolution: { w: 640, h: 360 }, skipFrames: 0 },
|
|
108
108
|
})
|
|
109
109
|
```
|
|
110
110
|
|
|
@@ -138,7 +138,7 @@ pipeline.destroy()
|
|
|
138
138
|
|
|
139
139
|
## Self-hosting weights
|
|
140
140
|
|
|
141
|
-
By default Longpipe fetches model weights from `https://cdn.longpipe.dev/models/v/0.0.
|
|
141
|
+
By default Longpipe fetches model weights from `https://cdn.longpipe.dev/models/v/0.0.2/`. You can browse the available files, sizes, and SHA-256 hashes at [cdn.longpipe.dev/models/v/0.0.2/index.html](https://cdn.longpipe.dev/models/v/0.0.2/index.html) (machine-readable list at [manifest.json](https://cdn.longpipe.dev/models/v/0.0.2/manifest.json)).
|
|
142
142
|
|
|
143
143
|
To serve them yourself, mirror the files under any base URL with the same `model_${name}.bin` naming convention and pass it via `weightsBaseUrl`:
|
|
144
144
|
|
|
@@ -158,20 +158,18 @@ Works on Chromium (Chrome, Edge), Firefox, and Safari (desktop and iOS). WebGPU
|
|
|
158
158
|
|
|
159
159
|
Two layers:
|
|
160
160
|
|
|
161
|
-
- **Model** (`src/model/`) — EfficientNet-Lite
|
|
162
|
-
-
|
|
161
|
+
- **Model** (`src/model/`) — an EfficientNet-Lite encoder (lite0; lite4 on the `xl` tier) with a U-Net decoder, plus a lightweight U-Net *wrapper* that sharpens the matte at higher resolution and a temporal ConvGRU that smooths it across frames. Written as TypeScript op classes — each layer is a class; weights load as binary tensors at init; the backend (WebGPU or WebGL2) is injected at construction. BatchNorm is fused into conv weights at export — there is no BN op at inference.
|
|
163
162
|
- **Pipeline** (`src/pipeline/`) — capability detection, per-browser frame transport selection, worker spawn, audio passthrough, autotune, and the adaptive controller. Designed to absorb the browser/codec/canvas plumbing complexity so consumers don't have to.
|
|
164
163
|
|
|
165
|
-
|
|
164
|
+
Five trained presets cover the hardware range. "Resolution" is the model's working (canvas) resolution; the encoder runs at a lower internal resolution and the U-Net wrapper refines back up to this.
|
|
166
165
|
|
|
167
|
-
| Preset
|
|
168
|
-
|
|
169
|
-
| xl
|
|
170
|
-
| large
|
|
171
|
-
| medium
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
| xs | 192×108 | small | standard | 1 |
|
|
166
|
+
| Preset | Resolution | Encoder | Decoder | Skip frames |
|
|
167
|
+
|--------|------------|--------------|----------|-------------|
|
|
168
|
+
| xl | 1280×720 | full (lite4) | 2× ch | 0 |
|
|
169
|
+
| large | 640×360 | full (lite0) | standard | 0 |
|
|
170
|
+
| medium | 512×288 | full (lite0) | standard | 1 |
|
|
171
|
+
| small | 384×216 | small | standard | 1 |
|
|
172
|
+
| xs | 384×216 | small | standard | 2 |
|
|
175
173
|
|
|
176
174
|
`Skip frames` is how many input frames the model sits out between runs — the compositor still renders every frame using the most recent alpha matte. Autotune picks one of these at init based on a microbenchmark of the actual network on the actual device.
|
|
177
175
|
|
|
@@ -190,3 +188,24 @@ Training scripts, fixture generation, and the weight export pipeline are not yet
|
|
|
190
188
|
- [ ] Lighting correction
|
|
191
189
|
- [ ] Background noise removal (audio, separate pipeline)
|
|
192
190
|
- [ ] Mobile SDKs
|
|
191
|
+
|
|
192
|
+
## License
|
|
193
|
+
|
|
194
|
+
SDK source code is MIT-licensed — see [LICENSE](LICENSE).
|
|
195
|
+
|
|
196
|
+
The pre-trained model weights distributed via `cdn.longpipe.dev` (and any mirrored copies) are also MIT-licensed — see [WEIGHTS_LICENSE](WEIGHTS_LICENSE). You're free to self-host them inside other open-source or commercial projects under MIT-compatible terms.
|
|
197
|
+
|
|
198
|
+
### Training data and pretrained weights
|
|
199
|
+
|
|
200
|
+
Longpipe's pre-trained weights are released under MIT (see [WEIGHTS_LICENSE](WEIGHTS_LICENSE)). They were trained on:
|
|
201
|
+
|
|
202
|
+
- [P3M-10k](https://github.com/JizhiziLi/P3M) — MIT
|
|
203
|
+
- [AISegment Matting Human Datasets](https://www.kaggle.com/datasets/laurentmih/aisegmentcom-matting-human-datasets) — MIT ([upstream license](https://github.com/aisegmentcn/matting_human_datasets/blob/master/LICENSE))
|
|
204
|
+
- [COCO](https://cocodataset.org) person masks — annotations are CC BY 4.0; the underlying images are Flickr-sourced under their own (mixed) licenses, which COCO does not relicense
|
|
205
|
+
- Synthetic images generated with [Z-Image](https://github.com/Tongyi-MAI/Z-Image) (text-to-image) — Apache 2.0
|
|
206
|
+
- A custom dataset of short webcam videos collected via [Prolific](https://www.prolific.com/), from participants who gave explicit, informed consent for their footage to be used to train an open-source virtual-background model. Faces are blurred before training; the raw videos are stored privately (EU), never distributed, and deleted after the training window.
|
|
207
|
+
- Pseudo-labels generated by [BiRefNet](https://github.com/ZhengPeng7/BiRefNet) (MIT), used as a teacher model
|
|
208
|
+
|
|
209
|
+
The encoder is initialized from a pre-trained [EfficientNet-Lite](https://github.com/RangiLyu/EfficientNet-Lite) backbone — Apache 2.0.
|
|
210
|
+
|
|
211
|
+
As is standard for trained models, the released weights are not a redistribution of any training image or video — they are published under MIT. Aside from COCO (whose underlying Flickr images carry mixed licenses), every source above is permissively licensed or used with explicit consent. If your use case has strict data-provenance requirements, review COCO's image terms for yourself.
|