Zumti Avatar Blog

Why we are replacing a giant segmentation model with a tiny one

Finding ears in side photos was the slowest part of a face build. The fix is not a faster big model, but a small model of our own.

A 3D head built from photos, with both ears outlined in pink and a grid of 7 by 7 blue points over each ear
Ear finding on a real build. The model is shown a grid of 7 × 7 points around each ear and returns the exact ear shape.

To build your head in 3D, we need to know where your ears are in the two side photos, and what shape they have. For a long time we did that with a large, general-purpose segmentation model: SAM 2.1, Meta's open "segment anything" model (the "small" version, Apache-2.0 licensed). You point at something in a photo, and it cuts out that object, pixel by pixel.

It works well. It is also, by far, the slowest thing in a face build.

The numbers

184 MB
model weights
~9 s
per photo, on CPU
~42 s
of a ~103 s face build
2–4×
the same photo was re-read

The biggest steps of one production face build (102.9 s)

Ear finding (segmentation model)Everything else
Ear candidatesbig segmentation model, two runs side by side
42.5 s
Ear searchbig segmentation model
21.7 s
Skin tone, hair, beard, blending
12.7 s
Painting texture from photos
12.1 s
Jaw surface directions
10.8 s
First quality gates
10.1 s
Filling unseen texture
8.6 s
One production run in the cloud. The two ear-candidate runs happen side by side, so their combined 42.5 s is longer than the real wait they cause. Even so, ear finding is the largest item.

Why it was so slow

A model like SAM has two parts. A heavy image encoder studies the whole photo once. A light mask decoder then answers questions about it: "what is the object at this point?" The rule for speed is simple: encode once, ask many times.

Inside each call we already did that. A 7 × 7 grid of 49 points is asked against one encoding. The problem was between calls. Every request started a fresh process, which loaded the deep-learning library, rebuilt the 184 MB model and encoded the photo again. Depending on the photos, the same side photo could be encoded two to four times in one build.

What we tried first

IdeaResult
A smaller, faster SAM variant (MobileSAM)20% faster, but lost the right ear on test photos. Rejected.
Lower precision (bf16) to speed up the mathBroke the masks: worst overlap with the correct ear fell to 0.14. Rejected.
Cropping around the ear firstAlready in place. It helps, but the model is still the model.
Keep one process alive, cache encodingsPossible, but it only removes the repeats, not the core cost.

The decision: a small model that only knows ears

A model that can segment anything in any photo is a big, general tool. We only ask it one question, in one kind of photo: where is the ear, and what shape is it? So we are training our own model for exactly that job. We call it EarNet.

SAM 2.1 smallEarNet
JobSegment anythingEars in side photos only
Size184 MB of weights1.56 million parameters (about 6 MB)
Speed on CPU~9 s per photo~16 ms per ear crop
TrainingGeneral, by MetaOur own ear dataset

Roughly 30 times smaller, and each ear takes milliseconds instead of seconds. The question is not speed; it is whether it finds every ear SAM finds. EarNet only replaces SAM once it passes the same ear checks on the same photos.

Where this leaves us

  • Ears: EarNet is in training and is being tested against SAM on our ear checks. It switches in only when it matches them.
  • Beards and the hair tools still use SAM for now. A beard model of our own is a separate project.
  • Beyond ears: removing SAM is the biggest single win, but not enough on its own. Jaw surfaces, texture painting, the first quality gates and texture filling each take 9 to 12 seconds. They are pure number crunching, and they are next in line to move to Rust.

The lesson we keep relearning: measure first. The slowest step is not always where you expect it, and the fix is often not a faster version of the same tool, but a smaller tool that does only the one thing you need.

Try it yourself. Make your own 3D avatar from three photos at avatar.zumti.com, or talk to us about avatars in your app or game.