DS4.0 TX2 : precision detection decreased a lot

Hello,
I’m using slim yolov3 model based on DS4.0 ,and modified yolo parse code, tensorRT could parse the net successfully ,but the precision detection decreased a lot, I try to use diffferent network-mode ,but it still no improvement.

I checked all the config file ,not found any problem.

I just update two points based on source code of createYoloNetwork function.

Could you help me to check this problem ,I think it shouldn’t decrease so much for precision.

adding parse more tensor for “m_configBlocks.at(i).at(“type”) == “route””

2.adding same padding for yolov3 maxpool

else if (m_configBlocks.at(i).at("type") == "maxpool")
        {
            // Add same padding layers
            if (m_configBlocks.at(i).at("size") == "2" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            if (m_configBlocks.at(i).at("size") == "5" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            if (m_configBlocks.at(i).at("size") == "9" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            if (m_configBlocks.at(i).at("size") == "13" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            std::string inputVol = dimsToString(previous->getDimensions());
            nvinfer1::ILayer* out = netAddMaxpool(i, m_configBlocks.at(i), previous, network);
            previous = out->getOutput(0);
            assert(previous != nullptr);
            std::string outputVol = dimsToString(previous->getDimensions());
            tensorOutputs.push_back(out->getOutput(0));
            printLayerInfo(layerIndex, "maxpool", inputVol, outputVol, std::to_string(weightPtr));
        }
Using winsys: x11 
Creating LL OSD context new
0:00:01.120080395  1614   0x7f38002300 INFO                 nvinfer gstnvinfer.cpp:519:gst_nvinfer_logger:<primary_gie_classifier> NvDsInferContext[UID 1]:initialize(): Trying to create engine from model files
0:00:01.121460246  1614   0x7f38002300 WARN                 nvinfer gstnvinfer.cpp:515:gst_nvinfer_logger:<primary_gie_classifier> NvDsInferContext[UID 1]:generateTRTModel(): INT8 not supported by platform. Trying FP16 mode.
Loading pre-trained weights...
Loading complete!
Total Number of weights read : 11114504
      layer               inp_size            out_size       weightPtr
(1)   conv-bn-leaky     3 x 608 x 608       9 x 608 x 608    279   
(2)   conv-bn-leaky     9 x 608 x 608      50 x 304 x 304    4529  
(3)   conv-bn-leaky    50 x 304 x 304      25 x 304 x 304    5879  
(4)   conv-bn-leaky    25 x 304 x 304      50 x 304 x 304    17329 
(5)   skip             50 x 304 x 304      50 x 304 x 304        - 
(6)   conv-bn-leaky    50 x 304 x 304     117 x 152 x 152    70447 
(7)   conv-bn-leaky   117 x 152 x 152      16 x 152 x 152    72383 
(8)   conv-bn-leaky    16 x 152 x 152     117 x 152 x 152    89699 
(9)   skip            117 x 152 x 152     117 x 152 x 152        - 
(10)  conv-bn-leaky   117 x 152 x 152      40 x 152 x 152    94539 
(11)  conv-bn-leaky    40 x 152 x 152     117 x 152 x 152    137127
(12)  skip            117 x 152 x 152     117 x 152 x 152        - 
(13)  conv-bn-leaky   117 x 152 x 152     244 x  76 x  76    395035
(14)  conv-bn-leaky   244 x  76 x  76      43 x  76 x  76    405699
(15)  conv-bn-leaky    43 x  76 x  76     244 x  76 x  76    501103
(16)  skip            244 x  76 x  76     244 x  76 x  76        - 
(17)  conv-bn-leaky   244 x  76 x  76      71 x  76 x  76    518711
(18)  conv-bn-leaky    71 x  76 x  76     244 x  76 x  76    675603
(19)  skip            244 x  76 x  76     244 x  76 x  76        - 
(20)  conv-bn-leaky   244 x  76 x  76      74 x  76 x  76    693955
(21)  conv-bn-leaky    74 x  76 x  76     244 x  76 x  76    857435
(22)  skip            244 x  76 x  76     244 x  76 x  76        - 
(23)  conv-bn-leaky   244 x  76 x  76      63 x  76 x  76    873059
(24)  conv-bn-leaky    63 x  76 x  76     244 x  76 x  76    1012383
(25)  skip            244 x  76 x  76     244 x  76 x  76        - 
(26)  conv-bn-leaky   244 x  76 x  76      48 x  76 x  76    1024287
(27)  conv-bn-leaky    48 x  76 x  76     244 x  76 x  76    1130671
(28)  skip            244 x  76 x  76     244 x  76 x  76        - 
(29)  conv-bn-leaky   244 x  76 x  76      56 x  76 x  76    1144559
(30)  conv-bn-leaky    56 x  76 x  76     244 x  76 x  76    1268511
(31)  skip            244 x  76 x  76     244 x  76 x  76        - 
(32)  conv-bn-leaky   244 x  76 x  76      60 x  76 x  76    1283391
(33)  conv-bn-leaky    60 x  76 x  76     244 x  76 x  76    1416127
(34)  skip            244 x  76 x  76     244 x  76 x  76        - 
(35)  conv-bn-leaky   244 x  76 x  76      43 x  76 x  76    1426791
(36)  conv-bn-leaky    43 x  76 x  76     244 x  76 x  76    1522195
(37)  skip            244 x  76 x  76     244 x  76 x  76        - 
(38)  conv-bn-leaky   244 x  76 x  76     457 x  38 x  38    2527595
(39)  conv-bn-leaky   457 x  38 x  38      89 x  38 x  38    2568624
(40)  conv-bn-leaky    89 x  38 x  38     457 x  38 x  38    2936509
(41)  skip            457 x  38 x  38     457 x  38 x  38        - 
(42)  conv-bn-leaky   457 x  38 x  38      74 x  38 x  38    2970623
(43)  conv-bn-leaky    74 x  38 x  38     457 x  38 x  38    3276813
(44)  skip            457 x  38 x  38     457 x  38 x  38        - 
(45)  conv-bn-leaky   457 x  38 x  38      69 x  38 x  38    3308622
(46)  conv-bn-leaky    69 x  38 x  38     457 x  38 x  38    3594247
(47)  skip            457 x  38 x  38     457 x  38 x  38        - 
(48)  conv-bn-leaky   457 x  38 x  38      87 x  38 x  38    3634354
(49)  conv-bn-leaky    87 x  38 x  38     457 x  38 x  38    3994013
(50)  skip            457 x  38 x  38     457 x  38 x  38        - 
(51)  conv-bn-leaky   457 x  38 x  38      72 x  38 x  38    4027205
(52)  conv-bn-leaky    72 x  38 x  38     457 x  38 x  38    4325169
(53)  skip            457 x  38 x  38     457 x  38 x  38        - 
(54)  conv-bn-leaky   457 x  38 x  38      63 x  38 x  38    4354212
(55)  conv-bn-leaky    63 x  38 x  38     457 x  38 x  38    4615159
(56)  skip            457 x  38 x  38     457 x  38 x  38        - 
(57)  conv-bn-leaky   457 x  38 x  38      38 x  38 x  38    4632677
(58)  conv-bn-leaky    38 x  38 x  38     457 x  38 x  38    4790799
(59)  skip            457 x  38 x  38     457 x  38 x  38        - 
(60)  conv-bn-leaky   457 x  38 x  38      65 x  38 x  38    4820764
(61)  conv-bn-leaky    65 x  38 x  38     457 x  38 x  38    5089937
(62)  skip            457 x  38 x  38     457 x  38 x  38        - 
(63)  conv-bn-leaky   457 x  38 x  38     864 x  19 x  19    8647025
(64)  conv-bn-leaky   864 x  19 x  19      91 x  19 x  19    8726013
(65)  conv-bn-leaky    91 x  19 x  19     864 x  19 x  19    9437085
(66)  skip            864 x  19 x  19     864 x  19 x  19        - 
(67)  conv-bn-leaky   864 x  19 x  19      53 x  19 x  19    9483089
(68)  conv-bn-leaky    53 x  19 x  19     864 x  19 x  19    9898673
(69)  skip            864 x  19 x  19     864 x  19 x  19        - 
(70)  conv-bn-leaky   864 x  19 x  19      52 x  19 x  19    9943809
(71)  conv-bn-leaky    52 x  19 x  19     864 x  19 x  19    10351617
(72)  skip            864 x  19 x  19     864 x  19 x  19        - 
(73)  conv-bn-leaky   864 x  19 x  19      63 x  19 x  19    10406301
(74)  conv-bn-leaky    63 x  19 x  19     864 x  19 x  19    10899645
(75)  skip            864 x  19 x  19     864 x  19 x  19        - 
(76)  conv-bn-leaky   864 x  19 x  19      11 x  19 x  19    10909193
(77)  conv-bn-leaky    11 x  19 x  19      33 x  19 x  19    10912592
(78)  conv-bn-leaky    33 x  19 x  19      12 x  19 x  19    10913036
inputDims.d=19,outputDim=19,padding.d[0]=0,stride.d[0]=1 /n(79)  maxpool          12 x  19 x  19      12 x  19 x  19    10913036
idx=-2 
tensorOutputs.size=79 
+idx=77 
(80)  route                  -             12 x  19 x  19    10913036
inputDims.d=19,outputDim=19,padding.d[0]=0,stride.d[0]=1 /n(81)  maxpool          12 x  19 x  19      12 x  19 x  19    10913036
idx=-4 
tensorOutputs.size=81 
+idx=77 
(82)  route                  -             12 x  19 x  19    10913036
inputDims.d=19,outputDim=19,padding.d[0]=0,stride.d[0]=1 /n(83)  maxpool          12 x  19 x  19      12 x  19 x  19    10913036
cont-idx[0]=-1 
pos=2 
cont-idx[1]=-3 
pos=5 
cont-idx[2]=-5 
pos=8 
cont-idx[3]=-6 
idx[0]=-1 
tensorOutputs.size=83 
idx[0]=82 
idx[1]=-3 
tensorOutputs.size=83 
idx[1]=80 
idx[2]=-5 
tensorOutputs.size=83 
idx[2]=78 
idx[3]=-6 
tensorOutputs.size=83 
idx[3]=77 
cont=4 
(84)  route                  -             48 x  19 x  19    10913036
(85)  conv-bn-leaky    48 x  19 x  19      18 x  19 x  19    10913972
(86)  conv-bn-leaky    18 x  19 x  19      20 x  19 x  19    10917292
(87)  conv-bn-leaky    20 x  19 x  19      12 x  19 x  19    10917580
(88)  conv-bn-leaky    12 x  19 x  19     120 x  19 x  19    10931020
(89)  conv-linear     120 x  19 x  19      45 x  19 x  19    10936465
(90)  yolo             45 x  19 x  19      45 x  19 x  19    10936465
idx=-4 
tensorOutputs.size=90 
+idx=86 
(91)  route                  -             12 x  19 x  19    10936465
(92)  conv-bn-leaky    12 x  19 x  19      72 x  19 x  19    10937617
(93)  upsample         72 x  19 x  19      72 x  38 x  38        - 
cont-idx[0]=-1 
pos=2 
cont-idx[1]=61 
idx[0]=-1 
tensorOutputs.size=93 
idx[0]=92 
idx[1]=61 
tensorOutputs.size=93 
idx[1]=61 
cont=2 
(94)  route                  -            529 x  38 x  38    10937617
(95)  conv-bn-leaky   529 x  38 x  38      43 x  38 x  38    10960536
(96)  conv-bn-leaky    43 x  38 x  38      18 x  38 x  38    10967574
inputDims.d=38,outputDim=38,padding.d[0]=0,stride.d[0]=1 /n(97)  maxpool          18 x  38 x  38      18 x  38 x  38    10967574
idx=-2 
tensorOutputs.size=97 
+idx=95 
(98)  route                  -             18 x  38 x  38    10967574
inputDims.d=38,outputDim=38,padding.d[0]=0,stride.d[0]=1 /n(99)  maxpool          18 x  38 x  38      18 x  38 x  38    10967574
idx=-4 
tensorOutputs.size=99 
+idx=95 
(100) route                  -             18 x  38 x  38    10967574
inputDims.d=38,outputDim=38,padding.d[0]=0,stride.d[0]=1 /n(101) maxpool          18 x  38 x  38      18 x  38 x  38    10967574
cont-idx[0]=-1 
pos=2 
cont-idx[1]=-3 
pos=5 
cont-idx[2]=-5 
pos=8 
cont-idx[3]=-6 
idx[0]=-1 
tensorOutputs.size=101 
idx[0]=100 
idx[1]=-3 
tensorOutputs.size=101 
idx[1]=98 
idx[2]=-5 
tensorOutputs.size=101 
idx[2]=96 
idx[3]=-6 
tensorOutputs.size=101 
idx[3]=95 
cont=4 
(102) route                  -             72 x  38 x  38    10967574
(103) conv-bn-leaky    72 x  38 x  38      42 x  38 x  38    10970766
(104) conv-bn-leaky    42 x  38 x  38      54 x  38 x  38    10991394
(105) conv-bn-leaky    54 x  38 x  38      23 x  38 x  38    10992728
(106) conv-bn-leaky    23 x  38 x  38     157 x  38 x  38    11025855
(107) conv-linear     157 x  38 x  38      45 x  38 x  38    11032965
(108) yolo             45 x  38 x  38      45 x  38 x  38    11032965
idx=-4 
tensorOutputs.size=108 
+idx=104 
(109) route                  -             23 x  38 x  38    11032965
(110) conv-bn-leaky    23 x  38 x  38      50 x  38 x  38    11034315
(111) upsample         50 x  38 x  38      50 x  76 x  76        - 
cont-idx[0]=-1 
pos=2 
cont-idx[1]=36 
idx[0]=-1 
tensorOutputs.size=111 
idx[0]=110 
idx[1]=36 
tensorOutputs.size=111 
idx[1]=36 
cont=2 
(112) route                  -            294 x  76 x  76    11034315
(113) conv-bn-leaky   294 x  76 x  76      33 x  76 x  76    11044149
(114) conv-bn-leaky    33 x  76 x  76      57 x  76 x  76    11061306
(115) conv-bn-leaky    57 x  76 x  76      15 x  76 x  76    11062221
inputDims.d=76,outputDim=76,padding.d[0]=0,stride.d[0]=1 /n(116) maxpool          15 x  76 x  76      15 x  76 x  76    11062221
idx=-2 
tensorOutputs.size=116 
+idx=114 
(117) route                  -             15 x  76 x  76    11062221
inputDims.d=76,outputDim=76,padding.d[0]=0,stride.d[0]=1 /n(118) maxpool          15 x  76 x  76      15 x  76 x  76    11062221
idx=-4 
tensorOutputs.size=118 
+idx=114 
(119) route                  -             15 x  76 x  76    11062221
inputDims.d=76,outputDim=76,padding.d[0]=0,stride.d[0]=1 /n(120) maxpool          15 x  76 x  76      15 x  76 x  76    11062221
cont-idx[0]=-1 
pos=2 
cont-idx[1]=-3 
pos=5 
cont-idx[2]=-5 
pos=8 
cont-idx[3]=-6 
idx[0]=-1 
tensorOutputs.size=120 
idx[0]=119 
idx[1]=-3 
tensorOutputs.size=120 
idx[1]=117 
idx[2]=-5 
tensorOutputs.size=120 
idx[2]=115 
idx[3]=-6 
tensorOutputs.size=120 
idx[3]=114 
cont=4 
(121) route                  -             60 x  76 x  76    11062221
(122) conv-bn-leaky    60 x  76 x  76      44 x  76 x  76    11086157
(123) conv-bn-leaky    44 x  76 x  76      41 x  76 x  76    11088125
(124) conv-bn-leaky    41 x  76 x  76      63 x  76 x  76    11111624
(125) conv-linear      63 x  76 x  76      45 x  76 x  76    11114504
(126) yolo             45 x  76 x  76      45 x  76 x  76    11114504
Output blob names :
yolo_90
yolo_108
yolo_126
Total number of layers: 272
Total number of layers on DLA: 0
Building the TensorRT Engine...

Sorry we haven’t tried slim yolov3 model before, but if you have been able to generate the engine successfully, you can check if something in the output bounding box parsing needs to be changed ? You can find it in nvdsparsebbox_Yolo.cpp file.

Hello,
I have checked the file of nvdsparsebbox_Yolo.cpp, the parametre is same with yolov3, such as kANCHORS/ kMASKS/ kNMS_THRESH/ kPROB_THRESH, you can see the cfg file of slimyolov3.

So I feel a little strange, why the precision detection decreased so lot, for example, it can detect out 10 objects using darknet to run this net model, but it can only detect out five objects using DS4.0, So I think somewhere maybe not correct for YoloNetwork engine.

Can you give me some suggestions? or a reference case ?

below is the my modified code:

else if (m_configBlocks.at(i).at("type") == "route")
        {   
            int cont=0;
            int idx[6];
            int lac[6];
            size_t found = m_configBlocks.at(i).at("layers").find(",");
            if (found != std::string::npos)
            {
		size_t pos;
		int size=m_configBlocks.at(i).at("layers").size();
		for(int j=0; j<size; j++)
		  {
		    pos= m_configBlocks.at(i).at("layers").find(",",j);
		    if(pos!= std::string::npos)
		    {
			if(cont==0)
			{
		      		lac[cont]=0;
			}


                      idx[cont] = std::stoi(trim(m_configBlocks.at(i).at("layers").substr(lac[cont], pos)));
		      printf("cont-idx[%d]=%d \n",cont,idx[cont]);
		      cont=cont+1;
		      lac[cont]=pos+1;
		      //std::string s= m_configBlocks.at(i).at("layers").substr(i,pos-i);
		      //result.push_back(s);
		      j=pos+1;
 		      printf("pos=%d \n",pos);
		    }
		else{
			idx[cont] = std::stoi(trim(m_configBlocks.at(i).at("layers").substr(lac[cont])));
		      printf("cont-idx[%d]=%d \n",cont,idx[cont]);
		      cont=cont+1;
			break;
			}
		  }



                //int idx1 = std::stoi(trim(m_configBlocks.at(i).at("layers").substr(0, found)));
               // int idx2 = std::stoi(trim(m_configBlocks.at(i).at("layers").substr(found + 1)));


		//int idx3 = std::stoi(trim(m_configBlocks.at(i).at("layers").substr(found + 2)));
		//int idx4 = std::stoi(trim(m_configBlocks.at(i).at("layers").substr(found + 3)));
		//int idx3=-5;
		//int idx4=-6;

		for(int j=0; j<cont; j++)
		{

			printf("idx[%d]=%d \n",j,idx[j]);
		     if (idx[j] < 0)
		        {
		            idx[j] = tensorOutputs.size() + idx[j];
		        }
			printf("tensorOutputs.size=%d \n",tensorOutputs.size());
                	assert(idx[j] < static_cast<int>(tensorOutputs.size()) && idx[j] >= 0);
			printf("idx[%d]=%d \n",j,idx[j]);
		//printLayerInfo(idx1, idx2);
		}
/*
                if (idx1 < 0)
                {
                    idx1 = tensorOutputs.size() + idx1;
                }
                if (idx2 < 0)
                {
                    idx2 = tensorOutputs.size() + idx2;
                }
                if (idx3 < 0)
                {
                    idx3 = tensorOutputs.size() + idx3;
                }
                if (idx4 < 0)
                {
                    idx4 = tensorOutputs.size() + idx4;
                }
                assert(idx1 < static_cast<int>(tensorOutputs.size()) && idx1 >= 0);
                assert(idx2 < static_cast<int>(tensorOutputs.size()) && idx2 >= 0);
                assert(idx3 < static_cast<int>(tensorOutputs.size()) && idx3 >= 0);
                assert(idx4 < static_cast<int>(tensorOutputs.size()) && idx4 >= 0);
*/
                nvinfer1::ITensor** concatInputs
                    = reinterpret_cast<nvinfer1::ITensor**>(malloc(sizeof(nvinfer1::ITensor*) * cont));
		printf("cont=%d \n",cont);
		for(int j=0; j<cont; j++)
		{
                	concatInputs[j] = tensorOutputs[idx[j]];
		}

 //               concatInputs[0] = tensorOutputs[idx1];
 //               concatInputs[1] = tensorOutputs[idx2];
 //               concatInputs[2] = tensorOutputs[idx3];
  //              concatInputs[3] = tensorOutputs[idx4];
                nvinfer1::IConcatenationLayer* concat
                    = network->addConcatenation(concatInputs, cont);
                assert(concat != nullptr);
                std::string concatLayerName = "route_" + std::to_string(i - 1);
                concat->setName(concatLayerName.c_str());
                // concatenate along the channel dimension
                concat->setAxis(0);
                previous = concat->getOutput(0);
                assert(previous != nullptr);
                std::string outputVol = dimsToString(previous->getDimensions());
                // set the output volume depth

		channels= getNumChannels(tensorOutputs[idx[0]]);
		for(int j=1; j<cont; j++)
		{
			printf("+channels=%d \n",channels);
			channels=channels+getNumChannels(tensorOutputs[idx[j]]);
		}
			printf("+channels=%d \n",channels);
               // channels
                  //  = getNumChannels(tensorOutputs[idx1]) + getNumChannels(tensorOutputs[idx2]) + getNumChannels(tensorOutputs[idx3]) + getNumChannels(tensorOutputs[idx4]);

                tensorOutputs.push_back(concat->getOutput(0));
                printLayerInfo(layerIndex, "route", "        -", outputVol,
                               std::to_string(weightPtr));
            }
else if (m_configBlocks.at(i).at("type") == "maxpool")
        {
            // Add same padding layers
            if (m_configBlocks.at(i).at("size") == "2" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            if (m_configBlocks.at(i).at("size") == "5" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            if (m_configBlocks.at(i).at("size") == "9" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            if (m_configBlocks.at(i).at("size") == "13" && m_configBlocks.at(i).at("stride") == "1")
            {
                m_TinyMaxpoolPaddingFormula->addSamePaddingLayer("maxpool_" + std::to_string(i));
            }
            std::string inputVol = dimsToString(previous->getDimensions());
            nvinfer1::ILayer* out = netAddMaxpool(i, m_configBlocks.at(i), previous, network);
            previous = out->getOutput(0);
            assert(previous != nullptr);
            std::string outputVol = dimsToString(previous->getDimensions());
            tensorOutputs.push_back(out->getOutput(0));
            printLayerInfo(layerIndex, "maxpool", inputVol, outputVol, std::to_string(weightPtr));
        }

.cfg file

[net]
# Testing
batch=1
subdivisions=1
# Training
# batch=64
# subdivisions=16
width=608
height=608
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 60200
policy=steps
steps=35000,50000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=9
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=50
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=25
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=50
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=117
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=16
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=117
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=40
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=117
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=244
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=43
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=71
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=74
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=63
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=48
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=56
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=60
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=43
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=244
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=457
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=89
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=74
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=69
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=87
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=72
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=63
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=38
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=65
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=457
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=864
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=91
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=864
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=53
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=864
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=52
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=864
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=63
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=864
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=11
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=33
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=12
size=1
stride=1
pad=1
activation=leaky

[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

[convolutional]
batch_normalize=1
filters=18
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=20
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=12
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=120
size=3
stride=1
pad=1
activation=leaky

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

[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 = 10
num = 9
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1

[route]
layers=-4

[convolutional]
batch_normalize=1
filters=72
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers=-1, 61

[convolutional]
batch_normalize=1
filters=43
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=18
size=3
stride=1
pad=1
activation=leaky

[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

[convolutional]
batch_normalize=1
filters=42
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=54
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=23
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=157
size=3
stride=1
pad=1
activation=leaky

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

[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 = 10
num = 9
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1

[route]
layers=-4

[convolutional]
batch_normalize=1
filters=50
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers=-1, 36

[convolutional]
batch_normalize=1
filters=33
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=57
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=15
size=1
stride=1
pad=1
activation=leaky

[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

[convolutional]
batch_normalize=1
filters=44
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=41
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=63
size=3
stride=1
pad=1
activation=leaky

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

[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 = 10
num = 9
jitter = .3
ignore_thresh = .7
truth_thresh = 1
random = 1

This change is fine, and this is why you are able to build the engine successfully. Regarding accuracy, you can verify if the detection probability and NMS thresholds is same as before ?

Hello,
I checked the detection parameter of kNMS_THRESH=0.3f and kPROB_THRESH=0.7f, and modified it according darknet test value(nms 0.4,pros_THRESH 0.5), the performence got some improvement ,but still not very well compared with using darknet to run.

I think the precision should be same if using FP32 network-mode,right?

Is there any other place to be modified and checked? Can you give me more suggestions?

thanks a lot

I used yolo-spp3 to do test,the precision detection also decreased a lot.
So confused for me,It looks like related with spp module parsing ,

SPP

[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

End SPP

.cfg file

[net]
# Testing
batch=1
subdivisions=1
# Training
# batch=64
# subdivisions=16
width=608
height=608
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 120200
policy=steps
steps=70000,100000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

# Downsample

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=128
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=256
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=512
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

# Downsample

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=2
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[shortcut]
from=-3
activation=linear

######################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

### SPP ###
[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

### End SPP ###

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky


[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky


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


[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=10
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1


[route]
layers = -4

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 61



[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

### SPP ###
[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

### End SPP ###


[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

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


[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=10
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1



[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 36



[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

### SPP ###
[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

### End SPP ###

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

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


[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=10
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

any update?

Hi,

We are looking into adding support for these models in upcoming releases but don’t have a specific ETA. For future reference, can you post the actual difference in results you are seeing between the original implementation and TensorRT ? Can you also link the repo you are using to train/infer the slim yolo model ?

Hi,
That’s great! Because it have a faster detection speed. I think it’s not a difficult thing for you to fix this problem.

Please download the result and my changed code from this link and you can recurrent using it.

If you have downloaded it,please tell me.

link:https://pan.baidu.com/s/14peF1rxTElrxycYwuEbKHw
Fetch Code:huw6

thanks

Hi,

Can you upload the images on google drive ? And also can you also link the repo you are using to train/infer the slim yolo model ?

Hi,
All you can get from https://drive.google.com/file/d/1h3Wsq106z_8vDMlPxo2VqH2ExVzlDJWu/view?usp=sharing

If you have downloaded it,please tell me.

thanks

Thanks! Can you also provide this info -

And also can you also link the repo you are using to train/infer the slim yolo model ?

You can get repo link from ‘slimyolov3 link.txt’, it include all the information of train/infer .

Hi,

change mask value in nvdsparsebbox_Yolo.cpp

static const std::vector<std::vector<int>> kMASKS = {

        {6,7,8},
        {3,4,5},
        {0,1,2}};

// {3, 4, 5},
        // {0, 1, 2}}; // as per output result, select {1,2,3}
        // {1, 2, 3}};

you can find it in .cfg file.

Hi sathiez,
I will try ,thanks a lot for your advice.

Hi sathiez,
I used NvDsInferParseCustomYoloV3 not YoloV3Tiny, so the default value is correct,no need to change it.
{6, 7, 8},
{3, 4, 5},
{0, 1, 2}};

extern "C" bool NvDsInferParseCustomYoloV3(
    std::vector<NvDsInferLayerInfo> const& outputLayersInfo,
    NvDsInferNetworkInfo const& networkInfo,
    NvDsInferParseDetectionParams const& detectionParams,
    std::vector<NvDsInferParseObjectInfo>& objectList)
{
    static const std::vector<float> kANCHORS = {
        10.0, 13.0, 16.0,  30.0,  33.0, 23.0,  30.0,  61.0,  62.0,
        45.0, 59.0, 119.0, 116.0, 90.0, 156.0, 198.0, 373.0, 326.0};
    static const std::vector<std::vector<int>> kMASKS = {
        {6, 7, 8},
        {3, 4, 5},
        {0, 1, 2}};
    return NvDsInferParseYoloV3 (
        outputLayersInfo, networkInfo, detectionParams, objectList,
        kANCHORS, kMASKS);
}

Hi NvCJR,
Did you review my code and recurrent it?

Hi,

Sorry we don’t have an update yet but we will get back to you.

@15822004929 Tried your multi-layer route solution for my custom model:

...


[convolutional]
batch_normalize=1
size=1
stride=1
pad=1
filters=64
activation=leaky

[reorg]
stride=2

[b][route]
layers=-1,-5,-9[/b]

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

...

And it almost fixed it, except that I’m still getting a “unused weights : 1”
Yes… just one unused weight, but still enought to make my model unusable.

Have you got any idea why? Maybe the fact that I use 3 layers and not 4?
Could you briefly explain what your code does or where you got the inspiration for it so I can try to comprehend and modify it accordingly?

Thanks!

Most probably its due to the header in your weights file. Which config did you use run your custom model ?

yolov2 has a 4 byte header whereas all other standard models have 5 byte headers which are ignored in this function from trt_utils.cpp

std::vector<float> loadWeights(const std::string weightsFilePath, const std::string& networkType)
{
    assert(fileExists(weightsFilePath));
    std::cout << "Loading pre-trained weights..." << std::endl;
    std::ifstream file(weightsFilePath, std::ios_base::binary);
    assert(file.good());
    std::string line;

    if (networkType == "yolov2")
    {
        // Remove 4 int32 bytes of data from the stream belonging to the header
        file.ignore(4 * 4);
    }
    else if ((networkType == "yolov3") || (networkType == "yolov3-tiny")
             || (networkType == "yolov2-tiny"))
    {
        // Remove 5 int32 bytes of data from the stream belonging to the header
        file.ignore(4 * 5);
    }
    else
    {
        std::cout << "Invalid network type" << std::endl;
        assert(0);
    }

    std::vector<float> weights;
    char* floatWeight = new char[4];
    while (!file.eof())
    {
        file.read(floatWeight, 4);
        assert(file.gcount() == 4);
        weights.push_back(*reinterpret_cast<float*>(floatWeight));
        if (file.peek() == std::istream::traits_type::eof()) break;
    }
    std::cout << "Loading complete!" << std::endl;
    delete[] floatWeight;

    std::cout << "Total Number of weights read : " << weights.size() << std::endl;
    return weights;
}