- Introduced by
- Kaiming He et al. (FAIR)
- Year
- 2017
- Type
- Instance segmentation deep neural network
- Family
- Object detection / segmentation
What does it do?
Mask R-CNN is a deep learning framework for instance segmentation introduced by Kaiming He, Georgia Gkioxari, Piotr Dollár, and Ross Girshick at Facebook AI Research (FAIR) in 2017.
It extends Faster R-CNN with a parallel branch that predicts a binary pixel-level mask for each detected object instance, so detection, classification and mask prediction are performed together within one network.
The intuition behind the method
Think of Mask R-CNN as a two-stage visual inspector. In the first stage it proposes rectangular candidate regions likely to contain objects. In the second stage, for each candidate, it simultaneously asks three questions: What class is this? Where exactly is the bounding box? And which pixels inside the box belong to the object? The mask branch answers the third question using a small convolutional network, producing a crisp per-instance silhouette that separates overlapping objects cleanly.
History
Mask R-CNN was presented at ICCV 2017 by He, Gkioxari, Dollár and Girshick. According to the original abstract, it is a conceptually simple, flexible and general framework for object instance segmentation that extends Faster R-CNN by adding a mask prediction branch in parallel with the existing bounding-box recognition branch. The authors present it as a solid baseline intended to ease future research in instance-level recognition, and report top results on the COCO instance segmentation, bounding-box detection and person keypoint detection tracks.
When to use it
Use Mask R-CNN when you need to distinguish individual object instances at the pixel level, not merely bounding boxes or semantic labels. It is appropriate for medical image analysis (cell counting, tumor delineation), autonomous driving (pedestrian silhouettes), satellite imagery (building footprints), and industrial inspection. Assumes sufficient labeled mask training data. Not ideal when only bounding boxes are needed (use Faster R-CNN) or when semantic segmentation without instance distinction suffices (use FCN or DeepLab). Computationally demanding; lighter alternatives include YOLOv8-seg or SOLO.
Limitations and considerations
- Higher computational cost than single-stage methods: the backbone runs once per image, but the box and mask heads run for every candidate region, so cost grows with the number of proposals
- Requires large amounts of pixel-level annotated training data, which is expensive and time-consuming to produce
- The mask is predicted on a fixed grid (typically 28×28), which limits fine detail recovery for very small or highly elongated objects
- Two-stage design has higher latency than single-stage instance segmentation methods. The original abstract reports running at 5 fps in the authors' own experimental setting; hardware and input size are not stated there, and speed depends strongly on GPU, input resolution and implementation, so real-time use usually requires lighter models or optimisation
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Separates mask prediction from classification: the mask branch has its own loss and predicts one mask per class, so the class decision is made by the classification head rather than by the mask head
- RoIAlign removes the rounding step of RoIPool, which is the change that makes pixel-accurate masks feasible within a two-stage detector
- Adds only a small overhead to Faster R-CNN and is simple to train, according to the original paper's abstract
- Extensible to other tasks: according to the original abstract, the framework is easy to generalise to other tasks, such as human pose estimation, and the paper reports results on COCO instance segmentation, bounding-box detection and person keypoint detection
Applications
- Medical imaging: nuclei detection and segmentation in histopathology slides, organ delineation in CT/MRI
- Autonomous driving: per-instance pedestrian, cyclist, and vehicle silhouette extraction for scene understanding
- Satellite and aerial imagery: building footprint extraction, agricultural field delineation
- Robotics: object grasping using precise shape information for pick-and-place planning
- Video analysis: per-frame instance masks, which must be linked across frames by an external tracker or a dedicated video instance segmentation method
How it works
How it works
A Region Proposal Network (RPN) slides over the feature map extracted by a backbone such as ResNet-50 with a Feature Pyramid Network. It scores anchor boxes at multiple scales and aspect ratios for objectness and regresses their coordinates, generating a ranked list of candidate regions of interest for further processing.
Formula
\text{RPN}(F) \rightarrow \{r_i\} \quad r_i = (x, y, w, h, p_{obj})RoIAlign replaces the rounding step of RoIPool with bilinear interpolation, sampling the feature map at four sub-pixel locations per bin. The rounding in RoIPool causes misalignment that is tolerable for bounding boxes but harmful for pixel-accurate masks, so removing it is the key technical change that makes high-quality masks possible within the two-stage design.
Formula
\hat{f}_i = \text{RoIAlign}(F, r_i) = \int_{\text{bin}} f(x,y)\,dx\,dy \quad (\text{bilinear interpolation, no quantization})Two fully connected heads applied to each RoIAlign output jointly predict the object class via softmax cross-entropy and refine the bounding box via smooth-L1 regression. These heads follow the Faster R-CNN design, so the detection branch can be trained with the same objectives as Faster R-CNN, independently of the mask branch.
Formula
\hat{c}_i,\, \hat{b}_i = \text{FC}(\hat{f}_i) \quad \mathcal{L}_{cls} + \mathcal{L}_{box} = \text{cross-entropy} + \text{smooth-}L_1A small fully convolutional network with several 3×3 convolutional layers and a final transposed convolution predicts an m×m binary mask for each of the K classes independently, avoiding class competition within the mask head. Only the mask corresponding to the predicted class is selected at inference time. The binary cross-entropy loss is computed over all spatial positions of the mask.
Formula
\hat{M}_i = \sigma\!\left(\text{Conv}^{(k)}(\hat{f}_i)\right) \in [0,1]^{m \times m} \quad \mathcal{L}_{mask} = -\frac{1}{m^2}\sum_{p} \left[y_p \log \hat{M}_{ip} + (1-y_p)\log(1-\hat{M}_{ip})\right]Common pitfalls
- Applying RoIPool instead of RoIAlign when adapting code leads to systematic mask misalignment and degraded mAP on segmentation metrics
- Computing the mask loss over all K class channels instead of only the ground-truth class channel mixes gradients from wrong classes and can slow convergence
- Too few anchors or a narrow FPN scale range reduces recall for very small or very large objects; the error appears as missed instances, which is easily misread as poor mask quality
- Reporting only bounding-box mAP can hide poor mask quality; mask metrics should be reported separately
Frequently asked questions
How does Mask R-CNN differ from semantic segmentation models like FCN or DeepLab?
Semantic segmentation assigns a class label to every pixel but does not distinguish between separate instances of the same class. Mask R-CNN performs instance segmentation: it detects each individual object, assigns a class and bounding box, and predicts a separate binary mask for each instance. Two overlapping pedestrians get two distinct masks rather than a merged semantic region.
Why is RoIAlign critical, and what exactly does it fix?
RoIPool rounds floating-point region coordinates to integer values before pooling, which misaligns the pooled features with image pixels. For bounding boxes this error is tolerable, but for pixel-level masks it is visible in the output. RoIAlign avoids rounding and uses bilinear interpolation at exact sub-pixel sample points within each pooling bin, preserving the spatial correspondence between features and image pixels.
Can Mask R-CNN be used for video instance segmentation?
Mask R-CNN operates on individual frames and has no built-in temporal modelling. For video, its per-frame masks must be combined with an external tracker that associates instances across frames, or used inside a dedicated video instance segmentation framework built on similar components. This requires engineering beyond the base model.
How should I read Mask R-CNN results?
Report bounding-box AP and mask AP separately. Mask AP follows the COCO-style protocol, averaging precision over several intersection-over-union thresholds between predicted and ground-truth masks, so a single-threshold score is not directly comparable. Interpret the two numbers together: if box AP is reasonable but mask AP is low, the mask boundaries are the likely problem. If instances are missed entirely, the cause is more likely low recall, which points to anchor, proposal or FPN scale settings rather than to the mask head.
Related methods
Sources
He, K., Gkioxari, G., Dollár, P., & Girshick, R. (2017). Mask R-CNN. IEEE International Conference on Computer Vision (ICCV), 2980–2988.
Open DOI reference