我是靠谱客的博主 忧伤山水,这篇文章主要介绍Detectron2 基准测试 | 十二,现在分享给大家,希望可以做个参考。

作者|facebookresearch 编译|Flin 来源|Github

基准测试

在这里,我们以一些其他流行的开源Mask R-CNN实现为基准,对Detectron2中Mask R-CNN的训练速度进行了基准测试。

设置

  • 硬件:8个带有NVLink的NVIDIA V100。

  • 软件: Python 3.7, CUDA 10.0, cuDNN 7.6.4, PyTorch 1.3.0 (链接(https://download.pytorch.org/whl/nightly/cu100/torch-1.3.0%2Bcu100-cp37-cp37m-linux_x86_64.whl)), TensorFlow 1.15.0rc2, Keras 2.2.5, MxNet 1.6.0b20190820.

  • 模型:端到端R-50-FPN Mask-RCNN模型,使用与Detectron基线配置(https://github.com/facebookresearch/Detectron/blob/master/configs/12_2017_baselines/e2e_mask_rcnn_R-50-FPN_1x.yaml)相同的超参数 。

  • 指标:我们使用100-500次迭代中的平均吞吐量来跳过GPU预热时间。请注意,对于R-CNN样式的模型,模型的吞吐量通常会在训练期间发生变化,因为它取决于模型的预测。因此,该指标不能直接与model zoo中的"训练速度"相比较,后者是整个训练过程的平均速度。

主要结果

工具吞吐率(img / s)
Detectron259
maskrcnn-benchmark51
tensorpack 50
mmdetection41
simpledet39
Detectron19
matterport/Mask_RCNN14
每个实现的链接:
  • Detectron2:https://github.com/facebookresearch/detectron2/
  • maskrcnn-benchmark:https://github.com/facebookresearch/maskrcnn-benchmark/
  • tensorpack:https://github.com/tensorpack/tensorpack/tree/master/examples/FasterRCNN
  • mmdetection:https://github.com/open-mmlab/mmdetection/
  • simpledet:https://github.com/TuSimple/simpledet/
  • Detectron:https://github.com/facebookresearch/Detectron
  • matterport/Mask_RCNN:https://github.com/matterport/Mask_RCNN/

每个实现的详细信息:

  • Detectron2:

    复制代码
    1
    python tools/train_net.py --config-file configs/Detectron1-Comparisons/mask_rcnn_R_50_FPN_noaug_1x.yaml --num-gpus 8
  • maskrcnn-benchmark: 通过sed -i ‘s/torch.uint8/torch.bool/g’ **/*.py使用commit 0ce8f6f与使其与最新的PyTorch兼容。然后,运行

    复制代码
    1
    python -m torch.distributed.launch --nproc_per_node=8 tools/train_net.py --config-file configs/e2e_mask_rcnn_R_50_FPN_1x.yaml

    我们观察到的速度比其model zoo快,这可能是由于软件版本不同所致。

  • tensorpack: 在提交caafda,export TF_CUDNN_USE_AUTOTUNE=0, 然后运行

    复制代码
    1
    mpirun -np 8 ./train.py --config DATA.BASEDIR=/data/coco TRAINER=horovod BACKBONE.STRIDE_1X1=True TRAIN.STEPS_PER_EPOCH=50 --load ImageNet-R50-AlignPadding.npz
  • mmdetection: commit4d9a5f,应用以下diff,然后运行

    复制代码
    1
    ./tools/dist_train.sh configs/mask_rcnn_r50_fpn_1x.py 8

    我们观察到的速度比其model zoo快,这可能是由于软件版本不同所致。

    (diff使其使用相同的超参数-单击展开)
    复制代码
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    diff --git i/configs/mask_rcnn_r50_fpn_1x.py w/configs/mask_rcnn_r50_fpn_1x.py index 04f6d22..ed721f2 100644 --- i/configs/mask_rcnn_r50_fpn_1x.py +++ w/configs/mask_rcnn_r50_fpn_1x.py @@ -1,14 +1,15 @@ # model settings model = dict( type='MaskRCNN', - pretrained='torchvision://resnet50', + pretrained='open-mmlab://resnet50_caffe', backbone=dict( type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, - style='pytorch'), + norm_cfg=dict(type="BN", requires_grad=False), + style='caffe'), neck=dict( type='FPN', in_channels=[256, 512, 1024, 2048], @@ -115,7 +116,7 @@ test_cfg = dict( dataset_type = 'CocoDataset' data_root = 'data/coco/' img_norm_cfg = dict( - mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) + mean=[123.675, 116.28, 103.53], std=[1.0, 1.0, 1.0], to_rgb=False) train_pipeline = [ dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
  • SimpleDet: 在commit9187a1时运行

    复制代码
    1
    python detection_train.py --config config/mask_r50v1_fpn_1x.py
  • Detectron: 运行

    复制代码
    1
    python tools/train_net.py --cfg configs/12_2017_baselines/e2e_mask_rcnn_R-50-FPN_1x.yaml

    请注意,它的许多操作都在CPU上运行,因此性能受到限制。

  • matterport/Mask_RCNN:在commit时3deaec,应用以下diff ,export TF_CUDNN_USE_AUTOTUNE=0, 然后运行

    复制代码
    1
    python coco.py train --dataset=/data/coco/ --model=imagenet

    请注意,此实现中的许多小细节可能与Detectron的标准不同。

(diff使其使用相同的超参数-单击展开)
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
diff --git i/mrcnn/model.py w/mrcnn/model.py index 62cb2b0..61d7779 100644 --- i/mrcnn/model.py +++ w/mrcnn/model.py @@ -2367,8 +2367,8 @@ class MaskRCNN(): epochs=epochs, steps_per_epoch=self.config.STEPS_PER_EPOCH, callbacks=callbacks, - validation_data=val_generator, - validation_steps=self.config.VALIDATION_STEPS, + #validation_data=val_generator, + #validation_steps=self.config.VALIDATION_STEPS, max_queue_size=100, workers=workers, use_multiprocessing=True, diff --git i/mrcnn/parallel_model.py w/mrcnn/parallel_model.py index d2bf53b..060172a 100644 --- i/mrcnn/parallel_model.py +++ w/mrcnn/parallel_model.py @@ -32,6 +32,7 @@ class ParallelModel(KM.Model): keras_model: The Keras model to parallelize gpu_count: Number of GPUs. Must be > 1 """ + super().__init__() self.inner_model = keras_model self.gpu_count = gpu_count merged_outputs = self.make_parallel() diff --git i/samples/coco/coco.py w/samples/coco/coco.py index 5d172b5..239ed75 100644 --- i/samples/coco/coco.py +++ w/samples/coco/coco.py @@ -81,7 +81,10 @@ class CocoConfig(Config): IMAGES_PER_GPU = 2 # Uncomment to train on 8 GPUs (default is 1) - # GPU_COUNT = 8 + GPU_COUNT = 8 + BACKBONE = "resnet50" + STEPS_PER_EPOCH = 50 + TRAIN_ROIS_PER_IMAGE = 512 # Number of classes (including background) NUM_CLASSES = 1 + 80 # COCO has 80 classes @@ -496,29 +499,10 @@ if __name__ == '__main__': # *** This training schedule is an example. Update to your needs *** # Training - Stage 1 - print("Training network heads") model.train(dataset_train, dataset_val, learning_rate=config.LEARNING_RATE, epochs=40, - layers='heads', - augmentation=augmentation) - - # Training - Stage 2 - # Finetune layers from ResNet stage 4 and up - print("Fine tune Resnet stage 4 and up") - model.train(dataset_train, dataset_val, - learning_rate=config.LEARNING_RATE, - epochs=120, - layers='4+', - augmentation=augmentation) - - # Training - Stage 3 - # Fine tune all layers - print("Fine tune all layers") - model.train(dataset_train, dataset_val, - learning_rate=config.LEARNING_RATE / 10, - epochs=160, - layers='all', + layers='3+', augmentation=augmentation) elif args.command == "evaluate":

原文链接:https://detectron2.readthedocs.io/notes/benchmarks.html

欢迎关注磐创AI博客站: http://panchuang.net/

sklearn机器学习中文官方文档: http://sklearn123.com/

欢迎关注磐创博客资源汇总站: http://docs.panchuang.net/

最后

以上就是忧伤山水最近收集整理的关于Detectron2 基准测试 | 十二的全部内容,更多相关Detectron2内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部