yoloV3 -spp3 bad accurate using deepstream 4.0.2 frame TX2 Jetpack4.2.2

Hello,
I updated the createYoloNetwork function code for Yolo.cpp file , in order to parse yoloV3-SPP network.
ObjectDetector-yolo could parse yoloV3-SPP network successfully after updated this code,but it has a bad accurate compared with darknet result, I’m very confused for this result.
This problem block my project seriously , I hope you can help me to solve it quickly.

Updated code please see below content: updated (else if (m_configBlocks.at(i).at(“type”) == “route”) and else if (m_configBlocks.at(i).at(“type”) == “maxpool”))
` 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)
{YoloCPP.log (25.0 KB) yolov3-spp3 CFG.log (8.7 KB)
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];
	        }
            	assert(idx[j] < static_cast<int>(tensorOutputs.size()) && idx[j] >= 0);
	//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(tensorOutputs.size()) && idx1 >= 0);
assert(idx2 < static_cast(tensorOutputs.size()) && idx2 >= 0);
assert(idx3 < static_cast(tensorOutputs.size()) && idx3 >= 0);
assert(idx4 < static_cast(tensorOutputs.size()) && idx4 >= 0);
/
nvinfer1::ITensor
* concatInputs
= reinterpret_castnvinfer1::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++)
	{
		channels=channels+getNumChannels(tensorOutputs[idx[j]]);
	}
           // 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
        {
            int idx = std::stoi(trim(m_configBlocks.at(i).at("layers")));
            if (idx < 0)
            {
                idx = tensorOutputs.size() + idx;
            }
            assert(idx < static_cast<int>(tensorOutputs.size()) && idx >= 0);
            previous = tensorOutputs[idx];
            assert(previous != nullptr);
            std::string outputVol = dimsToString(previous->getDimensions());
            // set the output volume depth
            channels = getNumChannels(tensorOutputs[idx]);
            tensorOutputs.push_back(tensorOutputs[idx]);
            printLayerInfo(layerIndex, "route", "        -", outputVol,
                           std::to_string(weightPtr));
        }
    }
    else if (m_configBlocks.at(i).at("type") == "upsample")
    {
        std::string inputVol = dimsToString(previous->getDimensions());
        nvinfer1::ILayer* out = netAddUpsample(i - 1, m_configBlocks[i], weights, trtWeights,
                                               channels, previous, network);
        previous = out->getOutput(0);
        std::string outputVol = dimsToString(previous->getDimensions());
        tensorOutputs.push_back(out->getOutput(0));
        printLayerInfo(layerIndex, "upsample", inputVol, outputVol, "    -");
    }
    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));
    }
    else
    {
        std::cout << "Unsupported layer type --> \"" << m_configBlocks.at(i).at("type") << "\""
                  << std::endl;
        assert(0);
    }
}

`

We will support yoloV3-spp in next release.

it’s great, when it can be released? why this frame can’t support all yolo network, like darknet frame,what’s the main point?

We start to test. It will be released soon.

Support all yolo network

Good idea. We will evaluate it. New Yolo networks often come out. We will try to complete yolo config parser.

Thanks a lot, I hope it can be released quickly, I’ve been waiting for a long time.

I could help you to test the draft version code,if you have solve this problem. Because I have several improved yolov3 network model , and all tested by darknet.

I just want to use it quickly ,

Appreciate your help, my wechat ID:15822004929 , mailbox:657695742@qq.com.

Hi ChrisDing,
YoloV4 has released,please speed up ,speed up!!!

Has this problem been solved, where to find

Hi ousheng525,

Please open a new topic for the issue your met at DeepStream SDK 5.0 DP version. Thanks