TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API

TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API

  • (一)下载TensorFlow模型源码
  • (二)将源码导入Anaconda
  • (三)编译proto文件
  • (四)装载research模块
  • (五)添加Slim环境变量
  • (六)测试API

(一)下载TensorFlow模型源码

到GitHub下载模型源码:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第1张图片

(二)将源码导入Anaconda

打开压缩包找到research文件,我们所需要的object detection的源码就在research中,如图所示:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第2张图片
将research文件夹解压到 (你的安装位置/Anaconda3/Lib/site-packages)下,如图所示:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第3张图片
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第4张图片

(三)编译proto文件

到GitHub下载protobuf包:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第5张图片

下载完成后,将压缩包内(/bin)目录下的protoc.exe文件放到(research/)目录下。
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第6张图片
在(research/)目录下按住shift键,点击右键打开powershell窗口,输入命令:

>>>.\protoc.exe .\object_detection\protos\*.proto --python_out=.(注意前后都有一个点)

在这里插入图片描述
编译成功不会显示其他信息,进入(\research\object_detection\protos)目录,发现所有.proto文件已被编译为.py文件。
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第7张图片

(四)装载research模块

打开Anconda Prompt,转到(\research)目录下,输入命令:

>>>python setup.py install

闪出很多行代码后出现如下界面:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第8张图片

(五)添加Slim环境变量

在(**\Anaconda3\Lib\site-packages**)目录下新建文本文档,输入:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第9张图片

保存并重命名为tensorflow_model.pth,如图所示:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第10张图片
要注意查看更改文件名后文件是否真的变为了.pth文件,若重命名没有更改文件类型,请对以下选项进行勾选:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第11张图片

(六)测试API

打开Anconda Prompt,转到(\research)目录下,输入命令:

>>>python object_detection/builders/model_builder_test.py

如图所示:
TensorFlow Object Detection API 技术手册(2)——安装TensorFlow Object Detection API_第12张图片
出现上图说明API已安装成功。
下一节我们开始运行模型源码中自带的示例程序。
TensorFlow Object Detection API 技术手册(3)——运行Demo程序

你可能感兴趣的:(TensorFlow,Object,Detection,API,TensorFlow,人工智能)