Minor fixes

This commit is contained in:
Marcos Luciano
2022-04-20 13:00:52 -03:00
parent 18ae611929
commit 4cae635529
7 changed files with 17 additions and 25 deletions

View File

@@ -21,5 +21,5 @@ custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so
engine-create-func-name=NvDsInferYoloCudaEngineGet engine-create-func-name=NvDsInferYoloCudaEngineGet
[class-attrs-all] [class-attrs-all]
nms-iou-threshold=0.6 nms-iou-threshold=0.45
pre-cluster-threshold=0.25 pre-cluster-threshold=0.25

View File

@@ -21,5 +21,5 @@ custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so
engine-create-func-name=NvDsInferYoloCudaEngineGet engine-create-func-name=NvDsInferYoloCudaEngineGet
[class-attrs-all] [class-attrs-all]
nms-iou-threshold=0.6 nms-iou-threshold=0.45
pre-cluster-threshold=0.25 pre-cluster-threshold=0.25

View File

@@ -21,5 +21,5 @@ custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so
engine-create-func-name=NvDsInferYoloCudaEngineGet engine-create-func-name=NvDsInferYoloCudaEngineGet
[class-attrs-all] [class-attrs-all]
nms-iou-threshold=0.6 nms-iou-threshold=0.5
pre-cluster-threshold=0.25 pre-cluster-threshold=0.25

View File

@@ -50,7 +50,6 @@ static bool getYoloNetworkInfo (NetworkInfo &networkInfo, const NvDsInferContext
networkInfo.deviceType = (initParams->useDLA ? "kDLA" : "kGPU"); networkInfo.deviceType = (initParams->useDLA ? "kDLA" : "kGPU");
networkInfo.numDetectedClasses = initParams->numDetectedClasses; networkInfo.numDetectedClasses = initParams->numDetectedClasses;
networkInfo.clusterMode = initParams->clusterMode; networkInfo.clusterMode = initParams->clusterMode;
networkInfo.iouThreshold = initParams->perClassDetectionParams->nmsIOUThreshold;
if(initParams->networkMode == 0) { if(initParams->networkMode == 0) {
networkInfo.networkMode = "FP32"; networkInfo.networkMode = "FP32";

View File

@@ -40,15 +40,13 @@ Yolo::Yolo(const NetworkInfo& networkInfo)
m_DeviceType(networkInfo.deviceType), m_DeviceType(networkInfo.deviceType),
m_NumDetectedClasses(networkInfo.numDetectedClasses), m_NumDetectedClasses(networkInfo.numDetectedClasses),
m_ClusterMode(networkInfo.clusterMode), m_ClusterMode(networkInfo.clusterMode),
m_IouThreshold(networkInfo.iouThreshold),
m_NetworkMode(networkInfo.networkMode), m_NetworkMode(networkInfo.networkMode),
m_InputH(0), m_InputH(0),
m_InputW(0), m_InputW(0),
m_InputC(0), m_InputC(0),
m_InputSize(0), m_InputSize(0),
m_NumClasses(0), m_NumClasses(0),
m_LetterBox(0), m_LetterBox(0)
m_BetaNMS(networkInfo.iouThreshold)
{} {}
Yolo::~Yolo() Yolo::~Yolo()
@@ -77,9 +75,6 @@ nvinfer1::ICudaEngine *Yolo::createEngine (nvinfer1::IBuilder* builder, nvinfer1
if (m_LetterBox == 1) { 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; 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) { 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; 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") { else if (m_ConfigBlocks.at(i).at("type") == "convolutional") {
float eps = 1.0e-5; 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; eps = 1.0e-3;
}*/ }
else if (m_NetworkType.find("yolor") != std::string::npos) {
eps = 1.0e-4;
}
std::string inputVol = dimsToString(previous->getDimensions()); std::string inputVol = dimsToString(previous->getDimensions());
nvinfer1::ILayer* out = convolutionalLayer(i, m_ConfigBlocks.at(i), weights, m_TrtWeights, weightPtr, weightsType, channels, eps, previous, &network); nvinfer1::ILayer* out = convolutionalLayer(i, m_ConfigBlocks.at(i), weights, m_TrtWeights, weightPtr, weightsType, channels, eps, previous, &network);
previous = out->getOutput(0); 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()) { 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")); 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); std::string layerName = "yolo_" + std::to_string(i);
nvinfer1::Dims prevTensorDims = previous->getDimensions(); nvinfer1::Dims prevTensorDims = previous->getDimensions();

View File

@@ -48,7 +48,6 @@ struct NetworkInfo
std::string deviceType; std::string deviceType;
uint numDetectedClasses; uint numDetectedClasses;
int clusterMode; int clusterMode;
float iouThreshold;
std::string networkMode; std::string networkMode;
}; };
@@ -83,7 +82,6 @@ protected:
const std::string m_DeviceType; const std::string m_DeviceType;
const uint m_NumDetectedClasses; const uint m_NumDetectedClasses;
const int m_ClusterMode; const int m_ClusterMode;
const float m_IouThreshold;
const std::string m_NetworkMode; const std::string m_NetworkMode;
uint m_InputH; uint m_InputH;
@@ -92,7 +90,6 @@ protected:
uint64_t m_InputSize; uint64_t m_InputSize;
uint m_NumClasses; uint m_NumClasses;
uint m_LetterBox; uint m_LetterBox;
float m_BetaNMS;
std::vector<TensorInfo> m_OutputTensors; std::vector<TensorInfo> m_OutputTensors;
std::vector<std::map<std::string, std::string>> m_ConfigBlocks; std::vector<std::map<std::string, std::string>> m_ConfigBlocks;

View File

@@ -85,7 +85,7 @@ NVIDIA DeepStream SDK 6.0.1 configuration for YOLO models
### Benchmarks ### 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) pre-cluster-threshold = 0.001 (mAP eval) / 0.25 (FPS measurement)
batch-size = 1 batch-size = 1
valid = val2017 (COCO) - 1000 random images for INT8 calibration 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 gcc make git libtool autoconf autogen pkg-config cmake
sudo apt-get install python3 python3-dev python3-pip 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 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) sudo apt-get install linux-headers-$(uname -r)
``` ```
@@ -351,8 +352,8 @@ num-detected-classes=80
... ...
[class-attrs-all] [class-attrs-all]
# IOU threshold # IOU threshold
nms-iou-threshold=0.6 nms-iou-threshold=0.45
# Socre threshold # Score threshold
pre-cluster-threshold=0.25 pre-cluster-threshold=0.25
``` ```
@@ -438,8 +439,8 @@ num-detected-classes=80
... ...
[class-attrs-all] [class-attrs-all]
# IOU threshold # IOU threshold
nms-iou-threshold=0.6 nms-iou-threshold=0.45
# Socre threshold # Score threshold
pre-cluster-threshold=0.25 pre-cluster-threshold=0.25
``` ```
@@ -557,8 +558,8 @@ num-detected-classes=80
... ...
[class-attrs-all] [class-attrs-all]
# IOU threshold # IOU threshold
nms-iou-threshold=0.6 nms-iou-threshold=0.5
# Socre threshold # Score threshold
pre-cluster-threshold=0.25 pre-cluster-threshold=0.25
``` ```