@tradalab/mediakit 2.4.1 → 2.6.0
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 +103 -0
- package/dist/{chunk-YW75KJJO.js → chunk-RWUGOTNJ.js} +12 -3
- package/dist/chunk-RWUGOTNJ.js.map +1 -0
- package/dist/detect-worker.js +22 -13
- package/dist/detect-worker.js.map +1 -1
- package/dist/index.d.ts +117 -5
- package/dist/index.js +459 -63
- package/dist/index.js.map +1 -1
- package/dist/mediakit.wasm +0 -0
- package/dist/recipe.d.ts +8 -0
- package/dist/recipe.js +1 -1
- package/dist/worker.js +287 -48
- package/dist/worker.js.map +1 -1
- package/package.json +11 -9
- package/dist/chunk-YW75KJJO.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,6 +6,107 @@ face retouching.
|
|
|
6
6
|
|
|
7
7
|
The examples named below live in the repository under `web/example/`; `make example` serves them.
|
|
8
8
|
|
|
9
|
+
### Upgrading to 2.6.0
|
|
10
|
+
|
|
11
|
+
Existing calls are unchanged. Serve the new `mediakit.wasm`, `worker.js` and `detect-worker.js`
|
|
12
|
+
with the new JS.
|
|
13
|
+
|
|
14
|
+
- **Fewer MediaPipe instances.** A recipe whose mask comes from a detect worker (the multiclass
|
|
15
|
+
model, or the person model with no background) no longer also builds the person segmenter in the
|
|
16
|
+
frame thread to stand in until the worker is up: the frames before it pass through as they do
|
|
17
|
+
before any mask. The Studio recipe (beauty, hair or skin-scoped grade, makeup) now builds two
|
|
18
|
+
instances instead of three, and fetches the 13.5 MB MediaPipe runtime twice instead of three
|
|
19
|
+
times (measured on the e2e server, which sends no cache headers). The person model in the frame
|
|
20
|
+
thread still comes up when a worker fails, when the multiclass model fails, and for any
|
|
21
|
+
background.
|
|
22
|
+
- **Detector loads time out at 60 s** (`LOAD_MS`), in a worker and in the frame thread. A timed-out
|
|
23
|
+
detector is not retried in the frame thread, which would wait on the same network: its effects
|
|
24
|
+
stay off, `effectError` says `... did not load within 60 s; face effects stay off`, and
|
|
25
|
+
`onIssue` fires `effect-off`. A failed load is no longer retried on every frame.
|
|
26
|
+
- **`preloadDetectors({ person, classes, face })`** fetches the MediaPipe runtime and those models
|
|
27
|
+
at low priority, to warm the HTTP cache before the first recipe that needs them (call it when the
|
|
28
|
+
camera screen opens). It never rejects. It only helps when `/mediakit/` is served cacheable.
|
|
29
|
+
- **GPU guard: a lost context is not repeated.** Chromium blocks WebGL for the whole site after a
|
|
30
|
+
few lost contexts in a short time, so a driver that loses the context on one shader must not be
|
|
31
|
+
handed that shader again. The Engine now tells when a loss happened:
|
|
32
|
+
- **building the shaders** (`init`): `start()` rejects with `GpuLostError` (`phase: "init"`) and
|
|
33
|
+
does NOT try the main thread after the worker. This browser remembers the GPU for 3 days:
|
|
34
|
+
`checkSupport()` reports `gpu-blocked` and `start()` rejects at once, before creating a context.
|
|
35
|
+
- **within 3 s of a makeup shader linking** (`link`): the pipeline rebuilds once without face
|
|
36
|
+
colour (makeup and teeth off, `effect-off` says why) and remembers it for that GPU, so later
|
|
37
|
+
starts skip the makeup shader from the beginning.
|
|
38
|
+
- **later** (`run`): a GPU reset or a reclaimed context, rebuilt as before and not remembered.
|
|
39
|
+
|
|
40
|
+
`checkSupport().remembered` and `gpuRecord(gpu)` show what is remembered; `forgetGpuFailures()`
|
|
41
|
+
clears it, for a "try again" button after a driver update. The memory is `localStorage`
|
|
42
|
+
(`mediakit-gpu-guard`) on the page's origin.
|
|
43
|
+
|
|
44
|
+
### Upgrading to 2.5.0
|
|
45
|
+
|
|
46
|
+
Existing calls are unchanged; everything below is new. Serve the new `mediakit.wasm`,
|
|
47
|
+
`worker.js` and `detect-worker.js` together with the new JS: an older `mediakit.wasm` still runs
|
|
48
|
+
under it, without the new effects.
|
|
49
|
+
|
|
50
|
+
**Fix: the filter never started on AMD Radeon 680M (Windows, ANGLE D3D11).** The composite
|
|
51
|
+
shader chose between the two skin measures (multiclass mask, or colour and face shape) with a
|
|
52
|
+
branch. Linking it hit a backend error after 4-7 s; ANGLE then loses the WebGL context instead of
|
|
53
|
+
writing a log, so the filter fell back to the raw camera with `webgl: link:` and an empty log, and
|
|
54
|
+
after a few tries Edge blocked WebGL for the page. Both measures are now computed and mixed, with
|
|
55
|
+
no branch; the picture is unchanged (GPU comparison over 400 random inputs: at most 1/255). Found
|
|
56
|
+
by bisecting on the failing laptop: either measure alone links, either branch form (`? :` or
|
|
57
|
+
`if/else`) fails, `mix` links (composite in 0.8 s).
|
|
58
|
+
|
|
59
|
+
Taken from what Tencent Beauty AR Web, BytePlus's web beauty extension and GPUPixel do better:
|
|
60
|
+
|
|
61
|
+
- **Makeup shader compiled per effect group** (GPUPixel's small per-filter programs). `facecolor`
|
|
62
|
+
is built with only the groups the recipe uses (lips, contour, brows, shadow, blush, iris colour,
|
|
63
|
+
makeup texture), the first time a recipe needs them, in the background where the browser has
|
|
64
|
+
`KHR_parallel_shader_compile`. Measured cold (driver shader cache off) on Edge, ANGLE GL,
|
|
65
|
+
Intel UHD: no group 55 ms, the Studio set (lips, blush, shadow) ~300 ms, all seven ~900 ms.
|
|
66
|
+
While a group set links, the closest ready one keeps drawing; smoothing, whitening and reshape
|
|
67
|
+
never wait for it.
|
|
68
|
+
- **Shader failures do not take the filter down.** A face colour link failure turns makeup and
|
|
69
|
+
teeth off, the rest keeps running, and the console says once
|
|
70
|
+
`mediakit: shader facecolor: ...; makeup and teeth stay off, the rest runs [GPU: ...]`.
|
|
71
|
+
`health.effectError` and `FrameStats.effectError` carry it. Any shader error names the shader
|
|
72
|
+
and the GPU, "the driver gave no log" for an empty log and "context lost" for a GPU reset.
|
|
73
|
+
- **`checkSupport()`** (BytePlus `checkCompatibility`): `{ supported, reasons, softwareRenderer, gpu }`,
|
|
74
|
+
`reasons` from `no-window`, `no-wasm`, `no-webgl2`, `no-transport`. `mediakitSupported()` is
|
|
75
|
+
`checkSupport().supported`.
|
|
76
|
+
- **`onIssue`** (Tencent's error and warning codes), once per code until it clears:
|
|
77
|
+
|
|
78
|
+
| Code | When | The app should |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| `stall` | no frame out for 2 s with the camera live (also `onStall`) | fall back to the raw camera after a grace period |
|
|
81
|
+
| `slow` | frames or face detection over 150 ms for 3 s (Tencent's 50005) | suggest a lower resolution or fewer effects |
|
|
82
|
+
| `effect-off` | some effects are off, the rest runs (`health.effectError`) | say which ones and why |
|
|
83
|
+
| `worker-moved` | the worker failed, the pipeline moved to the main thread | install the track from `onTrackReplaced` |
|
|
84
|
+
| `gpu-lost` | the WebGL context was lost | nothing: the pipeline rebuilds itself (up to twice; once without makeup after a makeup link loss, never after a loss building the shaders) and fires `onTrackReplaced` |
|
|
85
|
+
|
|
86
|
+
- **`replaceSource(track)`** (Tencent `resetCore(input)`): another camera into the running
|
|
87
|
+
pipeline. Same resolution: `processedTrack` stays the same track, on every transport. Another
|
|
88
|
+
resolution: it rebuilds and fires `onTrackReplaced`. The caller still owns both sources.
|
|
89
|
+
- **`sharpen`** 0..1 (Tencent `usm`, BytePlus sharpen): unsharp mask over the whole frame in the
|
|
90
|
+
grade pass, eased on skin while `beautify` smooths it. Measured at 1: edge energy x1.7 off skin;
|
|
91
|
+
with `beautify` 0.6, x1.35 on skin.
|
|
92
|
+
- **`hair` / `hairColor`** (Tencent `setHairColor`): dyes the hair from the multiclass segmenter's
|
|
93
|
+
hair class, keeping strands and shading. Needs `/mediakit/selfie_multiclass_256x256.tflite`;
|
|
94
|
+
without it the effect does nothing.
|
|
95
|
+
|
|
96
|
+
#### Handling a weak or failing GPU in an app
|
|
97
|
+
|
|
98
|
+
| Situation | mediakit | The app should |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| No WebGL2 / WASM / transport | `checkSupport().reasons` | not start; tell the user how to enable hardware acceleration |
|
|
101
|
+
| GPU lost its context building the shaders in the last 3 days | `checkSupport().reasons` has `gpu-blocked`; `start()` rejects with `GpuLostError` at once | use the raw camera; offer "update the driver, then try again" calling `forgetGpuFailures()` |
|
|
102
|
+
| Software renderer (SwiftShader, llvmpipe) | runs, slowly; `checkSupport().softwareRenderer` | warn |
|
|
103
|
+
| Makeup shader slow or failing to link, or losing the context linking | makeup off, rest runs, `effect-off`; remembered per GPU after a loss | show that makeup is off, keep the camera on |
|
|
104
|
+
| A detector does not load within 60 s | its effects off, rest runs, `effect-off` | say the network is slow; `preloadDetectors()` earlier helps the next time |
|
|
105
|
+
| Overloaded machine | `slow`, then `stall` | lower the load, then fall back to the raw camera |
|
|
106
|
+
| GPU context lost while running | rebuilds, `gpu-lost`, `onTrackReplaced` | install the new track |
|
|
107
|
+
| `start()` throws `GpuLostError` | lost the context building the shaders; remembered | use the raw camera; do not retry, mediakit would refuse anyway |
|
|
108
|
+
| `start()` throws another GPU error (`webgl`) | rejects with the shader and GPU named | use the raw camera; retry once on the next start, then stop trying for the session |
|
|
109
|
+
|
|
9
110
|
### Upgrading to 2.4.1
|
|
10
111
|
|
|
11
112
|
No API change: serve the new `worker.js` and `detect-worker.js`.
|
|
@@ -185,6 +286,7 @@ than building the object by hand, so a new field cannot arrive as `undefined`.
|
|
|
185
286
|
| `tint` | -1 … 1 | Positive magenta, negative green: with `warmth`, a white balance. GPUPixel's tint, a shift along YIQ's Q axis, so brightness does not move. |
|
|
186
287
|
| `vibrance` | -1 … 1 | Saturation that moves dull colours more than vivid ones and skin least. Measured at 1: a dull blue +84 %, skin +20 % - where `saturation: 0.5` takes skin +50 % and turns faces orange first. |
|
|
187
288
|
| `grain` | 0 … 1 | Film grain: luminance noise, a new pattern every frame, strongest in the midtones, none at black or white. About 6 levels at 1. Noise is what an encoder spends the most bits on; keep it low on a live stream. |
|
|
289
|
+
| `sharpen` | 0 … 1 | Unsharp mask over the whole frame, in the last (grade) pass, on luminance only so edges gain no colour fringe. Eased on skin while `beautify` smooths it, so it does not bring back what smoothing took. At 1, edge energy x1.7; on skin with `beautify` 0.6, x1.35. |
|
|
188
290
|
| `autoLight` | boolean | Lifts exposure when the room is dark, on top of `exposure`, and only ever brightens. Measures the person when a mask exists, the centre of the frame otherwise. Moves over about a second, so a lamp switching on does not flash the picture. |
|
|
189
291
|
| `mirror` | boolean | Flips the finished picture left to right, as a selfie preview shows it. Only the last pass flips, so face tracking, masks and autoframe still see the camera as it is; free on top of any other effect, one pass on its own. Off by default: a mirrored whiteboard reads backwards to everyone else. |
|
|
190
292
|
| `beautify` | 0 … 1 | Skin smoothing in two bands: uneven colour (redness, marks, patches) evened hard, fine texture (pores) only eased, so skin stays skin; features - eyes, brows, the lip line - keep both, and small dark spots are lifted. The radius follows the face's size when landmarks run. With the multiclass segmenter loaded it keeps to the skin it labels; otherwise to the person's skin-coloured pixels. |
|
|
@@ -192,6 +294,7 @@ than building the object by hand, so a new field cannot arrive as `undefined`.
|
|
|
192
294
|
| `whitenStyle` | `"natural"`, `"pink"` | `pink` is the "fair and rosy" look of East Asian beauty apps: GPUPixel's tuned skin tables (Apache-2.0, `dist/NOTICE`), served as `/mediakit/whiten_pink.png` and loaded the first time it is asked for. It takes over on light and medium skin and hands back to `natural` on dark skin, by the skin measured on each face - those tables were not tuned for it and came out mottled. |
|
|
193
295
|
| `skinLight` | 0 … 1 | The same relighting without the cooling: brightness on that same skin, its colour and shading kept. `exposure` stays whole-frame. |
|
|
194
296
|
| `clarity` | 0 … 1 | Local contrast on the faces: the detail `beautify` separates out, added on top. Its own knob - `beautify` gives back only what it took. Needs landmarks; kept off the cut-out edge, where it would draw a rim. Dropped with `beautify` when the governor is short of time. |
|
|
297
|
+
| `hair`, `hairColor` | 0 … 1, `[r, g, b]` | Hair dye: keeps the hair's own brightness and strands and takes the colour's hue; very dark hair takes less, as real dye does. Drawn from the hair class of the multiclass segmenter, so it needs `/mediakit/selfie_multiclass_256x256.tflite` - without it nothing is dyed. Facial hair is left alone. |
|
|
195
298
|
| `skinScope` | `"person"`, `"face"` | Where smoothing (and the two above, already held to the face) may land. `person`, the default, is skin anywhere on the person, hands included; `face` keeps smoothing to faces and necks, so a hand holding a product - or a lipstick swatch on the back of it - is left alone. With no face found, `face` lands nowhere. |
|
|
196
299
|
| `autoframe` | boolean | Keeps the person framed, with headroom. Moves by time, not by frame, so it looks the same at 24fps and 60fps. |
|
|
197
300
|
| `teeth` | 0 … 1 | Whitens teeth. |
|
|
@@ -12,6 +12,7 @@ var NO_EFFECTS = {
|
|
|
12
12
|
tint: 0,
|
|
13
13
|
vibrance: 0,
|
|
14
14
|
grain: 0,
|
|
15
|
+
sharpen: 0,
|
|
15
16
|
autoframe: false,
|
|
16
17
|
teeth: 0,
|
|
17
18
|
eyeBright: 0,
|
|
@@ -31,6 +32,8 @@ var NO_EFFECTS = {
|
|
|
31
32
|
whiten: 0,
|
|
32
33
|
skinLight: 0,
|
|
33
34
|
clarity: 0,
|
|
35
|
+
hair: 0,
|
|
36
|
+
hairColor: [0.45, 0.22, 0.12],
|
|
34
37
|
skinScope: "person",
|
|
35
38
|
lut: "",
|
|
36
39
|
grade: 0,
|
|
@@ -70,6 +73,7 @@ var EFFECTS_SCHEMA = {
|
|
|
70
73
|
tint: signed,
|
|
71
74
|
vibrance: signed,
|
|
72
75
|
grain: amount,
|
|
76
|
+
sharpen: amount,
|
|
73
77
|
autoframe: bool,
|
|
74
78
|
teeth: amount,
|
|
75
79
|
eyeBright: amount,
|
|
@@ -90,6 +94,8 @@ var EFFECTS_SCHEMA = {
|
|
|
90
94
|
whitenStyle: { kind: "choice", values: ["natural", "pink"] },
|
|
91
95
|
skinLight: amount,
|
|
92
96
|
clarity: amount,
|
|
97
|
+
hair: amount,
|
|
98
|
+
hairColor: color,
|
|
93
99
|
skinScope: { kind: "choice", values: ["person", "face"] },
|
|
94
100
|
lut: url,
|
|
95
101
|
grade: amount,
|
|
@@ -187,7 +193,7 @@ function backgroundMode(f) {
|
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
195
|
function needsMask(f, e) {
|
|
190
|
-
return f.kind !== "none" || e.beautify > 0 || e.autoframe || hasSkin(e) || e.grade > 0 && (e.gradeScope ?? "frame") !== "frame";
|
|
196
|
+
return f.kind !== "none" || e.beautify > 0 || e.autoframe || hasSkin(e) || e.grade > 0 && (e.gradeScope ?? "frame") !== "frame" || (e.hair ?? 0) > 0;
|
|
191
197
|
}
|
|
192
198
|
function hasSkin(e) {
|
|
193
199
|
return (e.whiten ?? 0) > 0 || (e.skinLight ?? 0) > 0 || (e.clarity ?? 0) > 0;
|
|
@@ -196,7 +202,7 @@ function needsSegmentation(f, e) {
|
|
|
196
202
|
return needsMask(f, e) && !e.chromaKey;
|
|
197
203
|
}
|
|
198
204
|
function needsSkinClasses(_f, e) {
|
|
199
|
-
return e.grade > 0 && (e.gradeScope ?? "frame") !== "frame";
|
|
205
|
+
return e.grade > 0 && (e.gradeScope ?? "frame") !== "frame" || (e.hair ?? 0) > 0;
|
|
200
206
|
}
|
|
201
207
|
function needsFace(e) {
|
|
202
208
|
return e.teeth > 0 || e.eyeBright > 0 || e.underEye > 0 || e.smileLines > 0 || e.lips > 0 || e.blush > 0 || e.iris > 0 || (e.eyeShadow ?? 0) > 0 || (e.lipGloss ?? 0) > 0 || (e.rosy ?? 0) > 0 || e.skinScope === "face" && (e.beautify > 0 || hasSkin(e)) || // Whitening and skin light measure skin on the face; clarity is held to it.
|
|
@@ -214,6 +220,7 @@ function coreRecipe(f, e) {
|
|
|
214
220
|
tint: e.tint ?? 0,
|
|
215
221
|
vibrance: e.vibrance ?? 0,
|
|
216
222
|
grain: e.grain ?? 0,
|
|
223
|
+
sharpen: e.sharpen ?? 0,
|
|
217
224
|
autoframe: e.autoframe,
|
|
218
225
|
teeth: e.teeth,
|
|
219
226
|
eyeBright: e.eyeBright,
|
|
@@ -233,6 +240,8 @@ function coreRecipe(f, e) {
|
|
|
233
240
|
whiten: e.whiten ?? 0,
|
|
234
241
|
skinLight: e.skinLight ?? 0,
|
|
235
242
|
clarity: e.clarity ?? 0,
|
|
243
|
+
hair: e.hair ?? 0,
|
|
244
|
+
hairColor: e.hairColor ?? NO_EFFECTS.hairColor,
|
|
236
245
|
skinScope: SKIN_SCOPE[e.skinScope] ?? 0,
|
|
237
246
|
grade: e.grade,
|
|
238
247
|
gradeScope: GRADE_SCOPE[e.gradeScope] ?? 0,
|
|
@@ -281,4 +290,4 @@ export {
|
|
|
281
290
|
needsFace,
|
|
282
291
|
coreRecipe
|
|
283
292
|
};
|
|
284
|
-
//# sourceMappingURL=chunk-
|
|
293
|
+
//# sourceMappingURL=chunk-RWUGOTNJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/recipe.ts"],"sourcesContent":["/**\n * The bridge between what the user picked and the recipe the Go core takes.\n *\n * Both halves live here because both map onto `core.Recipe` field for field: BgFilter carries\n * the background mode and its one parameter, Effects carries everything else. They are two\n * types rather than one because the UI edits them from two different places - a preset picker\n * and a slider panel - not because they belong to different layers.\n */\n\n/**\n * What replaces the background.\n *\n * `imagePath` is a URL the consuming app serves: a path under its own public root, or a data\n * URL for something the user uploaded. The Engine fetches it and cover-crops it to the frame\n * aspect, so any shape is safe to pass.\n */\nexport type BgFilter =\n | { kind: \"none\" }\n | { kind: \"blur\"; blurRadius: number }\n | { kind: \"image\"; imagePath: string }\n /**\n * The background becomes TRANSPARENT and the person stays: the output canvas carries the\n * mask as alpha. For a {@link Scene} to put the person over another source; a plain video\n * track has no alpha, so on its own this shows the person over black.\n */\n | { kind: \"cutout\" }\n\n/** A colour as red, green, blue, each 0..1. */\nexport type Rgb = [number, number, number]\n\n/** Where smoothing (`beautify`) may land. */\n/** An inner layer drawn instead of the picture, for tuning: skin weights, the mask, the tracked faces. */\nexport type DebugView = \"off\" | \"skin\" | \"mask\" | \"face\"\n\nexport const DEBUG_VIEWS: readonly DebugView[] = [\"off\", \"skin\", \"mask\", \"face\"]\n\nexport function debugCode(view: DebugView | undefined): number {\n return Math.max(0, DEBUG_VIEWS.indexOf(view ?? \"off\"))\n}\n\nexport type SkinScope = \"person\" | \"face\"\n\n/** Where the colour LUT lands. */\nexport type GradeScope = \"frame\" | \"person\" | \"skin\"\n\nexport interface Effects {\n /** Skin smoothing, 0..1. Needs the person mask, so it pulls in the segmentation cost. */\n beautify: number\n /** Exposure, -1..1. Positive lifts the shadows more than the highlights. */\n exposure: number\n /** Contrast, -1..1. */\n contrast: number\n /** Saturation, -1..1. */\n saturation: number\n /** Warm (positive) or cool (negative), -1..1. */\n warmth: number\n /** Magenta (positive) or green (negative), -1..1. */\n tint: number\n /** Saturation for dull colours more than vivid ones, skin least, -1..1. */\n vibrance: number\n /** Film grain, 0..1. Noise costs encoder bits: keep it low on a live stream. */\n grain: number\n /** Unsharp mask over the whole frame, 0..1; eased on skin while `beautify` smooths it. */\n sharpen: number\n /** Keep the person framed. Needs the person mask. */\n autoframe: boolean\n\n // ── Need FACE landmarks ──────────────────────────────────────────────────────────\n /** Teeth whitening, 0..1. */\n teeth: number\n /** Brighten the whites of the eyes, 0..1. */\n eyeBright: number\n /** Reduce under-eye shadow, 0..1. */\n underEye: number\n /** Soften the nasolabial folds, 0..1. */\n smileLines: number\n\n /**\n * Makeup, 0..1 each, in its colour. Drawn against the full landmark mesh, so the lip tint\n * follows the lip line rather than an ellipse. Not offered in meet, like reshaping.\n */\n lips: number\n lipColor: Rgb\n blush: number\n blushColor: Rgb\n /** Iris colour: the ring only, clipped by the eyelids, the pupil left black. */\n iris: number\n irisColor: Rgb\n /** Eye shadow, 0..1, multiplied into the lower part of the lid-to-brow band. */\n eyeShadow: number\n eyeShadowColor: Rgb\n /** A white highlight across the middle of the lower lip, 0..1. Matte is 0. */\n lipGloss: number\n /** A faint flush over the whole face's skin, 0..1 - the face, where `blush` is the cheeks. */\n rosy: number\n rosyColor: Rgb\n\n // ── Skin, beside beautify.\n /** Lift and cool the skin, 0..1: brighter, less yellow. */\n whiten: number\n /**\n * How `whiten` whitens. `natural` relights the skin and cools its yellow, keeping its colour.\n * `pink` is the \"fair and rosy\" look East Asian beauty apps ship - GPUPixel's tuned skin\n * tables (Apache-2.0, see NOTICE), served as `/mediakit/whiten_pink.png`; it fades out on\n * darker skin, which those tables were not tuned for.\n */\n whitenStyle: \"natural\" | \"pink\"\n /** Exposure on the skin only. */\n skinLight: number\n /** Local contrast on the face. */\n clarity: number\n /** Hair dye, 0..1, strands and shading kept. Needs `/mediakit/selfie_multiclass_256x256.tflite`. */\n hair: number\n hairColor: Rgb\n /** Where smoothing may land. See {@link SkinScope}. */\n skinScope: SkinScope\n\n /**\n * A colour LUT: `lut` is a URL the host serves (a 512x512 \"lookup\" PNG, 64 levels, 8x8 tiles,\n * row 0 at the top), `grade` how strongly it applies. \"\" means none.\n */\n lut: string\n grade: number\n /** Where the LUT lands. See {@link GradeScope}. */\n gradeScope: GradeScope\n\n /**\n * Take the person mask from a coloured screen instead of segmentation. Cheaper - MediaPipe\n * is never loaded - and the edge keeps hair the model loses. `keyColor` is the screen's\n * colour; [0, 0, 0] means \"find it\" from the frame's border. `keyTolerance` widens (+) or\n * narrows (-) what counts as screen, -1..1 around a tuned default.\n */\n chromaKey: boolean\n keyColor: Rgb\n keyTolerance: number\n\n /**\n * Lift exposure when the room is dark, on top of `exposure`. Only ever brightens. Needs no\n * detector: it reads the frame's own brightness.\n */\n autoLight: boolean\n\n /**\n * Flip the picture left to right, as a selfie preview shows it. Costs nothing on top of any\n * other effect; on its own it is one pass. Text on a whiteboard then reads backwards to\n * everyone watching, which is why it is a choice and not the default.\n */\n mirror: boolean\n\n /**\n * Jawline slimming, 0..1.\n *\n * Deliberately NOT offered in meet: Zoom, Google Meet and Teams all ship without face\n * reshaping, and in a work setting it reads as unserious. The field is here because the\n * second consumer of mediakit is slate, where reshaping is ordinary.\n */\n slimFace: number\n /** Eye enlargement, 0..1. Withheld from meet for the same reason as slimFace. */\n enlargeEyes: number\n /** Nose narrowing, 0..1. Withheld from meet like slimFace. */\n noseSlim: number\n /** Chin length, -1 (shorter) .. 1 (longer). Withheld from meet like slimFace. */\n chin: number\n /** Reshaping along the face's own outline. */\n jaw: number\n cheekbone: number\n forehead: number\n /** Brow fill, 0..1, multiplied in so the hairs show; lighter at the inner end. */\n brow: number\n browColor: Rgb\n /** Shading under the cheekbones, along the jaw and beside the nose, 0..1. */\n contour: number\n /** Light on the nose bridge, cheekbone tops, mid forehead and chin, 0..1. */\n highlight: number\n /** A look painted as an image on the canonical face. */\n makeupTexture: string\n makeup: number\n /** How the makeup texture blends: soft light (default), multiply, overlay, hard light, normal. */\n makeupBlend: \"softLight\" | \"multiply\" | \"overlay\" | \"hardLight\" | \"normal\"\n}\n\nexport const NO_EFFECTS: Effects = {\n beautify: 0,\n exposure: 0,\n contrast: 0,\n saturation: 0,\n warmth: 0,\n tint: 0,\n vibrance: 0,\n grain: 0,\n sharpen: 0,\n autoframe: false,\n teeth: 0,\n eyeBright: 0,\n underEye: 0,\n smileLines: 0,\n lips: 0,\n lipColor: [0.55, 0.18, 0.24],\n blush: 0,\n blushColor: [0.9, 0.5, 0.42],\n iris: 0,\n irisColor: [0.3, 0.5, 0.75],\n eyeShadow: 0,\n eyeShadowColor: [0.55, 0.42, 0.37],\n lipGloss: 0,\n rosy: 0,\n rosyColor: [0.9, 0.42, 0.49],\n whiten: 0,\n skinLight: 0,\n clarity: 0,\n hair: 0,\n hairColor: [0.45, 0.22, 0.12],\n skinScope: \"person\",\n lut: \"\",\n grade: 0,\n gradeScope: \"frame\",\n chromaKey: false,\n keyColor: [0, 0, 0],\n keyTolerance: 0,\n autoLight: false,\n mirror: false,\n slimFace: 0,\n enlargeEyes: 0,\n noseSlim: 0,\n chin: 0,\n jaw: 0,\n cheekbone: 0,\n forehead: 0,\n brow: 0,\n browColor: [0.36, 0.27, 0.22],\n contour: 0,\n highlight: 0,\n makeupTexture: \"\",\n makeup: 0,\n makeupBlend: \"softLight\",\n whitenStyle: \"natural\",\n}\n\n/**\n * What an `Effects` field accepts: `amount` 0..1, `signed` -1..1, `color` an {@link Rgb},\n * `choice` one of `values`, `url` a string (\"\" is none). Ranges match `Recipe.Normalized` in Go.\n */\nexport type FieldSpec =\n | { kind: \"amount\" | \"signed\" }\n | { kind: \"bool\" }\n | { kind: \"color\" }\n | { kind: \"choice\"; values: readonly string[] }\n | { kind: \"url\" }\n\nconst amount = { kind: \"amount\" } as const\nconst signed = { kind: \"signed\" } as const\nconst bool = { kind: \"bool\" } as const\nconst color = { kind: \"color\" } as const\nconst url = { kind: \"url\" } as const\n\n// The spec a field of type T may have. [T] stops a union being checked member by member.\ntype SpecFor<T> = [T] extends [boolean]\n ? { kind: \"bool\" }\n : [T] extends [number]\n ? { kind: \"amount\" | \"signed\" }\n : [T] extends [Rgb]\n ? { kind: \"color\" }\n : string extends T\n ? { kind: \"url\" }\n : { kind: \"choice\"; values: readonly T[] }\n\n/** Every {@link Effects} field; a missing field or a wrong kind does not compile. */\nexport const EFFECTS_SCHEMA: { readonly [K in keyof Effects]-?: SpecFor<Effects[K]> } = {\n beautify: amount,\n exposure: signed,\n contrast: signed,\n saturation: signed,\n warmth: signed,\n tint: signed,\n vibrance: signed,\n grain: amount,\n sharpen: amount,\n autoframe: bool,\n teeth: amount,\n eyeBright: amount,\n underEye: amount,\n smileLines: amount,\n lips: amount,\n lipColor: color,\n blush: amount,\n blushColor: color,\n iris: amount,\n irisColor: color,\n eyeShadow: amount,\n eyeShadowColor: color,\n lipGloss: amount,\n rosy: amount,\n rosyColor: color,\n whiten: amount,\n whitenStyle: { kind: \"choice\", values: [\"natural\", \"pink\"] },\n skinLight: amount,\n clarity: amount,\n hair: amount,\n hairColor: color,\n skinScope: { kind: \"choice\", values: [\"person\", \"face\"] },\n lut: url,\n grade: amount,\n gradeScope: { kind: \"choice\", values: [\"frame\", \"person\", \"skin\"] },\n chromaKey: bool,\n keyColor: color,\n keyTolerance: signed,\n autoLight: bool,\n mirror: bool,\n slimFace: amount,\n enlargeEyes: amount,\n noseSlim: amount,\n chin: signed,\n jaw: amount,\n cheekbone: amount,\n forehead: signed,\n brow: amount,\n browColor: color,\n contour: amount,\n highlight: amount,\n makeupTexture: url,\n makeup: amount,\n makeupBlend: { kind: \"choice\", values: [\"softLight\", \"multiply\", \"overlay\", \"hardLight\", \"normal\"] },\n}\n\n/**\n * Any value as a valid {@link Effects}: numbers clamped, missing or malformed fields from\n * {@link NO_EFFECTS}, unknown fields dropped.\n */\nexport function normalizeEffects(raw: unknown): Effects {\n const src = (raw && typeof raw === \"object\" ? raw : {}) as Record<string, unknown>\n const out: Record<string, unknown> = {}\n for (const [key, spec] of Object.entries(EFFECTS_SCHEMA) as [keyof Effects, FieldSpec][]) {\n const v = src[key]\n const fallback = NO_EFFECTS[key]\n switch (spec.kind) {\n case \"amount\":\n case \"signed\": {\n const lo = spec.kind === \"amount\" ? 0 : -1\n out[key] = typeof v === \"number\" && Number.isFinite(v) ? Math.min(1, Math.max(lo, v)) : fallback\n break\n }\n case \"bool\":\n out[key] = typeof v === \"boolean\" ? v : fallback\n break\n case \"color\":\n out[key] =\n Array.isArray(v) && v.length === 3 && v.every((x) => typeof x === \"number\" && Number.isFinite(x))\n ? v.map((x: number) => Math.min(1, Math.max(0, x)))\n : [...(fallback as Rgb)]\n break\n case \"choice\":\n out[key] = typeof v === \"string\" && spec.values.includes(v) ? v : fallback\n break\n case \"url\":\n out[key] = typeof v === \"string\" ? v : fallback\n break\n }\n }\n return out as unknown as Effects\n}\n\n/**\n * One knob for \"look a little fresher\": skin, eyes, under-eyes, smile lines and teeth, moved\n * together in proportions tuned to read as rested rather than filtered at 1.\n *\n * A host that shows this instead of five sliders gets the shape Zoom and TikTok ship - people\n * reach for one control, not five, and five half-understood knobs mostly get set too high. The\n * ratios live here, next to the fields they drive, so every host means the same thing by it.\n */\nexport function touchUp(amount: number): Pick<Effects, \"beautify\" | \"eyeBright\" | \"underEye\" | \"smileLines\" | \"teeth\"> {\n const a = Math.min(1, Math.max(0, amount))\n return {\n beautify: a * TOUCH_UP.beautify,\n eyeBright: a * TOUCH_UP.eyeBright,\n underEye: a * TOUCH_UP.underEye,\n smileLines: a * TOUCH_UP.smileLines,\n teeth: a * TOUCH_UP.teeth,\n }\n}\n\n/** What `touchUp(1)` sets. Exported so a host can read a stored recipe back into one knob. */\nexport const TOUCH_UP = {\n beautify: 0.6,\n eyeBright: 0.5,\n underEye: 0.45,\n smileLines: 0.5,\n teeth: 0.4,\n} as const\n\n/**\n * The touch-up position a recipe corresponds to: the LARGEST of its five fields relative to\n * `touchUp(1)`. A recipe whose fields were set one by one has no single answer, and reading one\n * field only would show 0 for a recipe still whitening teeth - a knob at 0 that cannot turn off\n * what is running. Taking the largest, any effect still on shows, and moving the knob rewrites\n * all five consistently.\n */\nexport function touchUpAmount(e: Effects): number {\n let a = 0\n for (const k of Object.keys(TOUCH_UP) as (keyof typeof TOUCH_UP)[]) {\n a = Math.max(a, (e[k] ?? 0) / TOUCH_UP[k])\n }\n return Math.min(1, a)\n}\n\n/** Go-side `BackgroundMode`. Must match `core/recipe.go`. */\nexport const MODE_NONE = 0\nexport const MODE_BLUR = 1\nexport const MODE_IMAGE = 2\nexport const MODE_CUTOUT = 3\n\n/** Go-side `SkinScope` and `Scope`. Must match `core/recipe.go`. */\nexport const SKIN_SCOPE = { person: 0, face: 1 } as const\nexport const MAKEUP_BLEND = { softLight: 0, multiply: 1, overlay: 2, hardLight: 3, normal: 4 } as const\nexport const GRADE_SCOPE = { frame: 0, person: 1, skin: 2 } as const\n\nexport function backgroundMode(f: BgFilter): number {\n switch (f.kind) {\n case \"blur\":\n return MODE_BLUR\n case \"image\":\n return MODE_IMAGE\n case \"cutout\":\n return MODE_CUTOUT\n default:\n return MODE_NONE\n }\n}\n\n/**\n * Whether this recipe needs the person mask.\n *\n * Must match `Recipe.NeedsMask` on the Go side. This is the single biggest saving in the\n * module: a colour-only recipe skips MediaPipe entirely - the most expensive part of a frame,\n * and 9 MB of wasm the user then never downloads.\n *\n * The Go version is authoritative; this one exists so the JS side knows whether to load the\n * segmenter at all, BEFORE it can ask Go.\n */\nexport function needsMask(f: BgFilter, e: Effects): boolean {\n return (\n f.kind !== \"none\" ||\n e.beautify > 0 ||\n e.autoframe ||\n hasSkin(e) ||\n (e.grade > 0 && (e.gradeScope ?? \"frame\") !== \"frame\") ||\n (e.hair ?? 0) > 0\n )\n}\n\nfunction hasSkin(e: Effects): boolean {\n return (e.whiten ?? 0) > 0 || (e.skinLight ?? 0) > 0 || (e.clarity ?? 0) > 0\n}\n\n/**\n * Whether this recipe needs the SEGMENTER: a mask, and not one a colour key already gives.\n * Must match `Recipe.NeedsSegmentation` on the Go side. This, not {@link needsMask}, decides\n * whether MediaPipe is loaded - with `chromaKey` on, its 9 MB are never fetched.\n */\nexport function needsSegmentation(f: BgFilter, e: Effects): boolean {\n return needsMask(f, e) && !e.chromaKey\n}\n\n/** Whether this recipe is better served by the multiclass segmenter. */\nexport function needsSkinClasses(_f: BgFilter, e: Effects): boolean {\n return (e.grade > 0 && (e.gradeScope ?? \"frame\") !== \"frame\") || (e.hair ?? 0) > 0\n}\n\n/**\n * Whether this recipe needs face landmarks.\n *\n * Must match `Recipe.NeedsFace` on the Go side. Split from {@link needsMask} because the two\n * detectors are independent costs, and the landmark model is 15 times the size of the\n * segmentation one - making someone who only wants a blurred background download it is waste\n * that shows up on the first load.\n */\nexport function needsFace(e: Effects): boolean {\n return (\n e.teeth > 0 ||\n e.eyeBright > 0 ||\n e.underEye > 0 ||\n e.smileLines > 0 ||\n e.lips > 0 ||\n e.blush > 0 ||\n e.iris > 0 ||\n (e.eyeShadow ?? 0) > 0 ||\n (e.lipGloss ?? 0) > 0 ||\n (e.rosy ?? 0) > 0 ||\n (e.skinScope === \"face\" && (e.beautify > 0 || hasSkin(e))) ||\n // Whitening and skin light measure skin on the face; clarity is held to it.\n hasSkin(e) ||\n (e.grade > 0 && (e.gradeScope ?? \"frame\") !== \"frame\") ||\n e.slimFace > 0 ||\n e.enlargeEyes > 0 ||\n e.noseSlim > 0 ||\n e.chin !== 0 ||\n (e.jaw ?? 0) > 0 ||\n (e.cheekbone ?? 0) > 0 ||\n (e.forehead ?? 0) !== 0 ||\n (e.brow ?? 0) > 0 ||\n (e.contour ?? 0) > 0 ||\n (e.highlight ?? 0) > 0 ||\n ((e.makeup ?? 0) > 0 && !!e.makeupTexture)\n )\n}\n\n/** The recipe in the shape the Go core takes. Field names must match `setRecipe` in wasmjs/main.go. */\nexport interface CoreRecipe {\n background: number\n blurRadius: number\n beautify: number\n exposure: number\n contrast: number\n saturation: number\n warmth: number\n tint: number\n vibrance: number\n grain: number\n sharpen: number\n autoframe: boolean\n teeth: number\n eyeBright: number\n underEye: number\n smileLines: number\n lips: number\n lipColor: Rgb\n blush: number\n blushColor: Rgb\n iris: number\n irisColor: Rgb\n eyeShadow: number\n eyeShadowColor: Rgb\n lipGloss: number\n rosy: number\n rosyColor: Rgb\n whiten: number\n skinLight: number\n clarity: number\n hair: number\n hairColor: Rgb\n skinScope: number\n grade: number\n gradeScope: number\n chromaKey: boolean\n keyColor: Rgb\n keyTolerance: number\n autoLight: boolean\n mirror: boolean\n slimFace: number\n enlargeEyes: number\n noseSlim: number\n chin: number\n jaw: number\n cheekbone: number\n forehead: number\n brow: number\n browColor: Rgb\n contour: number\n highlight: number\n makeup: number\n makeupBlend: number\n whitenStyle: number\n}\n\nexport function coreRecipe(f: BgFilter, e: Effects): CoreRecipe {\n return {\n background: backgroundMode(f),\n blurRadius: f.kind === \"blur\" ? f.blurRadius : 0,\n beautify: e.beautify,\n exposure: e.exposure,\n contrast: e.contrast,\n saturation: e.saturation,\n warmth: e.warmth,\n tint: e.tint ?? 0,\n vibrance: e.vibrance ?? 0,\n grain: e.grain ?? 0,\n sharpen: e.sharpen ?? 0,\n autoframe: e.autoframe,\n teeth: e.teeth,\n eyeBright: e.eyeBright,\n underEye: e.underEye,\n smileLines: e.smileLines,\n lips: e.lips,\n lipColor: e.lipColor,\n blush: e.blush,\n blushColor: e.blushColor,\n iris: e.iris,\n irisColor: e.irisColor,\n eyeShadow: e.eyeShadow ?? 0,\n eyeShadowColor: e.eyeShadowColor ?? NO_EFFECTS.eyeShadowColor,\n lipGloss: e.lipGloss ?? 0,\n rosy: e.rosy ?? 0,\n rosyColor: e.rosyColor ?? NO_EFFECTS.rosyColor,\n whiten: e.whiten ?? 0,\n skinLight: e.skinLight ?? 0,\n clarity: e.clarity ?? 0,\n hair: e.hair ?? 0,\n hairColor: e.hairColor ?? NO_EFFECTS.hairColor,\n skinScope: SKIN_SCOPE[e.skinScope] ?? 0,\n grade: e.grade,\n gradeScope: GRADE_SCOPE[e.gradeScope] ?? 0,\n chromaKey: e.chromaKey,\n keyColor: e.keyColor,\n keyTolerance: e.keyTolerance,\n autoLight: e.autoLight,\n mirror: e.mirror,\n slimFace: e.slimFace,\n enlargeEyes: e.enlargeEyes,\n noseSlim: e.noseSlim,\n chin: e.chin,\n jaw: e.jaw ?? 0,\n cheekbone: e.cheekbone ?? 0,\n forehead: e.forehead ?? 0,\n brow: e.brow ?? 0,\n browColor: e.browColor ?? NO_EFFECTS.browColor,\n contour: e.contour ?? 0,\n highlight: e.highlight ?? 0,\n makeup: e.makeupTexture ? (e.makeup ?? 0) : 0,\n makeupBlend: MAKEUP_BLEND[e.makeupBlend] ?? 0,\n whitenStyle: e.whitenStyle === \"pink\" ? 1 : 0,\n }\n}\n"],"mappings":";AAkCO,IAAM,cAAoC,CAAC,OAAO,QAAQ,QAAQ,MAAM;AAExE,SAAS,UAAU,MAAqC;AAC3D,SAAO,KAAK,IAAI,GAAG,YAAY,QAAQ,QAAQ,KAAK,CAAC;AACzD;AA+IO,IAAM,aAAsB;AAAA,EAC/B,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,UAAU,CAAC,MAAM,MAAM,IAAI;AAAA,EAC3B,OAAO;AAAA,EACP,YAAY,CAAC,KAAK,KAAK,IAAI;A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a;AAAA,IAC1B,SAAS,EAAE,WAAW;AAAA,IACtB,MAAM,EAAE,QAAQ;AAAA,IAChB,WAAW,EAAE,aAAa,WAAW;AAAA,IACrC,WAAW,WAAW,EAAE,SAAS,KAAK;AAAA,IACtC,OAAO,EAAE;AAAA,IACT,YAAY,YAAY,EAAE,UAAU,KAAK;AAAA,IACzC,WAAW,EAAE;AAAA,IACb,UAAU,EAAE;AAAA,IACZ,cAAc,EAAE;AAAA,IAChB,WAAW,EAAE;AAAA,IACb,QAAQ,EAAE;AAAA,IACV,UAAU,EAAE;AAAA,IACZ,aAAa,EAAE;AAAA,IACf,UAAU,EAAE;AAAA,IACZ,MAAM,EAAE;AAAA,IACR,KAAK,EAAE,OAAO;AAAA,IACd,WAAW,EAAE,aAAa;AAAA,IAC1B,UAAU,EAAE,YAAY;AAAA,IACxB,MAAM,EAAE,QAAQ;AAAA,IAChB,WAAW,EAAE,aAAa,WAAW;AAAA,IACrC,SAAS,EAAE,WAAW;AAAA,IACtB,WAAW,EAAE,aAAa;AAAA,IAC1B,QAAQ,EAAE,gBAAiB,EAAE,UAAU,IAAK;AAAA,IAC5C,aAAa,aAAa,EAAE,WAAW,KAAK;AAAA,IAC5C,aAAa,EAAE,gBAAgB,SAAS,IAAI;AAAA,EAChD;AACJ;","names":["amount"]}
|
package/dist/detect-worker.js
CHANGED
|
@@ -4675,14 +4675,28 @@
|
|
|
4675
4675
|
return ec(zc, t2, e2);
|
|
4676
4676
|
}, zc.POSE_CONNECTIONS = Lc, r("module$exports$google3$third_party$mediapipe$tasks$web$vision$pose_landmarker$pose_landmarker.PoseLandmarker.POSE_CONNECTIONS", zc.POSE_CONNECTIONS);
|
|
4677
4677
|
|
|
4678
|
+
// src/mp.ts
|
|
4679
|
+
var MP_DIR = "/mediakit/mp";
|
|
4680
|
+
var MODEL_URL = {
|
|
4681
|
+
person: "/mediakit/selfie_segmenter.tflite",
|
|
4682
|
+
classes: "/mediakit/selfie_multiclass_256x256.tflite",
|
|
4683
|
+
face: "/mediakit/face_landmarker.task"
|
|
4684
|
+
};
|
|
4685
|
+
var fileset = null;
|
|
4686
|
+
function visionFileset() {
|
|
4687
|
+
fileset ??= uh.forVisionTasks(MP_DIR).catch((e2) => {
|
|
4688
|
+
fileset = null;
|
|
4689
|
+
throw e2;
|
|
4690
|
+
});
|
|
4691
|
+
return fileset;
|
|
4692
|
+
}
|
|
4693
|
+
|
|
4678
4694
|
// src/face.ts
|
|
4679
|
-
var WASM_DIR = "/mediakit/mp";
|
|
4680
|
-
var MODEL_URL = "/mediakit/face_landmarker.task";
|
|
4681
4695
|
var FACE_FLOATS = 478 * 3;
|
|
4682
4696
|
async function createFaceDetector(canvas, maxFaces, delegate = "GPU") {
|
|
4683
|
-
const
|
|
4684
|
-
const landmarker = await yc.createFromOptions(
|
|
4685
|
-
baseOptions: { modelAssetPath: MODEL_URL, delegate },
|
|
4697
|
+
const fileset2 = await visionFileset();
|
|
4698
|
+
const landmarker = await yc.createFromOptions(fileset2, {
|
|
4699
|
+
baseOptions: { modelAssetPath: MODEL_URL.face, delegate },
|
|
4686
4700
|
canvas,
|
|
4687
4701
|
runningMode: "VIDEO",
|
|
4688
4702
|
// As many as the core tracks: one landmark pass returns them all, so the cost of a second
|
|
@@ -4715,15 +4729,10 @@
|
|
|
4715
4729
|
}
|
|
4716
4730
|
|
|
4717
4731
|
// src/segmenter.ts
|
|
4718
|
-
var WASM_DIR2 = "/mediakit/mp";
|
|
4719
|
-
var MODEL_URL2 = {
|
|
4720
|
-
person: "/mediakit/selfie_segmenter.tflite",
|
|
4721
|
-
classes: "/mediakit/selfie_multiclass_256x256.tflite"
|
|
4722
|
-
};
|
|
4723
4732
|
async function createMaskReader(canvas, model, delegate) {
|
|
4724
|
-
const
|
|
4725
|
-
const segmenter = await $c.createFromOptions(
|
|
4726
|
-
baseOptions: { modelAssetPath:
|
|
4733
|
+
const fileset2 = await visionFileset();
|
|
4734
|
+
const segmenter = await $c.createFromOptions(fileset2, {
|
|
4735
|
+
baseOptions: { modelAssetPath: MODEL_URL[model], delegate },
|
|
4727
4736
|
canvas,
|
|
4728
4737
|
runningMode: "VIDEO",
|
|
4729
4738
|
outputCategoryMask: true,
|