1.简要介绍下Jetson Inference
Nvidia官方给出的Deploying Deep Learning实例可以在DIGITS/Jetson多种设备上运行。实例使用NVIDIA TensorRT高效地将神经网络部署到嵌入式平台上,并利用Jetson上的图形优化、内核融合和hafl-precision FP16提高性能。
实例有这么几项:
(1)imgenet
用于图像识别,识别出图像为苹果、橘子等等;
(2)detectnet
用于目标检测,标注行人、瓶子、飞机等等;
(3)segnet
用于图像、语义分割等。
2.实现Hello AI World(Inference Only)
摄像头的实时识别和检测无法实现,我的摄像头是USB接口,按照注意事项中提示,修改对应.cpp
源码中id,重新编译,仍然无法使用,貌似和V4L2有关系,坑太深了,期待大神的实现。本文中和摄像头相关的内容一概忽略不表。
(1)安装cmake
sudo apt-get install cmake
(2)克隆仓库到本地
git clone https://github.com/dusty-nv/jetson-inference
cd jetson-inference
git submodule update --init
(3) 修改文件CMakePreBuild. sh
jetson-inference
这个仓库中有24个caffe网络模型是在cmake
过程中下载,我们的网络没办法完成这件事,加上linux终端搭梯子的复杂繁琐以及保证ss账号可用等恶劣情况,我弃疗了。好在天无绝人之路,通过修改CMakePreBuild.sh
文件可以解决这个问题。
将CMakePreBuild.sh
文件中的关于下载和解压的部分全部注释掉,太长了,仅示例4行,
35 #wget --no-check-certificate 'https://nvidia.box.com/shared/static/c84wp3axbtv4e2gybn40jprdquav9azm.prototx t' -O alexnet.prototxt
36 #mv alexnet.prototxt ../data/networks
37
38 #wget --no-check-certificate 'https://nvidia.box.com/shared/static/o0w0sl3obqxj21u09c0cwzw4khymz7hh.prototx t' -O alexnet_noprob.prototxt
39 #mv alexnet_noprob.prototxt ../data/networks
(4)使用cmake完成配置
$ cd jetson-inference/build # omit if pwd is already /build from above
$ make
$ sudo make install
完成后,确认下文件夹结构如下:
|-build
\aarch64 (64-bit)
\bin where the sample binaries are built to
\include where the headers reside
\lib where the libraries are build to
\armhf (32-bit)
\bin where the sample binaries are built to
\include where the headers reside
\lib where the libraries are build to
(5)下载caffe网络模型
刚该注释掉的下载内容,其实还是需要下载的,我已经全部存在以下网盘了,如需请自提,全部1.5G吧…
百度网盘
提取码:rtr4
下载完了,需要解压的解压,然后都放在/jetson-inference/data/networks
路径下,就这么愉快的完成了。
(6)测试
进入到以下目录
$ cd jetson-inference/build/aarch64/bin
执行,首次加载模型,还是有点久,发热也很厉害,
$ ./imagenet-console orange_0.jpg output_0.jpg
查看结果,计算结果会有些许差异
执行目标检测
./detectnet-console peds-003.jpg output_3.jpg