0
点赞
收藏
分享

微信扫一扫

TensorFlow2.x目标检测API安装配置步骤详细教程


    TensorFlow Object Detection API支持TensorFlow2.x版本已经有一段时间了,这里对安装配置步骤做详细说明。

TensorFlow2.x目标检测API安装配置步骤详细教程_python

TensorFlow2.x目标检测API安装配置步骤详细教程_python_02

安装步骤也可以参考如下两个链接:

​​https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md​​

​​https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/ ​​

    有些步骤可能有点繁琐或者容易出错,这里整理一下安装步骤和常见的问题解决方法如下:

一、安装Python和TensorFlow-GPU 2.2.0版本。笔者这里使用Python3.7.5和TensorFlow-GPU 2.2.0,安装方法可以参考下面博客 ​​TensorFlow2.x GPU版安装与CUDA版本选择指南​​

二、下载Object Detection API文件并解压。https://github.com/tensorflow/models,将解压后的目录重命名保存到指定目录,下载 解压后是models-master文件夹,重命名为models,然后放到指定目录,比如:D:\TensorFlow\models

TensorFlow2.x目标检测API安装配置步骤详细教程_python_03

三、配置目标检测API目录。在python安装目录的Lib\site-packages下创建tensorflow.pth文件,在其中添加Object Detection API文件路径:

D:\TensorFlow\models\
D:\TensorFlow\models\research\
D:\TensorFlow\models\research\object_detection\
D:\TensorFlow\models\research\slim\

四、安装Protobuf。下载地址:https://github.com/protocolbuffers/protobuf/releases/tag/v3.12.3 ,下载后加压到指定目录,并将bin目录添加到系统环境变量如下:

TensorFlow2.x目标检测API安装配置步骤详细教程_指定目录_04

TensorFlow2.x目标检测API安装配置步骤详细教程_tensorflow_05

 然后在models/research目录cmd窗口输入指令:protoc object_detection/protos/*.proto --python_out=.

 成功了会在D:\TensorFlow\models\research\object_detection\protos下面生成一些py文件

五、安装缺失模块。在models/research目录下打开cmd窗口,输入python object_detection/builders/model_builder_tf2_test.py 回车运行会提示缺模块

① ModuleNotFoundError: No module named 'matplotlib' 

     ------直接安装 pip install matplotlib

② ModuleNotFoundError: No module named 'yaml'

     ------直接安装 pip install yaml提示找不到yaml安装包,换指令pip install pyyaml

③ ModuleNotFoundError: No module named 'tf_slim'

    ------直接安装pip install tf-slim (注意版本tf-slim-1.1.0,1.0会出错)

六、运行测试。在TensorFlow\models\research目录下cmd运行python object_detection/builders/model_builder_tf2_test.py

如果没有报错,运行成功提示如下:

TensorFlow2.x目标检测API安装配置步骤详细教程_指定目录_06

TensorFlow2.x目标检测API安装配置步骤详细教程_python_07

举报

相关推荐

0 条评论