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

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

前置作業

  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進行圖像辨識》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

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

未来医疗

未来医疗

【美】埃里克•托普 (Eric Topol) / 郑杰 / 浙江人民出版社 / 2016-5 / 69.90

在传统医学中,医生是上帝,是权威,拥有至高无上的解释权和裁决权,面对疾病,患者总是被动接受,为医命是从。而在大数据时代下,医疗领域将发生颠覆性的变化,以患者为中心的民主医疗时代即将到来。 享誉全美的医疗预言家埃里克•托普在《未来医疗》中,为我们展示了医疗领域创新的憧憬, 分析了在开放的智能时代中,无线医疗技术将从医疗服务、医患关系上颠覆自古以来的家长式医疗,实现“以患者为中心”的个体医疗革命......一起来看看 《未来医疗》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具