Fix logger error in DeepStream 6.0 / 6.0.1 + Change output classes format + Fixes
This commit is contained in:
@@ -73,14 +73,14 @@ addBBoxProposal(const float bx1, const float by1, const float bx2, const float b
|
||||
}
|
||||
|
||||
static std::vector<NvDsInferParseObjectInfo>
|
||||
decodeTensorYolo(const float* boxes, const float* scores, const int* classes, const uint& outputSize, const uint& netW,
|
||||
decodeTensorYolo(const float* boxes, const float* scores, const float* classes, const uint& outputSize, const uint& netW,
|
||||
const uint& netH, const std::vector<float>& preclusterThreshold)
|
||||
{
|
||||
std::vector<NvDsInferParseObjectInfo> binfo;
|
||||
|
||||
for (uint b = 0; b < outputSize; ++b) {
|
||||
float maxProb = scores[b];
|
||||
int maxIndex = classes[b];
|
||||
int maxIndex = (int) classes[b];
|
||||
|
||||
if (maxProb < preclusterThreshold[maxIndex])
|
||||
continue;
|
||||
@@ -102,14 +102,14 @@ decodeTensorYolo(const float* boxes, const float* scores, const int* classes, co
|
||||
}
|
||||
|
||||
static std::vector<NvDsInferParseObjectInfo>
|
||||
decodeTensorYoloE(const float* boxes, const float* scores, const int* classes, const uint& outputSize, const uint& netW,
|
||||
decodeTensorYoloE(const float* boxes, const float* scores, const float* classes, const uint& outputSize, const uint& netW,
|
||||
const uint& netH, const std::vector<float>& preclusterThreshold)
|
||||
{
|
||||
std::vector<NvDsInferParseObjectInfo> binfo;
|
||||
|
||||
for (uint b = 0; b < outputSize; ++b) {
|
||||
float maxProb = scores[b];
|
||||
int maxIndex = classes[b];
|
||||
int maxIndex = (int) classes[b];
|
||||
|
||||
if (maxProb < preclusterThreshold[maxIndex])
|
||||
continue;
|
||||
@@ -136,26 +136,14 @@ NvDsInferParseCustomYolo(std::vector<NvDsInferLayerInfo> const& outputLayersInfo
|
||||
|
||||
std::vector<NvDsInferParseObjectInfo> objects;
|
||||
|
||||
NvDsInferLayerInfo* boxes;
|
||||
NvDsInferLayerInfo* scores;
|
||||
NvDsInferLayerInfo* classes;
|
||||
const NvDsInferLayerInfo& boxes = outputLayersInfo[0];
|
||||
const NvDsInferLayerInfo& scores = outputLayersInfo[1];
|
||||
const NvDsInferLayerInfo& classes = outputLayersInfo[2];
|
||||
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (outputLayersInfo[i].dataType == NvDsInferDataType::INT32) {
|
||||
classes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else if (outputLayersInfo[i].inferDims.d[1] == 4) {
|
||||
boxes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else {
|
||||
scores = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
}
|
||||
const uint outputSize = boxes.inferDims.d[0];
|
||||
|
||||
const uint outputSize = boxes->inferDims.d[0];
|
||||
|
||||
std::vector<NvDsInferParseObjectInfo> outObjs = decodeTensorYolo((const float*) (boxes->buffer),
|
||||
(const float*) (scores->buffer), (const int*) (classes->buffer), outputSize, networkInfo.width, networkInfo.height,
|
||||
std::vector<NvDsInferParseObjectInfo> outObjs = decodeTensorYolo((const float*) (boxes.buffer),
|
||||
(const float*) (scores.buffer), (const float*) (classes.buffer), outputSize, networkInfo.width, networkInfo.height,
|
||||
detectionParams.perClassPreclusterThreshold);
|
||||
|
||||
objects.insert(objects.end(), outObjs.begin(), outObjs.end());
|
||||
@@ -176,26 +164,14 @@ NvDsInferParseCustomYoloE(std::vector<NvDsInferLayerInfo> const& outputLayersInf
|
||||
|
||||
std::vector<NvDsInferParseObjectInfo> objects;
|
||||
|
||||
NvDsInferLayerInfo* boxes;
|
||||
NvDsInferLayerInfo* scores;
|
||||
NvDsInferLayerInfo* classes;
|
||||
const NvDsInferLayerInfo& boxes = outputLayersInfo[0];
|
||||
const NvDsInferLayerInfo& scores = outputLayersInfo[1];
|
||||
const NvDsInferLayerInfo& classes = outputLayersInfo[2];
|
||||
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (outputLayersInfo[i].dataType == NvDsInferDataType::INT32) {
|
||||
classes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else if (outputLayersInfo[i].inferDims.d[1] == 4) {
|
||||
boxes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else {
|
||||
scores = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
}
|
||||
const uint outputSize = boxes.inferDims.d[0];
|
||||
|
||||
const uint outputSize = boxes->inferDims.d[0];
|
||||
|
||||
std::vector<NvDsInferParseObjectInfo> outObjs = decodeTensorYoloE((const float*) (boxes->buffer),
|
||||
(const float*) (scores->buffer), (const int*) (classes->buffer), outputSize, networkInfo.width, networkInfo.height,
|
||||
std::vector<NvDsInferParseObjectInfo> outObjs = decodeTensorYoloE((const float*) (boxes.buffer),
|
||||
(const float*) (scores.buffer), (const float*) (classes.buffer), outputSize, networkInfo.width, networkInfo.height,
|
||||
detectionParams.perClassPreclusterThreshold);
|
||||
|
||||
objects.insert(objects.end(), outObjs.begin(), outObjs.end());
|
||||
|
||||
@@ -37,7 +37,7 @@ extern "C" bool
|
||||
NvDsInferParseYoloECuda(std::vector<NvDsInferLayerInfo> const& outputLayersInfo, NvDsInferNetworkInfo const& networkInfo,
|
||||
NvDsInferParseDetectionParams const& detectionParams, std::vector<NvDsInferParseObjectInfo>& objectList);
|
||||
|
||||
__global__ void decodeTensorYoloCuda(NvDsInferParseObjectInfo *binfo, float* boxes, float* scores, int* classes,
|
||||
__global__ void decodeTensorYoloCuda(NvDsInferParseObjectInfo *binfo, float* boxes, float* scores, float* classes,
|
||||
int outputSize, int netW, int netH, float minPreclusterThreshold)
|
||||
{
|
||||
int x_id = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
@@ -46,7 +46,7 @@ __global__ void decodeTensorYoloCuda(NvDsInferParseObjectInfo *binfo, float* box
|
||||
return;
|
||||
|
||||
float maxProb = scores[x_id];
|
||||
int maxIndex = classes[x_id];
|
||||
int maxIndex = (int) classes[x_id];
|
||||
|
||||
if (maxProb < minPreclusterThreshold) {
|
||||
binfo[x_id].detectionConfidence = 0.0;
|
||||
@@ -76,7 +76,7 @@ __global__ void decodeTensorYoloCuda(NvDsInferParseObjectInfo *binfo, float* box
|
||||
binfo[x_id].classId = maxIndex;
|
||||
}
|
||||
|
||||
__global__ void decodeTensorYoloECuda(NvDsInferParseObjectInfo *binfo, float* boxes, float* scores, int* classes,
|
||||
__global__ void decodeTensorYoloECuda(NvDsInferParseObjectInfo *binfo, float* boxes, float* scores, float* classes,
|
||||
int outputSize, int netW, int netH, float minPreclusterThreshold)
|
||||
{
|
||||
int x_id = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
@@ -85,7 +85,7 @@ __global__ void decodeTensorYoloECuda(NvDsInferParseObjectInfo *binfo, float* bo
|
||||
return;
|
||||
|
||||
float maxProb = scores[x_id];
|
||||
int maxIndex = classes[x_id];
|
||||
int maxIndex = (int) classes[x_id];
|
||||
|
||||
if (maxProb < minPreclusterThreshold) {
|
||||
binfo[x_id].detectionConfidence = 0.0;
|
||||
@@ -119,23 +119,11 @@ static bool NvDsInferParseCustomYoloCuda(std::vector<NvDsInferLayerInfo> const&
|
||||
return false;
|
||||
}
|
||||
|
||||
NvDsInferLayerInfo* boxes;
|
||||
NvDsInferLayerInfo* scores;
|
||||
NvDsInferLayerInfo* classes;
|
||||
const NvDsInferLayerInfo& boxes = outputLayersInfo[0];
|
||||
const NvDsInferLayerInfo& scores = outputLayersInfo[1];
|
||||
const NvDsInferLayerInfo& classes = outputLayersInfo[2];
|
||||
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (outputLayersInfo[i].dataType == NvDsInferDataType::INT32) {
|
||||
classes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else if (outputLayersInfo[i].inferDims.d[1] == 4) {
|
||||
boxes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else {
|
||||
scores = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
}
|
||||
|
||||
const int outputSize = boxes->inferDims.d[0];
|
||||
const int outputSize = boxes.inferDims.d[0];
|
||||
|
||||
thrust::device_vector<NvDsInferParseObjectInfo> objects(outputSize);
|
||||
|
||||
@@ -146,8 +134,8 @@ static bool NvDsInferParseCustomYoloCuda(std::vector<NvDsInferLayerInfo> const&
|
||||
int number_of_blocks = ((outputSize - 1) / threads_per_block) + 1;
|
||||
|
||||
decodeTensorYoloCuda<<<number_of_blocks, threads_per_block>>>(
|
||||
thrust::raw_pointer_cast(objects.data()), (float*) (boxes->buffer), (float*) (scores->buffer),
|
||||
(int*) (classes->buffer), outputSize, networkInfo.width, networkInfo.height, minPreclusterThreshold);
|
||||
thrust::raw_pointer_cast(objects.data()), (float*) (boxes.buffer), (float*) (scores.buffer),
|
||||
(float*) (classes.buffer), outputSize, networkInfo.width, networkInfo.height, minPreclusterThreshold);
|
||||
|
||||
objectList.resize(outputSize);
|
||||
thrust::copy(objects.begin(), objects.end(), objectList.begin());
|
||||
@@ -164,23 +152,11 @@ static bool NvDsInferParseCustomYoloECuda(std::vector<NvDsInferLayerInfo> const&
|
||||
return false;
|
||||
}
|
||||
|
||||
NvDsInferLayerInfo* boxes;
|
||||
NvDsInferLayerInfo* scores;
|
||||
NvDsInferLayerInfo* classes;
|
||||
const NvDsInferLayerInfo& boxes = outputLayersInfo[0];
|
||||
const NvDsInferLayerInfo& scores = outputLayersInfo[1];
|
||||
const NvDsInferLayerInfo& classes = outputLayersInfo[2];
|
||||
|
||||
for (uint i = 0; i < 3; ++i) {
|
||||
if (outputLayersInfo[i].dataType == NvDsInferDataType::INT32) {
|
||||
classes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else if (outputLayersInfo[i].inferDims.d[1] == 4) {
|
||||
boxes = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
else {
|
||||
scores = (NvDsInferLayerInfo*) &outputLayersInfo[i];
|
||||
}
|
||||
}
|
||||
|
||||
const int outputSize = boxes->inferDims.d[0];
|
||||
const int outputSize = boxes.inferDims.d[0];
|
||||
|
||||
thrust::device_vector<NvDsInferParseObjectInfo> objects(outputSize);
|
||||
|
||||
@@ -191,8 +167,8 @@ static bool NvDsInferParseCustomYoloECuda(std::vector<NvDsInferLayerInfo> const&
|
||||
int number_of_blocks = ((outputSize - 1) / threads_per_block) + 1;
|
||||
|
||||
decodeTensorYoloECuda<<<number_of_blocks, threads_per_block>>>(
|
||||
thrust::raw_pointer_cast(objects.data()), (float*) (boxes->buffer), (float*) (scores->buffer),
|
||||
(int*) (classes->buffer), outputSize, networkInfo.width, networkInfo.height, minPreclusterThreshold);
|
||||
thrust::raw_pointer_cast(objects.data()), (float*) (boxes.buffer), (float*) (scores.buffer),
|
||||
(float*) (classes.buffer), outputSize, networkInfo.width, networkInfo.height, minPreclusterThreshold);
|
||||
|
||||
objectList.resize(outputSize);
|
||||
thrust::copy(objects.begin(), objects.end(), objectList.begin());
|
||||
|
||||
@@ -76,7 +76,7 @@ Yolo::createEngine(nvinfer1::IBuilder* builder)
|
||||
|
||||
if (m_NetworkType == "onnx") {
|
||||
|
||||
#if NV_TENSORRT_MAJOR >= 8
|
||||
#if NV_TENSORRT_MAJOR >= 8 && NV_TENSORRT_MINOR > 0
|
||||
parser = nvonnxparser::createParser(*network, *builder->getLogger());
|
||||
#else
|
||||
parser = nvonnxparser::createParser(*network, logger);
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
#define INT int32_t
|
||||
#else
|
||||
#define INT int
|
||||
#endif
|
||||
|
||||
#if NV_TENSORRT_MAJOR < 8 || (NV_TENSORRT_MAJOR == 8 && NV_TENSORRT_MINOR == 0)
|
||||
static class Logger : public nvinfer1::ILogger {
|
||||
void log(nvinfer1::ILogger::Severity severity, const char* msg) noexcept override {
|
||||
if (severity <= nvinfer1::ILogger::Severity::kWARNING)
|
||||
|
||||
Reference in New Issue
Block a user