用pip或easy_install在Win10上安装TensorFlow Object Detection API

对于TensorFlow Object Detection API 官方安装指导,我觉得有以下两点可以改进的地方:

1、安装:指导中要求使用者先克隆下整个models仓库,然后安装Protobuf解压出object_detection模块,然后将object_detection模块与slim模块的目录添加到PYTHONPATH中,这一操作在新打开Shell后都需要重新进行(当然,添加到环境变量配置文件中可以免除此麻烦)。

2、使用:在object_detection的ipython tutorial中,使用了如下语句:

from utils import label_map_util, visualization_utils

这里的utils是object_detection下的子模块。如果按照这个写法,运行脚本不在object_detection目录下就无法找到utils。

实际上,可以将object detection api做成whl或egg包,安装使用则要方便的多。
我这里已经将他们打包出来(slim我也一并打包了),Python环境是3.6.6和Python2.7.15(Win10 64位系统)。前往下载:whl_and_egg_of_TF_Object_Detection_API

下载后,请先安装依赖:

  • Protobuf 3.0.0
  • Python-tk
  • Pillow 1.0
  • lxml
  • Jupyter notebook
  • Matplotlib
  • Tensorflow
  • Cython
  • contextlib2

安装whl只需执行:

pip install xxx.whl

即可。

安装egg只需执行:

easy_install xxx.egg

即可。

使用时,请使用标准的引用Python模块的子模块的用法,对于object_detection的utils或是其他子模块,请使用:

from object_detection.utils import label_map_util, visualization_utils

这样运行脚本不管放在哪里,都是可以搜索到utils并执行的。

此法在其他平台上同样可以使用,我在树莓派上也是使用这种方法安装的,只是需要在树莓派上去编译。

猜你喜欢

转载自blog.csdn.net/zbgjhy88/article/details/81183535