detect sample assert failed with createDeviceWorker(nChannels=1,, maxBatchSize=8)

Since the deepstream 1.5 support for maximum batch size, the detect sample need some update, output tensor batch is not channel number any more

void ParserModule::initialize() {
	vFrameCount_.resize(nChannels_);
	vpOutputTensors_.resize(1, nullptr);
	vpOutputTensors_[0] = createStreamTensor(<b>nChannels_</b>, sizeof(BBOXS_PER_FRAME),
											OBJ_COORD, CPU_DATA, devID_);
	assert(nullptr != vpOutputTensors_[0]);
}
void ParserModule::execute(const ModuleContext& context, const std::vector<IStreamTensor *>& vpInputTensors,  const std::vector<IStreamTensor *>& vpOutputTensors) {
	assert(2 == vpInputTensors.size());
	Dims3 outputDims;
        ...
	assert(1 == vpOutputTensors.size());
	IStreamTensor *pOutputTensor = vpOutputTensors[0];
	// just for check
	{
		assert(nullptr != pOutputTensor);
		size_t nElemSize = pOutputTensor->getElemSize();
		assert(sizeof(BBOXS_PER_FRAME) == nElemSize);
		TENSOR_TYPE Ttype = pOutputTensor->getTensorType();
		assert(OBJ_COORD == Ttype);
		<b>assert(nFrames <= pOutputTensor->getMaxBatch());</b>

	}

	BBOXS_PER_FRAME *pBBox_batch = reinterpret_cast<BBOXS_PER_FRAME*>(pOutputTensor->getCpuData());	
        ...
}

Thanks.

I fixed it with

vpOutputTensors_[0] = createStreamTensor(mBatch, sizeof(BBOXS_PER_FRAME),
					OBJ_COORD, CPU_DATA, devID_);

and then the mBatch is the max frame number deepstream will push the frame to module, maybe come from different channel.
We deploy deepstream 1.5 with success.

Hi,

Thanks for your feedback.
We have passed this issue to our developer team.

Will make a comment here once we have further information.

Hi,

For non-default max batch size parameter in createDeviceWorker,
We expect all the following stage such as inference and results parsing should be equipped to handle the larger number of frames per invocation.

One pattern that you could adopt is to set a global variable to the maximum batch size and use that consistently as shown below:

// Init a worker on a GPU device
 IDeviceWorker *pDeviceWorker = createDeviceWorker(g_nChannels, g_devID_infer, g_maxBatchsize);
.....................
 // Add inference task
 IModule *pInfer = pDeviceWorker->addInferenceTask(preModule_infer,
              g_deployFile,
              g_modelFile,
              g_meanFile,
              inputLayerName,
              outputLayerNames,
              g_maxBatchsize,
              &param);

 // Detection
 ParserModule *pParser = new ParserModule(preModules_parser,
            g_maxBatchsize,
            g_devID_infer,
            logger);

We will add this requirement to the documentation to make it clear.

Thanks.

Hi,

We’ll follow the guide, and make our custom module process according to maxBatchSize.

Thanks.