边缘计算热火正旺,GTI把速度做到极致,若派基于GTI光矛2801S的神经网络计算棒分类检测验证 请收下!!

时间:2024-03-18 10:38:05

本文介绍以Gyrfalcon Technology公司Lightspeeur
2801S芯片为核心的USB神经网络计算卡上进行目标检测(Object
Detection)推论(Inference)。其中模型的建立、训练与转换部份需要在有Nvidia的GPU的电脑上进行,所使用框架为Caffe,算法为SSD(Single
Shot MultiBox
Detector)。本文是参照若派提供的SSD模型工具包(MDK)文件实作后所做的整理,电脑使用的操作系统为Ubuntu 16.04.5
LTS(Xenial Xerus)64-bit PC(AMD64)desktop,相关档案的取得请联若派。

首先将SSD算法的相关档案拷贝到家目录:
边缘计算热火正旺,GTI把速度做到极致,若派基于GTI光矛2801S的神经网络计算棒分类检测验证 请收下!!
接著進行模型開發工具解壓縮:
tar zxvf GTI_SSD_model_development_kit_v1-0.tar.gz
安裝OpenCV 3:
cd ~/GTI_SSD_conversion_tool_v1-0/lightsprModelConvert/
sh install_opencv.sh
cd ~
參照廠商文件,進行 1.環境安裝 :

1)基礎依賴安裝:

sudo apt-get update && sudo apt-get upgrade &&
sudo apt-get install -y --no-install-recommends
build-essential
cmake
git
wget
libatlas-base-dev
libboost-all-dev
libgflags-dev
libgoogle-glog-dev
libhdf5-serial-dev
libleveldb-dev
liblmdb-dev
libprotobuf-dev
libsnappy-dev
protobuf-compiler
python-pip
python-setuptools
python-scipy
libopenblas-dev

2) python2依賴安裝

cd GTI_SSD_model_development_kit_v1-0/FilesAndInstructions/caffe-ssd/

cd python

sudo pip install --upgrade pip &&
for req in $(cat requirements.txt) pydot; do sudo pip install $req; done

3) CUDA(英偉達顯卡)

cd /tmp

sudo apt-get update && sudo apt-get install wget -y --no-install-recommends &&
wget “https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.61-1_amd64.deb” &&
sudo dpkg -i cuda-repo-ubuntu1604_8.0.61-1_amd64.deb &&
sudo apt-get update &&
sudo apt-get install -y cuda-8-0

wget https://developer.download.nvidi … -linux-x64-v5.1.tgz &&
sudo tar -xzf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local &&
rm cudnn-8.0-linux-x64-v5.1.tgz && sudo ldconfig &&
cd -

# 回到Caffe原始碼目錄:

cd ~/GTI_SSD_model_development_kit_v1-0/FilesAndInstructions/caffe-ssd/
編譯Caffe前請修改Makefile.config如下所示:
PYTHON_INCLUDE := /usr/include/python2.7
/usr/local/lib/python2.7/dist-packages/numpy/core/include
再進行Caffe編譯:

4)編譯caffe-ssd

make clean

make all

make pycaffe

接著進行 2.模型訓練:

1)數據準備

cd ~

tar zxvf GTI_SSD_DataSets_v1-0.tar.gz

進入"多目標檢測"專案目錄:

cd ~/GTI_SSD_model_development_kit_v1-0/FilesAndInstructions/ssd_typ_mdk/
訓練前請修改run_ssd_training.sh如下所示:
KaTeX parse error: Expected 'EOF', got '\ ' at position 19: …LS/caffe train \̲ ̲--solver=slovertxttyp
–weights=$ssd
–gpu 0 2>&1 | tee $LOG [email protected]
完成後執行run_ssd_training.sh進行訓練(執行時間很久):
source run_ssd_training.sh

訓練完成後,進行 3.模型轉換 :
cd ~/GTI_SSD_conversion_tool_v1-0/lightsprModelConvert/

source setting_caffe.sh
將生成的模型放入inputs/SSD_typ並命名為SSD_typ_quant.caffemodel後進行轉換:
make SSD_typ_vgg

make SSD_typ_ssd

轉換完成後,進行 4.模型使用:
cd ~

tar zxvf Gti2801_SSD_sample_v1-0.tar.gz

cp ~/GTI_SSD_conversion_tool_v1-0/lightsprModelConvert/cnn_weights_SSD_typ/vgg.dat ~/Gti2801_SSD_sample_v1-0/Data/Models/gti2801/multi-object

cp ~/GTI_SSD_conversion_tool_v1-0/lightsprModelConvert/cnn_weights_SSD_typ/ssd.bin ~/Gti2801_SSD_sample_v1-0/Data/Models/gti2801/multi-object
修改Gti2801_SSD_sample_v1-0/Data/Models/gti2801/userinput.txt,如下所示:
{
“Gti device type”: 0, # 0: GTI 2801, 1: GTI 2803
“model”: [
{
“Network name”: “Gnet1”,
“Image output format”: 0, # 0: Conv out pooling, 1: Sub layers, 2: Conv out, 3: Major layers
“Dump input image”: 0,
“USB write block numbers”: 2048, # eMMC USB dongle block numbers for one write or read command, 2048 for best performance, 128 for USB 2.0 compatibility
“USB read delay”: 15000, # Delay time (us) between eMMC USB dongle write and read commands, 4000 for gNet3, 12000 for gNet1
“USB device node”: “/dev/sg1”, # The first available eMMC device node, find the node name from folder /dev/ after dongle is plugged in
}
]
}
完成後編譯與執行展示程式:
cd ~/Gti2801_SSD_sample_v1-0/Sample/Linux/

cp Makefile_x86 Makefile

make

sudo chmod 777 /dev/sg1

./ssdSample -dev_id /dev/sg1
執行結果如下所示:
边缘计算热火正旺,GTI把速度做到极致,若派基于GTI光矛2801S的神经网络计算棒分类检测验证 请收下!!
至此,就完成在USB神经网络计算卡上进行目标检测SSD算法推论之验证。

若派专注于人工智能产业化,让大众成为人工智能专家!