Cant Get Output Nodes

Description

Using the block of code below,

parser->parseFromFile(
    onnx_file_path.c_str(), static_cast<int>(nvinfer1::ILogger::Severity::kINFO));
  std::vector<nvinfer1::ITensor *> scores, boxes, classes;
  const auto input = network->getInput(0);
  const auto num_outputs = network->getNbOutputs();
  std::cout<<num_outputs<<std::endl;
  const auto input_dims = input->getDimensions();
  const auto input_channel = input_dims.d[1];
  const auto input_height = input_dims.d[2];
  const auto input_width = input_dims.d[3];
  for (int i = 0; i < num_outputs; ++i) {
    auto output = network->getOutput(i);
    std::vector<float> anchor(
      yolo_config.anchors.begin() + i * yolo_config.num_anchors * 2,
      yolo_config.anchors.begin() + (i + 1) * yolo_config.num_anchors * 2);
    auto yoloLayerPlugin = yolo::YoloLayerPlugin(
      input_width, input_height, 3, anchor, yolo_config.scale_x_y[i], yolo_config.score_thresh,
      yolo_config.use_darknet_layer);
    std::vector<nvinfer1::ITensor *> inputs = {output};
    auto layer = network->addPluginV2(inputs.data(), inputs.size(), yoloLayerPlugin);
    scores.push_back(layer->getOutput(0));
    boxes.push_back(layer->getOutput(1));
    classes.push_back(layer->getOutput(2));
  }

  std::cout<<"SCORES !!!!!!!!!!!!!!!!!!!!!!"<< scores.size() <<std::endl;
  std::cout<<"BOXES !!!!!!!!!!!!!!!!!!!!!!"<< boxes.size() <<std::endl;
  std::cout<<"CLASSES !!!!!!!!!!!!!!!!!!!!!!"<< classes.size() <<std::endl;


  // Cleanup outputs
  for (int i = 0; i < num_outputs; i++) {
    std::cout<<"Output "<<i<<std::endl;
    auto output = network->getOutput(i);
    network->unmarkOutput(*output);
  }

  // Concat tensors from each feature map
  std::vector<nvinfer1::ITensor *> concat;
  for (auto tensors : {scores, boxes, classes}) {
    std::cout<<"ADDING !!!!!!!!!!!!!!!!!!!!!! "<< tensors.data()<< tensors.data() <<std::endl;
    auto layer = network->addConcatenation(tensors.data(), tensors.size());
    layer->setAxis(1);
    std::cout<<"ADDED !!!!!!!!!!!!!!!!!!!!!!"<<std::endl;
    auto output = layer->getOutput(0);
    concat.push_back(output);
  }

I get num_outputs = 0. When I manually set num_outputs it yields;

Parameter check failed at: ../builder/Layers.cpp::PluginV2Layer::1728, condition: (inputs[0]) != nullptr
Parameter check failed at: ../builder/Layers.cpp::PluginV2Layer::1728, condition: (inputs[0]) != nullptr
Parameter check failed at: ../builder/Layers.cpp::PluginV2Layer::1728, condition: (inputs[0]) != nullptr

By doing

model = onnx.load('yolov4.onnx')
output = model.graph.output

I can get output nodes correctly. So i guess onnx model is ok.

Environment

TensorRT Version: 7.0.0.11
GPU Type: RTX2070
Nvidia Driver Version: 460
CUDA Version: 10.0
CUDNN Version: 7.6.5
ONNX Version: 1.6.0

Relevant files

I use this onnx model.

Hi @orcdnz,

Are you still facing this issue

Upgraded to v7.2.1.6 and I dont face it no more

1 Like