How Slot Attention Learns to See Objects
Look at a photo and you see objects, a gray cube here, a green cube there, a yellow cylinder. That feels obvious, but most computer vision models do not see the world that way. They process pixels with no built-in idea that a scene is made of separate things. A paper from Google Brain, ETH Zurich, and MPI adds it back. It is called object-centric learning with slot attention, and it teaches a model to split a scene into objects from pixels alone.
There are two tasks. Object discovery, unsupervised: point to the pixels where the objects are and segment them, with no labels. Set prediction, supervised: say what objects are there. The hard part is that objects form a set, with no natural order. "A green cube and a yellow cylinder" is the same answer as "a yellow cylinder and a green cube". The architecture has to be invariant to ordering.
The core is the slot attention module. A CNN encoder turns the image into a grid of feature vectors. Then there are slots, fewer than the features, four in the video's example. The job is to assign features to slots, one object per slot. Once that works, classifying each slot on its own classifies the objects. The loss uses Hungarian matching, which gives the model the benefit of the doubt: a predicted gray cube counts as a match if there is a gray cube somewhere. A second slot predicting the same yellow rectangle is a mistake, because there is only one to match.
The attention mechanism does the assignment. The features emit keys, the slots emit queries, and a feature is routed to the slot whose query agrees most with its key. The softmax is taken over the slots, so they compete: the best-matching slot wins, and the attention becomes fairly hard, something like 0.9 for one slot and 0.1 for the rest. The slots are initialized randomly, which matters. In Facebook's DETR, similar slots are learned, and learned slots specialize, one for the top left, one for long objects in the middle. With only a few slots, the authors keep them random so they stay agnostic.
Then comes the iterative part. The updates go through a GRU plus an optional residual MLP, and the whole thing repeats, like a Transformer with weight sharing between layers. Step one assigns roughly. Step two is where the magic happens: a slot with some blue pixels asks for more blue pixels, and one with golden pixels asks for more of those. Competition sends the golden pixels to one slot and the blue pixels to another, and the separation sharpens with each round. The experiments show exactly this.
For the unsupervised task, each slot is decoded back into an image. The decoder is like a GAN generator: it upsamples a slot into a picture with four channels, red, green, blue, and alpha. The alpha channel says where the object is, and the alpha maps are combined with a softmax so they sum to one. Train the whole thing to reconstruct the input image and the slots are forced to split the scene into objects, because that is the only way to reconstruct it well. Four slots for three objects, because one slot always ends up holding the background.
What I like is how little it assumes: no labels, no bounding boxes, just slots competing and a reconstruction objective, and the objects emerge.
Try this
bashcurl -s https://arxiv.org/abs/2006.15055 pip install transformers python -c "import transformers; print(transformers.__version__)"
Sources
- Source: Object-Centric Learning with Slot Attention (Paper Explained) - Yannic Kilcher
- Object-Centric Learning with Slot Attention, arXiv:2006.15055 - https://arxiv.org/abs/2006.15055
