explaingit

facebookresearch/detectron2

Analysis updated 2026-06-20

34,450PythonAudience · researcherComplexity · 4/5LicenseSetup · hard

TLDR

Meta AI's Python toolkit for detecting objects and segmenting images. Download pre-trained models or train your own to identify and locate objects in photos and video, no AI research degree needed to get started.

Mindmap

mindmap
  root((repo))
    Detection Tasks
      Object Detection
      Instance Segmentation
      Semantic Segmentation
      Panoptic Segmentation
    Architectures
      Faster R-CNN
      Mask R-CNN
      RetinaNet
      ViTDet
    Model Zoo
      Pre-trained Weights
      Fine-tune Ready
      TorchScript Export
    Use Cases
      Autonomous Driving
      Medical Imaging
      Retail Detection
      Video Surveillance
    Developer Tools
      Training Scripts
      Evaluation Tools
      PyTorch Backend
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Draw bounding boxes around every object in a photo or video frame automatically.

USE CASE 2

Build a retail system that detects and counts products on store shelves from camera feeds.

USE CASE 3

Fine-tune a pre-trained model on your own image dataset to detect custom objects.

USE CASE 4

Run medical image analysis to highlight and segment regions of interest in scans.

What is it built with?

PythonPyTorchTorchScriptCUDA / GPU

How does it compare?

facebookresearch/detectron2khoj-ai/khojposthog/posthog
Stars34,45034,41134,321
LanguagePythonPythonPython
Setup difficultyhardmoderatehard
Complexity4/53/54/5
Audienceresearchergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires a CUDA-capable GPU and matching PyTorch + CUDA versions. Install via pip from the pre-built wheel for your CUDA version. CPU-only runs are slow and not practical for training.

Apache 2.0, free to use, modify, and distribute, including in commercial products. Just keep the license notice.

In plain English

Detectron2 is a Python library from Meta AI Research (formerly Facebook AI Research) that provides tools for object detection, image segmentation, and related computer vision tasks. Object detection means identifying what objects are in an image and drawing bounding boxes around them, telling you there is a cat at a specific location and a chair at another. Segmentation goes further by identifying the exact pixels belonging to each object rather than just a bounding box. Detectron2 covers multiple variants of these tasks, including instance segmentation (outlining each individual object), semantic segmentation (labeling every pixel with a category), and panoptic segmentation (combining both at once). The library is built on top of PyTorch, a popular deep learning framework, and is designed to be a research platform: it implements many well-known detection architectures and provides training code, evaluation scripts, and a large model zoo, a collection of pre-trained model weights you can download and either use directly or fine-tune on your own dataset. Architectures available include Faster R-CNN, Mask R-CNN, RetinaNet, and more recent models like ViTDet. Trained models can be exported to deployment-ready formats like TorchScript. You would use Detectron2 when building or experimenting with a computer vision system that needs to locate and identify objects in images or video. Typical applications include autonomous driving perception systems, medical imaging analysis, product detection in retail, video surveillance, and academic computer vision research. It is primarily a research and prototyping tool. For production deployment, its export capabilities allow moving to optimized inference runtimes. The library is Python-based, requires a GPU for practical training speeds, and is released under the Apache 2.0 open-source license.

Copy-paste prompts

Prompt 1
Using Detectron2 with a pre-trained Mask R-CNN model, write Python code to load an image from disk, run inference, and draw the detected objects and their segmentation masks on the image.
Prompt 2
I have a folder of labeled images. Write a Detectron2 training script that fine-tunes a pre-trained Faster R-CNN model on my custom dataset using the COCO annotation format.
Prompt 3
Using Detectron2, write a Python script that processes a video file frame by frame, runs panoptic segmentation on each frame, and saves the annotated video to disk.
Prompt 4
Show me how to download a pre-trained ViTDet model from the Detectron2 model zoo and run it on a single image to get bounding box predictions as a JSON list.
Prompt 5
Write a Detectron2 evaluation script that loads my fine-tuned model checkpoint and computes COCO metrics on a validation dataset stored locally.

Frequently asked questions

What is detectron2?

Meta AI's Python toolkit for detecting objects and segmenting images. Download pre-trained models or train your own to identify and locate objects in photos and video, no AI research degree needed to get started.

What language is detectron2 written in?

Mainly Python. The stack also includes Python, PyTorch, TorchScript.

What license does detectron2 use?

Apache 2.0, free to use, modify, and distribute, including in commercial products. Just keep the license notice.

How hard is detectron2 to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is detectron2 for?

Mainly researcher.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub facebookresearch on gitmyhub

Verify against the repo before relying on details.