功能:使用googlenet模型對輸入視頻進行分類推理。
樣例輸入:原始mp4視頻。
樣例輸出:presenter界面展現推理結果。
請檢查以下條件要求是否滿足,如不滿足請按照備注進行相應處理。如果CANN版本升級,請同步檢查第三方依賴是否需要重新安裝(5.0.4及以上版本第三方依賴和5.0.4以下版本有差異,需要重新安裝)。
條件 | 要求 | 備注 |
---|---|---|
CANN版本 | >=5.0.4 | 請參考CANN樣例倉介紹中的安裝步驟完成CANN安裝,如果CANN低于要求版本請根據版本說明切換samples倉到對應CANN版本 |
硬件要求 | Atlas200DK/Atlas300(ai1s) | 當前已在Atlas200DK和Atlas300測試通過,產品說明請參考硬件平臺 ,其他產品可能需要另做適配 |
第三方依賴 | presentagent, opencv | 請參考第三方依賴安裝指導(C++樣例)完成對應安裝 |
獲取源碼包。
可以使用以下兩種方式下載,請選擇其中一種進行源碼準備。
# 開發環境,非root用戶命令行中執行以下命令下載源碼倉。
cd ${HOME}
git clone https://gitee.com/ascend/samples.git
git checkout v0.5.0
# 1. samples倉右上角選擇 【克隆/下載】 下拉框并選擇 【下載ZIP】。
# 2. 將ZIP包上傳到開發環境中的普通用戶家目錄中,【例如:${HOME}/ascend-samples-master.zip】。
# 3. 開發環境中,執行以下命令,解壓zip包。
cd ${HOME}
unzip ascend-samples-master.zip
模型轉換。
模型名稱 | 模型說明 | 模型下載路徑 |
---|---|---|
googlenet | 圖片分類推理模型。是基于Caffe的GoogLeNet模型。 | 請參考https://gitee.com/ascend /ModelZoo-TensorFlow/tree/master /TensorFlow/contrib/cv/googlenet /ATC_googlenet_caffe_AE目錄中README.md下載原始模型章節 下載模型和權重文件。 |
# 為了方便下載,在這里直接給出原始模型下載及模型轉換命令,可以直接拷貝執行。也可以參照上表在modelzoo中下載并手工轉換,以了解更多細節。
cd ${HOME}/samples/cplusplus/level2_simple_inference/1_classification/googlenet_imagenet_video/model
wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/classification/googlenet.caffemodel
wget https://modelzoo-train-atc.obs.cn-north-4.myhuaweicloud.com/003_Atc_Models/AE/ATC%20Model/classification/googlenet.prototxt
wget https://c7xcode.obs.cn-north-4.myhuaweicloud.com/models/googlenet_imagenet_video/insert_op.cfg
atc --model="./googlenet.prototxt" --weight="./googlenet.caffemodel" --framework=0 --output="googlenet" --soc_version=Ascend310 --insert_op_conf=./insert_op.cfg --input_shape="data:1,3,224,224" --input_format=NCHW
執行以下命令,執行編譯腳本,開始樣例編譯。
cd ${HOME}/samples/cplusplus/level2_simple_inference/1_classification/googlenet_imagenet_video/scripts
bash sample_build.sh
注:開發環境與運行環境合一部署,請跳過步驟1,直接執行步驟2即可。
執行以下命令,將開發環境的 googlenet_imagenet_video 目錄上傳到運行環境中,例如 /home/HwHiAiUser,并以HwHiAiUser(運行用戶)登錄運行環境(Host)。
# 【xxx.xxx.xxx.xxx】為運行環境ip,200DK在USB連接時一般為192.168.1.2,300(ai1s)為對應的公網ip。
scp -r ${HOME}/samples/cplusplus/level2_simple_inference/1_classification/googlenet_imagenet_video HwHiAiUser@xxx.xxx.xxx.xxx:/home/HwHiAiUser
ssh HwHiAiUser@xxx.xxx.xxx.xxx
cd ${HOME}/googlenet_imagenet_video/scripts
bash sample_run.sh
請參考常見問題定位對遇到的錯誤進行排查。如果wiki中不包含,請在samples倉提issue反饋。