maskrcnn-benchmark 工程配置

栏目: Python · 发布时间: 6年前

内容简介:工程:环境:MacOS + pip + torch + maskrcnn-benchmark

maskrcnn-benchmark 是Facebook开源的基准(benchmark)算法,其中包含检测、分割和人体关键点检测。

工程: github.com/facebookres…

Faster R-CNN and Mask R-CNN in PyTorch 1.0

maskrcnn-benchmark 工程配置
  1. 如何使用pip环境配置工程;
  2. 如何使用MacOS的CPU环境配置依赖库;

环境:MacOS + pip + torch + maskrcnn-benchmark

基础配置

下载maskrcnn-benchmark工程

git clone https://github.com/facebookresearch/maskrcnn-benchmark.git
复制代码

virtualenv创建虚拟环境,选择 python 3,同时激活。

virtualenv -p python3 mlp3_venv
复制代码

必须使用Python3.6.8+,推荐使用3.7

或者 使用已有的虚拟环境。

安装依赖包:

pip install ninja yacs cython matplotlib tqdm opencv-python
复制代码

安装PyTorch,直接官网

pip3 install torch torchvision
复制代码
maskrcnn-benchmark 工程配置

依赖库

maskrcnn-benchmark需要两个依赖库cocoapi和apex, 参考略有不同

安装包:pycocotools 2.0, 激活已有的虚拟环境 ,再执行:

git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install
复制代码

安装包:apex 0.1,执行:

git clone https://github.com/NVIDIA/apex.git
cd apex
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install --cpp_ext
复制代码

注意:

MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++
--cuda_ext

安装包:maskrcnn-benchmark 0.1,执行

cd maskrcnn-benchmark
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py build develop
复制代码

测试

·.torch/models 中,下载模型,约458M:

wget https://dl.fbaipublicfiles.com/detectron/37697547/12_2017_baselines/e2e_keypoint_rcnn_R-50-FPN_1x.yaml.08_42_54.kdzV35ao/output/train/keypoints_coco_2014_train%3Akeypoints_coco_2014_valminusminival/generalized_rcnn/model_final.pkl
复制代码

重命名:

mv model_final.pkl _detectron_37697547_12_2017_baselines_e2e_keypoint_rcnn_R-50-FPN_1x.yaml.08_42_54.kdzV35ao_output_train_keypoints_coco_2014_train%3Akeypoints_coco_2014_valminusminival_generalized_rcnn_model_final.pkl
复制代码

预测

Troubleshooting

常见问题的解决方案。

libomp.dylib

遇到如下问题:libomp.dylib无法加载

ImportError: dlopen(python3.7/site-packages/torch/_C.cpython-37m-darwin.so, 9): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: python3.7/site-packages/torch/lib/libshm.dylib
  Reason: image not found
复制代码

安装libomp包:

brew install libomp
复制代码

参考: github.com/pytorch/pyt…

torch.version.cuda.split('.')

GPU的版本,异常:

get_cuda_version
    return tuple(int(x) for x in torch.version.cuda.split('.'))
AttributeError: 'NoneType' object has no attribute 'split'
复制代码

环境是Mac的CPU环境,没有GPU,而在apex源码中,依然寻找GPU,导致Bug,修改源码即可:

/apex/amp/lists/torch_overrides.py 的第69行,增加Try-Except语句,屏蔽异常:

try:
    if utils.get_cuda_version() >= (9, 1, 0):
        FP16_FUNCS.extend(_bmms)
    else:
        FP32_FUNCS.extend(_bmms)
except:
    FP32_FUNCS.extend(_bmms)
复制代码

OK, that's all!


以上所述就是小编给大家介绍的《maskrcnn-benchmark 工程配置》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Iterative Methods for Sparse Linear Systems, Second Edition

Iterative Methods for Sparse Linear Systems, Second Edition

Yousef Saad / Society for Industrial and Applied Mathematics / 2003-04-30 / USD 102.00

Tremendous progress has been made in the scientific and engineering disciplines regarding the use of iterative methods for linear systems. The size and complexity of linear and nonlinear systems arisi......一起来看看 《Iterative Methods for Sparse Linear Systems, Second Edition》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具