默认你已经安装好环境了。以下教程完全遵照官网。
并且从官网下载好代码包了:https://github.com/matterport/Mask_RCNN,注意不是detrecton那个
直接到setup.py路径,也就是根路径
python3 setup.py install
看下都干啥了:
WARNING:root:Fail load requirements file, so using default ones. running install running bdist_egg running egg_info creating mask_rcnn.egg-info writing mask_rcnn.egg-info/PKG-INFO writing dependency_links to mask_rcnn.egg-info/dependency_links.txt writing top-level names to mask_rcnn.egg-info/top_level.txt writing manifest file 'mask_rcnn.egg-info/SOURCES.txt' reading manifest file 'mask_rcnn.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'mask_rcnn.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py creating build creating build/lib creating build/lib/mrcnn copying mrcnn/parallel_model.py -> build/lib/mrcnn copying mrcnn/model.py -> build/lib/mrcnn copying mrcnn/utils.py -> build/lib/mrcnn copying mrcnn/visualize.py -> build/lib/mrcnn copying mrcnn/config.py -> build/lib/mrcnn copying mrcnn/__init__.py -> build/lib/mrcnn creating build/bdist.linux-x86_64 creating build/bdist.linux-x86_64/egg creating build/bdist.linux-x86_64/egg/mrcnn copying build/lib/mrcnn/parallel_model.py -> build/bdist.linux-x86_64/egg/mrcnn copying build/lib/mrcnn/model.py -> build/bdist.linux-x86_64/egg/mrcnn copying build/lib/mrcnn/utils.py -> build/bdist.linux-x86_64/egg/mrcnn copying build/lib/mrcnn/visualize.py -> build/bdist.linux-x86_64/egg/mrcnn copying build/lib/mrcnn/config.py -> build/bdist.linux-x86_64/egg/mrcnn copying build/lib/mrcnn/__init__.py -> build/bdist.linux-x86_64/egg/mrcnn byte-compiling build/bdist.linux-x86_64/egg/mrcnn/parallel_model.py to parallel_model.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/mrcnn/model.py to model.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/mrcnn/utils.py to utils.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/mrcnn/visualize.py to visualize.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/mrcnn/config.py to config.cpython-36.pyc byte-compiling build/bdist.linux-x86_64/egg/mrcnn/__init__.py to __init__.cpython-36.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO copying mask_rcnn.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying mask_rcnn.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying mask_rcnn.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying mask_rcnn.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO zip_safe flag not set; analyzing archive contents... creating dist creating 'dist/mask_rcnn-2.1-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it removing 'build/bdist.linux-x86_64/egg' (and everything under it) Processing mask_rcnn-2.1-py3.6.egg Copying mask_rcnn-2.1-py3.6.egg to /home/liutian/anaconda3/envs/mask1/lib/python3.6/site-packages Adding mask-rcnn 2.1 to easy-install.pth file Installed /home/liutian/anaconda3/envs/mask1/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg Processing dependencies for mask-rcnn==2.1 Finished processing dependencies for mask-rcnn==2.1
然后用jupyter lab打开demo.ipynb
1 cell1
也就是第一个code cell。
1 看一下./samples/coco/coco.py
2 下载coco工具包
3 注意下载作者改过的适用于python3的版本。https://github.com/waleedka/coco
4 然后改一下/pythonAPI下面的makefile
5 或者你不改成地址+python,你先激活环境再make,总之要保证你的实验安装等等都在该环境下。
至于为什么作者没有直接改,因为这个coco工具包是python2,3通用的。所以作者propose a pull request
make
make install
如果成功了,会在你的环境/lib里面出现pycocotools包
至于下载,作者的代码是可以自动下载的,但是默认下载2014.你也可以选择2017.
他会自动把coco权重下载到项目主目录,也就是/samples 所在目录。你也可以手动下载:
https://github.com/matterport/Mask_RCNN/releases
coco图片:http://cocodataset.org/#download如果要手动下载
然后看下coco.py代码,我选择用jupyter lab来肢解代码。先看下把lib加入到路径。这样你才能找到。
然后看下coco.py怎么用,coco.py是所有的训练以及测试代码,建模不在这里。他负责处理你的命令:
具体的处理代码在__main__
第二个代码改了gpu的运算方式一个GPU运算一张图片
这里改过了config,将会用于下一个建立模型,加载权重的代码段
3 cell3
对于测试,我们需要把模型用原有的结构,但是新建立的参数重新建立一个,
权重就用之前的权重
下一个代码段是解决类别数目不连续的情况,这里掠过直接进如run object detection阶段
用了新参数的config,建立的新的模型,对随机图片进行标注:
这里有两个未知,一个是verbose代表什么
另一个是r的内容
这需要看代码