Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Features Business Explore Marketplace Pricing This repository Search Sign in or Sign up
Dismiss
Join GitHub today
GitHub is home to over 20 million developers working together to host and
review code, manage projects, and build software together.
Sign up
Guide to deploying deep-learning inference networks and deep vision primitives with TensorRT and Jetson TX1/TX2.
https://developer.nvidia.com/embedded
deep-learning inference computer-vision embedded image-recognition object-detection segmentation jetson jetson-tx1 jetson-tx2
tensorNet.cpp added maxBatchSize to tensorcache filename to allow multiple batch si 3 months ago
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 1/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
tensorNet.h added Doxygen build target under make: Nothing to be done for 'docs'. 4 months ago
README.md
This repo uses NVIDIA TensorRT for efficiently deploying neural networks onto the embedded platform, improving
performance and power efficiency using graph optimizations, kernel fusion, and half-precision FP16 on the Jetson.
Vision primitives, such as imageNet for image recognition, detectNet for object localization, and segNet for
segmentation, inherit from the shared tensorNet object. Examples are provided for streaming from live camera feed and
processing images from disk. See the Deep Vision API Reference Specification for accompanying documentation.
> Read our recent Parallel ForAll post, NVIDIA Jetson TX2 Delivers Twice the Intelligence to the Edge.
> See Image Segmentation models and training guide with aerial drone dataset.
> Try Object Detection training guide using DIGITS & MS-COCO training dataset.
> Use Image Recognition training guide using DIGITS & ImageNet ILSVRC12 dataset.
Table of Contents
DIGITS Workflow
System Setup
Building from Source on Jetson
Classifying Images with ImageNet
Using the Console Program on Jetson
Running the Live Camera Recognition Demo
Re-training the Network with DIGITS
Downloading Image Recognition Dataset
Customizing the Object Classes
Importing Classification Dataset into DIGITS
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 2/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Deployment: Jetson TX2 Developer Kit with JetPack 3.0 or newer (Ubuntu 16.04 aarch64).
Jetson TX1 Developer Kit with JetPack 2.3 or newer (Ubuntu 16.04 aarch64).
note: this branch is verified against the following BSP versions for Jetson TX1/TX2:
> Jetson TX2 - JetPack 3.0 / L4T R27.1 aarch64 (Ubuntu 16.04 LTS)
> Jetson TX1 - JetPack 2.3 / L4T R24.2 aarch64 (Ubuntu 16.04 LTS)
> Jetson TX1 - JetPack 2.3.1 / L4T R24.2.1 aarch64 (Ubuntu 16.04 LTS)
Note that TensorRT samples from the repo are intended for deployment on embedded Jetson TX1/TX2 module, however
when cuDNN and TensorRT have been installed on the host side, the TensorRT samples in the repo can be compiled for PC.
DIGITS Workflow
New to deep neural networks (DNNs) and machine learning? Take this introductory primer on training and inference.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 3/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Using NVIDIA deep learning tools, it's easy to Get Started training DNNs and deploying them into the field with high
performance. Discrete GPUs are typically used in a server, PC, or laptop for training with DIGITS, while Jetson and integrated
GPU is used by embedded form factors.
NVIDIA DIGITS is used to interactively train network models on annotated datasets in the cloud or PC, while TensorRT and
Jetson are used to deploy runtime inference in the field. TensorRT uses graph optimizations and half-precision FP16 support
to more than double DNN inferencing. Together, DIGITS and TensorRT form an effective workflow for developing and
deploying deep neural networks capable of implementing advanced AI and perception.
System Setup
During this tutorial, we will use a host PC (or AWS), for training DNNs, alongside a Jetson for inference. The host PC will also
serve to flash the Jetson with the latest JetPack. First we'll setup and configure the host PC with the required OS and tools.
http://releases.ubuntu.com/16.04/ubuntu-16.04.2-desktop-amd64.iso
http://releases.ubuntu.com/16.04/ubuntu-16.04.2-desktop-amd64.iso.torrent
Ubuntu 14.04 x86_64 may also be acceptable with minor modifications later while installing some packages with apt-get.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 4/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
After downloading JetPack from the link above, run it from the host PC with the following commands:
The JetPack GUI will start. Follow the step-by-step Install Guide to complete the setup. Near the beginning, JetPack will
confirm which generation Jetson you are developing for.
Select Jetson TX1 if you are using TX1, or Jetson TX2 if you're using TX2, and press Next to continue.
The next screen will list the packages available to be installed. The packages installed to the host are listed at the top under
the Host - Ubuntu dropdown, while those intended for the Jetson are shown near the bottom. You can select or deselect an
individual package for installation by clicking it's Action column.
Since CUDA will be used on the host for training DNNs, it's recommended to select the Full install by click on the radio button
in the top right. Then press Next to begin setup. JetPack will download and then install the sequence of packages. Note that
all the .deb packages are stored under the jetpack_downloads subdirectory if you are to need them later.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 5/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
After the downloads have finished installing, JetPack will enter the post-install phase where the JetPack is flashed with the
L4T BSP. You'll need to connect your Jetson to your host PC via the micro-USB port and cable included in the devkit. Then
enter your Jetson into recovery mode by holding down the Recovery button while pressing and releasing Reset. If you type
lsusb from the host PC after you've connected the micro-USB cable and entered the Jetson into recovery mode, you should
see the NVIDIA device come up under the list of USB devices. JetPack uses the micro-USB connection from the host to flash
the L4T BSP to the Jetson.
After flashing, the Jetson will reboot and if attached to an HDMI display, will boot up to the Ubuntu desktop. After this,
JetPack connects to the Jetson from the host via SSH to install additional packages to the Jetson, like the ARM aarch64
builds of CUDA Toolkit, cuDNN, and TensorRT. For JetPack to be able to reach the Jetson via SSH, the host PC should be
networked to the Jetson via Ethernet. This can be accomplished by running an Ethernet cable directly from the host to the
Jetson, or by connecting both devices to a router or switch the JetPack GUI will ask you to confirm which networking
scenario is being used. See the JetPack Install Guide for the full directions for installing JetPack and flashing Jetson.
To verify the CUDA toolkit and NVIDIA driver are working, run some tests that come with the CUDA samples:
$ cd /usr/local/cuda/samples
$ sudo make
$ cd bin/x86_64/linux/release/
$ ./deviceQuery
$ ./bandwidthTest --memory=pinned
https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v6/prod/8.0_20170307/Ubuntu16_04_x64/libcudnn6_6.0.20-1
https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v6/prod/8.0_20170307/Ubuntu16_04_x64/libcudnn6-dev_6.0.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 6/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
NVcaffe is the NVIDIA branch of Caffe with optimizations for GPU. NVcaffe uses cuDNN and is used by DIGITS for training
DNNs. To install it, clone the NVcaffe repo from GitHub and compile from source. Use the NVcaffe-0.15 branch like below.
note: for this tutorial, NVcaffe is only required on the host (for training). During inferencing phase TensorRT is used on
the Jetson and doesn't require caffe.
First some prequisite packages for Caffe are installed, including the Python bindings required by DIGITS:
$ sudo apt-get install --no-install-recommends build-essential cmake git gfortran libatlas-base-dev libboost-filesystem-de
$ sudo pip install --upgrade pip
$ git clone -b caffe-0.15 http://github.com/NVIDIA/caffe
$ cd caffe
$ sudo pip install -r python/requirements.txt
$ mkdir build
$ cd build
$ cmake ../ -DCUDA_USE_STATIC_CUDA_RUNTIME=OFF
$ make --jobs=4
$ make pycaffe
Caffe should now be configured and built. Now edit your user's ~/.bashrc to include the path to your Caffe tree (replace the
paths below to reflect your own):
export CAFFE_ROOT=/home/dusty/workspace/caffe
export PYTHONPATH=/home/dusty/workspace/caffe/python:$PYTHONPATH
Close and re-open the terminal for the changes to take effect.
To install DIGITS, first install the prerequisiste packages, then clone the DIGITS repo from GitHub:
$ sudo apt-get install --no-install-recommends graphviz python-dev python-flask python-flaskext.wtf python-gevent python-h
$ git clone http://github.com/nvidia/DIGITS
$ cd DIGITS
$ sudo pip install -r requirements.txt
Assuming that your terminal is still in the DIGITS directory, the webserver can be started by running the digits-devserver
Python script:
$ ./digits-devserver
___ ___ ___ ___ _____ ___
| \_ _/ __|_ _|_ _/ __|
| |) | | (_ || | | | \__ \
|___/___\___|___| |_| |___/ 5.1-dev
DIGITS will store user jobs (training datasets and model snapshots) under the digits/jobs directory.
To access the interactive DIGITS session, open your web browser and navigate to 0.0.0.0:5000 .
note: by default the DIGITS server will start on port 5000, but the port can be specified by passing the --port
argument to the digits-devserver script.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 7/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
The latest source can be obtained from GitHub and compiled onboard Jetson TX1/TX2.
note: this branch is verified against the following BSP versions for Jetson TX1/TX2:
> Jetson TX2 - JetPack 3.0 / L4T R27.1 aarch64 (Ubuntu 16.04 LTS)
> Jetson TX1 - JetPack 2.3 / L4T R24.2 aarch64 (Ubuntu 16.04 LTS)
> Jetson TX1 - JetPack 2.3.1 / L4T R24.2.1 aarch64 (Ubuntu 16.04 LTS)
To obtain the repository, navigate to a folder of your choosing on the Jetson. First, make sure git and cmake are installed
locally:
When cmake is run, a special pre-installation script (CMakePreBuild.sh) is run and will automatically install any
dependencies.
$ cd jetson-inference
$ mkdir build
$ cd build
$ cmake ../
note: the cmake command will launch the CMakePrebuild.sh script which asks for sudo while making sure prerequisite
packages have been installed on the Jetson. The script also downloads the network model snapshots from web
services.
Make sure you are still in the jetson-inference/build directory, created above in step #2.
Depending on architecture, the package will be built to either armhf or aarch64, with the following directory structure:
|-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
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 8/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
For reference, see the available vision primitives, including imageNet for image recognition and detectNet for object
localization.
/**
* Image recognition with GoogleNet/Alexnet or custom models, using TensorRT.
*/
class imageNet : public tensorNet
{
public:
/**
* Network choice enumeration.
*/
enum NetworkType
{
ALEXNET,
GOOGLENET
};
/**
* Load a new network instance
*/
static imageNet* Create( NetworkType networkType=GOOGLENET );
/**
* Load a new network instance
* @param prototxt_path File path to the deployable network prototxt
* @param model_path File path to the caffemodel
* @param mean_binary File path to the mean value binary proto
* @param class_info File path to list of class name labels
* @param input Name of the input layer blob.
*/
static imageNet* Create( const char* prototxt_path, const char* model_path, const char* mean_binary,
const char* class_labels, const char* input="data",
/**
* Determine the maximum likelihood image class.
* @param rgba float4 input image in CUDA device memory.
* @param width width of the input image in pixels.
* @param height height of the input image in pixels.
* @param confidence optional pointer to float filled with confidence value.
* @returns Index of the maximum class, or -1 on error.
*/
int Classify( float* rgba, uint32_t width, uint32_t height, float* confidence=NULL );
};
Both inherit from the shared tensorNet object which contains common TensorRT code.
The imageNet object accepts an input image and outputs the probability for each class. Having been trained on ImageNet
database of 1000 objects, the standard AlexNet and GoogleNet networks are downloaded during step 2 from above. As
examples of using imageNet we provide a command-line interface called imagenet-console and a live camera program
called imagenet-camera .
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 9/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
First, try using the imagenet-console program to test imageNet recognition on some example images. It loads an image,
uses TensorRT and the imageNet class to perform the inference, then overlays the classification and saves the output
image.
After building, make sure your terminal is located in the aarch64/bin directory:
$ cd jetson-inference/build/aarch64/bin
Then, classify an example image with the imagenet-console program. imagenet-console accepts 2 command-line
arguments: the path to the input image and path to the output image (with the class overlay printed).
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 10/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Next, we will use imageNet to classify a live video feed from the Jetson onboard camera.
The frames per second (FPS), classified object name from the video, and confidence of the classified object are printed to the
openGL window title bar. By default the application can recognize up to 1000 different types of objects, since Googlenet and
Alexnet are trained on the ILSVRC12 ImageNet database which contains 1000 classes of objects. The mapping of names for
the 1000 types of objects, you can find included in the repo under data/networks/ilsvrc12_synset_words.txt
note: by default, the Jetson's onboard CSI camera will be used as the video source. If you wish to use a USB webcam
instead, change the DEFAULT_CAMERA define at the top of imagenet-camera.cpp to reflect the /dev/video V4L2 device
of your USB camera. The model it's tested with is Logitech C920.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 11/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
To recognize a new object class, you can use DIGITS to re-train the network on new data. You can also organize the existing
classes differently, including group multiple subclasses into one. For example in this tutorial we'll take 230 of the 1000
classes, group those into 12 classes and retrain the network.
Let's start by downloading the ILSVRC12 images to work with, or you can substitute your own dataset in an Image Folder.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 12/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
includes 1 million images over 1000 different classes. The dataset is downloaded to the DIGITS server using the imagenet-
download.py image crawler.
To download the dataset, first make sure you have enough disk space on your DIGITS server (120GB recommended), then
run the following commands from a directory on that machine where you want the dataset stored:
In the commands above the list of image URLs along with the scripts are downloaded before launching the crawler.
note: be considerate running the image crawler from a corporate network, IT may flag the activity. It will probably take
overnight on a decent connection to download the 1000 ILSVRC12 classes (100GB).
The crawler will download images to subdirectories that correspond to it's classification. Each image class is stored in it's own
directory, with 1000 directories in total (one for each class in ILSVRC12). The folders are organized with a naming scheme
similar to:
n01440764/
n01443537/
n01484850/
n01491361/
n01494475/
...
These 8-digit ID's prefixed wth N are referred to as the synset ID of the class. The name string of the class can be looked up
in ilsvrc12_synset_words.txt . For example, synset n01484850 great white shark .
DIGITS expects the data in a hierarchy of folders, so we can create directories for the groups and then symbolically link to the
synsets from ILSVRC12 downloaded above. DIGITS will automatically combine images from all folders under the top-level
groups. The directory structure resembles the following, with the value in parenthesis indicates the number of classes used to
make up the group and the value next to the arrows indicating the synset ID linked to.
ball/ (7)
baseball (n02799071)
basketball (n02802426)
soccer ball (n04254680)
tennis ball (n04409515)
...
bear/ (4)
brown bear (n02132136)
black bear (n02133161)
polar bear (n02134084)
sloth bear (n02134418)
bike/ (3)
bird/ (17)
bottle/ (7)
cat/ (13)
dog/ (122)
fish/ (5)
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 13/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
fruit/ (12)
turtle/ (5)
vehicle/ (14)
sign/ (2)
Since there are actually a lot of synsets linked to from ILSVRC12, we provide the imagenet-subset.sh script to generate
the directory structure and links given the path to the dataset. Run the folowing commands from the DIGITS server:
$ wget https://rawgit.com/dusty-nv/jetson-inference/master/tools/imagenet-subset.sh
$ chmod +x imagenet-subset.sh
$ mkdir 12_classes
$ ./imagenet-subset.sh /opt/datasets/imagenet/ilsvrc12 12_classes
In this example the links are created in the 12_classes folder, with the first argument to the script being the path to
ILSVRC12 downloaded in the previous step.
Set the Training Images path to the 12_classes folder from the previous step and make the following
% for validation: 10
Group Name: ImageNet
Dataset Name: ImageNet-ILSVRC12-subset
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 14/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Use the Create button at the bottom of the page to launch the dataset import job. The size of the data subset is around
20GB, so depending on server I/O performance it takes 10-15 minutes. Next we'll create the new model and begin training it.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 15/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
After selecting a GPU to train on, click the Create button at the bottom to begin training.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 16/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 17/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
At this point, we can try testing our new model's inference on some example images in DIGITS. On the same page as the plot
above, scroll down under the Trained Models section. Under Test a Single Image , select an image to try (for example,
/ilsvrc12/n02127052/n02127052_1203.jpg ):
Press the Classify One button and you should see a page similar to:
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 18/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
The image is classified as the new GoogleNet-12 model as cat , while in the original GoogleNet-1000 it was under Lynx .
This indicates the new model is working ok, because the Lynx category was included in GoogleNet-12's training of cat.
Alternatively, if your Jetson and DIGITS server aren't accessible from the same network, you can use the step above to
download the snapshot to an intermediary machine and then use SCP or USB stick to copy it to Jetson.
Next we will load our custom snapshot into TensorRT, running on the Jetson.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 19/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
$ NET=networks/GoogleNet-ILSVRC12-subset
As before, the classification and confidence will be overlayed to the output image. When compared to the output of the
original network, the re-trained GoogleNet-12 makes similar classifications to the original GoogleNet-1000:
The extended command line parameters above also load custom classification models with imagenet-camera .
The detectNet object accepts as input the 2D image, and outputs a list of coordinates of the detected bounding boxes. To
train the object detection model, first a pretrained ImageNet recognition model (like Googlenet) is used with bounding
coordinate labels included in the training dataset in addition to the source imagery.
The following pretrained DetectNet models are included with the tutorial:
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 20/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
As with the previous examples, provided are a console program and a camera streaming program for using detectNet.
Regardless of dataset, DIGITS uses KITTI metadata format for ingesting the detection bounding labels. These consist of text
files with frame numbers corresponding to image filenames, including contents such as:
Read more about the folder structure and KITTI label format that DIGITS uses.
From a terminal on your DIGITS server download and extract sample MS-COCO classes already in DIGITS/KITTI format
here:
Included is the training data in DIGITS format for the airplane, bottle, chair, and dog classes. coco2kitty.py can be used to
convert other classes.
In the form fields, specify the following options and paths to the image and label folders under the location where you
extracted the aerial dataset:
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 21/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 22/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Name the dataset whatever you choose and click the Create button at the bottom of the page to launch the importing job.
Next we'll create the new detection model and begin training it.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 23/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
DetectNet's network default batch size of 10 consumes up to 12GB GPU memory during training. However by using the
Batch Accumulation field, you can also train DetectNet on a GPU with less than 12GB memory. See the table below
depending on the amount of GPU memory available in your DIGITS server:
4GB 2 5
8GB 5 2
If you're training on a card with 12GB of memory or more, leave the Batch Size as the default and leave the Batch
Accumulation blank. For GPUs with less memory, use the settings from above.
In the network area select the Custom Network tab and then copy/paste the contents of detectnet.prototxt
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 24/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Since DetectNet is derived from Googlenet, it is strongly recommended to use pre-trained weights from Googlenet as this will
help speed up and stabilize training significantly. Download the Googlenet model from here or by running the following
command from your DIGITS server:
wget http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel
Then specify the path to your Googlenet under the Pretrained Model field.
Select a GPU to train on and set a name and group for the model:
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 25/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 26/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 27/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
At this point, we can try testing our new model's inference on some example images in DIGITS. On the same page as the plot
above, scroll down under the Trained Models section. Set the Visualization Model to Bounding Boxes and under Test
a Single Image , select an image to try (for example, /coco/val/images/dog/000074.png ):
Press the Test One button and you should see a page similar to:
Alternatively, if your Jetson and DIGITS server aren't accessible from the same network, you can use the step above to
download the snapshot to an intermediary machine and then use SCP or USB stick to copy it to Jetson.
layer {
name: "cluster"
type: "Python"
bottom: "coverage"
bottom: "bboxes"
top: "bbox-list"
python_param {
module: "caffe.layers.detectnet.clustering"
layer: "ClusterDetections"
param_str: "640, 640, 16, 0.6, 2, 0.02, 22, 1"
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 28/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
}
}
Without this Python layer, the snapshot can now be imported into TensorRT.
To specify your model that you downloaded from DIGITS, use the syntax to detectnet-console below. First, for
convienience, set the path to your extracted snapshot into a $NET variable:
$ NET=20170504-190602-879f_epoch_100
note: the input_blob , output_cvg , and output_bbox arguments may be omitted if your DetectNet layer names
match the defaults above (i.e. if you are using the prototxt from following this tutorial). These optional command line
parameters are provided if you are using a customized DetectNet with different layer names.
Alternatively, to load one of the pretrained snapshots that comes with the repo, you can specify the pretrained model name as
the 3rd argument to detectnet-console :
The above command will process dog_1.jpg, saving it to output_1.jpg, using the pretrained DetectNet-COCO-Dog model.
This is a shortcut of sorts so you don't need to wait for the model to complete training if you don't want to.
Below is a table of the pretrained DetectNet snapshots downloaded with the repo (located in the data/networks directory
after running cmake step) and the associated argument to detectnet-console used for loading the pretrained model:
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 29/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
These all also have the python layer patch above already applied.
Let's try running some of the other COCO models. The training data for these are all included in the dataset downloaded
above. Although the DIGITS training example above was for the coco-dog model, the same procedure can be followed to
train DetectNet on the other classes included in the sample COCO dataset.
Included in the repo are also DetectNet models pretrained to detect humans. The pednet and multiped models
recognized pedestrians while facenet recognizes faces (from FDDB). Here's an example of detecting multiple humans
simultaneously in a crowded space:
note: to achieve maximum performance while running detectnet, increase the Jetson clock limits by running the script:
sudo ~/jetson_clocks.sh
note: by default, the Jetson's onboard CSI camera will be used as the video source. If you wish to use a USB webcam
instead, change the DEFAULT_CAMERA define at the top of detectnet-camera.cpp to reflect the /dev/video V4L2 device
of your USB camera and recompile. The webcam model it's tested with is Logitech C920.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 30/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
The segNet object accepts as input the 2D image, and outputs a second image with the per-pixel classification mask
overlay. Each pixel of the mask corresponds to the class of object that was classified.
note: see the DIGITS semantic segmentation example for more background info on segmentation.
To download and extract the dataset, run the following commands from the host PC running the DIGITS server:
The dataset includes various clips captured from flights of drone platforms, but the one we'll be focusing on in this tutorial is
under FPV/SFWA . Next we'll create the training database in DIGITS before training the model.
In the dataset creation form, specify the following options and paths to the image and label folders under the location where
you extracted the aerial dataset:
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 31/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Name the dataset whatever you choose and click the Create button at the bottom of the page to launch the importing job.
Next we'll create the new segmentation model and begin training.
To generate the pre-trained FCN-Alexnet model, open a terminal, navigate to the DIGITS semantic-segmantation example,
and run the net_surgery script:
$ cd DIGITS/examples/semantic-segmentation
$ ./net_surgery.py
Downloading files (this might take a few minutes)...
Downloading https://raw.githubusercontent.com/BVLC/caffe/rc3/models/bvlc_alexnet/deploy.prototxt...
Downloading http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel...
Loading Alexnet model...
...
Saving FCN-Alexnet model to fcn_alexnet.caffemodel
In the model creation form, select the dataset you previously created. Set Subtract Mean to None and the Base Learning
Rate to 0.0001 . To set the network topology in DIGITS, select the Custom Network tab and make sure the Caffe sub-tab
is selected. Copy/paste the FCN-Alexnet prototxt into the text box. Finally, set the Pretrained Model to the output that the
net_surgery generated above: DIGITS/examples/semantic-segmentation/fcn_alexnet.caffemodel
Give your aerial model a name and click the Create button at the bottom of the page to start the training job. After about 5
epochs, the Accuracy plot (in orange) should ramp up and the model becomes usable:
At this point, we can try testing our new model's inference on some example images in DIGITS.
Press Test One and you should see a display similar to:
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 32/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
There exist a couple non-essential layers included in the original FCN-Alexnet which aren't supported in TensorRT and
should be deleted from the deploy.prototxt included in the snapshot.
layer {
name: "upscore"
type: "Deconvolution"
bottom: "score_fr"
top: "upscore"
param {
lr_mult: 0.0
}
convolution_param {
num_output: 21
bias_term: false
kernel_size: 63
group: 21
stride: 32
weight_filler {
type: "bilinear"
}
}
}
layer {
name: "score"
type: "Crop"
bottom: "upscore"
bottom: "data"
top: "score"
crop_param {
axis: 2
offset: 18
}
}
And on line 24 of deploy.prototxt , change pad: 100 to pad: 0 . Finally copy the fpv-labels.txt and fpv-deploy-
colors.txt from the aerial dataset to your model snapshot folder on Jetson. Your FCN-Alexnet model snapshot is now
compatible with TensorRT. Now we can run it on Jetson and perform inference on images.
First, for convienience, set the path to your extracted snapshot into a $NET variable:
$ NET=20170421-122956-f7c0_epoch_5.0
This runs the specified segmentation model on a test image downloaded with the repo.
In addition to the pre-trained aerial model from this tutorial, the repo also includes pre-trained models on other segmentation
datasets, including Cityscapes, SYNTHIA, and Pascal-VOC.
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 33/34
7/13/2017 GitHub - dusty-nv/jetson-inference: Guide to deploying deep-learning inference networks and deep vision primitives with Ten
Extra Resources
In this area, links and resources for deep learning developers are listed:
Appendix
NVIDIA Deep Learning Institute Introductory QwikLabs
Building nvcaffe
Other Examples
ros_deep_learning - TensorRT inference ROS nodes
2017 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub API Training Shop Blog About
https://github.com/dusty-nv/jetson-inference#classifying-images-with-imagenet 34/34