Dev.to WebDev 🛠 Dev 👁 2 📖 4 min read

An empty matting mask is a valid answer. A confident wrong one is not

When a video matting model looks at a frame with nobody in it, there are two outcomes worth separating. It can return nothing, or something confident and wrong. The first is easy to design around. The second passes every

When a video matting model looks at a frame with nobody in it, there are two outcomes worth separating. It can return nothing, or something confident and wrong. The first is easy to design around. The second passes every check that asks "did we get a mask?"

This is an outside view: what the output shows, not how the model is built. The sample was a self-made clip, one run, on one Apple-silicon Mac in a desktop browser, using the ImgIng video matting beta at https://imging.ai/ in its compatibility and quality modes.

The clip

The test clip is 960×540, 30 fps, 180 frames, no audio track. Frames 0 to 96 are an empty room. From frame 97 a person slides in from the right edge and is fully in frame around frame 104. The clip has three background versions: a plain wall, a wall with a framed portrait poster, and a clothes rack with a dark coat next to a colorful bookshelf.

The person is a public-domain clip from Wikimedia Commons (VOA Learning English), cropped, keyed, and composited onto self-made backgrounds. The poster shows a photo of the same person. Limits: one person, low resolution, a static background, a rigid slide as the entry. Walk-ins, moving backgrounds and long footage were not tested.

What the empty frames produced

"Mask ratio" below means the share of pixels with alpha above 128 in a frame.

Background Frames 0-96 What got masked
Plain wall 0%, alpha max 2 nothing
Poster on wall 2.46-2.66%, mean 2.48% the person inside the poster
Coat on rack 5.78% the coat
Colorful bookshelf 0% nothing

No noise-like masks appeared in this run. The plain wall left a faint floor of about 119 pixels per frame at alpha 1 or 2. The poster and the coat were different. Each became one solid block with clean edges, roughly 104×205 pixels for the poster, that barely changed over 90 frames.

The blocks stay after the person arrives. At frames 150 to 179 the poster block still takes 2.46% of the frame and the coat block 5.65%, so a transparent export keeps them to the end.

Why a threshold only solves half of it

The plain-wall case is detectable. With a floor of 2, a threshold at alpha above 16 throws the noise away, and a frame with nothing above it can be called empty. That cutoff is an inference from this one clip.

The poster case is not. Those pixels sit at alpha 255. Any threshold that keeps the real person keeps the poster too. A pipeline that asks "is the mask non-empty?" gets yes.

Memory does not rescue it. The same MobileNetV3 weights were run two ways on the same Mac: clearing the recurrent state every frame, and carrying it across frames. Over the empty segment the poster clip came out at 2.68% versus 2.55%, the coat at 5.77% versus 5.73%, and the plain wall at 0% in both. The mistake is made per frame; carrying state neither removes it nor grows it.

Entry is not where the risk is

A temporal model might be expected to lag when someone enters. It did not here. At frame 97 the arm covers 0.31% of the frame in the ground truth, and the compatibility mode already had a mask there with IoU 0.84 on the poster clip. From frame 100 the IoU was 0.97 or higher. The per-frame run dipped once, to 0.62 at frame 99 versus 0.69 with carried state. The weak spot here is the opening, not the entry.

What the preview says

On the plain wall at one second it says "No subject recognized in the current frame", with a note that this will not count as a successful mask. On the poster wall at the same second it says the subject covers about 2.6% of the frame and that you can process the full video once the edges and background look right.

The second message does not say the subject is the poster. Preview a timestamp where the person is clearly in frame, then check where the mask lands.

A 4-second plain-wall clip with nobody in it ran to the end without an error. All 120 exported frames were transparent, and the page said the video finished but no subject was recognized, and waited for confirmation instead of saving. That is a sensible shape for an empty answer, but it covers only the empty case.

What to build around this

  • Treat all-zero or under-threshold output as its own state, and do not count "a mask exists" as success.
  • Flag any blob that stays nearly identical for the whole clip, since a person does not hold a pixel-perfect outline for 180 frames. This is a proposed rule, not tested.
  • Check overlap with the region where a subject is expected, such as the entry side.
  • Let a human preview at a frame that contains the subject before the full run is saved.

The beta targets desktop Chrome or Edge. Long videos, 4K, older devices, heavy occlusion and fast motion may be slower or less clean, and none were in this clip.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.