diff --git a/README.md b/README.md index 50a0acc..cdba6d2 100644 --- a/README.md +++ b/README.md @@ -107,14 +107,14 @@ eval = val2017 (COCO) sample = 1920x1080 video ``` -**NOTE**: Used maintain-aspect-ratio=1 in config_infer file for YOLOv4 (with letter_box=1), YOLOv5 and YOLOR models. +**NOTE**: Used maintain-aspect-ratio=1 in config_infer file for Darknet (with letter_box=1) and PyTorch models. #### NMS config - Eval ``` -nms-iou-threshold = 0.6 / 0.65 (YOLOv5, YOLOR, YOLOv7 PyTorch) / 0.7 (PP-YOLOE) +nms-iou-threshold = 0.6 (Darknet) / 0.65 (PyTorch) / 0.7 (Paddle) pre-cluster-threshold = 0.001 topk = 300 ``` @@ -122,7 +122,7 @@ topk = 300 - Test ``` -nms-iou-threshold = 0.45 / 0.7 (PP-YOLOE) +nms-iou-threshold = 0.45 / 0.7 (Paddle) pre-cluster-threshold = 0.25 topk = 300 ``` diff --git a/config_infer_primary_yoloV7.txt b/config_infer_primary_yoloV7.txt index 9dcf28c..d063418 100644 --- a/config_infer_primary_yoloV7.txt +++ b/config_infer_primary_yoloV7.txt @@ -15,7 +15,7 @@ gie-unique-id=1 process-mode=1 network-type=0 cluster-mode=2 -maintain-aspect-ratio=0 +maintain-aspect-ratio=1 parse-bbox-func-name=NvDsInferParseYolo custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so engine-create-func-name=NvDsInferYoloCudaEngineGet diff --git a/nvdsinfer_custom_impl_Yolo/layers/reorg_layer.cpp b/nvdsinfer_custom_impl_Yolo/layers/reorg_layer.cpp index c126df2..9633ebb 100644 --- a/nvdsinfer_custom_impl_Yolo/layers/reorg_layer.cpp +++ b/nvdsinfer_custom_impl_Yolo/layers/reorg_layer.cpp @@ -25,14 +25,14 @@ nvinfer1::ITensor* reorgLayer( slice1->setName(slice1LayerName.c_str()); nvinfer1::ISliceLayer *slice2 = network->addSlice( - *input, nvinfer1::Dims{3, {0, 0, 1}}, nvinfer1::Dims{3, {inputDims.d[0], inputDims.d[1] / 2, inputDims.d[2] / 2}}, + *input, nvinfer1::Dims{3, {0, 1, 0}}, nvinfer1::Dims{3, {inputDims.d[0], inputDims.d[1] / 2, inputDims.d[2] / 2}}, nvinfer1::Dims{3, {1, 2, 2}}); assert(slice2 != nullptr); std::string slice2LayerName = "slice2_" + std::to_string(layerIdx); slice2->setName(slice2LayerName.c_str()); nvinfer1::ISliceLayer *slice3 = network->addSlice( - *input, nvinfer1::Dims{3, {0, 1, 0}}, nvinfer1::Dims{3, {inputDims.d[0], inputDims.d[1] / 2, inputDims.d[2] / 2}}, + *input, nvinfer1::Dims{3, {0, 0, 1}}, nvinfer1::Dims{3, {inputDims.d[0], inputDims.d[1] / 2, inputDims.d[2] / 2}}, nvinfer1::Dims{3, {1, 2, 2}}); assert(slice3 != nullptr); std::string slice3LayerName = "slice3_" + std::to_string(layerIdx); diff --git a/nvdsinfer_custom_impl_Yolo/layers/route_layer.cpp b/nvdsinfer_custom_impl_Yolo/layers/route_layer.cpp index fd8d149..6115e9e 100644 --- a/nvdsinfer_custom_impl_Yolo/layers/route_layer.cpp +++ b/nvdsinfer_custom_impl_Yolo/layers/route_layer.cpp @@ -46,20 +46,21 @@ nvinfer1::ITensor* routeLayer( layers += std::to_string(idxLayers[idxLayers.size() - 1]); if (concatInputs.size() == 1) - return concatInputs[0]; + output = concatInputs[0]; + else { + int axis = 0; + if (block.find("axis") != block.end()) + axis = std::stoi(block.at("axis")); + if (axis < 0) + axis = concatInputs[0]->getDimensions().nbDims + axis; - int axis = 0; - if (block.find("axis") != block.end()) - axis = std::stoi(block.at("axis")); - if (axis < 0) - axis = concatInputs[0]->getDimensions().nbDims + axis; - - nvinfer1::IConcatenationLayer* concat = network->addConcatenation(concatInputs.data(), concatInputs.size()); - assert(concat != nullptr); - std::string concatLayerName = "route_" + std::to_string(layerIdx); - concat->setName(concatLayerName.c_str()); - concat->setAxis(axis); - output = concat->getOutput(0); + nvinfer1::IConcatenationLayer* concat = network->addConcatenation(concatInputs.data(), concatInputs.size()); + assert(concat != nullptr); + std::string concatLayerName = "route_" + std::to_string(layerIdx); + concat->setName(concatLayerName.c_str()); + concat->setAxis(axis); + output = concat->getOutput(0); + } if (block.find("groups") != block.end()) { diff --git a/nvdsinfer_custom_impl_Yolo/yolo.cpp b/nvdsinfer_custom_impl_Yolo/yolo.cpp index 54e84f9..f5dc68e 100644 --- a/nvdsinfer_custom_impl_Yolo/yolo.cpp +++ b/nvdsinfer_custom_impl_Yolo/yolo.cpp @@ -304,7 +304,17 @@ NvDsInferStatus Yolo::buildYoloNetwork(std::vector& weights, nvinfer1::IN else if (m_ConfigBlocks.at(i).at("type") == "reorg") { std::string inputVol = dimsToString(previous->getDimensions()); - previous = reorgLayer(i, m_ConfigBlocks.at(i), previous, &network); + if (m_NetworkType.find("yolov2") != std::string::npos) { + nvinfer1::IPluginV2* reorgPlugin = createReorgPlugin(2); + assert(reorgPlugin != nullptr); + nvinfer1::IPluginV2Layer* reorg = network.addPluginV2(&previous, 1, *reorgPlugin); + assert(reorg != nullptr); + std::string reorglayerName = "reorg_" + std::to_string(i); + reorg->setName(reorglayerName.c_str()); + previous = reorg->getOutput(0); + } + else + previous = reorgLayer(i, m_ConfigBlocks.at(i), previous, &network); assert(previous != nullptr); std::string outputVol = dimsToString(previous->getDimensions()); tensorOutputs.push_back(previous); diff --git a/utils/gen_wts_yoloV7.py b/utils/gen_wts_yoloV7.py index d827fac..2f7ad45 100644 --- a/utils/gen_wts_yoloV7.py +++ b/utils/gen_wts_yoloV7.py @@ -135,7 +135,8 @@ class Layers(object): self.fc.write('[net]\n' + 'width=%d\n' % self.width + 'height=%d\n' % self.height + - 'channels=3\n') + 'channels=3\n' + + 'letter_box=1\n') def reorg(self): self.blocks[self.current] += 1