# YOLACT: Real-time Instance Segmentation

YOLACT splits instance segmentation into parallel tasks for real-time speed

Daniel Bolya, Chong Zhou, Fanyi Xiao, Yong Jae Lee · arXiv · 2019-4-4

- **Problem** Two-stage instance segmentation re-pools features inside each box before predicting masks, which is sequential and hard to speed up. One-stage methods avoid this but still need costly post-processing, so neither runs in real time.
- **Method** YOLACT predicts prototype masks for the whole image and mask coefficients for each instance, in parallel. It then linearly combines the prototypes with each instance's coefficients and crops the result with a predicted box.
- **Results** YOLACT reaches 29.8 mask mAP on COCO test-dev at 33.5 FPS on a single Titan Xp, as one model without test-time augmentation.

## Why real-time instance segmentation is hard

Instance segmentation methods such as Mask R-CNN and FCIS were built on object detectors like Faster R-CNN and R-FCN, and they concentrate on accuracy rather than speed. Real-time detectors such as SSD and YOLO therefore have no instance segmentation counterpart, and the goal of this work is a fast, one-stage instance segmentation model that plays the role SSD and YOLO play for detection.

The target is the first real-time approach above 30 FPS with around 30 mask mAP on COCO test-dev.

Detectors gain speed by dropping the second stage, but that trick does not carry over to masks, because the mask predictor of a two-stage method depends on features that were localized for each region. Two-stage methods re-pool features in a bounding box region, for example with RoI-pool or RoI-align, and feed the localized features to the mask predictor, a chain that is inherently sequential.

One-stage methods that run these steps in parallel, such as FCIS, still need substantial post-processing after localization, which keeps them far from real-time.

## Building masks from prototypes and coefficients

YOLACT splits instance segmentation into two parallel tasks, and both are learned from one image. The first task builds a dictionary of prototype masks that cover the entire image, and the second predicts a set of linear combination coefficients for each instance. To form the mask for an instance, the prototypes are combined with that instance's coefficients and the result is cropped with a predicted bounding box.

The design rests on spatial coherence: pixels that are close to each other usually belong to the same instance. Convolutional layers exploit this coherence, while fully-connected layers do not, and one-stage detectors produce class and box outputs for each anchor through fc layers. Two-stage methods sidestep the problem with RoI-Align, but the first-stage RPN has to finish before the mask head can run, which costs speed.

YOLACT keeps fc layers for the mask coefficients, since they suit producing semantic vectors, and uses conv layers for the prototype masks, since they suit producing spatially coherent masks. Because the prototypes and coefficients are computed independently, the extra cost over the backbone detector comes mostly from assembly, which is a single matrix multiplication.

## The prototype branch

Protonet is an FCN whose last layer has k channels, one per prototype, and it is attached to a backbone feature layer. It takes its input from P3, the largest feature layer of the FPN, because the deepest features give more robust masks. Its output is upsampled to one fourth of the input resolution, which helps small objects. For a 550×550 input, the P3 level is 69×69 and the prototype output is 138×138 with k channels.

Protonet has no loss of its own, so the prototypes receive all their supervision from the mask loss applied after assembly. The output is left unbounded so that the network can produce large activations for prototypes that are confidently background, and a ReLU follows the branch because it gives more interpretable prototypes.

## Mask coefficients, assembly and losses

Each anchor gets a third output branch alongside the class and box branches, which predicts k mask coefficients, so each anchor produces 4 + c + k values instead of 4 + c. The k coefficients pass through tanh, which the authors found more stable than leaving them linear and which allows prototypes to be subtracted from the final mask.

Assembly is written as \\( M = \\sigma(P C^{T}) \\), where \\(P\\) is an h×w×k matrix of prototype masks and \\(C\\) is an n×k matrix of coefficients for the n instances that survive NMS and score thresholding. A sigmoid follows the linear combination, so the whole step is one matrix multiplication and a sigmoid.

Training uses a classification loss, a box regression loss and a mask loss, weighted 1, 1.5 and 6.125 respectively. The mask loss is a pixel-wise binary cross entropy between the assembled masks and the ground truth masks. During training the mask is cropped with the ground truth box, and the mask loss is divided by that box's area so that small objects still contribute to the prototypes; at evaluation the predicted box is used.

## What the prototypes learn to localize

Fully convolutional networks are normally translation invariant, so methods such as FCIS and Mask R-CNN add translation variance explicitly, through position-sensitive mechanisms or a second-stage mask branch.

A convolution over a uniform input gives a uniform output, so a solid image cannot be distinguished in position without padding. The authors suggest that padding in ResNet-style networks gives the network a way to tell how far a pixel is from the image edge, for example by spreading padded zeros inward across layers, and this makes ResNet translation variant.

Many prototypes respond only to objects on one side of an implicit boundary, and prototypes 1 to 3 in Figure 5 are examples of this partition behavior. Subtracting one partition prototype from another can separate overlapping instances of the same class, as in the umbrella example where prototype 3 is subtracted from prototype 2. Other prototypes respond to the bottom-left of objects, to the background and object edges, and to the ground in the scene.

Because prototypes are learned, one prototype can take on several roles, and the coefficient branch decides which situation calls for which function.

## Backbone and detection head

The default backbone is ResNet-101 with FPN at a base image size of 550×550, and the aspect ratio is not preserved so that evaluation time per image stays consistent. The design follows RetinaNet with an emphasis on speed, so P2 is not produced, P6 and P7 are built as successive 3×3 stride 2 convolutions starting from P5, and three anchors with aspect ratios 1, 1/2 and 2 sit on each level.

Anchor scales run from 24 to 384, with each level doubling the scale of the previous one.

Each level shares one 3×3 convolution across the three branches, and each branch then has its own 3×3 convolution, which makes the head lighter than RetinaNet's. Box regressors use smooth-L1 loss with box coordinates encoded as in SSD, and the class loss is softmax cross entropy with c positive labels and one background label, with OHEM selecting examples at a 3:1 neg:pos ratio.

Focal loss is not used because the authors did not find it viable here. At the same image size this backbone performs better and faster than SSD modified to use ResNet-101.

## Why sequential NMS is a bottleneck and how Fast NMS removes it

Standard NMS runs class by class: boxes are sorted by confidence, and each detection removes lower-confidence boxes whose IoU overlap with it exceeds a threshold. This is acceptable near 5 fps, but at 30 fps a 10 ms saving is worth 12.9 fps, while the same saving at 5 fps is worth only 0.26 fps.

Fast NMS makes every keep-or-discard decision in parallel by letting already-removed detections suppress others, which standard NMS does not allow. The whole procedure is written in standard GPU matrix operations. For the top n detections of each of c classes, a c×n×n pairwise IoU matrix X is computed, its lower triangle and diagonal are set to zero, and the column-wise maximum gives the matrix of largest IoU values.

The matrix is written as \\( K\_{kj} = \\max\_i X\_{kij} \\), and a detection is kept when its value K is below the threshold t.

Because already-removed boxes still suppress others, Fast NMS removes slightly too many boxes. In the authors' code base it is 11.8 ms faster than a Cython implementation of standard NMS and loses 0.1 mAP. In the Mask R-CNN benchmark suite it is 15.0 ms faster than the CUDA implementation of standard NMS, at a loss of 0.3 mAP.

## Semantic segmentation loss during training

A training-only loss is applied to the feature space, using a 1×1 convolution with c output channels on the largest feature map, P3. Since a pixel can belong to more than one class, the loss uses sigmoid outputs rather than softmax over c + 1 classes. The ground truth for this loss is built from instance annotations, so it does not strictly enforce one class per pixel.

The loss has weight 1, and the text gives its effect as a +0.4 mAP gain at no speed cost. The gain is stated in the text only, with no separate table for it in this text.

## Training and evaluation setup

On MS COCO the models are trained on train2017 and evaluated on val2017 and test-dev. Training uses batch size 8 on one GPU with ImageNet pretrained weights, and the pretrained batch norm is left unfrozen without adding extra batch norm layers. A COCO training run takes 4 to 6 days, depending on configuration, on one Titan Xp.

For Pascal, training runs for 120k iterations with the learning rate divided at 60k and 100k, and the anchor scales are multiplied by 4/3. Speeds in the paper were all computed on a single Titan Xp.

## COCO accuracy and speed against prior models

The base YOLACT-550 with ResNet-101 reaches 29.8 mask AP and 33.5 FPS on COCO test-dev, with the Titan Xp timing shown in Table 1.

At the 50% overlap threshold YOLACT-550 scores 48.5 AP against 58.0 for Mask R-CNN, a gap of 9.5 AP. At the 75% threshold the gap is 6.6 AP, with YOLACT-550 at 31.2 and Mask R-CNN at 37.8. The gap between FCIS and Mask R-CNN is more even, at 7.5 and 7.6 AP at the two thresholds the authors compare.

At the 95% IoU threshold the base model reaches 1.6 AP, against 1.3 AP for Mask R-CNN. Lowering the input to 400×400 gives YOLACT-400 at 45.3 FPS and 24.9 AP, while 700×700 gives YOLACT-700 at 23.4 FPS and 31.2 AP. Replacing the backbone with ResNet-50 gives 45.0 FPS and 28.2 AP, and DarkNet-53 gives 40.7 FPS and 28.7 AP, both at 550×550.

## Speed and accuracy trade-offs in the ablations

On COCO val2017, YOLACT with standard NMS reaches 30.0 AP at 24.0 FPS, and with Fast NMS it reaches 29.9 AP at 33.5 FPS. Mask R-CNN with standard NMS reaches 36.1 AP at 8.6 FPS, and with Fast NMS it reaches 35.8 AP at 9.9 FPS.

With k = 8 prototypes the model reaches 26.8 AP, with k = 32 it reaches 27.7 AP at 32.4 FPS, and with k = 64 it reaches 27.8 AP at 31.7 FPS. At k = 256 the model reaches 27.7 AP but only 29.8 FPS, and the authors chose 32 for its mix of performance and speed. These models were trained for 400k iterations instead of 800k.

FCIS without mask voting reaches 27.8 AP at 9.5 FPS, and Mask R-CNN at 550×550 reaches 32.2 AP at 13.5 FPS. The fc-mask variant, which predicts 16×16 masks from an fc layer, reaches 20.7 AP at 25.7 FPS. YOLACT-550 on val2017 reaches 29.9 AP at 33.0 FPS, which is a different split and run from the test-dev figures of 29.8 AP at 33.5 FPS.

## Mask quality and temporal stability

The final mask is 138×138 and is built directly from the original features, with no re-pooling that could misalign them. This gives noticeably better masks for large objects than Mask R-CNN and FCIS, as in the arm example where YOLACT follows the boundary more cleanly. The base model is 5.9 mAP worse overall but reaches 1.6 AP at the 95% IoU threshold, against 1.3 AP for Mask R-CNN, and the authors read this as evidence that re-pooling reduces mask quality.

Training uses only static images with no temporal smoothing, yet the masks are more stable across video frames than Mask R-CNN masks. The authors attribute this to higher mask quality, to the one-stage design, and to prototypes that do not change when the predicted boxes shift between frames. The temporal result is a qualitative observation, and no stability metric is reported in the text.

## Box detection against YOLOv3

Box performance on COCO test-dev is compared with YOLOv3 at matched speed levels, with YOLACT timed without its mask branch. YOLACT-700 with ResNet-101 reaches 33.7 AP at 29.61 FPS, and YOLOv3-608 with DarkNet-53 reaches 33.0 AP at 30.54 FPS. Both methods were timed on the same Titan Xp.

The mask branch takes about 5 ms in the mask evaluation timing, and about 6 ms in the box-detection measurement. The authors attribute the similar detection results mainly to FPN and to training with masks, both orthogonal to YOLO's improvements, and suggest that combining YOLO and YOLACT could give a better detector; this combination was not tested.

## Pascal 2012 SBD with the ResNet-50 variant

On Pascal 2012 SBD, YOLACT-550 with ResNet-50 and FPN reaches 47.6 FPS, with mAP r50 of 72.3 and mAP r70 of 56.2. MNC with VGG-16 reaches 63.5 mAP r50 and 41.5 mAP r70 at 2.8 FPS, and FCIS with ResNet-101 reaches 65.7 mAP r50 and 52.1 mAP r70 at 9.6 FPS. Speeds for COCO and Pascal are not comparable, because Pascal has fewer classes.

## Limitations

Overall YOLACT-550 is 5.9 mAP behind Mask R-CNN, and the authors attribute most of this gap to the detector rather than to the mask generation.

Localization failure happens when many objects sit in one spot, so the network yields something closer to a foreground mask for some of them; the blue truck under the red airplane in Figure 6 is an example. Leakage happens because masks are cropped after assembly without any suppression of outside noise, so an inaccurate box, or a box that is too big, lets far-away instance masks in.

Experiments use COCO and Pascal 2012 SBD only, and the models are trained on static images. Temporal stability is shown only qualitatively, and whether larger prototype counts beyond 32 help was not tested, since the authors observe that higher k mostly adds redundant prototypes.

## Paper info

- **Authors**: Daniel Bolya, Chong Zhou, Fanyi Xiao, Yong Jae Lee
- **Venue**: arXiv · Preprint
- **First published**: 2019-4-4
- **Added**: 2026-11-12
- **Updated**: 2019-10-24
- **Version**: v2
- **arXiv**: 1904.02689
- **Category**: cs.CV
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1904.02689v2) · [PDF ↗](https://arxiv.org/pdf/1904.02689v2)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Daniel Bolya, Chong Zhou, Fanyi Xiao, Yong Jae Lee (2019). YOLACT: Real-time Instance Segmentation. arXiv:1904.02689v2. https://arxiv.org/abs/1904.02689v2

**BibTeX**

```
@misc{bolya2019yolact,
  title = {{YOLACT: Real-time Instance Segmentation}},
  author = {Daniel Bolya and Chong Zhou and Fanyi Xiao and Yong Jae Lee},
  year = {2019},
  eprint = {1904.02689},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1904.02689v2}
}
```

## Other paper commentary

- [SiamRPN++: Evolution of Siamese Visual Tracking with Very Deep Networks](https://refivu.com/en/papers/bd27ac05-aab2-4448-8e23-79659dfe759b-siamrpn-evolution-of-siamese-visual-tracking-with-very.md)
- [A Review on Deep Learning Techniques Applied to Semantic Segmentation](https://refivu.com/en/papers/8ae0e955-3ed5-48a2-b638-f9e5d7aa334e-a-review-on-deep-learning-techniques-applied-to.md)
- [Run, Don't Walk: Chasing Higher FLOPS for Faster Neural Networks](https://refivu.com/en/papers/dffa1011-36cd-44c9-b21a-c10cc00af851-run-don-t-walk-chasing-higher-flops-for.md)
- [An All-in-One Network for Dehazing and Beyond](https://refivu.com/en/papers/03c50633-ad40-4af4-b88a-e6cb99e97639-an-all-in-one-network-for-dehazing-and.md)
- [SmoothGrad: removing noise by adding noise](https://refivu.com/en/papers/ab609ae7-27e3-4473-bc00-e8bc5f0e8a91-smoothgrad-removing-noise-by-adding-noise.md)
- [Fine-Grained Visual Classification of Aircraft](https://refivu.com/en/papers/3543af61-7a52-4fb1-ac78-312fdda48697-fine-grained-visual-classification-of-aircraft.md)
- [A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification](https://refivu.com/en/papers/f99c2916-c5f5-45e3-8503-ed9342776182-a-gentle-introduction-to-conformal-prediction-and.md)
- [Neural Turing Machines](https://refivu.com/en/papers/98345e56-0459-409a-bde9-37eadc2f2d0a-neural-turing-machines.md)
- [Thumbs up? Sentiment Classification using Machine Learning Techniques](https://refivu.com/en/papers/099cc783-1d4a-4899-b08c-ce3886810f1a-thumbs-up-sentiment-classification-using-machine-learning.md)

## Terms in this paper

- [Mask R-CNN](https://refivu.com/en/terms/6da881f24c0c-mask-r-cnn)
- [IoU](https://refivu.com/en/terms/49f3d09602a9-iou)
- [AP](https://refivu.com/en/terms/476f7c8deadf-ap)
- [MS COCO](https://refivu.com/en/terms/1a7c38d39825-ms-coco)
- [Resnet-101](https://refivu.com/en/terms/e1917778abec-resnet-101)
- [FPS](https://refivu.com/en/terms/e6b895af6e27-fps)
- [RetinaNet](https://refivu.com/en/terms/7a1197d7203b-retinanet)
- [FCN](https://refivu.com/en/terms/a92993ff7ed6-fcn)
- [FPN](https://refivu.com/en/terms/ad78e3a6bd84-fpn)
- [NMS](https://refivu.com/en/terms/c36344a53ebf-nms)
- [SSD](https://refivu.com/en/terms/dd58c602e311-ssd)
- [OHEM](https://refivu.com/en/terms/539047a448da-ohem)
- [Darknet-53](https://refivu.com/en/terms/1a817af08f03-darknet-53)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/5c58130c-e869-497b-8b85-e21d46848fe1-yolact-real-time-instance-segmentation)
