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

查看所有标签

猜你喜欢:

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

精通Android游戏开发

精通Android游戏开发

[美] Vladimir Silva / 王恒、苏金国 等 / 人民邮电出版社 / 2011-2 / 45.00元

作为引领移动技术潮流的软件平台,Android发布了NDK以支持Java和C的混合开发,使PC游戏可以在Android平台上焕发更多魅力。 本书是为那些在Android游戏开发工作中寻求突破的人准备的。书中不仅通过Space Blaster和Asteroids这两个炫酷 的街机游戏深入介绍了如何从头构建纯Java游戏,更详细展示了如何将PC上的3D经典游戏Doom和Wolfenstein 3......一起来看看 《精通Android游戏开发》 这本书的介绍吧!

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

在线压缩/解压 HTML 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具