{"id":122,"date":"2017-12-28T00:29:36","date_gmt":"2017-12-27T16:29:36","guid":{"rendered":"http:\/\/www.rxxxxx.net\/wordpress\/?p=122"},"modified":"2017-12-28T00:47:55","modified_gmt":"2017-12-27T16:47:55","slug":"mask-r-cnn-imp","status":"publish","type":"post","link":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/2017\/12\/28\/mask-r-cnn-imp\/","title":{"rendered":"Mask R-CNN \u5b9e\u73b0\u4e2d\u9047\u5230\u7684\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"<p>\u5927\u80cc\u666f\uff1a\u7cfb\u7edf\u73af\u5883\u4e3aUbuntu 16.04\uff0canaconda2\/3\uff0c\u8fd9\u4e24\u4e2a\u5b89\u88c5\u65f6\u601d\u8def\u6df7\u4e71\uff0c\u6240\u4ee5anaconda2\u548c3\u5171\u5b58\u65f6\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\u3002\u6709jupyter notebook\u3002anaconda2\u6709pytorch\u3001tensorflow\u3001keras\uff0canaconda3\u53ea\u6709pytorch<\/p>\n<p>Mask R-CNN \u4f7f\u7528\u4e86https:\/\/github.com\/matterport\/Mask_RCNN\u7684\u4ee3\u7801\uff0c\u8fd9\u5957\u4ee3\u7801\u7528jupyter notebook\u505a\u524d\u7aef\uff0c\u4f7f\u7528Python 3, Keras, \u548c TensorFlow\u3002\u6240\u4ee5\u6211\u8981\u5728python3\u4e0a\u914d\u7f6eKeras\u548cTensorflow\uff0c\u5e76\u4e14\u8981\u5728jupyter notebook\u91cc\u8c03\u7528python3\u7684\u5185\u6838\u3002<\/p>\n<p>\u9996\u5148\u662f\u5728jupyter notebook\u91cc\u8c03python3\uff0c\u867d\u7136jupyter\u7ed9\u4e86\u5207\u6362kernel\u7684\u9009\u9879\uff0c\u4f46\u662f\u5207\u5230python3\u4e4b\u540e\u8c03\u7528sys.executable\u53d1\u73b0\u8fd8\u662f\u8fd0\u884c\u7684python2\uff0c\u6000\u7591\u662fjupyter\u914d\u7f6e\u7684python3\u8def\u5f84\u6307\u5411\u6709\u95ee\u9898\u3002<\/p>\n<p>jupyter\u5bf9\u6bcf\u4e00\u4e2a\u5185\u6838\u90fd\u6709\u4e00\u4e2ajson\uff0cpython3\u7684\u5185\u6838\u901a\u5e38\u4e3a\/usr\/local\/share\/jupyter\/kernels\/python3\/kernel.json\uff0c\u7f16\u8f91\u4e4b\u540e\u53d1\u73b0\u5185\u5bb9\u4e3a\uff1a<\/p>\n<pre><code>{\r\n\u00a0 \u00a0 \u00a0\"argv\": [\r\n\u00a0 \u00a0 \u00a0\"python\",\r\n\u00a0 \u00a0 \u00a0\"-m\",\r\n\u00a0 \u00a0 \u00a0\"ipykernel_launcher\",\r\n\u00a0 \u00a0 \u00a0\"-f\",\r\n\u00a0 \u00a0 \u00a0\"{connection_file}\"\r\n\u00a0 \u00a0 \u00a0],\r\n\u00a0 \u00a0 \u00a0\"display_name\": \"Python 3\",\r\n\u00a0 \u00a0 \u00a0\"language\": \"python\"\r\n }<\/code><\/pre>\n<p>\u4ed6\u8c03\u7528python3\u7684\u547d\u4ee4\u53ea\u662f\u201cpython\u201d\uff0c\u800c\u5728\u6211\u7684\u673a\u5668\u4e0a\u201cpython\u201d\u6307\u5411\u7684\u662fanaconda2\uff0c\u95ee\u9898\u6210\u529f\u5b9a\u4f4d\u3002\u5c06<br \/>\n\u201cpython\u201d\u6539\u4e3a\u201c\/home\/myusername\/anaconda3\/bin\/python\u201d\u4e4b\u540e\u95ee\u9898\u89e3\u51b3\u3002\u6ce8\u610f\u8fd9\u91cc\u4f3c\u4e4e\u4e0d\u80fd\u4f7f\u7528\u201c~\u201d\u6307\u4ee3\u7528\u6237\u76ee\u5f55<\/p>\n<p>\u6210\u529f\u5728jupyter\u91cc\u8fd0\u884cpython3\u4e4b\u540e\u5c31\u662f\u5b89\u88c5\u9700\u8981\u7684\u5404\u79cd\u5e93\u4e86\u3002pytorch\u597d\u8bf4\uff0c\u6309\u7167\u5b98\u7f51\u63d0\u793a\u5b89\u88c5\u5c31\u53ef\u4ee5\u3002\u4e0d\u8fc7\u6709\u4e00\u70b9\u8981\u6ce8\u610f\uff0c\u5982\u679c\u7528pip\u7684\u8bdd\uff0c\u5982\u679c\u4e0dsudo\u4f1a\u63d0\u793a\u6743\u9650\u4e0d\u591f\uff0c\u4f46\u662f\u5982\u679csudo\u7684\u8bdd\uff0c\u5b9e\u9645\u4e0a\u7cfb\u7edf\u4f1a\u8dd1\u53bb\u6267\u884c\/usr\/bin\/python3\uff0c\u800c\u4e0d\u662fanaconda\u7684python3\uff0c\u8fd9\u4e2a\u65f6\u5019\u8981\u6307\u660epython\u7684\u7edd\u5bf9\u8def\u5f84\uff0c\u4f8b\u5982<\/p>\n<pre><code>sudo ~\/anaconda3\/bin\/python -m pip install pytorch<\/code><\/pre>\n<p>\u540c\u6837\u5730\u4f7f\u7528\u4e0a\u9762\u7684\u65b9\u6cd5\u5b89\u88c5tensorflow-gpu\uff0c\u4f46\u662fimport tensorflow\u5931\u8d25\uff0c\u63d0\u793a\uff1a<code><\/code><\/p>\n<pre><code>ImportError: libcudnn.so.6: cannot open shared object file: No such file or directory<\/code><code>\r\n<\/code><\/pre>\n<p>\u539f\u56e0\u662f\u4e4b\u524d\u5728python2\u91cc\u7528\u7684tensorflow\u4f3c\u4e4e\u53ea\u7528\u4e86libcudnn.so.5\uff0c\u6240\u4ee5\u6309\u7167<a href=\"https:\/\/stackoverflow.com\/questions\/42013316\/after-building-tensorflow-from-source-seeing-libcudart-so-and-libcudnn-errors\/45787225#45787225\">https:\/\/stackoverflow.com\/questions\/42013316\/after-building-tensorflow-from-source-seeing-libcudart-so-and-libcudnn-errors\/45787225#45787225\u00a0 <\/a><\/p>\n<p>\u91cc\u7684\u65b9\u6cd5\u5c06\u7f3a\u5931\u7684libcudnn.so.6\u7b49\u6587\u4ef6\u8865\u5168\u5373\u53ef\u3002<\/p>\n<p>\u8865\u5168\u4e86\u4e4b\u540e\u518d\u5c1d\u8bd5import tensorflow\uff0c\u51fa\u73b0\u4e86\u65b0\u7684\u63d0\u793a\uff1a<\/p>\n<pre class=\"lang-html prettyprint prettyprinted\"><code><span class=\"pln\">RuntimeWarning: compiletime version 3.5 of module 'tensorflow.python.framework.fast_tensor_util' \r\ndoes not match runtime version 3.6 <\/span><\/code><\/pre>\n<p>\u8fd9\u662f\u7531\u4e8etensorflow 1.4\u4f3c\u4e4e\u57283.6\u7684\u652f\u6301\u4e0a\u6709\u95ee\u9898\uff0c\u5f3a\u884c\u5b89\u88c51.3\u5373\u53ef<\/p>\n<pre class=\"lang-html prettyprint prettyprinted\"><code><span class=\"pln\">sudo ~\/anaconda3\/bin\/python -m pip install tensorflow-gpu==1.3.0<\/span><\/code><\/pre>\n<p>\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\u4e4b\u540eimport tensorflow\u5c31\u6ca1\u95ee\u9898\u4e86\u3002\u518d\u5b89\u88c5keras\u4e5f\u6ca1\u95ee\u9898\u3002\u7136\u540e\u5c31\u53ef\u4ee5git clone\u4ee3\u7801\u4e0b\u6765\u4e86\u3002\u4f46\u662f\u8fd0\u884cdemo.ipynb\u65f6\u4ed6\u63d0\u793a\u6ca1\u6709pycocotools\u8fd9\u4e2a\u5305\uff0c\u90a3\u6211\u4eec\u5c31\u88c5\u5427\u3002\u8fd9\u4e2a\u5305\u662fms coco\u6570\u636e\u96c6\u7684\u8c03\u7528\u63a5\u53e3\uff0c\u5e76\u6ca1\u6709\u53d1\u5e03\u5728pypi\u4e0a\uff0c\u6240\u4ee5\u8981\u5355\u72ec\u4e0b\u8f7d<\/p>\n<pre class=\"lang-html prettyprint prettyprinted\"><code><span class=\"pln\">git clone https:\/\/github.com\/pdollar\/coco\r\n<span class=\"hljs-built_in\">cd<\/span> coco\/PythonAPI\r\nmake install<\/span><\/code><\/pre>\n<p>\u8fd9\u4e2a\u65f6\u5019\u62a5\u9519\uff1a<\/p>\n<pre class=\"default prettyprint prettyprinted\"><code><span class=\"pln\">unable to execute <\/span><span class=\"str\">'x86_64-conda_cos6-linux-gnu-gcc'<\/span><span class=\"pun\">:<\/span> <span class=\"typ\">No<\/span><span class=\"pln\"> such file <\/span><span class=\"kwd\">or<\/span><span class=\"pln\"> directory\r\nerror<\/span><span class=\"pun\">:<\/span><span class=\"pln\"> command <\/span><span class=\"str\">'x86_64-conda_cos6-linux-gnu-gcc'<\/span><span class=\"pln\"> failed <\/span><span class=\"kwd\">with<\/span> <span class=\"kwd\">exit<\/span><span class=\"pln\"> status <\/span><span class=\"lit\">1<\/span><\/code><\/pre>\n<p>\u8fd9\u662f\u7531\u4e8e\u6211\u7684anaconda2\u7248\u672c\u4e3a4.4\uff0c\u6b63\u597danaconda2\u5728\u8fd9\u4e2a\u7248\u672c\u9644\u8fd1\u4f7f\u7528\u4e86\u5947\u602a\u7684\u7f16\u8bd1\u5668\u540d\u79f0\uff0c\u6240\u4ee5\u8ba9pycocotools\u7684setup.py\u548cMakefile\u4e5f\u8c03\u7528\u4e86\u8fd9\u4e2a\u5947\u602a\u7684\u7f16\u8bd1\u5668\u540d\u5b57\u3002\u6211\u4eec\u6253\u5f00Makefile\uff1a<\/p>\n<pre class=\"lang-html prettyprint prettyprinted\"><code><span class=\"pln\">all:\r\n \u00a0\u00a0\u00a0# install pycocotools locally\r\n    python setup.py build_ext --inplace\r\n    rm -rf build\u00a0\r\ninstall:\r\n    # install pycocotools to the Python site-packages\r\n    python setup.py build_ext install\r\n    rm -rf build<\/span><\/code><\/pre>\n<p>\u95ee\u9898\u540c\u6837\u51fa\u5728\u76f4\u63a5\u4f7f\u7528\u201cpython\u201d\u8c03\u7528\u4e86\u9519\u8bef\u7684python\u89e3\u91ca\u5668\u3002\u6211\u4eec\u4e5f\u5c06\u201cpython\u201d\u6539\u4e3aanaconda3\u7684\u89e3\u91ca\u5668\u7edd\u5bf9\u8def\u5f84\uff0c\u95ee\u9898\u89e3\u51b3~<\/p>\n<p>&nbsp;<\/p>\n<p>\u7136\u540e\u4ee3\u7801\u5c31\u4e00\u5207\u6b63\u5e38\u4e86\uff0chave fun~<\/p>\n<p>&nbsp;<\/p>\n<p>\u5982\u679c\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u5e2e\u52a9\uff0c\u6216\u8005\u6ca1\u6709\u5e2e\u52a9\uff0c\u90fd\u8bf7\u7559\u8a00\u4ea4\u6d41~<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5927\u80cc\u666f\uff1a\u7cfb\u7edf\u73af\u5883\u4e3aUbuntu 16.04\uff0canaconda2\/3\uff0c\u8fd9\u4e24\u4e2a\u5b89\u88c5\u65f6\u601d\u8def\u6df7\u4e71\uff0c\u6240\u4ee5anaconda [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/122"}],"collection":[{"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=122"}],"version-history":[{"count":6,"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":128,"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/122\/revisions\/128"}],"wp:attachment":[{"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.rxxxxx.net\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}