Updated YOLOv5

This commit is contained in:
Marcos Luciano
2020-12-27 12:31:54 -03:00
parent b679087ed7
commit 917d345375
3 changed files with 15 additions and 14 deletions

View File

@@ -198,9 +198,15 @@ to
model-engine-file=yolov5x.engine model-engine-file=yolov5x.engine
``` ```
To change NMS_THRESH and THRESH_CONF, edit nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp file and recompile To change NMS_THRESH, edit nvdsinfer_custom_impl_Yolo/nvdsparsebbox_Yolo.cpp file and recompile
``` ```
#define NMS_THRESH 0.45 #define kNMS_THRESH 0.45
#define CONF_THRESH 0.25 ```
To change CONF_THRESH, edit config_infer_primary.txt file
```
[class-attrs-all]
pre-cluster-threshold=0.25
``` ```

View File

@@ -14,3 +14,6 @@ maintain-aspect-ratio=0
parse-bbox-func-name=NvDsInferParseCustomYoloV5 parse-bbox-func-name=NvDsInferParseCustomYoloV5
custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so 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]
pre-cluster-threshold=0.25

View File

@@ -25,10 +25,7 @@
#include <map> #include <map>
#define NMS_THRESH 0.45 #define kNMS_THRESH 0.45
#define CONF_THRESH 0.25
static const int NUM_CLASSES_YOLO = 80;
static constexpr int LOCATIONS = 4; static constexpr int LOCATIONS = 4;
struct alignas(float) Detection{ struct alignas(float) Detection{
@@ -90,16 +87,11 @@ static bool NvDsInferParseYoloV5(
NvDsInferParseDetectionParams const& detectionParams, NvDsInferParseDetectionParams const& detectionParams,
std::vector<NvDsInferParseObjectInfo>& objectList) std::vector<NvDsInferParseObjectInfo>& objectList)
{ {
if (NUM_CLASSES_YOLO != detectionParams.numClassesConfigured) const float kCONF_THRESH = detectionParams.perClassThreshold[0];
{
std::cerr << "WARNING: Num classes mismatch. Configured:"
<< detectionParams.numClassesConfigured
<< ", detected by network: " << NUM_CLASSES_YOLO << std::endl;
}
std::vector<Detection> res; std::vector<Detection> res;
nms(res, (float*)(outputLayersInfo[0].buffer), CONF_THRESH, NMS_THRESH); nms(res, (float*)(outputLayersInfo[0].buffer), kCONF_THRESH, kNMS_THRESH);
for(auto& r : res) { for(auto& r : res) {
NvDsInferParseObjectInfo oinfo; NvDsInferParseObjectInfo oinfo;