Back to paper library
arXiv 2019ECCV 2020SegmentationPaper notes

SOLO

The Grid Decides

Original paper

SOLO: Segmenting Objects by Locations

Paper authors

Xinlong Wang · Tao Kong · Chunhua Shen · Yuning Jiang · Lei Li

Publication
ECCV 2020Conference
First submitted to arXiv
arXiv:1912.04488
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{segmentationsolo2019,
  title = {{SOLO: Segmenting Objects by Locations}},
  author = {Xinlong Wang and Tao Kong and Chunhua Shen and Yuning Jiang and Lei Li},
  year = {2019},
  eprint = {1912.04488},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1912.04488}
}
On this page

Semantic segmentation is easy to write as a classification problem. The classes are fixed, the network outputs CC channels, each pixel picks the largest of the CC channels, and you're done.

Instance segmentation gets stuck on "the count isn't fixed". An image may hold 3 people or 30, and the network doesn't know how many channels to prepare.

So the methods of the time all took a detour. Detect-then-segment methods such as Mask R-CNN and YOLACT find boxes first and then cut masks inside them; another camp first learns an embedding vector for each pixel so that pixels of the same object sit close together, then clusters them at the end. Both are indirect, the first depending on how accurate the boxes are and the second on how well the clustering goes.

Xinlong Wang and Chunhua Shen of the University of Adelaide, Tao Kong of ByteDance AI Lab and their co-authors wanted to go back to the most basic question. What actually sets two objects in the same image apart?

Defining the Problem

The authors went through statistics on the COCO validation set. It holds 36,780 objects in total, and when you pair them up, 98.3% of object pairs have centers more than 30 pixels apart. Of the remaining 1.7% of pairs with close centers, 40.5% differ in size by more than 1.5 times.

In other words, two objects in the same image almost always differ either in where their centers are or in how big they are.

If that's so, can instances be told apart directly by "where the center is" and "how big it is"? Semantic segmentation uses one channel to represent one semantic class; SOLO wants one channel to represent one "instance category", meaning a quantized center location and object size.

That's where the name comes from: Segmenting Objects by LOcations.

Solving the Problem

Location as a Category

Location comes first. Divide the image into an S×SS \times S grid, and whichever cell an object's center falls in is responsible for that object.

Diagram compiled for this note. On the left is an image divided into a 5×5 grid, with the center of blue object A in cell (1, 3) and the center of orange object B in cell (3, 1). In the middle is the 5×5 output of the category branch, with cells (1, 3) and (3, 1) colored for objects A and B. On the right is the output of the mask branch, showing three masks: k = 0 is empty, k = 8 holds only object A, k = 16 holds only object B, and more follow.
Drawn for this note from Section 2.1 and the idea of Fig. 2 of the paper; object positions are illustrative.

SOLO has two parallel branches:

  1. Category branch. It outputs S×S×CS \times S \times C, with each cell predicting probabilities for CC classes. This assumes each cell belongs to only one object.
  2. Mask branch. It outputs H×W×S2H \times W \times S^2, that is, S2S^2 masks roughly the size of the image. Mask kk handles the object in cell (i,j)(i, j), where k=i⋅S+jk = i \cdot S + j (counting ii and jj from 0).

Look at the example in the figure. Object A's center is in cell (1,3)(1, 3), so the category branch predicts "A's class" at that cell, and mask number 1×5+3=81 \times 5 + 3 = 8 of the mask branch is responsible for cutting out A. Object B is in cell (3,1)(3, 1) and corresponds to mask 16.

The two branches line up naturally through the cell index, with no boxes and no clustering. At inference, you pair each cell's class with its mask and remove duplicates with NMS.

You might worry whether the order of the masks affects learning. The authors say the simplest row-major order is enough.

Letting the Convolution Know Where It Is

There's a snag here. Convolution is roughly translation-invariant: the same thing on the left or on the right gets about the same response. But SOLO demands that the object in the top-right corner show up in mask 8 and the one in the bottom-left corner in mask 16, so the network has to know which part of the frame it's computing.

The authors borrow a simple fix from CoordConv: at the very start of the mask branch, each pixel's xx and yy coordinates, normalized to [−1,1][-1, 1], are concatenated as two extra channels. The original H×W×DH \times W \times D features become H×W×(D+2)H \times W \times (D + 2).

This small change works well. Without coordinates, AP is 32.2; with one CoordConv layer it's 35.8, 3.6 more. Adding more layers makes no difference. The authors also mention that ordinary convolutions can actually learn a little positional information from zero padding (the YOLACT paper observed the same thing), but what they learn is crude and not precise enough.

Handling Size with FPN

Size comes next. SOLO sits on an FPN, and objects of different sizes go to feature maps at different levels. Each level also has a different number of grid cells:

FPN levelP2P3P4P5P6
Grid SS4036241612
Object scale< 9648–19296–384192–768≥ 384

(From Table 8 in the appendix of the paper; scales are in pixels, and the ranges of neighboring levels overlap on purpose.)

Small objects can appear in many more places in the frame, so their grid is finer; large objects get a coarser grid. Every level gets the same two branches with shared weights, and only the last layer is separate for each level because the grid sizes differ.

The category branch has to map H×WH \times W features onto the S×SS \times S grid. The authors use bilinear interpolation, and they also tried adaptive pooling and other approaches, with differences all within 0.1 AP.

Labels and Loss

Which cells count as positives? SOLO borrows the center sampling of detectors such as FCOS: take the centroid of the annotated mask as the center, scale the width and height by 0.2, and every cell falling in this center region counts as a positive. On average, each object gets about 3 positive cells.

The loss is the category loss plus the mask loss:

L=Lcate+λLmaskL = L_\text{cate} + \lambda L_\text{mask}

The category loss is Focal Loss, with λ=3\lambda = 3. The mask loss is computed only on positive cells and uses Dice Loss:

LDice=1−2∑x,ypx,y qx,y∑x,ypx,y2+∑x,yqx,y2L_\text{Dice} = 1 - \frac{2 \sum_{x,y} p_{x,y} \, q_{x,y}}{\sum_{x,y} p_{x,y}^2 + \sum_{x,y} q_{x,y}^2}

pp is the predicted soft mask, and qq is the annotated mask.

Why not ordinary binary cross-entropy? SOLO's masks are the size of the whole image, and an object takes up only a small patch of it, so the vast majority of pixels are background. The authors compared three losses: binary cross-entropy at 30.0 (and only after hand-tuning the mask loss weight to 10 and the positive pixel weight to 2), Focal Loss at 31.6, and Dice Loss at 35.8, which needs no weight tuning at all and also trains the most stably.

The appendix has a nice check from the opposite direction. Swapping Mask R-CNN's mask loss for Dice actually drops AP by 0.9. Mask R-CNN's masks are computed only inside the box, where foreground and background aren't imbalanced in the first place, so Dice's advantage has nothing to work on.

At inference, the authors also compute a "maskness", the average probability of the foreground pixels (those above 0.5) in a mask, and multiply it into the classification score as the final confidence. The more decisively a mask is cut, the higher the score.

Decoupled SOLO

SOLO comes with an obvious cost. The P2 level has 40×40=1,60040 \times 40 = 1{,}600 masks to output, yet an image usually holds only a few objects, so the vast majority of masks are empty.

The authors propose an equivalent version that saves a great deal. Split the S2S^2 masks into two sets of SS: XX handles "which column", and YY handles "which row". The mask for cell (i,j)(i, j) is simply the product of two of them:

mk=xj⊗yim_k = x_j \otimes y_i
Diagram compiled for this note. Three 5×5 grids. On the left, y₁ lights up only objects A and C, whose centers lie in row i = 1; in the middle, x₃ lights up only objects A and D, whose centers lie in column j = 3; multiplying the two pixel by pixel leaves only object A in m₈ on the right. A note below says the output drops from S² = 25 masks to 2S = 10.
Drawn for this note from Eq. 5 in Section 4 of the paper; object positions are illustrative.

Both xjx_j and yiy_i go through a sigmoid, and can be read as "the probability that this pixel belongs to an object centered in column jj" and "the probability that it belongs to an object centered in row ii". The authors assume these two events are independent, so their product is the probability of belonging to the object in cell (i,j)(i, j).

Taking P2 as an example, the output drops from 1,600 masks to 80. Accuracy doesn't fall; it's actually 0.6 AP higher than the original, and training and inference also use a lot less memory.

Discussion

Main Results

Training uses 8 GPUs and 16 images per batch, with the shorter side randomly scaled between 640 and 800. The main results on COCO test-dev (Table 1 of the paper, with a 72-epoch training schedule):

MethodBackboneAPAPSAPL
Mask R-CNNR-101-FPN35.715.552.4
TensorMaskR-101-FPN37.117.451.6
YOLACTR-101-FPN31.212.147.1
PolarMaskR-101-FPN30.413.442.8
SOLOR-101-FPN37.816.454.2
Decoupled SOLOR-101-FPN38.416.854.6
Decoupled SOLODCN-101-FPN40.517.759.3

SOLO ties the authors' own better-trained Mask R-CNN (37.8) and beats every single-stage method of the time. Its AP on large objects is especially good, 54.2 against Mask R-CNN's 52.4; SOLO's masks are the size of the whole image, unlike Mask R-CNN's, which are limited to 28×28.

Ablations

  • Grid number and FPN. With a single feature map (stride 8), S=12S = 12 already gets 27.2 AP and S=24S = 24 gets 29.0, but going finer to 36 drops it to 28.6. Switching to multi-level prediction with FPN jumps straight to 35.8. The authors call FPN one of SOLO's core components.
  • Head depth. Going from 4 to 7 convolution layers in the mask branch raises AP from 34.6 to 35.8, and adding more changes nothing. Mask R-CNN's mask head needs only 4 layers; SOLO needs more because it has to learn to infer from coordinates "which mask this object should appear in".

Speed

SOLO with ResNet-101 runs at 10.4 images per second on a V100 (post-processing included), close to Mask R-CNN's 11.1 and much faster than TensorMask's 2.6. With the input's shorter side cut from 800 to 512, SOLO-512 with ResNet-50 runs at 22.5 FPS with 34.2 AP.

How Much Room Is Left

The authors did a very honest error analysis. Replace each mask SOLO predicts with the annotated mask that has the highest IoU with it, leave everything else (classes, scores) unchanged, and AP jumps from 37.1 to 68.1. Small-object AP jumps from 16.0 to 46.1.

So SOLO does reasonably well at "finding objects and classifying them", and the real bottleneck is the mask branch. The authors hope to improve it later by borrowing techniques from semantic segmentation and from work on occlusion and small objects.

Conclusion

SOLO rewrites instance segmentation as two classification problems: what class is each cell, and which cell's object does each pixel belong to. Center locations are separated by grid cells, sizes by FPN levels, position sensitivity comes from CoordConv, and the foreground–background imbalance is left to Dice Loss. No boxes, no RoIs and no clustering, and the results tie Mask R-CNN.

The S2S^2 masks are its heaviest burden. Decoupled SOLO's row-times-column factorization brings the channel count down from quadratic to linear, which at least stops the bleeding. Three months later, SOLOv2 replaced the whole mask branch with dynamic convolution, letting each cell generate its own set of kernels.

If you want to try SOLO on your own data, first check whether your objects have overlapping centers and similar sizes. SOLO's opening statistic holds on COCO; on a production-line photo packed with identical parts, it may not.