欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Tensorflow Object Detection API

程序员文章站 2024-03-14 10:05:10
...

1 首先下载源码

https://github.com/tensorflow/models

2 按照官方说明文档安装 依赖库:

Tensorflow Object Detection API depends on the following libraries:

Protobuf 2.6
Pillow 1.0
lxml
tf Slim (which is included in the “tensorflow/models” checkout)
Jupyter notebook
Matplotlib
Tensorflow

(一般地:直接安装anacnonda基本这些库都会有,不过要手动安装tensoflow)

3 配置环境变量

models/research/ 和 slim 目录需要添加进 PYTHONPATH:
d:\tensorflow\models\research
d:\tensorflow\models\research\slim
(斜体部分按照你放置models文件夹的盘符来定。)

4 安装protoc

我下载的版本是protoc-3.3.0-win32.zip,解压后将bin文件夹中的【protoc.exe】放到C:\Windows

5 编译proto模型(重点)

进入目录:**/models/research/
在命令行下执行下面命令,protobuf 2.6不再支持文件名通配符,吐一下血,建议做个.bat文件,批量执行下述命令,同时将–proto_path中指定的目录添加进PATH环境变量。

【D:\tensorflow\要换成你的电脑放置models文件夹的盘符位置】

protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\anchor_generator.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\argmax_matcher.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\bipartite_matcher.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\box_coder.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\box_predictor.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\eval.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\faster_rcnn.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\faster_rcnn_box_coder.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\grid_anchor_generator.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\hyperparams.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\image_resizer.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\input_reader.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\keypoint_box_coder.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\losses.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\matcher.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\mean_stddev_box_coder.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\model.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\optimizer.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\pipeline.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\post_processing.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\preprocessor.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\region_similarity_calculator.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\square_box_coder.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\ssd.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\ssd_anchor_generator.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\string_int_label_map.proto
protoc --proto_path=D:\tensorflow\models\research\  --python_out=. D:\tensorflow\models\research\object_detection\protos\train.proto

6 检测模型安装成功

在 object_detection/builders/目录下,cmd命令行运行
运行python model_builder_test.py,检测是否安装成功
Tensorflow Object Detection API

相关标签: tensorflow