How to get information from DL model
  • 25 Apr 2022
  • 2 Minutes to read
  • Contributors
  • Dark
    Light

How to get information from DL model

  • Dark
    Light

Article Summary

In order to get information about DL model, we need to use a third party tool named Netron. You can get more information on how to install or use it online through webapp at https://github.com/lutzroeder/netron. In this article, we will use Netron webapp.

From Author of Netron 

Netron is a viewer for neural network, deep learning and machine learning models.

Netron supports ONNX, TensorFlow Lite, Caffe, Keras, Darknet, PaddlePaddle, ncnn, MNN, Core ML, RKNN, MXNet, MindSpore Lite, TNN, Barracuda, Tengine, CNTK, TensorFlow.js, Caffe2 and UFF.

Netron has experimental support for PyTorch, TensorFlow, TorchScript, OpenVINO, Torch, Vitis AI, kmodel, Arm NN, BigDL, Chainer, Deeplearning4j, MediaPipe, ML.NET and scikit-learn.

Above is a sample of Netron when open Inception_V1 model from ONNX format. We will use a Yolov4 model to as sample in our next part.

For EVA, we will need the information of the following aspects ( not all information is required for all plugins but it differs based on plugin ) :

  • Input tensor dimension and channel order 
  • Output tensor dimension

After uploading your model to the webapp, press on the top left button with three horizontal line and select Properties. As in above image, you can see that there is one input node with name "000_net" which has dimension 1,3,416,416. This will give use two information, First is that the input dimension order is NCHW and the second is that input image width and height is 416 pixels each.

For output nodes, we have thress nodes with name : "082_convolutional","094_convolutional", "106_convolutional". Their dimension give us information we need for the blob-size parameter of adtrans_yolo plugin. In here because all the two dimensions of each output node are similar, we can use it as 13,26,52 to input in adtrans_yolo plugin. This also indirectly give us another parameter for adtrans_yolo, which is class_num ( number of class trained for this model). According to Yolov3/v4 paper, the second value of output nodes dimension will related to class_num  in this equation :

                   b = (class_num  +5 ) x 3

With b is the second value of output nodes dimension

As of above model, b = 255, which lead to class_num  = 80

For Yolov3/v4 and Yolov3/v4-Tiny

Yolo family also need special parameters which can only get from the .cfg file of their original Darknet format. Information we can get from this .cfg file that may need in using adtrans_yolo plugin is mask and anchors

..........
..........
[yolo]
mask = 6,7,8
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326
classes=80
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
..........
..........
[yolo]
mask = 3,4,5
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326
classes=80
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
..........
..........
[yolo]
mask = 0,1,2
anchors = 10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326
classes=80
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

Above is the text of one of three output nodes from Yolov3 model. We can search for the keyword "mask" which will lead to these nodes. We can see that the mask value in order from top-down are : "(6,7,8),(3,4,5),(0,1,2)". The anchors parameters of these three are the same and is "10,13,  16,30,  33,23,  30,61,  62,45,  59,119,  116,90,  156,198,  373,326" , which can be used in adtrans_yolo 's "anchor" parameter in format of  "(10,13),(16,30),(33,23),(30,61),(62,45),(59,119),(116,90),(156,198),(373,326)" . Note that Yolov3 and Yolov4 shares the same anchors but that is correct with original darknet model only. Yolov3-Tiny and Yolov4-Tiny also shares the same anchor value but they are different from Yolov3/v4 model. Yolov4-Tiny also differs with Yolov3-Tiny in "mask" value. 


Was this article helpful?