Jetson Nano Developer Kit
The Jetson Nano Developer Kit is an AI computer for learning and for making.
一个推理框架,用于部署模型到嵌入式设备.
Four Steps to Deep Learning
- System Setup
- Image Recognition
- Object Detection
- Segmentation
CUDA
一种并行计算技术
https://zh.wikipedia.org/wiki/CUDA
https://github.com/dusty-nv/jetson-inference#system-setup
Hello AI World
环境准备
- https://github.com/dusty-nv/jetson-inference/blob/master/docs/jetpack-setup-2.md
- https://github.com/dusty-nv/jetson-inference/blob/master/docs/building-repo-2.md

预训练好的模型位于data目录下.
图像分类
核心类imageNet https://github.com/dusty-nv/jetson-inference/blob/master/imageNet.h
imageNet接收image作为input,输出每一种类别的概率.
在编译出来的build/aarch64/bin目录下有2个示例程序
- imagenet-console
- iamgenet-camera
编写自己的图像识别程序.
https://github.com/dusty-nv/jetson-inference/tree/master/examples/my-recognition
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
// include imageNet header for image recognition
#include <jetson-inference/imageNet.h>
// include loadImage header for loading images
#include <jetson-utils/loadImage.h>
// main entry point
int main( int argc, char** argv )
{
// a command line argument containing the image filename is expected,
// so make sure we have at least 2 args (the first arg is the program)
if( argc < 2 )
{
printf("my-recognition: expected image filename as argument\n");
printf("example usage: ./my-recognition my_image.jpg\n");
return 0;
}
// retrieve the image filename from the array of command line args
const char* imgFilename = argv[1];
// these variables will be used to store the image data and dimensions
// the image data will be stored in shared CPU/GPU memory, so there are
// pointers for the CPU and GPU (both reference the same physical memory)
float* imgCPU = NULL; // CPU pointer to floating-point RGBA image data
float* imgCUDA = NULL; // GPU pointer to floating-point RGBA image data
int imgWidth = 0; // width of the image (in pixels)
int imgHeight = 0; // height of the image (in pixels)
// load the image from disk as float4 RGBA (32 bits per channel, 128 bits per pixel)
if( !loadImageRGBA(imgFilename, (float4**)&imgCPU, (float4**)&imgCUDA, &imgWidth, &imgHeight) )
{
printf("failed to load image '%s'\n", imgFilename);
return 0;
}
// load the GoogleNet image recognition network with TensorRT
// you can use imageNet::ALEXNET to load AlexNet model instead
imageNet* net = imageNet::Create(imageNet::GOOGLENET);
// check to make sure that the network model loaded properly
if( !net )
{
printf("failed to load image recognition network\n");
return 0;
}
// this variable will store the confidence of the classification (between 0 and 1)
float confidence = 0.0;
// classify the image with TensorRT on the GPU (hence we use the CUDA pointer)
// this will return the index of the object class that the image was recognized as (or -1 on error)
const int classIndex = net->Classify(imgCUDA, imgWidth, imgHeight, &confidence);
// make sure a valid classification result was returned
if( classIndex >= 0 )
{
// retrieve the name/description of the object class index
const char* classDescription = net->GetClassDesc(classIndex);
// print out the classification results
printf("image is recognized as '%s' (class #%i) with %f%% confidence\n",
classDescription, classIndex, confidence * 100.0f);
}
else
{
// if Classify() returned < 0, an error occurred
printf("failed to classify image\n");
}
// free the network's resources before shutting down
delete net;
// this is the end of the example!
return 0;
}
- 载入图像 loadImageRGBA
加载的图像存储于共享内存,映射到cpu和gpu.实际的内存里的image只有1份,cpu/gpu pointer指向的都是同一份物理内存。
The loaded image will be stored in shared memory that's mapped to both the CPU and GPU. There are two pointers available for access in the CPU and GPU address spaces, but there is really only one copy of the image in memory. Both the CPU and GPU pointers resolve to the same physical memory, without needing to perform memory copies (i.e. cudaMemcpy()).
- 载入神经网络模型
imageNet::Create()
GOOGLENET是一个预先训练好的模型,使用的数据集是ImageNet(注意不是imageNet对象).类别有1000个,包括了动植物,常见生活用品等.
// load the GoogleNet image recognition network with TensorRT
// you can use imageNet::ALEXNET to load AlexNet model instead
imageNet* net = imageNet::Create(imageNet::GOOGLENET);
// check to make sure that the network model loaded properly
if( !net )
{
printf("failed to load image recognition network\n");
return 0;
}
- 对图片进行分类
Classify返回的是类别对应的index
//this variable will store the confidence of the classification (between 0 and 1)
float confidence = 0.0;
// classify the image with TensorRT on the GPU (hence we use the CUDA pointer)
// this will return the index of the object class that the image was recognized as (or -1 on error)
const int classIndex = net->Classify(imgCUDA, imgWidth, imgHeight, &confidence);
- 解释结果
// make sure a valid classification result was returned
if( classIndex >= 0 )
{
// retrieve the name/description of the object class index
const char* classDescription = net->GetClassDesc(classIndex);
// print out the classification results
printf("image is recognized as '%s' (class #%i) with %f%% confidence\n",
classDescription, classIndex, confidence * 100.0f);
}
else
{
// if Classify() returned < 0, an error occurred
printf("failed to classify image\n");
}
These descriptions of the 1000 classes are parsed from ilsvrc12_synset_words.txt when the network gets loaded (this file was previously downloaded when the jetson-inference repo was built).
- 退出
程序退出前要释放掉资源
// free the network's resources before shutting down
delete net;
// this is the end of the example!
return 0;
}
cmake文件
# require CMake 2.8 or greater
cmake_minimum_required(VERSION 2.8)
# declare my-recognition project
project(my-recognition)
# import jetson-inference and jetson-utils packages.
# note that if you didn't do "sudo make install"
# while building jetson-inference, this will error.
find_package(jetson-utils)
find_package(jetson-inference)
# CUDA and Qt4 are required
find_package(CUDA)
find_package(Qt4)
# setup Qt4 for build
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
# compile the my-recognition program
cuda_add_executable(my-recognition my-recognition.cpp)
# link my-recognition to jetson-inference library
target_link_libraries(my-recognition jetson-inference)
没什么要特别说的,主要的依赖如下:
- find_package(jetson-utils)
- find_package(jetson-inference)
- target_link_libraries(my-recognition jetson-inference)
实时图片识别
上面的代码展示的是本地图片的识别,这一节给出实时的摄像头拍摄图片识别的demo.
- iamgenet-camera
Jetson Nano Developer Kit的更多相关文章
- Jetson Nano系列教程3:GPIO
摘要: JetsonTX1,TX2,AGXXavier和Nano开发板包含一个40引脚的GPIO头,类似于Raspberry PI中的40引脚头.这些GPO可以通过JetsonGPIOLibrary包 ...
- Jetson Nano系列教程1:烧写系统镜像
下载镜像 NVIDIA官方为Jetson Nano Developer Kit (后面统称为Jetson Nano了)提供了SD卡版本的系统镜像,并且根据JetPack版本不断得在更新.所以你可以直接 ...
- Jetson Nano系列教程0:初识Jetson Nano
关于Jetson Nano Developer Kit Jetson nano搭载四核Cortex-A57 MPCore 处理器,采用128 核 Maxwell™ GPU.支持JetPack SDK ...
- jetson nano 安装 snowboy 遇到的问题及处理
Snowboy 是 KITT.AI 开发的一个高度可定制的热词检测引擎,当笔者的 jetson nano 加上话筒后,就立马尝试安装,但在安装过程中却发生了错误,所以把处理方式记录了下来以作备忘. 首 ...
- jetson nano开发使用的基础详细分享
前言: 最近拿到一块jetson nano 2GB版本的板子,折腾了一下,从烧录镜像.修改配件等,准备一篇开箱基础文章给大家介绍一下这块AI开发板. 作者:良知犹存 转载授权以及围观:欢迎关注微信公众 ...
- [Jetson Nano]Jetson Nano快速入门
NVIDIAJetsonNano开发套件是适用于制造商,学习者和开发人员的小型AI计算机.相比Jetson其他系列的开发板,官方报价只要99美金,可谓是相当有性价比.本文如何是一个快速入门的教程,主要 ...
- Jetson Nano 系列教程2:串口调试接口登录Jetson Nano
连接Jetson Nano可以有多种方法,这里我们一一介绍一下.开始本章节前,请先参考上一章,烧写好镜像 直接连接 所谓直接连接,就是将Jetson Nano当做主机,连接HDMI屏幕,连接键盘和鼠标 ...
- Darknet YOLOv3 on Jetson Nano
推荐比较好的博客:https://ai4sig.org/2019/06/jetson-nano-darknet-yolov3/ 用的AlexeyAB的版本,并且给出了yolov3和tiny的效果对比. ...
- 1、Jetson Nano 远程桌面XP问题
jeston nano上网 方法3(最简单的方法) 最简单的方法真的特简单,用USB数据线连接主板的USB接口以及手机,打开手机的USB共享即可,若要使用静态IP,可在主板上修改配置文件,接口一般为u ...
随机推荐
- JVM内存异常与常用内存参数设置总结
Java Web程序由于引入大量第三方java类库,在启动时经常会遇到内存溢出(Memory Overflow)或者内存泄漏(Memory leak)问题,导致程序启动失败. 一.OOM异常分类: O ...
- js、jq事件绑定方式总结——以click事件为例
一.JavaScript点击事件绑定方法 1.1 HTML onclick事件属性 <button onclick="clickMe(this)">click me&l ...
- ELK入门使用-与springboot集成
前言 ELK官方的中文文档写的已经挺好了,为啥还要记录本文?因为我发现,我如果不写下来,过几天就忘记了,而再次捡起来必然还要经历资料查找筛选测试的过程.虽然这个过程很有意义,但并不总是有那么多时间去做 ...
- 循环神经网络之LSTM和GRU
看了一些LSTM的博客,都推荐看colah写的博客<Understanding LSTM Networks> 来学习LSTM,我也找来看了,写得还是比较好懂的,它把LSTM的工作流程从输入 ...
- Java后端框架之Spring Boot详解,文末有Java分布式实战项目视频可取
在 Java 后端框架繁荣的今天,Spring 框架无疑是最最火热,也是必不可少的开源框架,更是稳坐 Java 后端框架的龙头老大. 用过 Spring 框架的都知道 Spring 能流行是因为它的两 ...
- KnockoutJS知识规整目录
对于Web开发来讲,前端接触是避免不了的,特别是对于中小公司,没有严格的职位区分,前后端人员互相身兼是常有的事情,使用一些好的框架,能够帮助我们快速开发并完成需要的功能,对于前端的JS框架来讲MVVM ...
- C#-Xamarin的Android项目开发(三)——发布、部署、打包
前言 部署,通常的情况下,它其实也是项目开发的一个难点. 为什么这么说呢?因为,它不是代码开发,所以很多开发者本能的拒绝学习它. 并且一个项目配置好一次以后,部署的步骤和部署的人通常很固定,所以大部分 ...
- 对.NET Core未来发展趋势的浅层判断
经常听到园里.NET开发人员在抱怨生态不如JAVA,想要转JAVA,所谓打不过你,我就加入你!杜兰特的思维方式固然是获取总冠军的一种方式,但是我们要关起门来问自己有没有杜兰特的实力. 用开发生态来类比 ...
- 3.JAVA-方法重载,类的封装,构造/析构方法
1.方法重载 和C++的函数重载一样,主要是实现多个相同的函数名,但是参数表不同. 参数表不同主要有以下几种 1) 参数个数不同 2) 参数类型不同 3) 参数顺序不同 2.类和对象 类class 用 ...
- 我们是如何通过全球第一免费开源ERP Odoo做到项目100%交付
传统友商ERP的交付过程 一.先初步需求调研,后选型功能模块 传统友商ERP第一件事情先对客户方进行初步的调研,客户方无论说什么,友商听过算过,只关心你人数多少,有哪些人涉及到哪些模块,接着对模块进行 ...