windows下tensorflow/objectdetection API环境搭建(基于tensorflow1.14和python3.6)
燃烧的砟子 人气:1此前就听闻室友说tensorflow在windows下坑很多,这次终于亲身领会到了。以下是参考网上大佬的教程以及自己的踩坑史总结出的有效步骤(亲测有效)
1.下载objectdetection所在的models(文件很大,考虑到国内github的速度,以下的资源均给出码云地址,进入后点击克隆/下载,选择下载方式)
https://gitee.com/burningcarbon/tensorflow-models
2.在自己的python环境中安装依赖(给出版本号的必须下载对应版本,否则报错,其余下最新版即可)
tensorflow==1.14.0
numpy==1.16
matplotlib
lxml
pillow
Cython
3. 安装cocoapi(由于该项目官方并不支持windows编译,所以下载大佬的修改版)
下载:地址https://gitee.com/burningcarbon/windows-cocoapi
安装:在命令行下进入cocoapi/PythonAPI目录,执行: python setup.py build_ext install
注意:
以上命令适用于在全局的python环境安装
如果想要安装在虚拟环境中,则需要执行 python安装路径/python.exe setup.py build_ext install
或者激活虚拟环境,在其中执行原命令即可
将PythonAPI目录下的pycocotools复制到research目录下
4.protobuf的编译
下载编译器
进入https://github.com/protocolbuffers/protobuf/releases,在最新版(当前为3.11.4)中,下载Assets中的protoc-3.11.4-win64.zip
进入models/research目录,执行protoc object_detection/protos/*.proto --python_out=.
如果报错提示No such file or directory,则一个一个进行编译
protoc object_detection/protos/anchor_generator.proto --python_out=.
protoc object_detection/protos/argmax_matcher.proto --python_out=.
protoc object_detection/protos/bipartite_matcher.proto --python_out=.
protoc object_detection/protos/box_coder.proto --python_out=.
protoc object_detection/protos/box_predictor.proto --python_out=.
protoc object_detection/protos/calibration.proto --python_out=.
protoc object_detection/protos/eval.proto --python_out=.
protoc object_detection/protos/faster_rcnn.proto --python_out=.
protoc object_detection/protos/faster_rcnn_box_coder.proto --python_out=.
protoc object_detection/protos/grid_anchor_generator.proto --python_out=.
protoc object_detection/protos/hyperparams.proto --python_out=.
protoc object_detection/protos/image_resizer.proto --python_out=.
protoc object_detection/protos/input_reader.proto --python_out=.
protoc object_detection/protos/keypoint_box_coder.proto --python_out=.
protoc object_detection/protos/losses.proto --python_out=.
protoc object_detection/protos/matcher.proto --python_out=.
protoc object_detection/protos/mean_stddev_box_coder.proto --python_out=.
protoc object_detection/protos/model.proto --python_out=.
protoc object_detection/protos/multiscale_anchor_generator.proto --python_out=.
protoc object_detection/protos/optimizer.proto --python_out=.
protoc object_detection/protos/pipeline.proto --python_out=.
protoc object_detection/protos/post_processing.proto --python_out=.
protoc object_detection/protos/preprocessor.proto --python_out=.
protoc object_detection/protos/region_similarity_calculator.proto --python_out=.
protoc object_detection/protos/square_box_coder.proto --python_out=.
protoc object_detection/protos/ssd.proto --python_out=.
protoc object_detection/protos/ssd_anchor_generator.proto --python_out=.
protoc object_detection/protos/string_int_label_map.proto --python_out=.
protoc object_detection/protos/train.proto --python_out=.
安装:
命令行进入models/research目录,执行python setup.py install(python虚拟环境的安装同第二步cocoapi的安装)
5.配置环境变量
此电脑》属性》高级系统设置》环境变量,找到path,添加 models存放路径/models/research/object_detection
7.安装slim
删除 models/research/slim目录下的BUILD文件,然后命令行下cd 到 models/research/slim目录下,运行: python setup.py install.py(python虚拟环境的安装同上)
8.测试
命令行进入models/research路径,运行测试命令python object_detection/builders/model_builder_test.py(python虚拟环境的测试同上)
最后出现以下输出则证明环境安装成功
加载全部内容