Jetson nano快速上手,跑通tiny-yolov2

Jetson nano快速上手

下载镜像文件

首先我们需要下jetson的镜像文件,实际上就是一个针对jetson nano优化过的ubuntu系统。 官方推荐是16G的高速tf卡,这里建议大家最少使用32G。因为后面加上各种模型数据和库,再打开swap区可以轻松超过20G

大家可以前往下面网站,并通过在左侧选中第三栏,红圈的位置为镜像下载地址。https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#write

 

 

可以看到nv的下载速度还是不错的。

 

格式化TF

如果你的tf卡之前做过系统安装盘,或者有mac备份等等,新卡可以跳过这一步。通过官方推荐的SD Memory Card Formatter格式化tf卡。或者你想把tf恢复如初,也可以用这个工具。(tf卡刷了jetson镜像后插到电脑上会出现十来个u盘盘符)

我们下载官方推荐的etcher工具进行镜像烧录。 https://www.balena.io/etcher/

第一项直接选中我们刚刚下载的zip文件,etcher不需要解压刚刚下载的zip文件,会自动读取里面的镜像文件。

之后就开始漫长的烧录过程了,如果你的sd卡读卡器还是USB 2.01.1估计要半个小时以上。USB3.0的读卡器大约需要10分钟,注意电脑机箱上蓝色的(9p)才是usb3.0的接口。

当烧录完成后如果电脑上弹出来一堆盘符这是正常现象,将读卡器弹出就好了~

首次启动jetson

tf卡插到jetson主板背面: 之后插上hdmi线,键盘鼠标和网线。电源可以选择micro-usb口,这里需要使用5V 3A的适配器或充电宝。如果使用外部适配器,请一定要选择5V输出的,并且输出电流在3A以上。 Jetson nanoDC接口只支持5V输入,请千万别将5V以上的适配器插到jetson上面。 使用外部适配器还需要闭合dc口后边的跳线帽。

如果手上有小喵家rosbot主板可以像下面这样将主板连接到jetson,安装的时候需要额外的2.5mm铜螺柱,rosbotdc口支持612v的电源输入。再三强调,千万不要手滑把高于5v的电源直接查到jetson上。

首次启动后需要完成ubuntu剩下的安装过程,除了时区外基本选默认就行了。

 

ubuntulinux不熟的同学请牢记打开终端的快捷键是 ctrl+alt+t linux下的图形化节目我们用的不多,大部分东西都是在命令行下操作~

 

https://zhuanlan.zhihu.com/p/65188026

WiFi 联网通常需要用到屏幕,鼠标,键盘,并需要登录桌面。但是一般我们没有多余的屏幕和键鼠,导致每次设置WiFi都需要将PC的外设换来换去。

使用命令行设置WiFi只需要一根1米网线即可解决。

Win10共享网络设置

首先用网线把Jetson Nano和电脑连接起来。

然后依次打开:控制面板——>网络和Internet——>网络和共享中心——>更改适配器设置——>Wlan属性(或者以太网属性)——>共享

https://pic4.zhimg.com/80/v2-f9c2a9795d3e577d001209fe5c2eb573_hd.jpg

然后将“允许其他网络用户通过此计算机的Internet连接来连接”打钩。

查找 Jetson Nano IP 地址

使用 Advanced IP Scanner 软件进行搜索就能找到。

 

使用 SSH 登录 Jetson Nano

这里使用 PuTTY 作为终端,输入上面找到的Jetson Nano 的IP地址。

Installation

  1. Install dependent libraries.
  2. $ sudo apt update
  3. $ sudo apt install python3-pip protobuf-compiler libprotoc-dev libjpeg-dev cmake
  4. You might need to install Cython alone prior to the other python modules installation. Otherwise "RuntimeError: Running cythonize failed!" might happens at the numpy installation.
$ pip3 install --user cython
  1. Install this application and the dependent modules.
  2. $ git clone https://github.com/tsutof/tiny_yolov2_onnx_cam
  3. $ cd tiny_yolov2_onnx_cam
  4. $ export PATH=$PATH:/usr/local/cuda/bin
  5. $ python3 -m pip install -r requirements.txt

There is the "onnx==1.4.1" restriction in the requirements.txt, because TensorRT dosen't work with ONNX 1.5.x. It seems that ONNX 1.6.0 has no problem with TensorRT. So the version restriction will be changed to "onnx>=1.6.0" in the near future.

Usage

First, clock up your Jetson. Only the nvpmodel is not enough, the jetson_clocks command is also needed. Without the jetson_clocks, "select timeout" error happens at the frame capture.

$ sudo nvpmodel -m 0$ sudo jetson_clocks

The following command starts this application. Press ESC key to exit from this application.

$ python3 tiny_yolov2_onnx_cam.py [-h] [--camera CAMERA_NUM] [--width WIDTH][--height HEIGHT] [--objth OBJ_THRESH] [--nmsth NMS_THRESH]optional arguments: -h, --help            show this help message and exit --camera CAMERA_NUM, -c CAMERA_NUMCamera number, use any negative integer for MIPI-CSI camera--width WIDTH         Capture width--height HEIGHT       Capture height--objth OBJ_THRESH    Threshold of object confidence score (between 0 and 1)
  --nmsth NMS_THRESH    Threshold of NMS algorithm (between 0 and 1)

For Raspberry Pi camera v2, use any negative number as the camera number.

$ python3 tiny_yolov2_onnx_cam.py --camera -1 

For USB Web camera, if you camera is detected as /dev/video1, use 1 as the camera number.

$ python3 tiny_yolov2_onnx_cam.py --camera 1

If your USB Web camera does not support this application's default capture resolution, please change it with the --widht and --height command-line options.

To know the supported resolutions by your camera, the gst-device-monitor-1.0 command is very useful.

结果显示tiny-yolov2大约显示8帧

 

Jetson AI第一课

官方的jetson系统烧录完后首先就是推荐大家使用hello AI进行上手,但是在国内网络环境下需要做一些额外的工作。这篇教程就是教大家如何在墙内的世界跑起来~

原项目地址: https://github.com/dusty-nv/jetson-inference

jetson-inference正如其名只是调用现有训练好的模型进行计算,并不存在数据采集训练的过程,也不需要安装tensorflowcaffe等库。jetson nano的镜像已经内置安装好了cudacudnnopencv

克隆项目到jetson

由于github比较卡,我们将项目挪到国内gitee上了~

cd ~
git clone https://gitee.com/Kittenbot/jetson-inference.git

接下来我们需要编译项目,默认使用的都是树莓派兼容的csi摄像头,如果大家使用的是usb摄像头可以到不同的项目.cpp文件下将DEFAULT_CAMERA定义后面的-1改成/dev/video

由于大部分模型都托管在google drive的映射上,所以在大防火墙内运行CMakePreBuild.sh安装脚本下载模型的时候基本都会超时报错。这里我们已经将下载好的模型放到百度盘上了,下载为data.zip文件。

链接: https://pan.baidu.com/s/12DPjN79Jn26EW-gR7cLfMA 提取码: 5fx8 

大家下载后可以拷贝到u盘上,查到jetson上可以用ubuntu自带的图形化解压工具解压到jetson-inference下覆盖原有的data目录就行了。

接下来我们运行下面的脚本

cd jetson-inference
git submodule update --init

如果大家下载并覆盖了data文件夹,运行cmake的时候不会重新去网上找模型数据库。

mkdir build
cd build
cmake ../
make
sudo make install

如果编译没错的话,会在build/aarch64/bin生产各个程序的可执行文件。接下来基本就可以照着 https://github.com/dusty-nv/jetson-inference/blob/master/README.md一步步尝试jetson nanoai能力了~

例如:

cd jetson-inference/build/aarch64/bin
./imagenet-console orange_0.jpg output_0.jpg

 

发布了88 篇原创文章 · 获赞 9 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/jwy2014/article/details/103706387
今日推荐