Docker container and test
一、開始體驗Nvidia的魅力吧
Two Days to a Demo
從Hello AI World開始吧,下面是github的連結
https://github.com/dusty-nv/jetson-inference
先登入Jetson Nano Kit,這裡使用putty登入,當然您也可以在本機端登入直接使用,相關教學可以在Cavedu找到,所以就不多做說明。
putty下載最新版本 https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
開始吧
下載 Docker Container https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-docker.md
執行之前,有兩種方式開始個專案(jetson-inference project)
Getting the Project
There are two ways to use the jetson-inference project:
Run the pre-built Docker Container
我自己是使用預先建立好的Docker當模擬器
根據自己的JetPack下載對應的 dustynv/jetson-inference:r32.4.4 ,我的是4.4.1版,所以就直接下載了
These containers use the l4t-pytorch base container, so support for transfer learning / re-training is already included.
因為我很懶,所以我應該是直接就使用Docker了,我直接在使用Downloading Models Tool下載模型就好,也不需要再下載PyTorch。
當然如果要自己build一個環境也可以,可以參考以下文章:https://github.com/dusty-nv/jetson-inference/blob/master/docs/building-repo-2.md
Launching the Container
$ git clone --recursive https://github.com/dusty-nv/jetson-inference
這一行是把jetson-inference從github下載下來
$ cd jetson-inference
切換到jetson-inference目錄
$ docker/run.sh
執行docker container
allena@allena-desktop:~/jetson-inference$ docker/run.sh 執行docker
以下是執行的說明...
reading L4T version from /etc/nv_tegra_release
L4T BSP Version: L4T R32.4.4
[sudo] password for allena:
size of data/networks: 592333967 bytes
CONTAINER: dustynv/jetson-inference:r32.4.4 容器版本說明
以下是說明自動被mount進入docker 的目錄
DATA_VOLUME: --volume /home/allena/jetson-inference/data:/jetson-inference/data --volume /home/allena/jetson-inference/python/training/classification/data:/jetson-inference/python/training/classification/data --volume /home/allena/jetson-inference/python/training/classification/models:/jetson-inference/python/training/classification/models --volume /home/allena/jetson-inference/python/training/detection/ssd/data:/jetson-inference/python/training/detection/ssd/data --volume /home/allena/jetson-inference/python/training/detection/ssd/models:/jetson-inference/python/training/detection/ssd/models
USER_VOLUME:
USER_COMMAND:
V4L2_DEVICES: --device /dev/video0 這個是我的USB羅技鏡頭
xhost: unable to open display ""
root@allena-desktop:/jetson-inference#
root@allena-desktop:/jetson-inference# ls 檢視目錄
CMakeLists.txt build calibration docs plugins tools 藍色的是目錄
CMakePreBuild.sh c data examples python utils
至於要自己mount目錄就太靠北了,我覺得這件事就....算了,可以自行參閱網頁說明
https://github.com/dusty-nv/jetson-inference/blob/master/docs/aux-docker.md
開始執行應用程式吧
每次關掉Docker後,要重新再跑那些python的程式跟模型都需要在一次切換到目錄,然後執行docker/run.sh
這件事情很重要
# cd build/aarch64/bin 必須執行Docker成功後才有這些目錄,就不要在亂切換目錄了,否則會找不到喔
# ./video-viewer /dev/video0 這一行是開啟攝影機,然後終端機視窗會跑出一大堆你看不懂的字串,代表您的攝影機執行正常,按ctrl+c可以結束
很多人在執行完不知所以然
切換到可以執行的資料夾,如果您切換到其他資料夾,那自己要修改程式指令碼喔..
我的鏡頭畫面沒有問題喔,你的呢?
建議先跳過這段,先往下看
會出現以下錯誤訊息
root@allena-desktop:/jetson-inference# ./imagenet images/jellyfish2.jpeg images/test/jellyfish.jpg
bash: ./imagenet: No such file or directory
root@allena-desktop:/jetson-inference#
改成這樣試試看吧
root@allena-desktop:/jetson-inference#./build/aarch64/bin/imagenet images/jellyfish2.jpeg images/test/jellyfish.jpg
要這樣才會成功喔
辨識jellyfish
ImageNet(下面範例用到的)
專案是一個大型視覺資料庫,用於視覺目標辨識軟體研究。該專案已手動注釋了1400多萬張圖像,以指出圖片中的物件,並在至少100萬張圖像中提供了邊框。ImageNet包含2萬多個典型類別,例如「氣球」或「草莓」,每一類包含數百張圖像。(wiki百科)
# ./imagenet images/jellyfish.jpg images/test/jellyfish.jpg
切換到本機目錄裡看吧
辨識結果這是jellyfish的準確度為99.85%
您也可以下在一張照片,我從網路下載一張jellyfish的照片,放進image資料夾裡,我們執行看看吧
# ./imagenet images/jellyfish2.jpeg images/test/jellyfish.jpg
我這樣會顧蓋原本的檔案喔
到image/test/資料夾裡看看吧
執行完畢
辨識結果
以下的實作是深度學習神經網路在DIGITS的物件辨識
# ./detectnet images/peds_0.jpg images/test/peds_0.jpg
開始執行吧
# (press Ctrl+D to exit the container)
要結束Docker container就按Ctrl+D
這個人辨識率只有69.9%
胖是一種錯嗎?
記得下在要使用這個專案的程式必須要再次執行
$ cd jetson-inference
切換到jetson-inference目錄
$ docker/run.sh
執行docker container