AI Face Swap (Fun Filter)
Drop a source face, drop a target scene, hit swap. AI detects 68 facial landmarks in both and warps the source face onto the target's head with a feathered mask and skin-tone match. Runs entirely in your browser.
How it works · limitations
Both images get passed through face-api.js — a TensorFlow.js port of the dlib face landmark model. Each face yields 68 (x, y) landmarks: jaw line, eyebrows, nose, mouth, eye contours.
- Compute a 6-DOF affine transform that aligns the source's eye-centre, eye-spacing, and chin to the target's same triplet.
- Warp the source face onto a working canvas of the target's size using that affine.
- Build a soft mask from the target's 17-point jaw outline, expanded slightly. Feather it with a blur whose radius is the "mask softness" slider.
- Sample average skin RGB from both faces and shift the warped source's mean to match the target's (per-channel, blended by the "skin-tone match" slider).
- Composite the warped + tinted source onto the target using the soft mask. Done.
It's a single global affine, not per-triangle warping, so it cannot match expression / head-tilt mismatches well. Best results: both faces looking roughly forward, similar size, similar lighting. Bad results: profile shots, sunglasses, hair partly covering the face, dramatic angle differences. All processing local; ~6 MB of models cached after first run.