Yes they are duplicate. I like to make clearer.
This is TensorRT input for batchsize 10.
Dims NumPlateRecognition::loadJPEGFile(std::vector<std::string> fileName, int num)
{
Dims4 inputDims{num, 24, 94, 3};
Dims4 inputDims_1img{1, 24, 94, 3};
const size_t vol = samplesCommon::volume(inputDims);
const size_t vol_1img = samplesCommon::volume(inputDims_1img);
unsigned char *data = new unsigned char[vol];
for(int f=0; f < num; f++){
cv::Mat image, im_rgb;
image = cv::imread(fileName[f], cv::IMREAD_COLOR);
cv::cvtColor(image, im_rgb, cv::COLOR_BGR2RGB);
image.release();
memcpy(data+(f*vol_1img), im_rgb.ptr<unsigned char>(), vol_1img);
im_rgb.release();
mInput.hostBuffer.resize(inputDims);
float* hostDataBuffer = static_cast<float*>(mInput.hostBuffer.data());
std::transform(data, data+vol, hostDataBuffer, [](uint8_t x) { return (static_cast<float>(x) / 255.0); });
}
delete[] data;
return inputDims;
}
Output from the last customized plugin layer CTCGreedyDecoder
is
26 20 12 8 5 3 1 33 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 20 14 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 5 6 0 27 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 16 11 14 8 5 5 3 27 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 20 30 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 17 13 1 1 2 9 25 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 19 26 2 8 3 8 16 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 19 27 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 13 26 7 7 5 1 32 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 15 10 9 3 14 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
That is 20 x 10 long buffer. Output parser in TensorRT sample is quite straightforward. Go through every 20 data and decode to Characters. It worked correctly with good accuracy in TensorRT.
For Deepstream.
net-scale-factor=0.0039215697906911373, that is 1/255.
Inside nvdsinfer_context_impl.cpp
NvDsInferStatus InferPreprocessor::transform(NvDsInferContextBatchInput& batchInput, void* devBuf, CudaStream& mainStream, CudaEvent* waitingEvent)
{
convertFcnFloat(outPtr, (float *)batchInput.inputFrames[i],
m_NetworkInfo.width, m_NetworkInfo.height, batchInput.inputPitch,
m_Scale, m_MeanDataBuffer.get() ? m_MeanDataBuffer->ptr<float>() : nullptr,
*m_PreProcessStream);
}
Assumed it is same as x 1/255 as I don’t have meandata.
model-color-format=0 (RGB format, same as in TensorRT)
infer-dims=24;94;3 (same as in TensorRT)
The whole config file is as follows.
[property]
gpu-id=0
net-scale-factor=0.0039215697906911373
onnx-file=../../../../samples/models/platerect/numplate_recg_nhwc_removed_sparsetodense.onnx
model-engine-file=../../../../samples/models/platerect/numplate_recg_nhwc_removed_sparsetodense.onnx_batch_max10_gpu0_fp16.engine
#mean-file=../../../../samples/models/Secondary_CarColor/mean.ppm
#labelfile-path=../../../../samples/models/platerect/labels.txt
#int8-calib-file=../../../../samples/models/Secondary_CarColor/cal_trt.bin
infer-dims=24;94;3
force-implicit-batch-dim=0
batch-size=10
# 0=FP32 and 1=INT8 mode
network-mode=2
input-object-min-width=20
input-object-min-height=10
process-mode=2
model-color-format=0
gpu-id=0
gie-unique-id=2
operate-on-gie-id=1
operate-on-class-ids=1
network-type=1
parse-classifier-func-name=NvDsInferParseCustomCTCGreedy
custom-lib-path=/usr/src/tensorrt/CTCGreedyDecoder_Plugin/build/libCTCGreedyDecoder.so
output-blob-names=trest:0
classifier-threshold = 0
Then output at CTCGreedyDecoder(printed at CTCGreedyDecoder plugin) for batchsize 3 is
26 20 26 26 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 11 26 11 11 11 11 11 11 11 11 11 14 -1 -1 -1 -1 -1 -1 -1 26 19 26 17 9 8 17 5 9 5 4 17 9 26 -1 -1 -1 -1 -1 -1
So total is 3x20 number of data in output buffer.
It looks corrupted at CTCGreedyDecoder output. Second output is always
26 11 11 11 11 11 11 11 11 11 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
even though input image is changed.
Output at CTCGreedyDecoder and data at customized parser are totally different.
Output at CTCGreedyDecoder
26 20 26 26 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 26 11 26 11 11 11 11 11 11 11 11 11 14 -1 -1 -1 -1 -1 -1 -1 26 19 26 17 9 8 17 5 9 5 4 17 9 26 -1 -1 -1 -1 -1 -1
When data is checked at customized parser (parser is called three times for batch size 3)
dims 20 (chopped into one image data from batch size 3)
0 2 0 2 0 2 0 2 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1
dims 20 (chopped into one image data from batch size 3)
0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1
dims 20 (chopped into one image data from batch size 3)
0 2 0 2 0 2 0 2 0 -1 0 -1 0 -1 0 -1 0 -1 0 -1
They are totally different.
Then data at parser are always same, never changed. Even though, CTCGreedyDecoder plugin output has changes for different image inputs.