DEV Community

FaceSwapAI
FaceSwapAI

Posted on

A beard is a texture problem before it is a shape problem

Most guides to face swaps talk about jawlines, eyes and lighting. Facial hair breaks more swaps than any of those, and it breaks them in a way the usual checks do not catch: not as a wrong shape, but as a wrong surface.

Here is what actually goes wrong when either face in the pair has a beard, stubble, or a moustache, and how to test for it.

1. Whisker pattern is identity, and it is the first thing lost

A 256-pixel face crop gives you roughly three to five pixels per hair. That is below the resolution needed to keep individual strands, so the model reconstructs a plausible average instead: a smooth grey-brown gradient across the chin. The jawline is right, the face is right, and the person still looks wrong, because no two people have the same stubble density, growth direction, or patchiness.

At normal viewing size this reads as "slightly airbrushed". At 200% it reads as "not a beard".

2. The beard edge is a hard boundary, and blending is soft

Where a beard meets the cheek there is a transition band of individual hairs, maybe 20–40 pixels wide on a phone photo. A feathered mask over that band produces a haze; a hard cut produces a line. Neither reproduces hair over skin. This is the same class of failure as a hairline, but it happens on the cheek, in the middle of the frame, where nobody thinks to look.

3. Beard shadow survives the swap

If the source photo has a five o'clock shadow, some of that darkening is baked into the source's texture and lighting. Swap onto a clean-shaven target and you often keep a residue of it under the nose and along the jaw. The reverse is worse: a full beard swapped onto a smooth chin leaves a chin that is too smooth and too light, with a hard edge at the moustache line.

4. A moustache moves the mouth

Upper-lip hair occludes the lip line. When the mouth opens on a vowel, the hairs move independently of the lip. A still frame hides this completely; a video exposes it on the first "f" or "v". It is the same occlusion-ordering problem as hair falling across a face, compressed into two square centimetres.

5. Hair and skin do not take light the same way

Strands have specular highlights that run along their length; skin has a broad diffuse falloff. When a model relights the face to match the new scene but not the beard, the chin keeps the old light and reads as pasted. Beard colour is also usually warmer than scalp hair and skin, so matching skin tone does not match the beard.

Four checks before you publish

  1. 200% on the chin edge. Individual hairs, or a uniform gradient? A gradient means the beard was averaged away.
  2. Tilt the head 15 degrees. Beard shadow should move with the face. If it stays put, it came from the source.
  3. Say "five, very fine, vivid" on video. Watch the upper lip for hair that does not follow the lip.
  4. Compare beard colour to the temple hair under the same light. Two different warmths means two different photos.

The cheap workaround

Match the facial hair. Both clean-shaven, or both stubble, or both full beard. Failing that, crop to the shoulders and keep the beard region as far from the swap mask edge as you can. A swap that ends above the jaw hides most of this; a swap that runs to the collar does not.

I build FaceSwapAI, a browser face swap for photos, video and GIFs — up to ten faces in a group shot, up to ten minutes of video, HD and no watermark. The resolution budget and the paste-back step are where beards are won or lost, so this is the check I run on every output before it ships.

Top comments (0)