Masking as the Rate Knob: A Single Codec That Keeps Facial Expression Timing

Video calls, remote health monitoring and affect-aware assistants all send faces over networks whose bandwidth keeps changing, and the receiving side often needs more than a pretty picture: it needs to tell when a smile starts, how long a brow stays raised, and whether a flicker of disgust lasted a quarter of a second. Standard video codecs spend bits on whatever looks worst to the eye, not on the small muscle movements that carry expression. Learned codecs trained for a recognition task can do better, but today they work on still images and need one trained network per bitrate. We propose a different way to vary the rate. We borrow from masked image modeling, a self-supervised method in which a network learns to fill in large hidden portions of an image from the visible remainder. The sender transmits only the video patches the receiver could not guess. The rate is then simply how many patches are sent.

The core bet is that, for faces, the patches a masked video model cannot predict are the ones where expression happens. These are the eyes, brows and mouth during the onset (the start of a movement) and the apex (its peak), not the static cheek or background. If that holds, a single network ordered by "what the receiver can't guess" gives an embedded bitstream that can be cut at any length. Cutting it early should drop the predictable parts first and keep expression timing intact down to very low rates. We also argue that the choice of training signal for this ordering is where a known problem in vision-language models appears inside compression. That problem is the global-local alignment gap: models trained on one label per image or clip learn what the image shows but not where. We expect a clip-level emotion loss to preserve which emotion was shown while losing when and where the muscles moved.

Core Claim

A masked spatiotemporal autoencoder has three parts: a learned scorer that ranks space-time patches by how badly the receiver would reconstruct them if they were withheld, a quantizer, and an entropy model over the transmitted patches. Trained with a randomly varying keep-ratio, this one model works as a variable-rate expression codec. It can be truncated to any rate. At matched bitrate, it preserves local, time-resolved expression information better than two alternatives: task-aware codecs driven by a global emotion loss, and conventional codecs. Local information here means action-unit activations (the anatomically defined facial muscle movements of FACS, the Facial Action Coding System) and onset/apex timing. The new ingredient is that rate is set by the number and identity of transmitted tokens, not by one global quantization step. The ordering is learned from reconstruction surprise and not from a global class label.

Relation to Prior Work

Three works supply pieces of this but stop short of it. Optimized Learned Image Compression for Facial Expression Recognition jointly trains a hyperprior image codec with an expression classifier. It shows the codec then keeps eyes and mouth at about 0.1 bits per pixel, reporting a BD-rate of −89.12% and a BD-accuracy gain of +4.04% over mbt2018-mean on AffectNet. It motivates the proposal, but it is static, trains one model per rate, and drives bit allocation only through an image-level cross-entropy loss. Our hypothesis is that this signal is exactly the global objective that loses local timing. From Pixels to Semantics (D-FACE) shows that a tiny discrete codebook over onset–apex frame pairs strips identity while keeping muscle activations. It supplies evidence that an expression bottleneck can be very narrow. However, its token length is fixed, it has no rate term, and it only sees two frames rather than full onset–apex–decay trajectories. Arbitrary Ratio Feature Compression via Next Token Prediction gets any compression ratio by truncating an ordered token sequence. We reuse that truncation idea. The difference is that ARFC orders pre-extracted CLIP vectors, while we order space-time pixel patches by a receiver-side predictability score, so the stream can serve both reconstruction and several downstream tasks.

On the rate-control side, gain units (Guo et al.), rate-conditioned layers (Choi et al.) and the quantization-error-aware reparameterization of QVRF all vary rate by rescaling latents everywhere at once. We keep QVRF as a secondary fine-rate knob and as our main baseline mechanism. Region-of-interest gain maps (Ma et al.) allocate spatially but need the regions specified in advance. Our allocation is learned and changes over time. For initialization we use FaRL, which combines masked image modeling with image-text contrastive learning on 20M face-text pairs and reaches 92.32 F1 on LaPa face parsing. It gives us a face encoder that already has local geometry, but it is static and has no rate component. On the temporal side, LOGO-Former provides the receiver-side recognizer: local 3D windows for muscle actions plus global attention across the clip. Jiang et al. supplies our sharpest test, the finding that time-averaged features cannot tell neutral→anger from anger→neutral.

Research Program

The model splits a face clip of $T$ frames into $N$ space-time patches. A shared transformer encoder maps each patch to a latent. A lightweight scorer assigns each patch a score $s_i$ predicting the reconstruction error the decoder would make if patch $i$ were withheld. The sender sorts patches by $s_i$ and transmits the top $k$ in that order. Each patch is sent as its quantized latent, with a QVRF-style scalar step, plus its position. The receiver's decoder fills in the rest, as in masked image modeling. Training samples a keep-ratio $\rho$ uniformly per clip and minimizes

$$ L = \mathbb{E}_{\rho}\Big[\, \lVert x - g(\hat z_{S_\rho}) \rVert^2 + \lambda\, R(\hat z_{S_\rho}) + \gamma\, L_{\text{local}} \Big] + \beta\, \lVert s - e \rVert^2 , $$

The terms are as follows. $x$ is the clip. $S_\rho$ is the set of the top $\rho N$ patches by score. $\hat z_{S_\rho}$ are their quantized latents. $g$ is the decoder. $R$ is the estimated bit cost of the transmitted latents and their positions from the entropy model. $L_{\text{local}}$ is an optional per-frame action-unit loss on the reconstruction, with weight $\gamma$ (set to zero in the pure variant). The last term trains the scorer to regress $e$, the decoder's actual per-patch error under a random mask. This sidesteps the non-differentiable top-$k$ selection. Position cost is charged honestly: in the worst case it is about $\log_2\binom{N}{k}$ bits, which the entropy model reduces by exploiting spatial and temporal contiguity. Because of the sort, one trained model produces an embedded stream, and any prefix is a valid lower-rate encoding.

We pretrain on VoxCeleb talking-face video, the same source D-FACE used for about 1M face pairs, starting from FaRL weights. We then build three variants that differ only in what drives the scorer. The first uses reconstruction surprise alone. The second adds a global clip-level emotion cross-entropy, analogous to Li et al. The third adds the local action-unit loss. Comparing them is the global-local test: we predict that the global variant matches or beats the others on clip-level emotion accuracy at low rate, but loses on action-unit F1 and onset timing.

Baselines

The naive reference points are uncompressed video fed to the receiver recognizer, which sets the ceiling, and the same video compressed with HEVC across a sweep of quantization parameters, which is the deployed default. For the ceiling on DFEW, LOGO-Former reports 54.21% unweighted average recall (UAR) and 66.98% weighted average recall (WAR) LOGO-Former. On the micro-expression composite of CASME II, SMIC-HS and SAMM, D-FACE reports 0.8943 UF1. On DFME the best reported baseline is 52.59% accuracy DFME. We found no reported result on Lacuna for dynamic expression recognition on compressed video at any bitrate, so every rate-dependent curve here is new. To keep comparisons fair, every codec's output is decoded to pixels and scored by the same frozen LOGO-Former-style recognizer trained on uncompressed data. For each codec, a second recognizer is fine-tuned on that codec's decoded output with an identical tuning budget. This separates codec quality from recognizer mismatch.

The strongest existing competitor is our reconstruction of Li et al.'s task-aware hyperprior codec applied frame by frame to video. We make it variable-rate by adding QVRF reparameterization, so it is a single model like ours. Its expression cross-entropy is computed per frame. We train it on the same VoxCeleb data, with the same backbone scale and the same GPU-hour budget, and tune its loss weights over the same grid as ours. It is the strongest competitor because it is the only method in the file with demonstrated expression-preserving compression at very low rate. Adding QVRF also removes the one-model-per-rate objection that would otherwise make the comparison easy. A second strong competitor is ARFC-style truncation applied to the recognizer's own per-frame features. Here nothing visual is transmitted, and this may be very cheap for recognition alone.

Two ablations isolate the key ingredient. In the first, the transmitted set is chosen by random masking at the same $k$ rather than by the learned score. This tests whether predictability-ordered selection matters, or whether any masked autoencoder with an entropy model would do. In the second, we keep all patches and vary rate only through the QVRF step. This tests whether token count as the rate knob beats global quantization. Beating the strongest baseline means a negative BD-rate against the QVRF-extended Li et al. codec on action-unit F1 versus bitrate, on both DFME and the micro-expression composite, without losing more than one point of BD-accuracy on clip-level UAR on DFEW and FERV39k.

Why not just…?

Why not just use HEVC or AV1 at a lower quantization setting? Li et al. show that perception-oriented codecs discard low-amplitude expression cues at low rates, and the portrait-compression study reports visible facial degradation for HEVC around 13 kbps Resolution-Agnostic Neural Compression. Still, conventional codecs have excellent motion compensation. For macro-expressions at moderate rates they may be a real threat. The HEVC sweep will settle this, and we expect it to lose mainly below the rate at which micro-expression action-unit F1 collapses.

Why not just extend Li et al. with gain units or QVRF and run it per frame? This is the most serious alternative, and it is our primary baseline for that reason. Its weakness in principle is twofold. It has no temporal redundancy removal, so static frames cost as much as onset frames. And its allocation is driven by a global label, which is the global-local alignment gap reappearing inside the codec. If the per-frame QVRF codec matches us on action-unit F1 and onset timing at equal rate, the selection mechanism is not earning its complexity, and we would report that.

Why not transmit only recognizer features, ARFC-style, and skip pixels? If the receiver only ever needs one fixed recognition task, this could win outright on rate, and we will say so if it does. The proposal's claim is narrower. One stream should serve reconstruction, emotion, action units and timing at once, without knowing the task at encode time. We test this by scoring the feature baseline on the tasks it was not built for, namely action-unit F1, onset latency and HDTF reconstruction. We also test whether per-frame features survive truncation with their temporal order intact.

Why not transmit landmarks or 3D face-model coefficients? These reach 12–30 kbps on HDTF at 30.85 dB PSNR Resolution-Agnostic Neural Compression. But a 79-dimensional linear expression space cannot represent brief asymmetric micro-movements, a point D-FACE also makes against landmark and flow representations. We include the coefficient pipeline on DFME and the micro-expression composite, where we expect it to fail.

Proposed Experiments

The main result is a set of rate curves: UAR and WAR on DFEW and FERV39k, action-unit F1 and emotion accuracy on DFME, and UF1/UAR under leave-one-subject-out evaluation on the CASME II, SMIC-HS and SAMM composite, all plotted against kilobits per second. Reconstruction PSNR and SSIM on HDTF are also plotted against the portrait-compression numbers above. We summarize the curves by BD-rate and BD-accuracy against each baseline.

Three checks decide whether the idea is right rather than merely competitive. The first is a timing check. On micro-expression clips, which come annotated with onset and apex frames, we measure the error in estimated onset and apex frame positions after decoding at each rate. We also measure the fraction of the transmitted budget that the learned scorer spends near those frames. The hypothesis fails if allocation over time is flat.

The second is a direction check following Jiang et al. We train a small probe to tell forward from time-reversed expression clips on decoded video. A codec that keeps dynamics should retain this ability at low rate. A codec that effectively keeps only apex content should drop to chance, and we expect the global-loss variant to degrade earliest.

The third is the global-local check: the three scorer variants compared at matched rate. The prediction is a crossover in which the global emotion loss wins or ties on clip-level UAR but loses on action-unit F1 and onset error. The random-mask ablation should lose to all three on both measures. If the random-mask ablation matches the learned scorer, the central claim is false, and the contribution reduces to "masked autoencoders are acceptable variable-rate face codecs." That is a weaker result, and we would report it as such.