Fix route layer

This commit is contained in:
Marcos Luciano
2022-08-16 14:36:52 -03:00
parent ab082fc292
commit dc023b308e
6 changed files with 33 additions and 21 deletions

View File

@@ -107,14 +107,14 @@ eval = val2017 (COCO)
sample = 1920x1080 video 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 #### NMS config
- Eval - 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 pre-cluster-threshold = 0.001
topk = 300 topk = 300
``` ```
@@ -122,7 +122,7 @@ topk = 300
- Test - Test
``` ```
nms-iou-threshold = 0.45 / 0.7 (PP-YOLOE) nms-iou-threshold = 0.45 / 0.7 (Paddle)
pre-cluster-threshold = 0.25 pre-cluster-threshold = 0.25
topk = 300 topk = 300
``` ```

View File

@@ -15,7 +15,7 @@ gie-unique-id=1
process-mode=1 process-mode=1
network-type=0 network-type=0
cluster-mode=2 cluster-mode=2
maintain-aspect-ratio=0 maintain-aspect-ratio=1
parse-bbox-func-name=NvDsInferParseYolo parse-bbox-func-name=NvDsInferParseYolo
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

View File

@@ -25,14 +25,14 @@ nvinfer1::ITensor* reorgLayer(
slice1->setName(slice1LayerName.c_str()); slice1->setName(slice1LayerName.c_str());
nvinfer1::ISliceLayer *slice2 = network->addSlice( 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}}); nvinfer1::Dims{3, {1, 2, 2}});
assert(slice2 != nullptr); assert(slice2 != nullptr);
std::string slice2LayerName = "slice2_" + std::to_string(layerIdx); std::string slice2LayerName = "slice2_" + std::to_string(layerIdx);
slice2->setName(slice2LayerName.c_str()); slice2->setName(slice2LayerName.c_str());
nvinfer1::ISliceLayer *slice3 = network->addSlice( 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}}); nvinfer1::Dims{3, {1, 2, 2}});
assert(slice3 != nullptr); assert(slice3 != nullptr);
std::string slice3LayerName = "slice3_" + std::to_string(layerIdx); std::string slice3LayerName = "slice3_" + std::to_string(layerIdx);

View File

@@ -46,20 +46,21 @@ nvinfer1::ITensor* routeLayer(
layers += std::to_string(idxLayers[idxLayers.size() - 1]); layers += std::to_string(idxLayers[idxLayers.size() - 1]);
if (concatInputs.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; nvinfer1::IConcatenationLayer* concat = network->addConcatenation(concatInputs.data(), concatInputs.size());
if (block.find("axis") != block.end()) assert(concat != nullptr);
axis = std::stoi(block.at("axis")); std::string concatLayerName = "route_" + std::to_string(layerIdx);
if (axis < 0) concat->setName(concatLayerName.c_str());
axis = concatInputs[0]->getDimensions().nbDims + axis; 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()) if (block.find("groups") != block.end())
{ {

View File

@@ -304,7 +304,17 @@ NvDsInferStatus Yolo::buildYoloNetwork(std::vector<float>& weights, nvinfer1::IN
else if (m_ConfigBlocks.at(i).at("type") == "reorg") else if (m_ConfigBlocks.at(i).at("type") == "reorg")
{ {
std::string inputVol = dimsToString(previous->getDimensions()); 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); assert(previous != nullptr);
std::string outputVol = dimsToString(previous->getDimensions()); std::string outputVol = dimsToString(previous->getDimensions());
tensorOutputs.push_back(previous); tensorOutputs.push_back(previous);

View File

@@ -135,7 +135,8 @@ class Layers(object):
self.fc.write('[net]\n' + self.fc.write('[net]\n' +
'width=%d\n' % self.width + 'width=%d\n' % self.width +
'height=%d\n' % self.height + 'height=%d\n' % self.height +
'channels=3\n') 'channels=3\n' +
'letter_box=1\n')
def reorg(self): def reorg(self):
self.blocks[self.current] += 1 self.blocks[self.current] += 1