Tiny YoloV3: Number of unused weights left : 1

• Jetson Nano
• DeepStream Version 4.0
• JetPack Version 4.2.2
• TensorRT Version 5.1

Hi! I am trying to use my custom tiny yolov3 model, but i got this error:

0:00:01.554948727 12022 0x55c692c830 INFO nvinfer gstnvinfer.cpp:519:gst_nvinfer_logger:<primary-nvinference-engine> NvDsInferContext[UID 1]:initialize(): Trying to create engine from model files
Loading pre-trained weights...
Loading complete!
Total Number of weights read : 8676245
      layer               inp_size            out_size       weightPtr
(1)   conv-bn-leaky     3 x 416 x 416      16 x 416 x 416    496   
(2)   maxpool          16 x 416 x 416      16 x 208 x 208    496   
(3)   conv-bn-leaky    16 x 208 x 208      32 x 208 x 208    5232  
(4)   maxpool          32 x 208 x 208      32 x 104 x 104    5232  
(5)   conv-bn-leaky    32 x 104 x 104      64 x 104 x 104    23920 
(6)   maxpool          64 x 104 x 104      64 x  52 x  52    23920 
(7)   conv-bn-leaky    64 x  52 x  52     128 x  52 x  52    98160 
(8)   maxpool         128 x  52 x  52     128 x  26 x  26    98160 
(9)   conv-bn-leaky   128 x  26 x  26     256 x  26 x  26    394096
(10)  maxpool         256 x  26 x  26     256 x  13 x  13    394096
(11)  conv-bn-leaky   256 x  13 x  13     512 x  13 x  13    1575792
(12)  maxpool         512 x  13 x  13     512 x  13 x  13    1575792
(13)  conv-bn-leaky   512 x  13 x  13    1024 x  13 x  13    6298480
(14)  conv-bn-leaky  1024 x  13 x  13     256 x  13 x  13    6561648
(15)  conv-bn-leaky   256 x  13 x  13     512 x  13 x  13    7743344
(16)  conv-linear     512 x  13 x  13      18 x  13 x  13    7752578
(17)  yolo             18 x  13 x  13      18 x  13 x  13    7752578
(18)  route                  -            256 x  13 x  13    7752578
(19)  conv-bn-leaky   256 x  13 x  13     128 x  13 x  13    7785858
(20)  upsample        128 x  13 x  13     128 x  26 x  26        - 
(21)  route                  -            384 x  26 x  26    7785858
(22)  conv-bn-leaky   384 x  26 x  26     256 x  26 x  26    8671618
(23)  conv-linear     256 x  26 x  26      18 x  26 x  26    8676244
(24)  yolo             18 x  26 x  26      18 x  26 x  26    8676244
Number of unused weights left : 1
jcounter: yolo.cpp:349: nvinfer1::INetworkDefinition* Yolo::createYoloNetwork(std::vector<float>&, std::vector<nvinfer1::Weights>&): Assertion `0` failed.

I have trained model for detecting only one class. So I changed NUM_CLASSES_YOLO = 1 in nvdsparsebbox_Yolo and filters=18, classes=1 for both yolo output in yolov3-tiny.cfg:

[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear

[yolo]
mask = 3,4,5
anchors = 10,14,  23,27,  37,58,  81,82,  135,169,  344,319
classes=1
num=6
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
#######################
[convolutional]
size=1
stride=1
pad=1
filters=18
activation=linear

[yolo]
mask = 0,1,2
anchors = 10,14,  23,27,  37,58,  81,82,  135,169,  344,319
classes=1
num=6
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

Model works fine with Darknet app. Can anyone help me?

Which training framework did you use ? Are the dimensions of the final layer as you expect ?

(17)  yolo             18 x  13 x  13      18 x  13 x  13    7752578
(24)  yolo             18 x  26 x  26      18 x  26 x  26    8676244

The issue may be due to the header size in the weights file. You can try increase that by 4bytes more.
Have a look at the loadWeights function in trt_utils.cpp

1 Like

Thank you very much! The problem was in file.ignore(4 * 5). Someone changed it to file.ignore(4 * 4).