Hi!
I’m trying to extend the nvinfer backend by performing inference for an input surface more than once. For instance, in the nvdsinfer_backend.cpp
, there’s a ImplicitTrtBackendContext::enqueueBuffer
method that queues an input buffer for inference:
if (!m_Context->enqueue(batchDims.batchSize, bindingBuffers.data(), stream,
(consumeEvent ? &consumeEvent->ptr() : nullptr)))
{
dsInferError("Failed to enqueue inference batch");
return NVDSINFER_TENSORRT_ERROR;
}
Where the bindingBuffers
are the input and output buffers of the model. Now, what my requirement is, for an input buffer (say an image I1
) I would like to perform the inference twice, once for I1
and once for flip(I1)
where the flip
is defined as an image flip operation. Finally, I would like to average out the predictions (I think I can figure out this part)
How I imagine this would work:
- Extract the
NvBufSurface
which is the input image. - Perform a buffer transform using
NvBufferTransform_Flip
by setting the flip transformation parameter toNvBufferTransform_FlipX
to create a mirror image. - Call
.enqueue()
on this batch - Extract the GPU buffer, perform average operation.
- Return the GPU buffer
I have theoretically figured how this would work out. Now my question is:
- Is my approach stated above correct? If no, how should I go about it?
- How do I access the
NvBufSurface
in theImplicitTrtBackendContext::enqueueBuffer
method which uses the CUDA Stream to perform inference?
• Hardware Platform: T4 / Jetson NX / Jetson TX2NX
•DeepStream Version: 5.1
•JetPack Version (valid for Jetson only): 4.5.1
•TensorRT Version: 7.2
•NVIDIA GPU Driver Version (valid for GPU only): 455
•Issue Type( questions, new requirements, bugs): question
•Requirement details: Editing the nvdsinfer_backend.cpp
to perform inference on a given image buffer twice