Top Related Projects
Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
Models and examples built with TensorFlow
Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
FAIR's research platform for object detection research, implementing popular algorithms like Mask R-CNN and RetinaNet.
YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
Quick Overview
MMDetection is a state-of-the-art object detection framework developed by the Open-MMLAB research group. It provides a comprehensive and modular codebase for training and deploying a wide range of object detection models, including popular architectures like Faster R-CNN, Mask R-CNN, and RetinaNet.
Pros
- Comprehensive Model Zoo: MMDetection offers a large and diverse collection of pre-trained object detection models, allowing users to easily experiment with different architectures and configurations.
- Modular and Extensible Design: The codebase is designed with modularity in mind, making it easy to add new models, backbones, and components to the framework.
- State-of-the-Art Performance: The models in MMDetection achieve competitive results on popular object detection benchmarks, such as COCO and Pascal VOC.
- Active Community and Documentation: The project has a vibrant community of contributors and users, and the documentation is comprehensive and well-maintained.
Cons
- Steep Learning Curve: The framework can be challenging to set up and configure, especially for beginners in the field of object detection.
- Limited Support for Deployment: While MMDetection provides tools for model conversion and deployment, the support for production-ready deployment pipelines is relatively limited compared to some other object detection frameworks.
- Dependency on PyTorch: MMDetection is built on top of the PyTorch deep learning framework, which may be a limitation for users who prefer other frameworks like TensorFlow.
- Resource-Intensive Training: Training the more complex object detection models in MMDetection can be computationally expensive and may require access to powerful hardware, such as high-end GPUs.
Code Examples
Here are a few code examples demonstrating the usage of MMDetection:
# Perform inference on a single image
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
result = inference_detector(model, 'demo/demo.jpg')
# Train a custom object detection model
from mmdet.apis import set_random_seed, train_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
# Modify the configuration as needed
cfg = Config.fromfile(config_file)
cfg.data.train.ann_file = 'path/to/your/train/annotations.json'
cfg.data.train.img_prefix = 'path/to/your/train/images'
cfg.data.val.ann_file = 'path/to/your/val/annotations.json'
cfg.data.val.img_prefix = 'path/to/your/val/images'
cfg.model.roi_head.bbox_head.num_classes = 10 # Number of classes in your dataset
set_random_seed(0)
train_detector(cfg, checkpoint_file, work_dir='your_work_dir', gpu_ids=[0])
# Convert a trained model to ONNX format
from mmdet.core.export import export_onnx_model
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
onnx_file = 'faster_rcnn.onnx'
export_onnx_model(config_file, checkpoint_file, onnx_file, input_shape=(1, 3, 800, 1216))
Getting Started
To get started with MMDetection
Competitor Comparisons
Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
Pros of Detectron2
- Faster training and inference speeds
- More extensive documentation and tutorials
- Tighter integration with PyTorch ecosystem
Cons of Detectron2
- Steeper learning curve for beginners
- Less flexibility in customizing model architectures
- Fewer pre-trained models available out-of-the-box
Code Comparison
MMDetection:
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
result = inference_detector(model, 'test.jpg')
Detectron2:
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
cfg = get_cfg()
cfg.merge_from_file("configs/COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml")
cfg.MODEL.WEIGHTS = "detectron2://COCO-Detection/faster_rcnn_R_50_FPN_1x/137257794/model_final_b275ba.pkl"
predictor = DefaultPredictor(cfg)
outputs = predictor(image)
Both frameworks offer powerful object detection capabilities, but Detectron2 excels in performance and PyTorch integration, while MMDetection provides more flexibility and a gentler learning curve for newcomers to the field.
YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
Pros of YOLOv5
- Simpler architecture and easier to use for beginners
- Faster training and inference times
- More lightweight and suitable for edge devices
Cons of YOLOv5
- Less flexible for customization and advanced use cases
- Limited to YOLO-based architectures
- Smaller community and fewer pre-trained models
Code Comparison
MMDetection:
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
result = inference_detector(model, 'test.jpg')
YOLOv5:
import torch
model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
results = model('test.jpg')
results.print()
MMDetection offers a more modular and customizable approach, while YOLOv5 provides a simpler, more streamlined implementation for object detection tasks.
Models and examples built with TensorFlow
Pros of models
- Broader scope, covering various ML tasks beyond object detection
- Officially maintained by Google, ensuring long-term support and updates
- Extensive documentation and tutorials for beginners
Cons of models
- Less specialized for object detection compared to mmdetection
- Steeper learning curve due to its broader focus
- May require more setup and configuration for specific tasks
Code Comparison
mmdetection:
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
result = inference_detector(model, 'test.jpg')
models:
import tensorflow as tf
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as viz_utils
model = tf.saved_model.load('path/to/saved_model')
image = tf.image.decode_jpeg(tf.io.read_file('test.jpg'), channels=3)
detections = model(tf.expand_dims(image, axis=0))
Both repositories offer powerful tools for object detection, but mmdetection is more specialized and easier to use for this specific task, while models provides a broader range of ML capabilities with official Google support.
Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
Pros of Mask_RCNN
- Simpler implementation, easier to understand and modify
- Focused specifically on instance segmentation tasks
- Well-documented with detailed explanations and examples
Cons of Mask_RCNN
- Less flexible and fewer features compared to mmdetection
- Not actively maintained, with fewer recent updates
- Limited to Mask R-CNN architecture, while mmdetection supports multiple models
Code Comparison
Mask_RCNN:
import mrcnn.model as modellib
model = modellib.MaskRCNN(mode="inference", config=config, model_dir=MODEL_DIR)
model.load_weights(COCO_MODEL_PATH, by_name=True)
results = model.detect([image], verbose=1)
mmdetection:
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/mask_rcnn/mask_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/mask_rcnn_r50_fpn_1x_coco_20200205-d4b0c5d6.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
result = inference_detector(model, img)
FAIR's research platform for object detection research, implementing popular algorithms like Mask R-CNN and RetinaNet.
Pros of Detectron
- Developed and maintained by Facebook AI Research, benefiting from their expertise
- Extensive documentation and tutorials for ease of use
- Strong integration with PyTorch and Caffe2
Cons of Detectron
- Less frequent updates compared to MMDetection
- Smaller community and fewer third-party contributions
- More limited range of pre-trained models and algorithms
Code Comparison
MMDetection:
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
result = inference_detector(model, 'test.jpg')
Detectron:
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
cfg = get_cfg()
cfg.merge_from_file("configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml")
cfg.MODEL.WEIGHTS = "detectron2://COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl"
predictor = DefaultPredictor(cfg)
outputs = predictor(image)
Both repositories offer powerful object detection frameworks, with MMDetection providing more frequent updates and a wider range of models, while Detectron benefits from Facebook's expertise and integration with PyTorch and Caffe2.
YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
Pros of darknet
- Lightweight and fast, optimized for real-time object detection
- Supports both CPU and GPU computation
- Easy to use with pre-trained models and simple configuration files
Cons of darknet
- Limited model architectures (primarily YOLO-based)
- Less extensive documentation and community support
- Fewer pre-trained models and datasets available
Code comparison
darknet:
network *net = load_network("cfg/yolov3.cfg", "yolov3.weights", 0);
image im = load_image("data/dog.jpg", 0, 0, net->w, net->h);
detection *dets = detect(net, im, 0.5, 0.5, 0, &num);
mmdetection:
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
result = inference_detector(model, 'test.jpg')
Summary
darknet is a lightweight and fast object detection framework, primarily focused on YOLO-based models. It's easy to use but has limited model options and community support. mmdetection offers a wider range of models and better documentation but may be more complex to set up and use.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
ðDocumentation | ð ï¸Installation | ðModel Zoo | ðUpdate News | ðOngoing Projects | ð¤Reporting Issues
English | ç®ä½ä¸æ
Introduction
MMDetection is an open source object detection toolbox based on PyTorch. It is a part of the OpenMMLab project.
The main branch works with PyTorch 1.8+.
Major features
-
Modular Design
We decompose the detection framework into different components and one can easily construct a customized object detection framework by combining different modules.
-
Support of multiple tasks out of box
The toolbox directly supports multiple detection tasks such as object detection, instance segmentation, panoptic segmentation, and semi-supervised object detection.
-
High efficiency
All basic bbox and mask operations run on GPUs. The training speed is faster than or comparable to other codebases, including Detectron2, maskrcnn-benchmark and SimpleDet.
-
State of the art
The toolbox stems from the codebase developed by the MMDet team, who won COCO Detection Challenge in 2018, and we keep pushing it forward. The newly released RTMDet also obtains new state-of-the-art results on real-time instance segmentation and rotated object detection tasks and the best parameter-accuracy trade-off on object detection.
Apart from MMDetection, we also released MMEngine for model training and MMCV for computer vision research, which are heavily depended on by this toolbox.
What's New
ð We have released the pre-trained weights for MM-Grounding-DINO Swin-B and Swin-L, welcome to try and give feedback.
Highlight
v3.3.0 was released in 5/1/2024:
MM-Grounding-DINO: An Open and Comprehensive Pipeline for Unified Object Grounding and Detection
Grounding DINO is a grounding pre-training model that unifies 2d open vocabulary object detection and phrase grounding, with wide applications. However, its training part has not been open sourced. Therefore, we propose MM-Grounding-DINO, which not only serves as an open source replication version of Grounding DINO, but also achieves significant performance improvement based on reconstructed data types, exploring different dataset combinations and initialization strategies. Moreover, we conduct evaluations from multiple dimensions, including OOD, REC, Phrase Grounding, OVD, and Fine-tune, to fully excavate the advantages and disadvantages of Grounding pre-training, hoping to provide inspiration for future work.
code: mm_grounding_dino/README.md
We are excited to announce our latest work on real-time object recognition tasks, RTMDet, a family of fully convolutional single-stage detectors. RTMDet not only achieves the best parameter-accuracy trade-off on object detection from tiny to extra-large model sizes but also obtains new state-of-the-art performance on instance segmentation and rotated object detection tasks. Details can be found in the technical report. Pre-trained models are here.
Task | Dataset | AP | FPS(TRT FP16 BS1 3090) |
---|---|---|---|
Object Detection | COCO | 52.8 | 322 |
Instance Segmentation | COCO | 44.6 | 188 |
Rotated Object Detection | DOTA | 78.9(single-scale)/81.3(multi-scale) | 121 |
Installation
Please refer to Installation for installation instructions.
Getting Started
Please see Overview for the general introduction of MMDetection.
For detailed user guides and advanced guides, please refer to our documentation:
-
User Guides
- Train & Test
- Learn about Configs
- Inference with existing models
- Dataset Prepare
- Test existing models on standard datasets
- Train predefined models on standard datasets
- Train with customized datasets
- Train with customized models and standard datasets
- Finetuning Models
- Test Results Submission
- Weight initialization
- Use a single stage detector as RPN
- Semi-supervised Object Detection
- Useful Tools
- Train & Test
-
Advanced Guides
We also provide object detection colab tutorial and instance segmentation colab tutorial .
To migrate from MMDetection 2.x, please refer to migration.
Overview of Benchmark and Model Zoo
Results and models are available in the model zoo.
Backbones | Necks | Loss | Common |
|
Some other methods are also supported in projects using MMDetection.
FAQ
Please refer to FAQ for frequently asked questions.
Contributing
We appreciate all contributions to improve MMDetection. Ongoing projects can be found in out GitHub Projects. Welcome community users to participate in these projects. Please refer to CONTRIBUTING.md for the contributing guideline.
Acknowledgement
MMDetection is an open source project that is contributed by researchers and engineers from various colleges and companies. We appreciate all the contributors who implement their methods or add new features, as well as users who give valuable feedbacks. We wish that the toolbox and benchmark could serve the growing research community by providing a flexible toolkit to reimplement existing methods and develop their own new detectors.
Citation
If you use this toolbox or benchmark in your research, please cite this project.
@article{mmdetection,
title = {{MMDetection}: Open MMLab Detection Toolbox and Benchmark},
author = {Chen, Kai and Wang, Jiaqi and Pang, Jiangmiao and Cao, Yuhang and
Xiong, Yu and Li, Xiaoxiao and Sun, Shuyang and Feng, Wansen and
Liu, Ziwei and Xu, Jiarui and Zhang, Zheng and Cheng, Dazhi and
Zhu, Chenchen and Cheng, Tianheng and Zhao, Qijie and Li, Buyu and
Lu, Xin and Zhu, Rui and Wu, Yue and Dai, Jifeng and Wang, Jingdong
and Shi, Jianping and Ouyang, Wanli and Loy, Chen Change and Lin, Dahua},
journal= {arXiv preprint arXiv:1906.07155},
year={2019}
}
License
This project is released under the Apache 2.0 license.
Projects in OpenMMLab
- MMEngine: OpenMMLab foundational library for training deep learning models.
- MMCV: OpenMMLab foundational library for computer vision.
- MMPreTrain: OpenMMLab pre-training toolbox and benchmark.
- MMagic: OpenMMLab Advanced, Generative and Intelligent Creation toolbox.
- MMDetection: OpenMMLab detection toolbox and benchmark.
- MMDetection3D: OpenMMLab's next-generation platform for general 3D object detection.
- MMRotate: OpenMMLab rotated object detection toolbox and benchmark.
- MMYOLO: OpenMMLab YOLO series toolbox and benchmark.
- MMSegmentation: OpenMMLab semantic segmentation toolbox and benchmark.
- MMOCR: OpenMMLab text detection, recognition, and understanding toolbox.
- MMPose: OpenMMLab pose estimation toolbox and benchmark.
- MMHuman3D: OpenMMLab 3D human parametric model toolbox and benchmark.
- MMSelfSup: OpenMMLab self-supervised learning toolbox and benchmark.
- MMRazor: OpenMMLab model compression toolbox and benchmark.
- MMFewShot: OpenMMLab fewshot learning toolbox and benchmark.
- MMAction2: OpenMMLab's next-generation action understanding toolbox and benchmark.
- MMTracking: OpenMMLab video perception toolbox and benchmark.
- MMFlow: OpenMMLab optical flow toolbox and benchmark.
- MMEditing: OpenMMLab image and video editing toolbox.
- MMGeneration: OpenMMLab image and video generative models toolbox.
- MMDeploy: OpenMMLab model deployment framework.
- MIM: MIM installs OpenMMLab packages.
- MMEval: A unified evaluation library for multiple machine learning libraries.
- Playground: A central hub for gathering and showcasing amazing projects built upon OpenMMLab.
Top Related Projects
Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
Models and examples built with TensorFlow
Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow
FAIR's research platform for object detection research, implementing popular algorithms like Mask R-CNN and RetinaNet.
YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot