[神經網絡]一步一步使用Mobile-Net完成視覺識別(一)


1.環境配置

2.數據集獲取

3.訓練集獲取

4.訓練

5.調用測試訓練結果

6.代碼講解

  本文是第一篇,環境配置篇。

先打開tensorflow object detection api 看看需要什么配置。

當然,我寫的教程不是很詳細,詳細的請看官方的教程:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md

Tensorflow Object Detection API depends on the following libraries:

  • Protobuf 3.0.0
  • Python-tk
  • Pillow 1.0
  • lxml
  • tf Slim (which is included in the "tensorflow/models/research/" checkout)
  • Jupyter notebook
  • Matplotlib
  • Tensorflow (>=1.9.0)
  • Cython
  • contextlib2
  • cocoapi

在安裝之前,我們先把這個object detection model 給git下來,在任意目錄下,命令行輸入以下命令。

git clone https://github.com/tensorflow/models.git

完成之后就能看到一個model文件夾,當然,git命令使用的基礎是你已經安裝了git,怎么安裝git自己百度吧。。

下一步安裝tensorflow,安裝過的可以直接跳過。

# 如果你要用CPU,就用下面的代碼
pip install tensorflow
#如果你用GPU,就用這里的代碼
pip install tensorflow-gpu

當然,pip命令使用的基礎是你已經安裝了pip,如果你不會安裝,請自行百度。

我默認你已經完成了上面的操作,下面就開始安裝其他東西。

sudo apt-get install protobuf-compiler python-pil python-lxml python-tk
pip install --user Cython
pip install --user contextlib2
pip install --user jupyter
pip install --user matplotlib

命令行里輸入以上的命令,完成Cython等庫的安裝。

下一步至關重要,你需要安裝COCOAPI。

在任何一個目錄下將cocoapi 給git下來,進入python api目錄,編譯。

然后進入之前輸入make之后的指令,清注意將<path_to_tensorflow>替換為models之前的絕對路徑。

git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
make
cp -r pycocotools <path_to_tensorflow>/models/research/

這里你已經完成了很多工作,從models/research執行以下命令

# From tensorflow/models/research/
protoc object_detection/protos/*.proto --python_out=.

#From tensorflow/models/research/
wget -O protobuf.zip https://github.com/google/protobuf/releases/download/v3.0.0/protoc-3.0.0-linux-x86_64.zip
unzip protobuf.zip

# From tensorflow/models/research/
./bin/protoc object_detection/protos/*.proto --python_out=.

這段代碼完成了對protobuf的編譯工作,這只適用於linux。

接下來就是將pythonpath添加進path

# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

 

接下來就是測試是否安裝成功了。

python object_detection/builders/model_builder_test.py

 

輸入以上指令,如果出現

.....................
----------------------------------------------------------------------
Ran 21 tests in 0.074s

OK

表明你安裝成功了。准備下一步吧。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM