Back to paper library
arXiv 2019CVPR 2020SegmentationPaper notes

PointRend

Only the Unsure Points

Original paper

PointRend: Image Segmentation as Rendering

Paper authors

Alexander Kirillov · Yuxin Wu · Kaiming He · Ross Girshick

Publication
CVPR 2020Conference
First submitted to arXiv
arXiv:1912.08193
Cite this paper · BibTeX

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

@misc{segmentationpointrend2019,
  title = {{PointRend: Image Segmentation as Rendering}},
  author = {Alexander Kirillov and Yuxin Wu and Kaiming He and Ross Girshick},
  year = {2019},
  eprint = {1912.08193},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1912.08193}
}
On this page

Mask R-CNN predicts a 28×28 mask for every object and then scales it up and pastes it back into the image. A tennis player who fills a third of the frame and a tennis ball far away both get the same 28×28.

That's fine for small things and terrible for large ones. Scaled up eight or ten times, the player's fingers and the edges of the racket all blur into a lump, and the paper simply calls the result "blobby".

Alexander Kirillov, Yuxin Wu, Kaiming He and Ross Girshick of FAIR borrowed an old trick from computer graphics to fix this. They treat segmentation as "rendering": a mask doesn't need every pixel computed with equal care. Spend a bit more on the few rings along the boundary, and just interpolate the flat interior.

Defining the Problem

Convolutional networks naturally compute on a regular grid. The input is a grid, the intermediate features are grids, and the output label map is a grid too.

But a label map isn't uniform. Neighboring pixels mostly share a class, and the only truly complex part is the ring of boundary between objects. A regular grid takes far too many samples in the flat interior and too few at the boundary, so you waste computation on one side and get blurry boundaries on the other.

That's why segmentation networks usually predict at a fairly low resolution, commonly 1/8 of the input for semantic segmentation and 28×28 for instance segmentation, and then upscale. It's a compromise between "too many samples" and "too few samples".

The authors point out that computer graphics ran into exactly the same problem decades ago. A renderer has to draw a 3D model as a regular pixel image, yet it doesn't work equally hard on every pixel. Classic adaptive subdivision first computes a coarse image, refines only where a value "differs a lot from its neighbors", and fills in everywhere else by interpolating values it has already computed. Antialiasing in ray tracing likewise takes extra samples along edges.

To carry this idea over to segmentation, you first have to decide how to pick the points worth refining. And when refining, what features does each point use, and which network makes the prediction?

Solving the Problem

Three Components

PointRend is a module. Its input is one or a few ordinary convolutional feature maps (usually at 1/4 to 1/16 of the image resolution), and its output is a finer prediction. It has three components:

  1. Point selection. Predict at only a few chosen points instead of computing every pixel at high resolution.
  2. Point-wise features. A point's coordinates are real numbers, so its feature is computed by bilinear interpolation from the 4 nearest grid points on the feature map. The channels of a feature map actually carry sub-pixel information, so the prediction can be finer than the feature map itself.
  3. Point head. A small network that predicts a label for each point independently.
Original Figure 3: PointRend applied to instance segmentation. On the left is the CNN backbone, with a red box marking a detected object, and above it is the 7×7 coarse mask prediction for that object. PointRend selects a few red points inside the box, takes one feature from the fine-grained feature map and one from the coarse prediction (dashed arrows), combines them into point-wise features, and passes them to an MLP that outputs a prediction for each point, which together form the refined mask on the right.
Original Figure 3, Kirillov et al., from PDF page 3, arXiv license, scholarly quotation.

Take instance segmentation. Mask R-CNN first computes a coarse mask for each box (PointRend uses 7×7), then PointRend picks some points inside the box (the red points), takes two kinds of features for each point and hands them to an MLP to predict again. Semantic segmentation works the same way, treating the whole image as one box.

Inference: Subdivide Only Where Unsure

Original Figure 4: one round of adaptive subdivision. On the left is a 4×4 prediction (dark is background, light is the object); it is upsampled to 8×8 by bilinear interpolation, and on the 8×8 grid in the middle the most uncertain points are marked (black dots, all near the object's boundary); after these points are predicted again, the 8×8 result on the right has a clearer boundary.
Original Figure 4, Kirillov et al., from PDF page 4, arXiv license, scholarly quotation.

Each step at inference:

  1. Upsample the current prediction by 2× with bilinear interpolation.
  2. On the upsampled grid, pick the NN most uncertain points. For a binary mask, these are the points whose probability is closest to 0.5.
  3. Compute features and run the point head on only these NN points, overwriting the interpolated values.

Repeat the three steps until the resolution is high enough. The uncertain points naturally cluster on the boundary, while the object interior and the background simply keep their interpolated values.

Let's work through the Mask R-CNN setting. The coarse mask is 7×7 and the target is 224×224, so it takes 5 subdivisions: 7 → 14 → 28 → 56 → 112 → 224. Each step picks N=282=784N = 28^2 = 784 points. The first step, up to 14×14, has only 196 points in total, so all of them are recomputed; the four steps after that take 784 points each. That adds up to 196+4×784=3,332196 + 4 \times 784 = 3{,}332 points, while 224×224 has 50,176 pixels, 15 times fewer.

Training: No Iteration, Random Sampling Instead

Subdivision at inference is a sequential, step-by-step process, which is awkward for backpropagation. So training uses one-shot random sampling instead, taking NN points per box under three principles:

  1. Over-generation. First scatter kNkN candidate points uniformly at random (k>1k > 1).
  2. Importance sampling. Interpolate the coarse prediction at these points, compute their uncertainty and keep the βN\beta N most uncertain.
  3. Coverage. Sample the remaining (1−β)N(1 - \beta) N points uniformly over the whole box.

The loss is computed only at these NN points (plus the loss of the coarse mask itself). Faster R-CNN does the same, computing the RPN and Fast R-CNN in parallel during training and chaining them into two stages only at inference.

Original Figure 5: 196 training points taken from the same coarse prediction with different strategies. (a) regular grid, points evenly spread; (b) uniform random (k = 1, β = 0); (c) mildly biased (k = 3, β = 0.75), with most points near the object boundary but some still in the interior and background; (d) heavily biased (k = 10, β = 0.75), with almost every point crowded onto the boundary.
Original Figure 5, Kirillov et al., from PDF page 4, arXiv license, scholarly quotation.

The one actually used is (c), with N=142=196N = 14^2 = 196, k=3k = 3 and β=0.75\beta = 0.75. Most points sit near the boundary, but a quarter are kept for the interior and the background.

Features for Each Point

Each point's feature is the concatenation of two parts.

The first part is the fine-grained feature, interpolated from one of the backbone's higher-resolution feature maps; the Mask R-CNN setting uses FPN's P2 (1/4 of the image), with 256 dimensions. This part handles the details.

Fine-grained features alone aren't enough, for two reasons. One is that they don't know which object they belong to: if a point falls inside two overlapping boxes, the fine-grained features taken for each box are identical, yet the point can be foreground for only one of the two objects. The other is that low-level features are semantically weak.

So the second part is the coarse prediction feature, the point's KK-dimensional prediction interpolated from the coarse mask. It comes from a specific box, so it carries "which object is this" information, along with more global semantics.

The point head is an MLP with 3 hidden layers of 256 channels each, sharing weights across all points and all boxes. The output of each layer has the KK-dimensional coarse prediction feature concatenated again before going to the next layer. The authors liken it to a graph convolution or PointNet, operating on each point independently.

As for the coarse mask, the authors don't keep Mask R-CNN's original four-conv mask head. They switch to a lighter version: take 14×14 features from P2, shrink them to 7×7 with a stride-2 convolution, then apply two 1024-wide MLP layers that output a 7×7 mask for each class.

Discussion

Main Results

The experiments use Mask R-CNN with ResNet-50 + FPN. COCO's annotations are often fairly coarse, and AP may not reflect improvements in mask quality, so the authors also evaluate the same model against LVIS's high-quality annotations for COCO's 80 classes, recorded as AP*.

The results (Table 1 of the paper):

Mask headOutputCOCO APAP*Cityscapes AP
4× conv (original)28×2835.237.633.0
PointRend28×2836.139.235.5
PointRend224×22436.339.735.8

Even with the same 28×28 output, PointRend beats the original, by 0.9 COCO AP, 1.6 AP* and 2.5 Cityscapes AP; at 224×224 the gains grow to 1.1, 2.1 and 2.8. The finer the annotations, the bigger the gap.

Between the 28×28 and 224×224 PointRend, AP differs by only 0.2. The authors explain that AP is computed from IoU, so most of the score comes from pixels inside the object and it's insensitive to improvements at the boundary. Look at the images, though, and it's a different story:

Original Figure 1: a side-by-side comparison at the top. On the left is the original Mask R-CNN 28×28 mask, where the tennis player's hand and outline are blurred; on the right is the 224×224 mask with PointRend, where the fingers and the edges of the clothes are clear (red arrows mark the differences). At the bottom are the four resolutions of PointRend inference, 28×28, 56×56, 112×112 and 224×224, with the points picked at each step (black dots) all concentrated on the person's outline.
Original Figure 1, Kirillov et al., from PDF page 1, arXiv license, scholarly quotation.

In the top row, the original is on the left and PointRend on the right, and the hand and clothing edges marked by the red arrows differ a lot. The bottom row is the subdivision process, with the black dots at every step lined up along the person's outline.

With larger backbones and longer training (a 3× schedule), the gap holds: 1.0 more for ResNet-50, 1.2 for ResNet-101 and 1.4 for ResNeXt-101, while the AP* gap ranges from 2.0 to 2.8.

Computation

PointRend's biggest selling point is making a resolution like 224×224 feasible inside Mask R-CNN (Table 2 of the paper):

Mask headOutputFLOPsActivations
4× conv28×280.5B0.5M
4× conv224×22434B33M
PointRend224×2240.9B0.7M

For the original convolutional mask head to output 224×224, RoIAlign first has to crop 112×112 features, and both computation and memory blow up by more than 60 times. PointRend outputs the same resolution at only a little more than the original 28×28, saving over 30 times.

As for actual speed, the authors' unoptimized implementation outputs 224×224 masks at about 13 per second, roughly the speed of "doubling the original RoIAlign to output 56×56", and the latter actually gets a lower COCO AP than the original 28×28 (34.5 vs. 35.2).

Ablations

  • Output resolution and point count. Going from a 28×28 output all the way to 224×224, COCO AP rises from 36.1 to 36.3 and saturates quickly. Raising the points picked per step from 14214^2 to 1122112^2 also stops helping after 28228^2, because the most uncertain points get picked first. The authors note that while AP saturates, the visible improvement continues for objects with complex outlines.
  • How to pick points during training. Regular grid 35.7, uniform random 35.9, mildly biased 36.3, and heavily biased (k=10k = 10, β=1.0\beta = 1.0) only 34.4, worse than uniform random. With every point crowded onto the boundary, the network never learns what the inside of an object should be, so coverage matters. Any kk from 2 to 5 and β\beta from 0.75 to 1.0 performs about the same.
  • Number of points. 196 points per box are enough, and more don't help; with only 49 points, AP stays the same, but the results vary more.
  • Size of the point head. Changing the MLP's depth or width makes no noticeable difference.

Semantic Segmentation

PointRend can also be attached to semantic segmentation models. On Cityscapes, DeepLabV3 (output stride 16) originally outputs 64×128 at 77.2 mIoU; switching to output stride 8 at inference gives a 128×256 output and 77.8; attaching PointRend and subdividing all the way to the original 1024×2048 resolution gives 78.4.

Here the uncertainty becomes "the probability gap between the top and second-highest classes". Each step picks 8,096 points, roughly the number of points on a 1/16 feature map (64×128 = 8,192). The full 1024×2048 image has about 2 million pixels, and PointRend actually predicts only about 32,000 points.

SemanticFPN behaves the same way, with the 1/4-resolution output version going from 77.7 to 78.6 and the 1/8 version from 77.4 to 78.5.

Conclusion

PointRend borrows a very old graphics trick, computing coarsely first and then spending the effort where things are least certain. In segmentation, it takes Mask R-CNN's masks from 28×28 to 224×224 at only a little extra computation, adds about 2 points of AP on high-quality annotations, and makes the boundaries much cleaner.

Its training-time sampling has outlived the module itself. Mask2Former computes the mask loss on only 112×112112 \times 112 points with the same importance sampling, and the official settings of k=3k = 3 and β=0.75\beta = 0.75 match PointRend's too; that is how per-image training memory dropped from 18GB to 6GB.

Still, sampling can't be greedy. The paper's ablation shows plainly that crowding every point onto the boundary scores worse than scattering them at random; the flat regions always need a few points.