Detectron2 segments instances with Mask R-CNN
Detectron2 is Facebook AI Research's library for detection and segmentation. In Supervisely you train Detectron2 Mask R-CNN instance segmentation models on your own polygons and masks, starting from weights pretrained on COCO, LVIS or Cityscapes, and serve them on a GPU or a CPU.

- Publisher
- Meta AI
- Labels
- Polygons
- Bitmaps
- Apps
- Train, Serve
Apps in the Supervisely Ecosystem
Every model in Supervisely comes as a Supervisely App: a module from the Ecosystem that plugs into the platform and runs on your own GPU, with no code to install. A Serve App puts the model behind the labeling tools, and where the model can be trained, a Train App fits it to your labeled project. All Apps work on the same projects, so you add a model, update it or swap it for another without changing anything else.
Detectron2 in Supervisely is about masks
Detectron2 is the PyTorch detection and segmentation library of Facebook AI Research, now Meta AI. Its model zoo covers several tasks, but the Supervisely apps use one part of it on purpose: Mask R-CNN instance segmentation, where each object gets its own mask and its own box.
The apps offer the Mask R-CNN baselines on three backbone designs:
| Backbone | What it is |
|---|---|
| FPN | ResNet with a feature pyramid and standard heads; the best speed and accuracy balance of the three. |
| C4 | A ResNet conv4 backbone with a conv5 head, the original Faster R-CNN baseline. |
| DC5 | A ResNet conv5 backbone with dilated convolutions, as in the Deformable ConvNets paper. |
Weights pretrained on COCO, LVIS and Cityscapes are in the list, so a project of street scenes can start from Cityscapes and a project with many rare classes from LVIS.
Labels it learns from
The training app runs on projects labeled with polygons or bitmap masks. Boxes alone are not enough: a Mask R-CNN learns the outline of each object, so every instance needs its shape. The brush, pen and Smart Tool of the image labeling toolbox all produce masks this model can learn from.
Existing datasets come in as they are. COCO stores instances as polygons or RLE masks, and PNG masks hold them as images; both import into a project, and COCO to Supervisely JSON shows what each COCO field becomes.
What the training dashboard sets
Add Train Detectron2 to your team and run it on the project. In the dashboard you define the train and validation split, choose the classes, set up augmentations, pick a pretrained model and tune the hyperparameters. During training it charts the metrics and previews the model's predictions on images as it learns, so an outline that keeps going wrong is visible before the run ends. Trained models are saved to Team Files.
Serving and pre-labeling
Serve Detectron2 deploys a pretrained or trained model on a GPU or on a CPU, which helps when the agent that labels has no graphics card. It predicts on a full image or on a region of interest. Once it runs, Apply NN to Images Project pre-labels a whole project with masks and NN Image Labeling adds them to the image an annotator has open.
When to choose another model
Detectron2 is fully supported in Supervisely: Train Detectron2 and Serve Detectron2 are supported Ecosystem apps for Mask R-CNN instance segmentation. Pick another app when you need a different architecture or export to ONNX and TensorRT:
- For real-time instance segmentation, the YOLO segmentation checkpoints are built for speed and export to ONNX and TensorRT.
- For more architectures than Mask R-CNN, MMDetection trains Cascade Mask R-CNN and dozens of other designs in one app.
- If you need a class for every pixel and do not care which object a pixel belongs to, that is semantic segmentation: use UNet or MMSegmentation.
- To get masks without training at all, Segment Anything 2.1 segments objects from a click or a box.
The Detectron2 integration page sums up the same apps from the integration side.
Frequently asked questions.
Is Detectron2 supported in Supervisely?
Yes. Train Detectron2 and Serve Detectron2 are supported Ecosystem apps for Mask R-CNN instance segmentation, with FPN, C4 and DC5 backbones and weights pretrained on COCO, LVIS or Cityscapes.
How do I train Detectron2 on a custom dataset?
Label each instance with a polygon or a mask, or import a COCO dataset, then run Train Detectron2 on the project. Boxes alone are not enough, because a Mask R-CNN learns the outline of each object. In the dashboard you set the split, classes, augmentations, pretrained model and hyperparameters.
Does Serve Detectron2 need a GPU?
No. It deploys a pretrained or trained model on a GPU or on a CPU, and predicts on a full image or on a region of interest.
What is Mask R-CNN used for?
Instance segmentation: it finds each object, gives it a class and a bounding box, and predicts a pixel mask for it. Mask R-CNN adds a mask branch to the Faster R-CNN detector, and it is the architecture the Train Detectron2 app trains on your polygons and masks.
Train and serve models on your own data.
Label a project in a free account, train a model on it from the browser and deploy it on your own GPU. Or book a demo to run Supervisely on your servers.



