AI学习库的安装jetson-inference
https://mp.****.net/console/editor/html/107425573
AI学习库的安装jetson-inference(国内详细教程)
源码在github上,
链接:https://github.com/dusty-nv/jetson-inference
但是在国内往往下载时会出现问题,我已经讲最新的源码项目移植到了码云,
链接:https://gitee.com/zhongxon/jetson-inference
安装方式相同。
1、安装cmake
$sudo apt update
$sudo apt upgrade
$sudo apt-get install cmake
2、源码的获取
①github获取
先试着从GitHub上获取源码
$git clone https://github.com/dusty-nv/jetson-inference
②码云获取
如果GitHub上获取源码失败,可以从我的码云上获取,执行如下代码即可,一样
$git clone https://gitee.com/zhongxon/jetson-inference
获取源码后
$cd jetson-inference
$git submodule update --init
在执行git submodule update --init后可能有文题可以参考GitHub登不上去问题解决办法。
3、换源
路径切换到jetson-inference/tools下
$cd jetson-inference/tools
模型下载的国内源(在以上路径下)
$sed -in-place -e '[email protected]://nvidia.box.com/shared/[email protected]://bbs.gpuworld.cn/[email protected]' download-models.sh
安装pytorch,此时只是添加了源可以在第四步build文件夹中安装。
$sed -in-place -e '[email protected]://nvidia.box.com/shared/[email protected]://bbs.gpuworld.cn/[email protected]' install-pytorch.sh
sed -in-place -e '[email protected]://github.com/pytorch/[email protected]://gitee.com/vcan123/[email protected]' install-pytorch.sh(不必做)
$sed -in-place -e '[email protected]://github.com/dusty-nv/[email protected]://gitee.com/vcan123/[email protected]'
install-pytorch.sh(不必做)
、编译安装
$sudo apt-get update
$sudo apt-get install git cmake libpython3-dev python3-numpy(不必做)
$cd jetson-inference
$mkdir build
$cd build
$cmake ../ (非常块)
$make
$sudo make install (也有下载过程,但很快)
执行以上过程时出现如图所示,根据自己的需要点确定就可以。我全部下载,共45个。
下载后有4.7G,此时AGX Xavier只剩下8.3G空间。
5、物体识别
物体识别在路径jetson-inference/build/aarch64/bin下
图片也可选,在bin路径下有images文件,橘子等的图片都在里边。
打开终端输入
c++:
$ ./imagenet-console --network = googlenet images/orange_0.jpg output_0.jpg #-- network标志是可选的
python:
$ ./imagenet-console.py --network = googlenet images/orange_0.jpg output_0.jpg #-- network标志是可选的
$display output_0.jpg
静态图像识别测试脚本:
$ vi static_picture.sh
内容如下:
#!/bin/sh
./imagenet-console $1 output_$1
display output_$1
添加执行权限和运行上边的脚本:
$ chmod a+x ./static_picture.sh
$ ./static_picture.sh orange_0.jpg
支持USB摄像头基本都可用,CSI摄像头(树莓派的)
$ ./imagenet-camera googlenet
$ ./imagenet-camera alexnet
如果使用USB摄像头,需要修改imagenet-camera.cpp中的宏定义DEFAULT_CAMERA,然后重新编译。
检测出对象病提取边框
$ ./detectnet-console dog_1.jpg output_1.jpg coco-dog
从网络上,尤其****找了很多参考资料,加以整理,验证。
重点参考:https://www.cnblogs.com/vcan123/p/13269218.html Yimiu大侠的文章。
有问题欢迎交流。
唐山深度科技有限公司 (内部资料)
王晓明 (zhongxon)
微信:199663740
手机:13582524826
2020.07.18