Python教程网
--左手Python,右手AI!

如何在windows系统上安装Tensorflow Object Detection API?

前言

都说Linux是最适合程序员使用的操作系统,这话还真不假。

之前一直在云服务器上跑代码,近期接手了师兄的台式机(GTX 1050),虽然配置很渣,但想在本地玩玩看,于是乎先安装一波Tensorflow Object Detection API。

之前云服上配置的时候十分顺利,可是到了windows下很容易进坑,这里简单整理下踩坑后的总结。

目录

大致的安装步骤其实差不多,只是在些细节上会遇到坑,在这些坑上注意避免即可。

  • 从GitHub下载官方的存储库
  • 依赖库的安装
  • 用protobuf解析API中的一些文件
  • 测试API是否安装成功
  • 运行官方教程中的代码查看效果

具体操作

不谈基本依赖库和框架版本的教程就是耍流氓!

相信在各种博客上查找教程的小伙伴们一定有这种感觉吧。所以先说下自己的版本情况:
– Tensorflow-gpu-1.10.0 + cuda9 + cuDNN7
– Python3.6.8
– Protobuf3.7.1

从GitHub下载官方存储库

官方github网站链接为:
https://github.com/tensorflow/models

在本地建立文件夹用于存储(这个自定义即可),然后将官方存储库下载到本地,至于是下载压缩包还是直接git取决于个人喜好就好。下图即为小詹的本地截图。

依赖库的安装

想运行官方教程,需要的第三方库有:pillow、lxml、Cython、jupyter、matplotlib、pandas等,如果使用anoconda安装的Python,大多数第三方库已经有啦。缺少第三方库的直接pip install就好了。

另外就是安装TensorFlow,CUDA,cuDNN了,这里主要是注意版本对应关系,其他的问题应该不大。

用protobuf解析API中的一些文件

官方API需要使用一些proto文件,这里需要用protobuf将其转换为Python的可运行代码格式。这些文件放置在官方库的research\object_detection\protos路径下。

这里需要使用protobuf将其转换格式,官方给的转换执行语句是:

#小詹提醒:在model/research路径下打开cmd执行下语句
protoc object_detection/protos/*.proto --python_out=.

这里就涉及到protoc到版本了,如前面所述,小詹下载TensorFlow-gpu1.10.0点时候自带了protobuf3.7.1。直接执行这语句会提示:No such file.

这是一个小坑了,查阅到官方的issue,有前辈们说说版本小bug,不支持正则查找。有两种方法,小詹亲测有效。

方法一:去官网查找下载使用protoc3.4.0版本,官方地址:https://github.com/protocolbuffers/protobuf/releases
方法二:不支持正则,可以考虑一个个proto文件进行处理转换,这个在量不大的时候可以这么做。小詹这里把逐个进行转换命令语句放置在下面,如果你需要可以复制粘贴即可。

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

经过小坑,选择解决方法后应该就处理完所有的proto文件,转换成啦对应的py文件。

测试API是否安装成功

测试API是否安装成功可以在research路径下执行下列语句:

python object_detection/builders/model_builder_test.py

这里肯定是不行的,因为还没有将必要的路径加入PYTHON环境中。会出现各种报错,诸如不能导入****pb之类的或者导入错误之类的。

网上教程有的说要先在Anaconda\Lib\site-packages 文件夹下新建一个txt文件,输入对应路径后改名tensorflow_model.pth的,也有其他说法的。

小詹最后亲测有效的是直接添加设置即可。将\models;\models\research;\models\research\slim;三个路径加入pythonpath中,代码执行如下:(注意前方路径要换成你自己的)

set PYTHONPATH=E:\Jan_Project\tf_models;E:\Jan_Project\tf_models\research;E:\Jan_Project\tf_models\research\slim

设置后再次执行测试语句没有报错,表示设置完成。

运行官方教程中的代码查看效果

官方的目标检测教程路径在第一步git到本地的文件中,路径为:

models/research/object_detection/object_detection_tutorial.ipynb

可以中jupyter中打开运行,成功执行结果如下图。

以上就是中windows系统安装Tensorflow Object Detection API的过程。注意版本问题和环境问题即可。

祝好!

推荐阅读:
动态规划问题学习笔记!

赞(18)
未经允许不得转载:Python教程网 » 如何在windows系统上安装Tensorflow Object Detection API?
分享到: 更多 (0)

评论 117

  1. #1

    厉害

    匿名2年前 (2019-05-05)回复
  2. #2

    亲测set需要每次都执行一次

    匿名2年前 (2019-05-06)回复
    • 请问设置python路径是啥

      匿名2年前 (2019-05-23)回复
  3. #3

    请问设置pythonpath是啥,是已有的python路径还是输入命令就行?

    匿名2年前 (2019-05-23)回复
  4. #4

    在windows系统上安装Tensorflow Object Detection API
    tnsolwnbdj http://www.g6t307p15f3flanv54t06824clh1ts1vs.org/
    [url=http://www.g6t307p15f3flanv54t06824clh1ts1vs.org/]utnsolwnbdj[/url]
    atnsolwnbdj

    匿名4个月前 (09-27)回复
  5. #5
  6. #6

    Grain Metal Detector

    匿名4个月前 (10-10)回复
  7. #7
  8. #8

    Double Suction Split Case Pump

    匿名4个月前 (10-11)回复
  9. #9

    7ml glass vial

    匿名3个月前 (10-13)回复
  10. #10

    Agricultural Fungicide

    匿名3个月前 (10-13)回复
  11. #11

    Curved Treadmill

    匿名3个月前 (10-14)回复
  12. #12

    4 Axis Cnc Milling Machine

    匿名3个月前 (10-15)回复
  13. #13

    Airsoft Red Dot Sights

    匿名3个月前 (10-15)回复
  14. #14

    Beans Packaging Machine

    匿名3个月前 (10-16)回复
  15. #15
  16. #16

    Benq Interactive Flat Panel Pdf

    匿名3个月前 (10-18)回复
  17. #17

    21 Inches Ukulele

    匿名3个月前 (10-19)回复
  18. #18

    Unions

    匿名3个月前 (10-19)回复
  19. #19

    Hydraulic Pressure Pipe Factory

    匿名3个月前 (10-24)回复
  20. #20

    Hpmc Factory

    匿名3个月前 (10-29)回复
  21. #21

    New York: Churchill Livingstone. http://saleviabuy.com viagra

    匿名3个月前 (10-30)回复
  22. #22

    44083-61000 Hydraulic Gear Pump

    匿名3个月前 (11-01)回复
  23. #23

    Fiber Bulk

    匿名3个月前 (11-03)回复
  24. #24

    Home Decor Craft

    匿名3个月前 (11-03)回复
  25. #25

    How the virus remains in the body or subsequently re-activates, is not well understood.
    is there a generic viagra – genqpviag.com, generic for
    viagra

    匿名3个月前 (11-05)回复
  26. #26

    This type of therapy addresses difficulties with attention, learning new information, memory, time management, planning, organization, and
    problem-solving. can i buy viagra online with a prescription [llviabest.com] buying
    online viagra

    匿名3个月前 (11-05)回复
  27. #27

    Hardware Cable Price

    匿名3个月前 (11-07)回复
  28. #28

    Vertical Suction Pump

    匿名3个月前 (11-09)回复
  29. #29
  30. #30
  31. #31

    Cable Knit Hat

    匿名2个月前 (11-15)回复
  32. #32

    alternative to viagra can i buy viagra over the counter in the us generic viagra sildenafil citrate

    匿名2个月前 (11-16)回复
  33. #33

    quem teve trombose pode tomar viagra o q o viagra faz existe alguna pastilla viagra para mujeres

    匿名2个月前 (11-16)回复
  34. #34
  35. #35

    preço viagra feminino viagra farmacia similares hillbilly viagra

    匿名2个月前 (11-17)回复
  36. #36

    Hotel Bath Gel Price

    匿名2个月前 (11-17)回复
  37. #37

    can u drink alcohol when taking viagra https://purevigra.com the rock viagra

    匿名2个月前 (11-18)回复
  38. #38

    what happens when you take viagra with nitroglycerin https://buybuyviamen.com/ viagra advert

    匿名2个月前 (11-18)回复
  39. #39

    viagra sale https://paradiseviagira.com viagra geneirc

    匿名2个月前 (11-19)回复
  40. #40

    is viagra over the counter https://wowviaprice.com/ viagra best price

    匿名2个月前 (11-19)回复
  41. #41

    Cheap viagra generic best price https://lightvigra.com/ australia viagra over the counter

    匿名2个月前 (11-20)回复
  42. #42

    Viagra gel australia hopeviagrin.com sildenafil online prices

    匿名2个月前 (11-21)回复
  43. #43

    how to buy viagra over the counter uk cheapest sildenafil 100mg uk viagra uk fast delivery

    匿名2个月前 (11-21)回复
  44. #44

    Viagra online purchase https://mygoviagar.com/ buy viagra
    with mastercard

    匿名2个月前 (11-21)回复
  45. #45

    How to get viagra united states https://miraclevigra.com sildenafil 20 mg pharmacy

    匿名2个月前 (11-21)回复
  46. #46

    Bulk Tin Boxes

    匿名2个月前 (11-22)回复
  47. #47
  48. #48

    viagra soft pills 20 mg sildenafil 680 viagra online usa

    匿名2个月前 (11-24)回复
  49. #49

    viagra coating difference between viagra and levitra viagra О±ОіОїПЃО± ОµО»О»О±ОґО±

    匿名2个月前 (11-25)回复
  50. #50

    viagra online in usa generic viagra pills online sildenafil canadian online pharmacy

    匿名2个月前 (11-26)回复
  51. #51

    finasteride with viagra how to get viagra in dublin will doctors prescribe viagra young men

    匿名2个月前 (11-26)回复
  52. #52

    Permalloy Covers

    匿名2个月前 (11-26)回复
  53. #53

    order generic viagra uk viagra cream price in india sildenafil cost india

    匿名2个月前 (11-27)回复
  54. #54

    Generator Power Station

    匿名2个月前 (11-27)回复
  55. #55

    viagra express viagra overnight mastercard canada canadian viagra using paypal

    匿名2个月前 (11-28)回复
  56. #56

    essays on canadian writing psychology research proposals best essay website for kids

    匿名2个月前 (11-29)回复
  57. #57

    Hour Meter

    匿名2个月前 (11-29)回复
  58. #58
  59. #59

    writing an introduction speech write case study college admission essay help

    匿名2个月前 (11-30)回复
  60. #60

    assignment problem solver creative writing essay format write a literature review for me

    匿名2个月前 (11-30)回复
  61. #61
  62. #62

    cheap essay writing service us ged essay writing questions term paper writing

    匿名2个月前 (12-01)回复
  63. #63

    essays about trump music for essay writing essay reflection

    匿名2个月前 (12-01)回复
  64. #64

    Dissertation methodology example https://dissertationhelpvfh.com/ dissertation assistance service

    匿名2个月前 (12-01)回复
  65. #65

    Buy an essay online cheap https://buyessayhelpbtg.com
    buy essays online cheap

    匿名2个月前 (12-01)回复
  66. #66

    college essay conclusion essay scholarships for college purpose of writing an essay

    匿名2个月前 (12-02)回复
  67. #67

    basics of essay writing university essay outline autobiography essay for college

    匿名2个月前 (12-02)回复
  68. #68

    brand viagra over the counter viagra washington state viagra persription

    匿名2个月前 (12-03)回复
  69. #69

    Air Conditioner Contactor

    匿名2个月前 (12-04)回复
  70. #70

    Approved Mini Kid Kayak

    匿名2个月前 (12-05)回复
  71. #71

    Waterproof Materials

    匿名2个月前 (12-05)回复
  72. #72

    generic cialis canada is generic cialis safe cialis no prescription paypal

    匿名2个月前 (12-09)回复
  73. #73

    cialis in vegas get online cialis without prescription overnight cialis legal online

    匿名2个月前 (12-09)回复
  74. #74

    cialis mit paypal bezahlen generic cialis india viagra • cialis •

    匿名2个月前 (12-10)回复
  75. #75

    supreme suppliers cialis daily cialis reviews cialis from usa

    匿名1个月前 (12-12)回复
  76. #76

    viagra triangle te viagra on sale over the counter viagra for sale in ireland

    匿名1个月前 (12-12)回复
  77. #77

    buy viagra viagra fedex overnight milwaukee generac viagra

    匿名1个月前 (12-13)回复
  78. #78

    free viagra online in canada viagra brand online sensitivity cheap canadian viagra

    匿名1个月前 (12-13)回复
  79. #79

    viagra overnite shipping pfizer viagra without presciption viagra lowest priced

    匿名1个月前 (12-14)回复
  80. #80

    formule viagra viagra générique prix prix du viagra en pharmacie en france
    comment préparer le viagra naturel ?

    匿名1个月前 (12-16)回复
  81. #81

    Wonderful items from you, man. I have be aware your stuff previous to and you’re
    just extremely excellent. I really like what you’ve received right here, really like
    what you are saying and the way during which you assert it.
    You are making it enjoyable and you continue
    to care for to stay it wise. I can not wait to read far more from you.

    This is actually a terrific website.

    Also visit my web site … porn videos

    匿名1个月前 (12-17)回复
  82. #82

    I’m impressed, I must say. Seldom do I encounter a blog that’s both
    educative and engaging, and let me tell you, you have hit
    the nail on the head. The problem is an issue that too
    few folks are speaking intelligently about. Now i’m very happy I found this in my search for something relating to this.

    Have a look at my webpage – mom sex son out dad1000html

    匿名1个月前 (12-17)回复
  83. #83

    This piece of writing is truly a good one it helps new web users, who
    are wishing for blogging.

    My web blog: porn videos

    匿名1个月前 (12-17)回复
  84. #84

    Интересные факты: гидра ссылка

    匿名1个月前 (12-17)回复
  85. #85

    This is very interesting, You are a very skilled blogger.
    I’ve joined your rss feed and look forward to seeking more
    of your magnificent post. Also, I’ve shared your web site in my social networks!

    Also visit my blog post porn videos

    匿名1个月前 (12-17)回复
  86. #86

    herbal viagra london drugs viagra viagra gold

    匿名1个月前 (12-17)回复
  87. #87

    viagra vrouwen acheter viagra pas cher belgique il met du viagra dans la boisson de sa copine
    ou acheter viagra sans ordonnance forum

    匿名1个月前 (12-17)回复
  88. #88

    cialis lapeyronie ou acheter du cialis viagra cialis levitra lequel choisir
    ou acheter cialis

    匿名1个月前 (12-18)回复
  89. #89

    cialis champagne cialis pharmacie france comparaison viagra cialis levitra spedra
    combien de temps avant un rapport faut il prendre cialis

    匿名1个月前 (12-18)回复
  90. #90

    Pediatric Once Daily Dosing Of Amoxicillin LiseMirl buy cialis online 20mg cackVial all day chemist cialis

    匿名1个月前 (12-19)回复
  91. #91

    prednisone dose asthma prednisone how to stop taking prednisone
    what side effects of prednisone

    匿名1个月前 (12-19)回复
  92. #92

    cialis levitra viagra sample pack levitra brand levitra vs levitra
    levitra photo

    匿名1个月前 (12-20)回复
  93. #93

    I like what you guys are up also. Such intelligent work and reporting! Keep up the excellent works guys I’ve incorporated you guys to my blogroll. I think it will improve the value of my web site :).

    匿名1个月前 (12-25)回复
  94. #94

    viagra pde5 acheter viagra site serieux pour commander viagra
    ou acheter le viagra

    匿名1个月前 (12-25)回复
  95. #95

    viagra dauer viagra legal kaufen viagra in polen kaufen
    wann wirkt viagra 100

    匿名4周前 (12-30)回复
  96. #96

    viagra prescription cost australia
    do i need prescription to buy cialis in mexico
    cheapest vardenafil online baism bralt

    匿名3周前 (01-03)回复
  97. #97

    cialis 100mg china
    best viagra online pharmacy
    cialis 20 mg didnt work baism bralt

    匿名3周前 (01-04)回复
  98. #98

    hello guos 9128738516

    匿名3周前 (01-05)回复
  99. #99

    buy cheap pfizer viagra online
    pfizer viagra 100mg price
    buy kamagra online in australia baism bralt

    匿名3周前 (01-06)回复
  100. #100

    viagra cialis where to buy
    viagra offer
    canada sildenafil citrate baism bralt

    匿名2周前 (01-08)回复
  101. #101

    canada rx pharmacy best drugstore face moisturizer pharmacies

    匿名2周前 (01-09)回复
  102. #102

    pharmacy discount card 24 hr pharmacy near me ed pills online

    匿名2周前 (01-09)回复
  103. #103

    best drugstore bb cream drug store news ce the peoples pharmacy

    匿名2周前 (01-10)回复
  104. #104

    pharmacy coupons ed medications erectile dysfunction causes

    匿名2周前 (01-11)回复
  105. #105

    approved canadian online pharmacies discount pharmacy card best online pharmacy

    匿名2周前 (01-11)回复
  106. #106

    medicine for erectile us online pharmacy 24 hour pharmacy

    匿名2周前 (01-11)回复
  107. #107

    on line pharmacy best drugstore eye cream 24 hr pharmacy

    匿名2周前 (01-12)回复
  108. #108

    generic cialis cod
    where to buy viagra in pattaya
    web md generic cialis baism bralt

    匿名2周前 (01-13)回复
  109. #109

    viagra tablets for sale in uk
    viagra samples overnight
    buy zyban tablets baism bralt

    匿名2周前 (01-14)回复
  110. #110

    cialis erectile dysfunction Buy Levitra Online best site to buy viagra online
    where to buy kamagra oral jelly in melbourne

    匿名1周前 (01-15)回复
  111. #111

    I also conceive thus, perfectly written post! .

    匿名1周前 (01-17)回复
  112. #112

    viagra 1000mg viagra 25 mg vente de viagra generique en france
    viagra 50 mg ou 100 mg

    匿名1周前 (01-17)回复
  113. #113

    viagra united states pharmacy
    cialis otc uk
    viagra canada s baism bralt

    匿名7天前回复
  114. #114

    levitra overnight cheap vardenafil how long before levitra works
    when does levitra become generic

    匿名6天前回复
  115. #115

    modafinil and prozac order modafinil online provigil sexual side effects
    why does modafinil nausea reddit

    匿名4天前回复
  116. #116

    can you buy viagra over the counter in new zealand
    viagra natural alternative
    can you buy viagra over the counter in costa rica baism bralt

    匿名3天前回复