NGC | Catalog
CatalogModelsVehicleTypeNet

VehicleTypeNet

Logo for VehicleTypeNet
Features
Description
Resnet18 model to classify a car crop into 1 out 6 car types.
Publisher
NVIDIA
Latest Version
pruned_v1.0.2
Modified
November 2, 2023
Size
19.06 MB

VehicleTypeNet Model Card

Model Overview

The model described in this card is a classification network, which aims to classify car images into 6 vehicle types:

  • coupe
  • sedan
  • SUV
  • van
  • large vehicle
  • truck

VehicleTypeNet is generally cascaded with DashCamNet or TrafficCamNet for smart city applications.

Model Architecture

This is a classification model with a Resnet18 backbone.

Training Algorithm

The training algorithm optimizes the network to minimize the categorical cross entropy loss for the classes. The training is carried out in two phases. In the first phase, the network is trained with regularization to facilitate pruning. Following the first phase, we prune the network removing channels whose kernel norms are below the pruning threshold. In the second phase the pruned network is retrained.

Reference

  • He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: CVPR (2016)

Intended Use

VehicleTypeNet is generally cascaded with DashCamNet or TrafficCamNet for smart city applications. For example, DashCamNet or TrafficCamNet acts as a primary detector, detecting the objects of interest and for each detected car the VehicleTypeNet acts as a secondary classifier determining the type of the car.

Input

RGB Images of dimensions: 224 X 224 X 3 (W x H x C) Channel Ordering of the Input: NCHW, where N = Batch Size, C = number of channels (3), H = Height of images (224), W = Width of the images (224) Input scale: None Mean subtraction: [103.939, 116.779, 123.68]

Output

Category labels.

How to use this model

This model needs to be used with NVIDIA Hardware and Software. For Hardware, the model can run on any NVIDIA GPU including NVIDIA Jetson devices. This model can only be used with Train Adapt Optimize (TAO) Toolkit, DeepStream SDK or TensorRT.

There are two flavors of the model:

  • unpruned
  • pruned

The unpruned model is intended for training using TAO Toolkit and the user's own dataset. This can provide high fidelity models that are adapted to the use case. The Jupyter notebook available as a part of TAO container can be used to re-train.

The pruned model is intended for efficient deployment on the edge using DeepStream SDK or TensorRT. This model accepts 224x224x3 dimension input tensors and outputs a 1x6 class confidence tensor. DeepStream provides a toolkit to create efficient video analytic pipelines to capture, decode, and pre-process the data before running inference. DeepStream provides a toolkit to attach the classification model to any primary detector. The primary detector will detect the object and crop the object before sending to secondary classifiers.

The unpruned and pruned models are encrypted and will only operate with the following key:

  • Model load key: tlt_encode

Please make sure to use this as the key for all TAO commands that require a model load key.

Model versions

  • unpruned_v1.0 - ResNet18 based pre-trained model.
  • pruned_v1.0 - ResNet18 deployment models. Contains common INT8 calibration cache for GPU and DLA.

Instructions to use the unpruned model with TAO

In order, to use this model as a pretrained weights for transfer learning, please use the below mentioned snippet as template for the model_config and traning_config component of the experiment spec file to train a Classification model. For more information on the experiment spec file, please refer to the TAO Toolkit User Guide.

model_config {
  arch: "resnet"
  n_layers: 18
  use_bias: True
  use_batch_norm: True
  all_projections: True
  use_pooling: False
  freeze_bn: False
  freeze_blocks: 0
  freeze_blocks: 1
  input_image_size: "3,224,224"
}

training_config{
  train_dataset_path: "/path/to/your/train/data"
  val_dataset_path: "/path/to/your/val/data"
  pretrained_model_path: "/path/to/your/pretrained/model"
  optimizer {
    sgd {
      lr: 0.01
      decay: 0.0
      momentum: 0.9
      nesterov: False
    }
  }
  batch_size_per_gpu: 256
  n_epochs: 80
  n_workers: 16
  reg_config {
    type: "L2"
    scope: "Conv2D,Dense"
    weight_decay: 0.00005
  }
}

Instructions to deploy the pruned model with DeepStream

To create the entire end-to-end video analytic application, deploy this model with DeepStream SDK. DeepStream SDK is a streaming analytic toolkit to accelerate building AI-based video analytic applications. DeepStream supports direct integration of this model into the deepstream sample app.

To deploy this model with DeepStream 5.1, please follow the instructions below:

  1. Run the default deepstream-app included in the DeepStream docker, by simply executing the commands below.

    ## Download Model:
    mkdir -p $HOME/vehicletypenet && \
    wget https://api.ngc.nvidia.com/v2/models/nvidia/tao/vehicletypenet/versions/pruned_v1.0/files/resnet18_vehicletypenet_pruned.etlt\
    -O $HOME/vehicletypenet/resnet18_vehicletypenet_pruned.etlt && \
    wget https://api.ngc.nvidia.com/v2/models/nvidia/tao/vehicletypenet/versions/pruned_v1.0/files/vehicletypenet_int8.txt \
    -O $HOME/vehicletypenet/vehicletypenet_int8.txt
    ## Run Application
    
    xhost +
    sudo docker run --gpus all -it --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -v $HOME:/opt/nvidia/deepstream/deepstream-5.1/samples/models/tlt_pretrained_models \
    -w /opt/nvidia/deepstream/deepstream-5.1/samples/configs/tlt_pretrained_models nvcr.io/nvidia/deepstream:5.1-21.02-samples \
    deepstream-app -c deepstream_app_source1_dashcamnet_vehiclemakenet_vehicletypenet.txt
    
  2. Install deepstream on your local host and run the deepstream-app.

To deploy this model with DeepStream, please follow the instructions below: Download and install DeepStream SDK. The installation instructions for DeepStream are provided in DeepStream development guide. The config files for the purpose-built models are located in:

/opt/nvidia/deepstream/deepstream-5.1/samples/configs/tlt_pretrained_models

/opt/nvidia/deepstream is the default DeepStream installation directory. This path will be different if you are installing in a different directory.

You will need multiple config files and 1 label file. These files are provided in the tlt_pretrained_models directory.

deepstream_app_source1_dashcamnet_vehiclemakenet_vehicletypenet.txt - Main config file for DeepStream app
config_infer_primary_dashcamnet.txt - File to configure primary detection (DashCamNet)
config_infer_secondary_vehicletypenet.txt - File to configure Vehicle type classifier
labels_dashcamnet.txt - Label file with 3 for object detection
labels_vehiclemakenet.txt - Label file with 6 classes of Vehicle type

Note: The deepstream_app_source1_dashcamnet_vehiclemakenet_vehicletypenet.txt configures 3 models: DashCamNet as primary detector, and VehicleMakeNet and VehicleTypeNet as secondary classifiers. The classification models are typically used after initial object detection.

Key Parameters in config_infer_secondary_vehicletypenet.txt

tlt-model-key
tlt-encoded-model
labelfile-path
int8-calib-file
input-dims
num-detected-classes

Run deepstream-app:

deepstream-app -c deepstream_app_source1_dashcamnet_vehiclemakenet_vehicletypenet.txt

Documentation to deploy with DeepStream is provided in "Deploying to DeepStream" chapter of TAO User Guide.

Training Data

VehicleTypeNet was trained on a proprietary dataset with more than 60K car images. The training dataset contains car crops from a mix of camera heights, camera angles, field-of view (FOV) and occlusions.

Evaluation Data

Dataset

The inference performance of the VehicleType model was measured against 3000 proprietary images across a variety of environments, occlusion conditions, camera heights and camera angles.

Methodology and KPI

The KPI for the evaluation data are reported in the table below. Model is evaluated based on Top-1 accuracy.

Model VehicleTypeNet
Content Top1 Accuracy
Evaluation Set 88%

Real-time Inference Performance

The inference is run on the provided pruned model at INT8 precision. On Jetson Nano, FP16 precision is used. The inference performance is run using trtexec on Jetson Nano, AGX Xavier, Xavier NX and NVIDIA T4 GPU. The Jetson devices are running at Max-N configuration for maximum GPU frequency. The performance shown here is the inference only performance. The end-to-end performance with streaming video data might slightly vary depending on other bottlenecks in the hardware and software.

Limitations

Top view

This model is design to classify detected cars from DashCamNet model with cars visible at a 5ft height, with visible front, back or side facia. The model doesn't classify well for cars seen from top view.

Using TAO Pre-trained Models

License

License to use this model is covered by the Model EULA. By downloading the unpruned or pruned version of the model, you accept the terms and conditions of these licenses.

Technical blogs

Suggested reading

Ethical Consideration

NVIDIA VehicleTypeNet model classifies the type of the car from a given crop. Training and evaluation dataset mostly consists of North American content. An ideal training and evaluation dataset would additionally include content from other geographies as well.

NVIDIA’s platforms and application frameworks enable developers to build a wide array of AI applications. Consider potential algorithmic bias when choosing or creating the models being deployed. Work with the model’s developer to ensure that it meets the requirements for the relevant industry and use case; that the necessary instruction and documentation are provided to understand error rates, confidence intervals, and results; and that the model is being used under the conditions and in the manner intended.