首先下载项目源码:Mask R-CNN源码
在Ubuntu环境中实验
一、配置环境:
Mask R-CNN是基于Python3,Keras,TensorFlow。
Python 3.4+
TensorFlow 1.3+
Keras 2.0.8+
Jupyter Notebook
Numpy, skimage, scipy, Pillow, cython, h5py
(我使用的是Ubuntu系统,安装Anaconda3。)
一个坑:一开始使用的keras版本是2.2.0,结果发现太高了,发生了错误:
AttributeError: module 'keras.engine.topology' has no attribute 'load_weights_from_hdf5_group_by_name'
,换成了2.1.6版本,pip install keras==2.1.6 )
二、安装
-
安装依赖关系
pip3 install -r requirements.txt
-
运行安装程序
python3 setup.py install
- 下载训练好的权重:mask_rcnn_coco.h5,地址:releases
- 安装pycocotools:
make
生成对应的文件,make之后将生成的pycocotools文件夹复制到samples中的coco文件夹。
(1)Linux地址:https://github.com/waleedka/coco (For Python, run "make" under coco/PythonAPI,
即进入文件夹PythonAPI,$make即可)
(2)windows地址:https://github.com/philferriere/cocoapi
You must have the Visual C++ 2015 build tools on your path (see the repo for additional details)
三、打开jupyter notebook运行demo.ipynb
在windows系统下配置环境类似
不同的是安装pycocotools时,提前下载Visual C++ 2015 build tools,地址:点击下载
安装完成之后在使用命令
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
可以看到屏幕上显示:
Collecting git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
Cloning https://github.com/philferriere/cocoapi.git to c:\users\phil\appdata\local\temp\pip-req-build-jn698z8p
Building wheels for collected packages: pycocotools
Running setup.py bdist_wheel for pycocotools ... done
Stored in directory: C:\Users\Phil\AppData\Local\Temp\pip-ephem-wheel-cache-rde3oevt\wheels\69\2b\12\2fa959e49f73d26cff202c2f4e5079096c9c57c8a8509fd75c
Successfully built pycocotools
Installing collected packages: pycocotools
Successfully installed pycocotools-2.0
安装成功后运行demo.ipynb