Detectron2 is Facebook's open source library for implementing state-of-the-art computer vision techniques in PyTorch. Facebook introduced Detectron2 in October 2019 as a complete rewrite of Detectron (which was implemented in Caffe). Facebook uses Detectron2 in a wide array of their products, including Portal, and notes the framework accelerates the feedback loop between research and production.
In releasing Detectron2, the Facebook Artificial Intelligence Research team also released a model zoo. The Detectron2 model zoo includes pre-trained models for a variety of tasks: object detection, semantic segmentation, and keypoint detection.
Using Detectron2 for Object Detection
The Roboflow team has published a Detectron2 tutorial on object detection, including a Detectron2 Colab notebook. (If you haven't yet followed that tutorial for training Detectron2, that is the recommended starting point.)
Our prior Detectron2 tutorial assumes using a specific Faster-RCNN from the model zoo. However, the notebook can be customized to any other object detection model from the model library with a simple change.
In the notebook, when we load our model for training (line 10 below), note that we call for COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml
:
However, if we visit the object detection model zoo in Detectron2, we see there are multiple implementations of Faster R-CNN available as well as RetinaNet and RetinaNet + Faster R-CNN.
To replace the YAML file with an alternative architecture (and pre-configured training checkpoint), simply:
- Right click the model name in the lefthand column
- Copy the link
- Replace the link in the Colab notebook with the newly copied link
This new model YAML file then replaces the architecture, and training starts from that same pre-trained checkpoint. It's that easy.
Happy training!
Cite this Post
Use the following entry to cite this post in your research:
Joseph Nelson. (Nov 1, 2020). How to Use the Detectron2 Model Zoo (for Object Detection). Roboflow Blog: https://blog.roboflow.com/how-to-use-the-detectron2-object-detection-model-zoo/
Discuss this Post
If you have any questions about this blog post, start a discussion on the Roboflow Forum.