环境是:在一台装了tensorflow1.8,python3.5环境的docker容器上进行的。
一台带有tensorflow1.8+python3.5的全新docker容器,lets go~
--------------
更新下命令
apt-get update
pip install Cython
pip install pillow
(已经有了,那就继续,可能还需要)
pip install lxml
apt-get install protobuf-compiler
提示信息:
The following additional packages will be installed:
libprotobuf9v5 libprotoc9v5
The following NEW packages will be installed:
libprotobuf9v5 libprotoc9v5 protobuf-compiler
0 upgraded, 3 newly installed, 0 to remove and 7 not upgraded.
Need to get 620 kB of archives.
After this operation, 2321 kB of additional disk space will be used.
-------------这些装完暂时没毛病
接下来开始同步models代码和cocoapi代码
在网站上可以自行进行git
-------------------------------
进入cocoapi文件夹
cd cocoapi/PythonAPI
make
cp -r pycocotools <path_to_tensorflow>/models/research/
--------------------------------------
# From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.
报错:::::::::::::
信息:
object_detection/protos/ssd.proto:87:3: Expected "required", "optional", or "repeated".
object_detection/protos/ssd.proto:87:12: Expected field name.
object_detection/protos/model.proto: Import "object_detection/protos/ssd.proto" was not found or had errors.
object_detection/protos/model.proto:12:5: "Ssd" is not defined.
-----------------------------------------进行问题解决
方案1
注释了proto下面ssd.proto文件中的87行
//reserved 6;
protoc object_detection/protos/*.proto --python_out=.
没报错,继续跑
##方案2
首先卸载之前的版本
apt-get remove protobuf-compiler
安装3.5.1的proto
-------------------------------------------解决了刚刚那个问题后,继续
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Note: This command needs to run from every new terminal you start. If you wish to avoid running this manually, you can add it as a new line to the end of your ~/.bashrc file.
接下来进行测试
工作目录
zldex/models/research/object_detection/
下面有个object_dection_tutorial.ipynb
测试成功,有一只狗和一个海滩
!!!!!!!!!!!成功了!!!!!!!!!!!!!
-----------------------下一步就是进行训练自己的项目集了~尽情期待----------------------
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:tensorflow 目标检测API的使用日记: - Python技术站