From 6fff0e47abaabc11325b6e5fcee3a4b96dbbcae5 Mon Sep 17 00:00:00 2001 From: andrejlevkovitch Date: Tue, 28 Nov 2023 16:08:59 +0100 Subject: [PATCH 1/2] fix problem with braces and logging library --- c/tensorNet.cpp | 9 ++++++--- examples/actionnet/actionnet.cpp | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/c/tensorNet.cpp b/c/tensorNet.cpp index e2e19b3df..ad6ba5d31 100644 --- a/c/tensorNet.cpp +++ b/c/tensorNet.cpp @@ -611,8 +611,9 @@ bool tensorNet::ProfileModel(const std::string& deployFile, // name for caf { nvinfer1::ITensor* tensor = blobNameToTensor->find(outputs[n].c_str()); - if( !tensor ) + if( !tensor ) { LogError(LOG_TRT "failed to retrieve tensor for Output \"%s\"\n", outputs[n].c_str()); + } else { #if NV_TENSORRT_MAJOR >= 4 @@ -1135,10 +1136,12 @@ bool tensorNet::LoadNetwork( const char* prototxt_path_, const char* model_path_ loadedPlugins = initLibNvInferPlugins(&gLogger, ""); - if( !loadedPlugins ) + if( !loadedPlugins ) { LogError(LOG_TRT "failed to load NVIDIA plugins\n"); - else + } + else { LogVerbose(LOG_TRT "completed loading NVIDIA plugins.\n"); + } } #endif diff --git a/examples/actionnet/actionnet.cpp b/examples/actionnet/actionnet.cpp index b5a42e5a7..a95f7ca4e 100644 --- a/examples/actionnet/actionnet.cpp +++ b/examples/actionnet/actionnet.cpp @@ -148,10 +148,12 @@ int main( int argc, char** argv ) float confidence = 0.0f; const int class_id = net->Classify(image, input->GetWidth(), input->GetHeight(), &confidence); - if( class_id >= 0 ) + if( class_id >= 0 ) { LogVerbose("actionnet: %2.5f%% class #%i (%s)\n", confidence * 100.0f, class_id, net->GetClassDesc(class_id)); - else + } + else { LogError("actionnet: failed to classify frame\n"); + } // overlay the results if( class_id >= 0 ) @@ -194,4 +196,3 @@ int main( int argc, char** argv ) LogVerbose("actionnet: shutdown complete.\n"); return 0; } - From 33e3c6e7bb7a02a43f9db344ceb84b79c3987739 Mon Sep 17 00:00:00 2001 From: andrejlevkovitch Date: Thu, 30 Nov 2023 12:59:23 +0100 Subject: [PATCH 2/2] fix issue with tabs --- c/tensorNet.cpp | 15 +++++++++------ examples/actionnet/actionnet.cpp | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/c/tensorNet.cpp b/c/tensorNet.cpp index ad6ba5d31..438a16291 100644 --- a/c/tensorNet.cpp +++ b/c/tensorNet.cpp @@ -611,9 +611,10 @@ bool tensorNet::ProfileModel(const std::string& deployFile, // name for caf { nvinfer1::ITensor* tensor = blobNameToTensor->find(outputs[n].c_str()); - if( !tensor ) { + if( !tensor ) + { LogError(LOG_TRT "failed to retrieve tensor for Output \"%s\"\n", outputs[n].c_str()); - } + } else { #if NV_TENSORRT_MAJOR >= 4 @@ -1136,12 +1137,14 @@ bool tensorNet::LoadNetwork( const char* prototxt_path_, const char* model_path_ loadedPlugins = initLibNvInferPlugins(&gLogger, ""); - if( !loadedPlugins ) { + if( !loadedPlugins ) + { LogError(LOG_TRT "failed to load NVIDIA plugins\n"); - } - else { + } + else + { LogVerbose(LOG_TRT "completed loading NVIDIA plugins.\n"); - } + } } #endif diff --git a/examples/actionnet/actionnet.cpp b/examples/actionnet/actionnet.cpp index a95f7ca4e..3ee16003b 100644 --- a/examples/actionnet/actionnet.cpp +++ b/examples/actionnet/actionnet.cpp @@ -148,12 +148,14 @@ int main( int argc, char** argv ) float confidence = 0.0f; const int class_id = net->Classify(image, input->GetWidth(), input->GetHeight(), &confidence); - if( class_id >= 0 ) { + if( class_id >= 0 ) + { LogVerbose("actionnet: %2.5f%% class #%i (%s)\n", confidence * 100.0f, class_id, net->GetClassDesc(class_id)); - } - else { + } + else + { LogError("actionnet: failed to classify frame\n"); - } + } // overlay the results if( class_id >= 0 )