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.
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
The biggest steps of one production face build (102.9 s)
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
| Idea | Result |
|---|---|
| A smaller, faster SAM variant (MobileSAM) | 20% faster, but lost the right ear on test photos. Rejected. |
| Lower precision (bf16) to speed up the math | Broke the masks: worst overlap with the correct ear fell to 0.14. Rejected. |
| Cropping around the ear first | Already in place. It helps, but the model is still the model. |
| Keep one process alive, cache encodings | Possible, 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 small | EarNet | |
|---|---|---|
| Job | Segment anything | Ears in side photos only |
| Size | 184 MB of weights | 1.56 million parameters (about 6 MB) |
| Speed on CPU | ~9 s per photo | ~16 ms per ear crop |
| Training | General, by Meta | Our 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.
