Abstract
Transformers have become prevalent in computer vision due to their performance and flexibility in modelling complex operations. Of particular significance is the 'cross-attention' operation, which allows a vector representation to be learned by attending to an arbitrarily sized set of input features. Recently, "Masked Attention" was proposed in which a given object representation only attends to those image pixel features for which the segmentation mask of that object is active. This specialization of attention proved beneficial for various image and video segmentation tasks. In this paper, we propose another specialization of attention which enables attending over 'soft-masks' (those with continuous mask probabilities instead of binary values), and is also differentiable through these mask probabilities, thus allowing the mask used for attention to be learned within the network without requiring direct loss supervision. We employ our "Differentiable Soft-Masked Attention" for the task of Weakly-Supervised Video Object Segmentation (VOS), where we develop a transformer-based network (HODOR) for VOS which only requires a single annotated image frame for training, but can also benefit from cycle consistency training on a video with just one annotated frame.
Introduction
Video Object Segmentation (VOS) is the task of tracking and segmenting specific objects across a video sequence. While Transformers are the standard architecture for this, they often rely on "Masked Attention," where the model only "looks" at features within a specific binary mask.
Standard masked attention has two major flaws: it is non-differentiable, meaning gradients cannot pass through the mask itself, and it is binary, failing to represent the soft probabilities and uncertainty inherent in neural network predictions. These limitations make it difficult to train models on unlabeled video data, as predicted masks cannot be used to improve the model via self-supervision.
Methods
We introduce a novel formulation for the attention operation. Instead of a hard binary mask, we use a soft mask $M$ and a learnable scalar $\alpha$:
$$\text{Attention} = \text{softmax}\left(\frac{K^T Q + \alpha M}{\sqrt{C}}\right) \cdot V$$
By adding the mask $M$ (weighted by $\alpha$) directly into the energy term before the softmax, the operation becomes fully differentiable with respect to the mask.
The HODOR Architecture
The HODOR (High-level Object Descriptors for Object Re-segmentation) framework implements this mechanism:
- Encoder: Uses soft-masked attention to "pool" image features into a concise object descriptor based on a mask.
- Decoder: Takes that descriptor and re-segments the object in a new frame.
Cycle Consistency
Because the mask is differentiable, we can train on unlabeled video. We take an annotated frame, propagate the mask to an unlabeled frame, and then propagate it back to the original frame. A loss is applied between the original ground truth and the "cycled" prediction. This allows the network to learn from the temporal structure of video without needing every frame labeled.
Key Results
HODOR was evaluated on primary VOS benchmarks, including DAVIS 2017 and YouTube-VOS. The model achieved impressive results, especially given its weakly supervised training regime.
On DAVIS 2017, HODOR achieved a 77.5 $J\&F$ score when trained only on static images, outperforming methods like STCN (75.8). When cycle consistency training was applied to unlabeled video, the performance increased to 80.6 $J\&F$. This demonstrates that the model effectively learns to segment objects in unlabeled frames despite the lack of direct mask supervision.
Conclusion
Differentiable Soft-Masked Attention allows models to express uncertainty and enables standard backpropagation through segmentation masks. By making the mask influence learnable, the model can adapt its focus, bridging the gap between static image pre-training and video data. This significantly reduces the need for expensive frame-by-frame video annotations while maintaining state-of-the-art performance.
Summary updated