ubuntu16.04 TensorFlow目标检测API安装

首先安装pip,然后进行下面的操作

tensorflow现在的安装已经很简单了,直接

pip install tensorflow

然后安装object detection API所需要的库:

sudo apt-get install protobuf-compiler python-pil python-lxml
pip install -i https://pypi.doubanio.com/simple/ ipython==5.3.0
sudo pip install -i https://pypi.doubanio.com/simple/ jupyter
sudo pip install matplotlib

最后,在github上下载models:

git clone https://github.com/tensorflow/models.git

下载下来后文件名是:models-master

注意:这里有点不一样的地方,网上的教程都是直接在models/object_detection去操作的,这个版本的tensorflow这里略有改动,我也是找了好久才找到的,现在的版本把object_detection放在了research文件夹下,另外一个是网上所有基于models文件夹下的操作这里对应的都是models-master,可以下载后改名为models

最后需要把slim这个文件夹加入环境变量不然运行的时候会报错:

  File "model_builder_test.py", line 21, in <module>
    from object_detection.builders import model_builder
ImportError: No module named object_detection.builders

输入下面命令:

vi ~/.bashrc

在最后加入:

export PYTHONPATH=$PYTHONPATH:/******/models-master/research:/*****/models-master/research/slim

这里的/******/models-master/research就是你下载的路径,保存退出

source ~/.bashrc

到这里就好了,运行model_builder_test.py试试,cd到research文件夹下:

python object_detection/builders/model_builder_test.py

不报错出现如下结果就OK了

...........
----------------------------------------------------------------------
Ran 11 tests in 0.047s

OK





猜你喜欢

转载自blog.csdn.net/qq_36810544/article/details/78468644