使用pip安装TensorFlow Object Detection API

使用pip安装TensorFlow Object Detection API

TensorFlow Object Detection API的安装相当麻烦,其 官方安装指导要求使用者先克隆下整个tensorflow/models仓库,然后安装Protobuf,编译出object_detection模块,再使用pip进行安装。虽然从开发者的角度看,此安装方法足以满足在各个系统平台下安装TensorFlow Object Detection API的需求,但对于使用者来说,安装这一个API可能就需要耗费大量的时间。

解决方法

【2021-07-05更新】TensorFlow在TensorFlow 2.2.0时推出了TensorFlow Models高级API的官方PyPI项目,然和遗憾的是,截止当前,TensorFlow官方仍然只在其中纳入Official分支,Community分支和Research分支(Object Detection就在其中)还是没有得到妥善安排。也就是说,我们仍然无法使用pip轻松地安装TensorFlow Object Detection API.

为跟上TensorFlow Object Detection API的官方更新,也为TensorFlow 2.x用户提供便捷安装途径,作出一些更新:

  • 更新项目至PyPI
  • 更新至支持TensorFlow 2.2.0以上版本
  • 更新至支持TensorFlow 1.15.0
  • 移除Python 2.x版本支持
  • 移除此前提供的egg包

最新项目地址:


鉴于上述问题,我将object detection api打包成whl包和egg包,直接使用pip或者easy_install安装即可。

我将打包好的whl包与egg包分享出来,打包环境为Raspbian 9 Stretch(Python环境是3.5.3和Python2.7.13)、Win10 64位(Python环境是3.6.6和Python2.7.15)、Manjaro Linux 64位(Python环境是3.6.6和Python2.7.15)。下载地址:Python_Packages_of_TensorFlow_Object_Detection_API

1. 安装依赖

Tensorflow Object Detection API 需要如下依赖:

[使用包管理工具安装(Linux)/系统级安装(Windows)]

  • protobuf
  • python-tk (tk in Manjaro)

[使用pip安装]

  • tensorflow
  • pillow
  • lxml
  • jupyter
  • matplotlib
  • cython
  • contextlib2

2. 安装下载的whl包或者egg包

安装whl只需执行:

1
pip install xxx.whl

安装egg只需执行:

1
easy_install xxx.egg

3. 使用

使用方法如下:

1
2
3
from object_detection.xxx import xxx
# e.g.:
from object_detection.utils import label_map_util, visualization_utils
Author

Forskamse

Posted on

2018-07-24

Updated on

2022-03-29

Licensed under

Comments