SOLOv2: Dynamic and Fast Instance Segmentation
- Publication
- NeurIPS 2020Conference
- First submitted to arXiv
- arXiv:2003.10152
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{segmentationsolov22020,
title = {{SOLOv2: Dynamic and Fast Instance Segmentation}},
author = {Xinlong Wang and Rufeng Zhang and Tao Kong and Lei Li and Chunhua Shen},
year = {2020},
eprint = {2003.10152},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2003.10152}
}
SOLO showed that instance segmentation can be done without boxes: divide the image into an grid, and whichever cell an object's center falls in takes charge of it; the mask branch outputs masks, with mask handling the object in cell .
This approach carries two obvious burdens. One is those masks, 1,600 of them at the finest FPN level, the vast majority empty. The other is post-processing, since NMS on masks is much slower than NMS on boxes; computing the IoU of two masks costs far more than for two boxes.
Three months later, the same group of authors (Xinlong Wang and Chunhua Shen of the University of Adelaide, Tao Kong and Lei Li of ByteDance, joined by Rufeng Zhang of Tongji University) delivered SOLOv2, with one fix for each burden: dynamic convolution and Matrix NMS.
Defining the Problem
The authors start by rewriting SOLO's mask branch.
The last layer of the mask branch applies a convolution to an feature and outputs channels. Broken apart, the mask for cell is just:
is a kernel, which is to say an -dimensional vector; is an mask containing only the object centered in cell .
So SOLO is really learning two things, a feature and fixed kernels . It computes all masks and trains on every one of them, yet the objects in an image are usually sparse, and only a handful of masks are actually useful.
If and are learned separately, then at inference you can pick out only the cells that contain objects and convolve with their , without computing the thousand-plus empty masks. Going a step further, if is no longer a fixed parameter but is generated dynamically from the input image, every cell gets a segmenter tailor-made for this image and this location.
Solving the Problem
Learning Kernels and Features Separately

SOLOv2 has three parts: the category branch (the same as SOLO's), the kernel branch and the mask feature branch.
Kernel branch. At each FPN level, the features are first resized to and passed through 4 convolution layers, and a final convolution outputs channels, giving kernels of size . Each cell's numbers are the weights of one kernel: to generate a kernel over input channels, ; for , . The output has no activation function.
Because each kernel is predicted "per cell", it is tied to location from the start. Before the first convolution layer, normalized and coordinates are concatenated as well.
Mask feature branch. The authors tried two designs. One, like SOLO, computes a separate mask feature at each FPN level; the other fuses all levels into one unified feature. The latter works better and is the one adopted.
The fusion borrows the semantic segmentation branch of Panoptic FPN: each of P2 to P5 repeats " convolution, GroupNorm, ReLU, 2× upsampling" until it reaches 1/4 resolution, they are all summed, and a convolution gives the feature . Coordinates are concatenated only on the deepest level, P5 (1/32), before any convolution or upsampling.
Assembly. At inference, cells whose category score falls below 0.1 are filtered out first, and each remaining cell takes its own , convolves it with , applies a sigmoid and binarizes at 0.5, giving each object's mask.
The loss is the same as SOLO's, with Focal Loss for categories and Dice Loss for masks.
How It Differs from YOLACT
This structure looks a bit like YOLACT, since both are "one shared thing, plus a set of numbers for each object". YOLACT multiplies 32 prototypes by 32 coefficients; SOLOv2 takes an -channel feature and applies a convolution with the -dimensional kernel predicted at each cell, which is in essence a weighted combination too.
The differences the authors single out lie elsewhere. YOLACT's coefficients hang on anchors and are normalized with tanh, and at inference it has to detect boxes first and then use them to crop the assembled masks; SOLOv2 has no anchors, needs no normalization and needs no boxes at all. Masks come straight from kernels determined by location.
Matrix NMS
The second problem is NMS.
Traditional NMS is greedy and sequential: sort by score, start from the highest, delete lower-scoring predictions that overlap it too much, then move on to the next prediction still alive. Soft-NMS doesn't delete outright but lowers scores according to the overlap, though it still has to process predictions one at a time, recursively.
YOLACT's Fast NMS turns it into matrix operations, at the cost of letting "predictions that have already been deleted delete others too", so it deletes too much.
Matrix NMS also finishes in one pass of matrix operations, but it looks at the problem from a different angle: how much a prediction gets suppressed depends on two things.
- (a) The penalty from each higher-scoring , expressed as a function of the overlap, .
- (b) How likely itself is to be suppressed. If is itself a duplicate prediction that ought to be deleted, its penalty on should be discounted.
(b) is hard to compute exactly, so the authors approximate it by the largest overlap between and any "prediction scoring higher than it":
The final decay factor for is:
The new score is . can be linear, , or Gaussian.
These formulas look a bit convoluted, and walking through a small example makes them clear. Take three predictions sorted by score: , , , with pairwise IoUs , and . Use the linear .
- . Nothing scores higher, so no decay.
- . The only higher-scoring prediction is , which no one suppresses, so the denominator is . The decay factor is , and the score becomes .
- . Both and count. From , it's . From , the denominator uses how much is suppressed by , , so it's . Taking the minimum, 0.9, the score becomes .
Although overlaps quite a bit, itself has already been heavily suppressed by , so its penalty on is discounted (a ratio above 1 amounts to no penalty).
Compare the other two kinds of NMS on the same numbers (threshold 0.5). Traditional NMS: 's IoU of 0.6 with exceeds the threshold, so it's deleted; overlaps by only 0.1 and is kept, and since is already gone, it can't delete . Fast NMS: is compared with every prediction scoring higher, and its largest IoU, 0.55 with , exceeds the threshold, so it's deleted. That's Fast NMS deleting too much, while Matrix NMS agrees with traditional NMS and can still be computed for the whole batch in one go.
In implementation, once the top predictions are sorted, the intersections of binary masks can be computed with a single matrix multiplication to give the IoU matrix; taking the upper triangle and the maximum of each column gives ; after all the ratios are computed, the minimum of each column is each prediction's decay factor. There are no loops at all, and the authors say a simple Python implementation handles 500 masks in under 1 millisecond.
Discussion
Main Results
The training setup is the same as SOLO's: 8 GPUs, 16 images per batch, 36 epochs, shorter side randomly scaled from 640 to 800. Results on COCO test-dev (compiled from Table 1 of the paper):
| Method | Backbone | AP | APS | APL |
|---|---|---|---|---|
| Mask R-CNN | R-101-FPN | 35.7 | 15.5 | 52.4 |
| BlendMask | R-101-FPN | 38.4 | 18.2 | 53.3 |
| SOLO | R-101-FPN | 37.8 | 16.4 | 54.2 |
| SOLOv2 | R-50-FPN | 38.8 | 16.5 | 56.2 |
| SOLOv2 | R-101-FPN | 39.7 | 17.3 | 57.4 |
| SOLOv2 | DCN-101-FPN | 41.7 | 18.0 | 61.6 |
SOLOv2 with ResNet-101 is 1.9 AP above SOLO, and the authors say it's 33% faster as well. The advantage on large objects is especially clear, 5.0 above Mask R-CNN. SOLOv2's masks come from a unified feature at 1/4 resolution, unlike Mask R-CNN's, which are limited to small 28×28 boxes.
On LVIS v0.5, with more than a thousand classes, SOLOv2 is also about 1 AP above Mask R-CNN.
Ablations
These ablations are all on the COCO validation set (Table 3 of the paper):
- Kernel shape. and both give 37.4, so the spatial size makes no difference; raising the input channels from 128 to 256 adds 0.4, and 512 brings no further gain. So the final choice is , and each cell has to predict only 256 numbers.
- Coordinates. With no coordinates in either branch, it's 36.3; only in the kernel branch, still 36.3; only in the mask feature branch, 37.1; in both, 37.8. The authors' explanation is that if the kernel branch doesn't know location, objects that look alike get the same kernel; if the mask feature doesn't know location, it can't tell how to arrange pixels into the channels that line up with the kernels.
- Mask features. A separate feature per FPN level gives 37.3 and one unified feature gives 37.8, with the difference mainly on medium and large objects. When levels are separate, large objects are assigned to the high levels with the lowest resolution, so their boundaries naturally come out coarser.
- NMS. This one measures NMS alone, with the IoU matrix computed in advance:
| Method | Recursive | Time | AP |
|---|---|---|---|
| Hard-NMS | Yes | 9 ms | 36.3 |
| Soft-NMS | Yes | 22 ms | 36.5 |
| Fast NMS | No | < 1 ms | 36.2 |
| Matrix NMS | No | < 1 ms | 36.6 |
Matrix NMS is both fast and accurate. Fast NMS is just as fast, but because it deletes too much, its AP ends up even lower than traditional Hard-NMS.
Real-Time Versions
The authors built two lightweight versions. SOLOv2-448 cuts the prediction head to 2 convolution layers with a 448 shorter side, at 46.5 FPS and 34.0 AP; SOLOv2-512 uses 3 convolution layers with a 512 shorter side and adds deformable convolution to the backbone and the last layer of the prediction head, at 31.3 FPS and 37.1 AP. On COCO test-dev, the latter is more than 7 points above YOLACT-550 (29.8), and it's still real-time.
Detection and Panoptic Segmentation
SOLOv2 predicts no boxes at all, but take the bounding rectangle of each mask as a box and its detection box AP comes to 44.9, with no box supervision of any kind during training.
Add a semantic segmentation branch similar to the mask feature branch and merge the outputs with Panoptic FPN's method, and it does panoptic segmentation. On the COCO validation set, SOLOv2 (ResNet-50) reaches 42.1 PQ, above Panoptic FPN's 39.0 and every other box-free method. Broken down, though, PQ on things is 49.6 and on stuff only 30.7, and on stuff it trails UPSNet (33.4), which uses deformable convolution, by a fair margin.
Conclusion
SOLOv2 splits SOLO's mask branch into two halves, "kernels" and "features". From the image content and its own location, each cell predicts a kernel and convolves a shared high-resolution feature with it. Where 1,600 masks used to be computed, now only the few with objects are.
Matrix NMS rewrites the idea of Soft-NMS as a single matrix operation, correcting each penalty by "whether whoever suppresses you was suppressed too" and computing both factors in one go, with no recursion and none of Fast NMS's over-deletion.
This dynamic approach of "each instance generates its own kernel" later turned, in the K-Net and MaskFormer line, into a dot product between query vectors and pixel features. Matrix NMS ports easily to other detectors and segmenters, needing only a few lines of matrix operations; just note that what it outputs are decayed scores, and you still have to set a threshold and take the top yourself.