CV之detectron2:detectron2的简介、安装、使用方法之详细攻略
目录
detectron2的简介
1、Detectron2—What's New
detectron2的安装
1、Requirements
2、Build and Install Detectron2
1、官方安装
2、Windows下安装
3、Detectron2 Model Zoo and Baselines
COCO Object Detection Baselines
COCO Instance Segmentation Baselines with Mask R-CNN
COCO Person Keypoint Detection Baselines with Keypoint R-CNN
COCO Panoptic Segmentation Baselines with Panoptic FPN
LVIS Instance Segmentation Baselines with Mask R-CNN
Cityscapes & Pascal VOC Baselines
Other Settings
detectron2的使用方法
detectron2的简介
GitHub: Detectron,https://github.com/facebookresearch/Detectron/ Detectron2,https://github.com/facebookresearch/detectron2
Detectron的目的是为目标检测研究提供高质量、高性能的codebase。它的设计是灵活的,以支持快速实施和评估的新研究。Detectron包括以下对象检测算法的实现:
- Mask R-CNN -- Marr Prize at ICCV 2017
- RetinaNet -- Best Student Paper Award at ICCV 2017
- Faster R-CNN
- RPN
- Fast R-CNN
- R-FCN
采用下列主干网络架构:
- ResNeXt{50,101,152}
- ResNet{50,101,152}
- Feature Pyramid Networks (with ResNet/ResNeXt)
- VGG16
附加的主干架构可能很容易实现。有关这些模型的详细信息,请参阅下面的参考资料。
1、Detectron2—What's New
- It is powered by the PyTorch deep learning framework.
- Includes more features such as panoptic segmentation, densepose, Cascade R-CNN, rotated bounding boxes, etc.
- Can be used as a library to support different projects on top of it. We'll open source more research projects in this way.
- It trains much faster.
detectron2的安装 1、Requirements
- Linux or macOS
- Python ≥ 3.6
- PyTorch ≥ 1.3
- torchvision that matches the PyTorch installation. You can install them together at pytorch.org to make sure of this.
- OpenCV, needed by demo and visualization
- pycocotools:
pip install cython; pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
- GCC ≥ 4.9
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
pip install -e .
# (add --user if you don't have permission)
# or if you are on macOS
# MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ pip install -e .
2、Windows下安装
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
python setup.py build develop
相关文章:CV之detectron2:detectron2安装过程记录
3、Detectron2 Model Zoo and Baselines COCO Object Detection Baselines
Faster R-CNN:
Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APmodel iddownloadR50-C41x0.5510.1104.835.7137257644model | metricsR50-DC51x0.3800.0685.037.3137847829model | metricsR50-FPN1x0.2100.0553.037.9137257794model | metricsR50-C43x0.5430.1104.838.4137849393model | metricsR50-DC53x0.3780.0735.039.0137849425model | metricsR50-FPN3x0.2090.0473.040.2137849458model | metricsR101-C43x0.6190.1495.941.1138204752model | metricsR101-DC53x0.4520.0826.140.6138204841model | metricsR101-FPN3x0.2860.0634.142.0137851257model | metricsX101-FPN3x0.6380.1206.743.0139173657model | metricsRetinaNet:
Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APmodel iddownloadR501x0.2000.0623.936.5137593951model | metricsR503x0.2010.0633.937.9137849486model | metricsR1013x0.2800.0805.139.9138363263model | metricsRPN & Fast R-CNN:
Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APprop. ARmodel iddownloadRPN R50-C41x0.1300.0511.5 51.6137258005model | metricsRPN R50-FPN1x0.1860.0452.7 58.0137258492model | metricsFast R-CNN R50-FPN1x0.1400.0352.637.8 137635226model | metrics COCO Instance Segmentation Baselines with Mask R-CNN Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APmask APmodel iddownloadR50-C41x0.5840.1175.236.832.2137259246model | metricsR50-DC51x0.4710.0746.538.334.2137260150model | metricsR50-FPN1x0.2610.0533.438.635.2137260431model | metricsR50-C43x0.5750.1185.239.834.4137849525model | metricsR50-DC53x0.4700.0756.540.035.9137849551model | metricsR50-FPN3x0.2610.0553.441.037.2137849600model | metricsR101-C43x0.6520.1556.342.636.7138363239model | metricsR101-DC53x0.5450.1557.641.937.3138363294model | metricsR101-FPN3x0.3400.0704.642.938.6138205316model | metricsX101-FPN3x0.6900.1297.244.339.5139653917model | metrics COCO Person Keypoint Detection Baselines with Keypoint R-CNN Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APkp. APmodel iddownloadR50-FPN1x0.3150.0835.053.664.0137261548model | metricsR50-FPN3x0.3160.0765.055.465.5137849621model | metricsR101-FPN3x0.3900.0906.156.466.1138363331model | metricsX101-FPN3x0.7380.1428.757.366.0139686956model | metrics COCO Panoptic Segmentation Baselines with Panoptic FPN Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APmask APPQmodel iddownloadR50-FPN1x0.3040.0634.837.634.739.4139514544model | metricsR50-FPN3x0.3020.0634.840.036.541.5139514569model | metricsR101-FPN3x0.3920.0786.042.438.543.0139514519model | metrics LVIS Instance Segmentation Baselines with Mask R-CNNMask R-CNN baselines on the LVIS dataset, v0.5. These baselines are described in Table 3(c) of the LVIS paper.
NOTE: the 1x schedule here has the same amount of iterations as the COCO 1x baselines. They are roughly 24 epochs of LVISv0.5 data. The final results of these configs have large variance across different runs.
Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APmask APmodel iddownloadR50-FPN1x0.2920.1277.123.624.4144219072model | metricsR101-FPN1x0.3710.1247.825.625.9144219035model | metricsX101-FPN1x0.7120.16610.226.727.1144219108model | metrics Cityscapes & Pascal VOC BaselinesSimple baselines for
- Mask R-CNN on Cityscapes instance segmentation (initialized from COCO pre-training, then trained on Cityscapes fine annotations only)
- Faster R-CNN on PASCAL VOC object detection (trained on VOC 2007 train+val + VOC 2012 train+val, tested on VOC 2007 using 11-point interpolated AP)
Ablations for Deformable Conv and Cascade R-CNN:
Namelr schedtrain time (s/iter)inference time (s/im)train mem (GB)box APmask APmodel iddownloadBaseline R50-FPN1x0.2610.0533.438.635.2137260431model | metricsDeformable Conv1x0.3420.0613.541.537.5138602867model | metricsCascade R-CNN1x0.3170.0664.042.136.4138602847model | metricsBaseline R50-FPN3x0.2610.0553.441.037.2137849600model | metricsDeformable Conv3x0.3490.0663.542.738.5144998336model | metricsCascade R-CNN3x0.3280.0754.044.338.5144998488model | metricsAblations for normalization methods: (Note: The baseline uses 2fc
head while the others use 4conv1fc
head. According to the GroupNorm paper, the change in head does not improve the baseline by much)
A few very large models trained for a long time, for demo purposes:
Nameinference time (s/im)train mem (GB)box APmask APPQmodel iddownloadPanoptic FPN R1010.12311.447.441.346.1139797668model | metricsMask R-CNN X1520.28115.150.244.0 18131413model | metricsabove + test-time aug. 51.945.9
detectron2的使用方法 1、demo测试
python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input input1.jpg input2.jpg [--other-options] --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl