@tradalab/mediakit 2.6.0 → 2.7.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 CHANGED
@@ -6,6 +6,213 @@ 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.7.0
10
+
11
+ Upgrade the package and serve its `mediakit.wasm`; the one new recipe field, `occluders`, is off by
12
+ default and, when on, needs two more files served (`face_cover.onnx` and the onnxruntime-web wasm,
13
+ both in the table under "Serve the assets first").
14
+
15
+ **Fix: whitening and skin light stopped in a straight line across the forehead.** With the face
16
+ mesh up and `skinScope: "face"`, skin outside the 478-point mesh was the neck alone, so every
17
+ skin effect ended where MediaPipe's mesh ends, part-way up the forehead - plain from
18
+ `whiten` about 0.5 or `skinLight` about 0.25. Outside the mesh the face scope now also takes the ring round
19
+ the head, held to this person's skin colour (as without the mesh), fading in as the mesh fades
20
+ out: the forehead lightens up to the hairline, hair and hats stay as they were.
21
+
22
+ **Fix: above the face mesh, brown or dark hair in dim light passed as skin.** The face scope there
23
+ kept any pixel of this person's skin chroma, so whitening ran past the hairline up to an oval
24
+ round the head. It now also drops what is under 0.3-0.5 or over 1.35-1.7 of the measured forehead luma
25
+ (and, with the multiclass mask, what it calls hair): the effects stop at the hairline, strand by
26
+ strand. Hair close to the skin in both colour and brightness still passes without the multiclass
27
+ mask.
28
+
29
+ **Fix: smoothing at the hairline.** Above the mesh, smoothing was weighed per sharp pixel, so it
30
+ smoothed the skin between hair strands and left the strands as dark dashes along the hairline;
31
+ and with smoothing alone there was no measured forehead luma, so nothing stopped it at the hair.
32
+ It is now weighed on the smoothed frame and fades where a darker neighbour (the hair) is within
33
+ about the smoothing radius, so the whole forehead is smoothed and the strands are not touched;
34
+ `beautify` with `skinScope: "face"` now measures the skin reference too.
35
+
36
+ **Fix: a whitened face over an untouched neck read as a mask.** Under the jaw the hair gate above
37
+ dropped a neck in shadow, and the neck region was a narrow band under the chin that missed the
38
+ side of the neck on a turned head. The neck now drops only what is under 0.12-0.25 of the
39
+ forehead luma (a beard), reaches the sides of the jaw, and just outside the mesh inside the face
40
+ outline the skin takes the mesh's wider colour band. On the e2e clips the face skin covered at full
41
+ whitening rose from 73.5 % to 75.9 % and from 70.5 % to 72 %, with the share landing on skin
42
+ unchanged.
43
+
44
+ **Fix: a tone kept off products trailed the person by up to 600 ms.** `gradeScope: "person"` and
45
+ `"skin"` (and `hair`) read the multiclass segmenter, about 85 ms a frame in its worker, so its mask
46
+ came about seven times a second and the tone's edge, and the face scope above the mesh, lagged a
47
+ moving body. The person segmenter (about 18 ms) now runs beside it in its own worker: its fresh
48
+ mask is the person's outline every frame, and the latest multiclass labels (skin, hair, a held
49
+ product) fill it. In a test run with a tone and products kept: mask age from 100-630 ms to 0-33 ms,
50
+ 24 to 28 fps. Such a recipe now also fetches the 244 kB person model.
51
+
52
+ **Fix: whitening stopped part way down the neck.** The neck region ended a third of a face below
53
+ the chin, so a long neck showed a whitened upper part over an untouched lower part. It now fades
54
+ out between 0.3 and 1 face-height below the chin. Neck skin covered at full whitening on the e2e
55
+ clips: 10 % to 71 %, 24 % to 90 % and 19 % to 59 %.
56
+
57
+ **Fix: with `syncFaces`, makeup and the skin effects trailed a moving face and spilled past it.**
58
+ The face landmarker runs on the CPU in its worker (on the GPU it queues behind the drawing and
59
+ takes 60-165 ms), about 27-40 ms a call, longer than a frame: only 37-49 % of frames had landmarks
60
+ of their own, and the rest were drawn with landmarks 33-80 ms old, carried along the face's velocity,
61
+ which overshoots when the head turns back. `syncFaces` now runs a second face worker, so every
62
+ frame is sent for detection, and draws each held frame only once its own landmarks are in (or,
63
+ for a frame no worker was free for, landmarks interpolated between the frames on either side);
64
+ the person and multiclass masks are kept by timestamp the same way, so each frame takes the mask
65
+ of its own frame or the nearest to it. At most 3 frames are held, and one frame a second is
66
+ dropped while more are queued than needed. Lipstick on a face moving 20 px a frame, with
67
+ `maxFaces: 1`: trail p90 25 -> 4-6 px (max 56 -> 15-25);
68
+ on the 3x-speed e2e clips lipstick spilling past the lips p90 0.52 -> 0.03 and 0.16 -> 0.07.
69
+ The cost is a second face worker (one more MediaPipe runtime and CPU core while the face is
70
+ tracked) and latency: the frame waits for its landmarks, 67-100 ms from camera to output in the
71
+ e2e runs; an app streaming the result should delay its audio by `stats.heldFrames` frames to keep
72
+ lip sync.
73
+
74
+ **Fix: makeup still trailed a face moving slowly, by one to four frames, with or without `syncFaces`.**
75
+ Two filters sat between a frame's landmarks and the frame drawn. The face tracker smoothed every
76
+ landmark with a 0.12 s time constant, a quarter of the way a frame, and let go only for a jump over
77
+ about 9 px a frame, so talking, nodding and turning the head were drawn three to four frames late
78
+ while fast test motion was not. And the landmarker ran in MediaPipe's video mode, which smooths a
79
+ single face's landmarks over time: another 0.3-0.7 of a frame. The landmarker now runs per frame in
80
+ image mode (same cost, about 25 ms) and the tracker's time constant is 0.03 s. Measured on a fake
81
+ camera playing the e2e clips, lipstick against reference landmarks of the very camera frame: frames
82
+ drawn with an earlier frame's lips 42-71 % -> 14-27 %, mean lag 0.7-1.9 -> 0-0.4 frames, lip
83
+ overlap p50 0.59 -> 0.67 on the 1x clip. Image mode finds the face anew in every frame and, on the
84
+ whole picture, loses it more often than video mode did; the next entry is what keeps it.
85
+
86
+ **Fix: the face dropped out for a few frames when it turned, was small in the frame or was half
87
+ covered.** Landmarks were found on the whole frame scaled to 512 px, where MediaPipe's face
88
+ detector sees a face a tenth of the frame wide at about 15 px, so a turned head or a cup at the
89
+ mouth sat at its threshold. On a fake camera playing the e2e clips 128 of 699 detections found no
90
+ face: most frames of a sip, and 16 with the lips in plain view, where makeup blinked off or stayed
91
+ behind where the face had been. Each frame is now cut to a square round the face of the frames
92
+ before it (2.6 times its size, drawn at 384 px), so the detector sees the face large; when that
93
+ finds nothing the worker tries once more on a tighter cut (2 times), and after a real miss the
94
+ next frame goes back to the whole picture. The detector keeps no state, so nothing lags. On the
95
+ same clips: no detection without a face, 10 of about 640 found on the second try. The same
96
+ detection run in Python on a synthetic clip, a frontal portrait under known motion: lip position
97
+ error p50 2.8 -> 1.3 px and frame-to-frame jitter 2.7 -> 0.9 px at 1280 px, and the face is kept
98
+ while a hand covers the mouth (44 frames lost -> 0). On the strongly turned face of the cafe clip
99
+ the lip outline sits where full-frame detection puts it (overlap with full-resolution reference
100
+ landmarks p50 0.83 and 0.82); the tight cut alone lost nothing either but moved a turned face's
101
+ lips towards the cheek (0.72), which is why it is only the second try. The crop takes the box
102
+ round every face found; when that box does not fit a square of the frame, detection runs on the
103
+ whole frame as before. While `maxFaces` has free slots, one detection a second runs on the whole
104
+ frame to find a newcomer. A face lost by the crop is looked for twice more in a crop two and three
105
+ times as wide before the crop is dropped. With no face at all, every other detection runs on one
106
+ square of a grid of half the frame's height instead of the whole frame, starting where the face
107
+ was last: a face 70 px wide, which the whole frame at 512 px never finds, is found within about a
108
+ second and then followed (on the fake-camera clip, lipstick missing in 233 -> 1 of 233 frames).
109
+ A detection that saw only part of the frame and found fewer faces than are followed changes
110
+ nothing. Detection in the page thread, without the detect worker, keeps MediaPipe's video mode
111
+ and the whole frame. Of two faces found overlapping by more than 30 %, the one less like the face
112
+ followed is dropped before it is drawn or followed: a hand over the mouth can come back from the
113
+ landmarker as a second face. A face more than the crop follows widens it only once three crop
114
+ detections in a row have it, while a whole-frame detection adds it at once, so a person walking in
115
+ is followed from the next second. With `maxFaces: 3`, lip jitter p90 on the hand clip 11.6 -> 3.7-5.5
116
+ px over three runs (3.2 with `maxFaces: 1`) and on the two-face clip 19.7 -> 4.4 px; a second person
117
+ walking in gets lipstick in every frame they are in.
118
+
119
+ **Fix: with `syncFaces`, a held frame was drawn with an older mask than it had to be.** It took the
120
+ last mask before it even when the mask of a later frame was already in; it now takes the mask
121
+ nearest in time. The multiclass mask's held-object channel is also no longer blended 45 % with the
122
+ previous segmentation, which kept an object's outline for a whole segmentation after it had moved.
123
+
124
+ **Fix: switching the source killed the detector worker.** `replaceSource` with a track whose clock
125
+ starts lower than the old one (another camera, a canvas or a video) handed MediaPipe a timestamp
126
+ that went backwards, which its video mode rejects ("Packet timestamp mismatch"): the worker
127
+ failed and the pipeline moved to the main thread. Each detector now shifts a step back forward,
128
+ keeping the spacing between frames.
129
+
130
+ **New: `occluders` keeps hands, hair and held objects in front of the face out of the face
131
+ effects.** The face mesh guesses the face behind whatever covers it, so a hand or a cup over the
132
+ mouth was smoothed and whitened and took the lipstick, and a blonde fringe passed every luma and
133
+ colour gate. Lip colour cannot tell bare lips from fingers (on four of nine test faces the lips sit
134
+ within 0.02 Cr of the cheek), and the multiclass segmenter, which can, takes 60-150 ms a mask
135
+ beside the drawing on an integrated GPU: two masks a second, late when a hand arrives and late when
136
+ it leaves. `occluders: true` instead runs a small network of this package's own in the face worker
137
+ (`face_cover.onnx`, 150 k parameters, 0.6 MB, onnxruntime-web on the CPU, about 2 ms) on each
138
+ frame's landmarks: a 96 px crop round the face in, a 96 x 96 map of where the face shows out.
139
+ Makeup, teeth and eye colour and the mesh skin (smoothing, whitening) fade where the map says
140
+ hidden, hold a hidden cell one frame longer, and count a face lost for two frames as hidden whole.
141
+ With `syncFaces` the map is of the very frame drawn.
142
+
143
+ The network was distilled from the multiclass segmenter on 14 401 LFW and COCO val faces with
144
+ hands, cut-out objects and drawn cups pasted over them. Lab status: those are research sets and
145
+ the licence of the weights is not cleared. Measured on the fake-camera run of the e2e clips with
146
+ skin effects and makeup, frames labelled by eye: lips covered by a cup, a glass or a hand, 159
147
+ frames - lipstick on the cover in none; lips in view, 416 frames - no lipstick in 3 and under half
148
+ of it in 11, all of them a cup rising just under the lips or the frame or two after it leaves. The
149
+ map errs towards hidden: lipstick goes a few frames before a cup reaches the lips, and a clear
150
+ glass counts as a cover. On the synthetic clip a hand passing over the mouth takes lipstick in at
151
+ most 1 of 36 covered frames, the one it arrives in. Such a recipe draws 29 fps of 30 on an
152
+ integrated GPU, where the multiclass mask held it to 23-26. The map is made in the detect worker
153
+ only: without `detect-worker.js`, `face_cover.onnx` or the onnxruntime-web wasm served, `occluders`
154
+ does nothing, and for the last two the console says so. Outside the face outline (its 36 landmarks)
155
+ the map counts as visible, because there it cannot tell a hand from the background. Inside it, a
156
+ hidden patch that touches nowhere on the outline counts as visible too: a hand or a cup comes in
157
+ from outside the face, while what the model wrongly hides on its own - closed dark lips in a soft
158
+ picture, a brow - sits in the middle. On a dark face blown up from a small picture, lips in view
159
+ with no lipstick 79 -> 3 of 232 frames and lip jitter p90 20 -> 6 px; on the hand, cup and brush
160
+ clips nothing more lands on the cover. The far end of a brow by the temple can still be dimmed, by
161
+ about a third on a man in a cap. Something held wholly inside the outline, a pen or a small microphone in
162
+ front of the mouth, counts as face by the same rule and takes the effects. A recipe with
163
+ only skin effects or only reshaping now gets the map too (it was read only with makeup), and the
164
+ reshaping (`slimFace`, `enlargeEyes`, nose, chin, jaw, cheekbone, forehead) no longer moves what
165
+ covers the face inside the outline: on the hand and brush clips the share of the slimming that
166
+ landed on the hand 0.58 -> 0.31 and 1.28 -> 0.92 with the slimming itself unchanged; what is left
167
+ is the part of a hand outside the jaw line. The mesh skin's hull channel is no longer cut by the
168
+ map, so a covered pixel stays out of the generic skin path, and with the multiclass mask bound the
169
+ makeup takes both cuts. A failure of the cover model no longer stops face detection: the worker
170
+ warns once and carries on without it. The map adds about 8 ms to each landmark
171
+ call. With `syncFaces` two workers share the frames and nothing changes; without it the one face
172
+ worker can fall past a frame a call and then lands on every other frame, so makeup trails a moving
173
+ face further (on the synthetic clip at 15-23 px a frame the lipstick sits 21 px off the lips, 13 px
174
+ without `occluders`): use `syncFaces` with makeup.
175
+
176
+ With the multiclass mask on for another reason, its fourth channel now carries body skin as well as
177
+ held objects, and a person-scoped grade drops only the part of it that is not skin-coloured.
178
+
179
+ **Fix: with the multiclass mask, a hand left a hand-shaped hole in the skin effects after it moved
180
+ away.** The mask arrives 67-133 ms behind the frame, so for 2-4 frames it still cut the hand out
181
+ where the face now shows. Each frame sent to the detectors now keeps a 64x36 luma thumbnail; where
182
+ the picture changed between the frame the classes came from and the newest person mask, a hand or
183
+ object label counts as stale and the skin effects take the pixel as skin again.
184
+
185
+ **Fix: a line down the cheek on a turned head.** The face mesh was drawn without depth, so the far
186
+ side's soft edge folded over the near cheek and cut a line from the eye to the jaw where smoothing
187
+ and whitening stopped; the makeup's face map folded the same way. Both mesh passes now drop the
188
+ triangles facing away, and the skin map keeps the larger value where two faces overlap.
189
+
190
+ **Fix: lipstick hardly showed on dark lips.** The shade was scaled by the square root of the lip's
191
+ own brightness, so on dark lips a wine shade came out nearly as dark as the bare lip. Dark lips
192
+ now keep most of the shade's brightness; light lips are unchanged.
193
+
194
+ **Fix: a pale rim along the face outline.** The mesh reaches a little past the cheek and its gate
195
+ reads the blurred frame, so the background just outside the face was whitened. The mesh's skin now
196
+ stops at the person mask.
197
+
198
+ **Fix: a step at the jaw.** Under the jaw the neck was held to two narrow skin-colour tests, so a
199
+ shaded neck took a third to two thirds of the face's whitening. The neck now passes the face's own
200
+ gate where the class mask says skin, or, without it, where the colour is near this person's skin.
201
+ Neck against face whitening on the e2e clips: 0.34 to 0.73, 0.60 to 0.97, 0.77 to 0.90; the share
202
+ landing on clothes rose by 0.1-1.6 points.
203
+
204
+ - `web/example/studio-live.html` caps each slider at a level that still looks natural (smooth
205
+ 0.8, whiten 0.5, rosy 0.45, brightness 0.5, clarity 0.7, slim face 0.7, sharpen 0.6), tones at
206
+ 0.8, makeup at about two thirds of 2.6.0 with lip gloss following the amount, and Sharpen moved
207
+ into the level sliders.
208
+ - `web/example/studio-live.html` plays sample videos besides the camera: four Wikimedia Commons
209
+ clips that `make example-assets` fetches into `web/mediakit/videos/` (makeup brushes over the
210
+ face, two sign-language clips with hands in front of the face, one of them portrait, and a
211
+ three-quarter talking head), plus the e2e clips when `web/e2e/media/` has them. "Side by side"
212
+ shows the original next to the filtered picture, frame-matched by timestamp, and `?source=` and
213
+ `?split=1` open the page that way. The clips are fetched whole and played from memory, because
214
+ `python3 -m http.server` cannot serve the byte ranges a seek needs.
215
+
9
216
  ### Upgrading to 2.6.0
10
217
 
11
218
  Existing calls are unchanged. Serve the new `mediakit.wasm`, `worker.js` and `detect-worker.js`
@@ -221,12 +428,14 @@ ever fetched from a third party while a frame is being processed.
221
428
  | `/mediakit/mediakit.wasm` | this package's `dist/` | always |
222
429
  | `/mediakit/wasm_exec.js` | this package's `dist/` | always, and it must stay with that `.wasm` |
223
430
  | `/mediakit/worker.js` | this package's `dist/` | to get the worker transport |
224
- | `/mediakit/detect-worker.js` | this package's `dist/` | face landmarks and the multiclass segmenter off the frame path; without it they run in-thread and can stall frames |
431
+ | `/mediakit/detect-worker.js` | this package's `dist/` | face landmarks and the multiclass segmenter off the frame path; without it they run in-thread and can stall frames, and `occluders` has no effect |
225
432
  | `/mediakit/mp/` | the files inside `@mediapipe/tasks-vision/wasm/`, flat, from the same 1.1.x release | any recipe where `needsMask()` or `needsFace()` is true |
226
433
  | `/mediakit/selfie_segmenter.tflite` | MediaPipe model | `needsMask()` is true |
227
434
  | `/mediakit/face_landmarker.task` | MediaPipe model | `needsFace()` is true |
228
435
  | `/mediakit/whiten_pink.png` | this package's `dist/` | `whitenStyle: "pink"` |
229
436
  | `/mediakit/selfie_multiclass_256x256.tflite` | MediaPipe model, 16 MB | `needsSkinClasses()` is true; without it those recipes fall back to skin measured on the face |
437
+ | `/mediakit/face_cover.onnx` | this package's `dist/`, 0.6 MB | `occluders` with a face effect; without it makeup is drawn over a hand or a cup |
438
+ | `/mediakit/ort/ort-wasm-simd-threaded.wasm` and `.mjs` | `onnxruntime-web/dist/` of exactly 1.31.1 (an optional peer dependency: the worker bundles its JS, so another release's wasm does not fit), 15 MB | the same recipes: the runtime of `face_cover.onnx` |
230
439
 
231
440
  `worker.js` is **fetched**, not imported, so no bundler will pick it up for you. The models are
232
441
  not shipped in the package; fetch them once and serve them yourself.
@@ -287,6 +496,7 @@ than building the object by hand, so a new field cannot arrive as `undefined`.
287
496
  | `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. |
288
497
  | `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
498
  | `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. |
499
+ | `occluders` | boolean | Keeps hands, hair and held objects in front of the face out of smoothing, whitening and face colour. Runs the face cover model in the face worker while any face effect is on: `face_cover.onnx` (0.6 MB) and the onnxruntime-web wasm must be served. |
290
500
  | `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. |
291
501
  | `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. |
292
502
  | `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. |
@@ -440,7 +650,7 @@ not a setting.
440
650
  const pipeline = new VideoPipeline(filter, effects, {
441
651
  alpha: true, // keep alpha for subscribeFrames + cutout
442
652
  maxFaces: 1, // one person per camera: ~a third less landmark cost
443
- syncFaces: true, // +1 frame of latency, makeup sits on the moving face
653
+ syncFaces: true, // each frame waits for its own landmarks, makeup sits on the moving face
444
654
  debug: "off", // or "skin" | "mask" | "face" - see below
445
655
  onStall: ({ transport, sinceMs }) => report(transport, sinceMs),
446
656
  onTrackReplaced: (track) => sender.replaceTrack(track),
@@ -42,6 +42,7 @@ var NO_EFFECTS = {
42
42
  keyColor: [0, 0, 0],
43
43
  keyTolerance: 0,
44
44
  autoLight: false,
45
+ occluders: false,
45
46
  mirror: false,
46
47
  slimFace: 0,
47
48
  enlargeEyes: 0,
@@ -104,6 +105,7 @@ var EFFECTS_SCHEMA = {
104
105
  keyColor: color,
105
106
  keyTolerance: signed,
106
107
  autoLight: bool,
108
+ occluders: bool,
107
109
  mirror: bool,
108
110
  slimFace: amount,
109
111
  enlargeEyes: amount,
@@ -249,6 +251,7 @@ function coreRecipe(f, e) {
249
251
  keyColor: e.keyColor,
250
252
  keyTolerance: e.keyTolerance,
251
253
  autoLight: e.autoLight,
254
+ occluders: e.occluders ?? false,
252
255
  mirror: e.mirror,
253
256
  slimFace: e.slimFace,
254
257
  enlargeEyes: e.enlargeEyes,
@@ -290,4 +293,4 @@ export {
290
293
  needsFace,
291
294
  coreRecipe
292
295
  };
293
- //# sourceMappingURL=chunk-RWUGOTNJ.js.map
296
+ //# sourceMappingURL=chunk-4YCBTZRB.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 occluders: 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 occluders: 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 occluders: 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 occluders: 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 occluders: e.occluders ?? false,\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,S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