Python深度學習筆記(二):使用TensorFlow API進行圖像辨識

栏目: Python · 发布时间: 6年前

前置作業

  1. 閱讀 TensorFlow Object Detection API installation documentation
  2. 下載 git for Windows .
  3. 下載 tensorflow-model repository .

下載 tensorflow-model repository

git clone <a href="https://github.com/tensorflow/models.git" rel="nofollow noopener noreferrer" target="_blank">https://github.com/tensorflow/models.git</a>
#下載到指定資料夾(如:C:\Users\<strong><em>your-username</em></strong>\tensorflow)

安裝TensorFlow

# For CPU
pip install tensorflow
# For GPU
pip install tensorflow-gpu

安裝相關模組

pip install pillow
pip install lxml
pip install jupyter
pip install matplotlib

下載COCO API

git clone <a href="https://github.com/cocodataset/cocoapi.git" rel="nofollow noopener noreferrer" target="_blank">https://github.com/cocodataset/cocoapi.git</a>
並將檔案移動到 tensorflow/models/research的目錄當中

下載Google Protobuf

<a href="https://github.com/google/protobuf/releases/tag/v3.4.0" rel="nofollow noopener noreferrer" target="_blank">https://github.com/google/protobuf/releases/tag/v3.4.0</a>
選擇 “protoc-3.4.0-win32.zip”
C:\Program Files\

將下列路徑加到環境變數當中

系統-> 進階系統設定 -> 環境變數 -> 編輯-> 新增下列路徑

path\Anaconda3
path\Anaconda3\Scripts
path\Anaconda3\Library\bin
path-to-tensorflow\models\research
path-to-tensorflow\models\research\slim
path-to-tensorflow\models\research\object_detection

重新開機

重新開機讓環境變數生效

使用CMD

cd tensorflow\models\research
C:\Program Files\protoc-3.4.0-win32\bin\protoc.exe object_detection/protos/*.proto --python_out=.
到 object_detection/protos 檢查是否有 .py 檔案

測試是否成功

Python深度學習筆記(二):使用TensorFlow API進行圖像辨識
python object_detection/builders/model_builder_test.py

如果出現 ImportError: No module named ‘object_detection’

<strong>在Anaconda\Lib\site-packages資料夾中,寫一個tensorflow_model.pth。</strong>
<strong>內容為兩條路徑</strong>
D:\tensor-flow\models\research
D:\tensor-flow\models\research\slim

開啟object_detection_tutorial.ipynb

在D:\tensor-flow\models\research\object_detection目錄底下
執行object_detection_tutorial.ipynb

官方範例:

Python深度學習筆記(二):使用TensorFlow API進行圖像辨識
Python深度學習筆記(二):使用TensorFlow API進行圖像辨識
海邊風景

使用自己的照片辨識

替換D:\tensor-flow\models\research\object_detection\test_images的照片
必須以image1,image2,image3,.....為檔名
<strong>修改object_detection_tutorial.ipynb中的程式</strong>
Detection的部分 #有多張照片就要修改range範圍
TEST_IMAGE_PATHS = [ os.path.join(PATH_TO_TEST_IMAGES_DIR, 'image{}.jpg'.format(i)) for i in range(1, 3) ]
或者也可自訂程式,做更彈性的辨識
Python深度學習筆記(二):使用TensorFlow API進行圖像辨識
人們
Python深度學習筆記(二):使用TensorFlow API進行圖像辨識
Python深度學習筆記(二):使用TensorFlow API進行圖像辨識
石虎被當成貓

以上所述就是小编给大家介绍的《Python深度學習筆記(二):使用TensorFlow API進行圖像辨識》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

JavaScript设计模式与开发实践

JavaScript设计模式与开发实践

曾探 / 人民邮电出版社 / 2015-5 / 59.00元

本书在尊重《设计模式》原意的同时,针对JavaScript语言特性全面介绍了更适合JavaScript程序员的了16个常用的设计模式,讲解了JavaScript面向对象和函数式编程方面的基础知识,介绍了面向对象的设计原则及其在设计模式中的体现,还分享了面向对象编程技巧和日常开发中的代码重构。本书将教会你如何把经典的设计模式应用到JavaScript语言中,编写出优美高效、结构化和可维护的代码。一起来看看 《JavaScript设计模式与开发实践》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

MD5 加密
MD5 加密

MD5 加密工具