diff --git a/config_infer_primary.txt b/config_infer_primary.txt index c661e95..b26c95f 100644 --- a/config_infer_primary.txt +++ b/config_infer_primary.txt @@ -21,5 +21,5 @@ custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so engine-create-func-name=NvDsInferYoloCudaEngineGet [class-attrs-all] -nms-iou-threshold=0.6 +nms-iou-threshold=0.45 pre-cluster-threshold=0.25 diff --git a/config_infer_primary_yoloV5.txt b/config_infer_primary_yoloV5.txt index e1744ba..0f2a818 100644 --- a/config_infer_primary_yoloV5.txt +++ b/config_infer_primary_yoloV5.txt @@ -21,5 +21,5 @@ custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so engine-create-func-name=NvDsInferYoloCudaEngineGet [class-attrs-all] -nms-iou-threshold=0.6 +nms-iou-threshold=0.45 pre-cluster-threshold=0.25 diff --git a/config_infer_primary_yolor.txt b/config_infer_primary_yolor.txt index ad082be..ad92a86 100644 --- a/config_infer_primary_yolor.txt +++ b/config_infer_primary_yolor.txt @@ -21,5 +21,5 @@ custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so engine-create-func-name=NvDsInferYoloCudaEngineGet [class-attrs-all] -nms-iou-threshold=0.6 +nms-iou-threshold=0.5 pre-cluster-threshold=0.25 diff --git a/nvdsinfer_custom_impl_Yolo/nvdsinfer_yolo_engine.cpp b/nvdsinfer_custom_impl_Yolo/nvdsinfer_yolo_engine.cpp index bd2e32c..d1e3127 100644 --- a/nvdsinfer_custom_impl_Yolo/nvdsinfer_yolo_engine.cpp +++ b/nvdsinfer_custom_impl_Yolo/nvdsinfer_yolo_engine.cpp @@ -50,7 +50,6 @@ static bool getYoloNetworkInfo (NetworkInfo &networkInfo, const NvDsInferContext networkInfo.deviceType = (initParams->useDLA ? "kDLA" : "kGPU"); networkInfo.numDetectedClasses = initParams->numDetectedClasses; networkInfo.clusterMode = initParams->clusterMode; - networkInfo.iouThreshold = initParams->perClassDetectionParams->nmsIOUThreshold; if(initParams->networkMode == 0) { networkInfo.networkMode = "FP32"; diff --git a/nvdsinfer_custom_impl_Yolo/yolo.cpp b/nvdsinfer_custom_impl_Yolo/yolo.cpp index aee0462..6e406fe 100644 --- a/nvdsinfer_custom_impl_Yolo/yolo.cpp +++ b/nvdsinfer_custom_impl_Yolo/yolo.cpp @@ -40,15 +40,13 @@ Yolo::Yolo(const NetworkInfo& networkInfo) m_DeviceType(networkInfo.deviceType), m_NumDetectedClasses(networkInfo.numDetectedClasses), m_ClusterMode(networkInfo.clusterMode), - m_IouThreshold(networkInfo.iouThreshold), m_NetworkMode(networkInfo.networkMode), m_InputH(0), m_InputW(0), m_InputC(0), m_InputSize(0), m_NumClasses(0), - m_LetterBox(0), - m_BetaNMS(networkInfo.iouThreshold) + m_LetterBox(0) {} Yolo::~Yolo() @@ -77,9 +75,6 @@ nvinfer1::ICudaEngine *Yolo::createEngine (nvinfer1::IBuilder* builder, nvinfer1 if (m_LetterBox == 1) { std::cout << "\nNOTE: letter_box is set in cfg file, make sure to set maintain-aspect-ratio=1 in config_infer file to get better accuracy" << std::endl; } - if (m_BetaNMS != m_IouThreshold) { - std::cout << "\nNOTE: beta_nms is set in cfg file, make sure to set nms-iou-threshold=" << m_BetaNMS << " in config_infer file to get better accuracy" << std::endl; - } if (m_ClusterMode != 2) { std::cout << "\nNOTE: Wrong cluster-mode is set, make sure to set cluster-mode=2 in config_infer file" << std::endl; } @@ -174,9 +169,12 @@ NvDsInferStatus Yolo::buildYoloNetwork( else if (m_ConfigBlocks.at(i).at("type") == "convolutional") { float eps = 1.0e-5; - /*if (m_NetworkType.find("yolov5") != std::string::npos) { + if (m_NetworkType.find("yolov5") != std::string::npos) { eps = 1.0e-3; - }*/ + } + else if (m_NetworkType.find("yolor") != std::string::npos) { + eps = 1.0e-4; + } std::string inputVol = dimsToString(previous->getDimensions()); nvinfer1::ILayer* out = convolutionalLayer(i, m_ConfigBlocks.at(i), weights, m_TrtWeights, weightPtr, weightsType, channels, eps, previous, &network); previous = out->getOutput(0); @@ -343,9 +341,6 @@ NvDsInferStatus Yolo::buildYoloNetwork( if (m_ConfigBlocks.at(i).find("scale_x_y") != m_ConfigBlocks.at(i).end()) { scaleXY = std::stof(m_ConfigBlocks.at(i).at("scale_x_y")); } - if (m_ConfigBlocks.at(i).find("beta_nms") != m_ConfigBlocks.at(i).end()) { - m_BetaNMS = std::stof(m_ConfigBlocks.at(i).at("beta_nms")); - } std::string layerName = "yolo_" + std::to_string(i); nvinfer1::Dims prevTensorDims = previous->getDimensions(); diff --git a/nvdsinfer_custom_impl_Yolo/yolo.h b/nvdsinfer_custom_impl_Yolo/yolo.h index e78e0fa..7b1c0aa 100644 --- a/nvdsinfer_custom_impl_Yolo/yolo.h +++ b/nvdsinfer_custom_impl_Yolo/yolo.h @@ -48,7 +48,6 @@ struct NetworkInfo std::string deviceType; uint numDetectedClasses; int clusterMode; - float iouThreshold; std::string networkMode; }; @@ -83,7 +82,6 @@ protected: const std::string m_DeviceType; const uint m_NumDetectedClasses; const int m_ClusterMode; - const float m_IouThreshold; const std::string m_NetworkMode; uint m_InputH; @@ -92,7 +90,6 @@ protected: uint64_t m_InputSize; uint m_NumClasses; uint m_LetterBox; - float m_BetaNMS; std::vector m_OutputTensors; std::vector> m_ConfigBlocks; diff --git a/readme.md b/readme.md index 3491e9c..89e37ba 100644 --- a/readme.md +++ b/readme.md @@ -85,7 +85,7 @@ NVIDIA DeepStream SDK 6.0.1 configuration for YOLO models ### Benchmarks ``` -nms = 0.45 (changed to beta_nms when used in Darknet cfg file) / 0.6 (YOLOv5 and YOLOR models) +nms-iou-threshold = 0.6 pre-cluster-threshold = 0.001 (mAP eval) / 0.25 (FPS measurement) batch-size = 1 valid = val2017 (COCO) - 1000 random images for INT8 calibration @@ -175,6 +175,7 @@ sudo reboot sudo apt-get install gcc make git libtool autoconf autogen pkg-config cmake sudo apt-get install python3 python3-dev python3-pip sudo apt install libssl1.0.0 libgstreamer1.0-0 gstreamer1.0-tools gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav libgstrtspserver-1.0-0 libjansson4 +sudo apt-get install libglvnd-dev sudo apt-get install linux-headers-$(uname -r) ``` @@ -351,8 +352,8 @@ num-detected-classes=80 ... [class-attrs-all] # IOU threshold -nms-iou-threshold=0.6 -# Socre threshold +nms-iou-threshold=0.45 +# Score threshold pre-cluster-threshold=0.25 ``` @@ -438,8 +439,8 @@ num-detected-classes=80 ... [class-attrs-all] # IOU threshold -nms-iou-threshold=0.6 -# Socre threshold +nms-iou-threshold=0.45 +# Score threshold pre-cluster-threshold=0.25 ``` @@ -557,8 +558,8 @@ num-detected-classes=80 ... [class-attrs-all] # IOU threshold -nms-iou-threshold=0.6 -# Socre threshold +nms-iou-threshold=0.5 +# Score threshold pre-cluster-threshold=0.25 ```