TensorRT icon indicating copy to clipboard operation
TensorRT copied to clipboard

Input image size less than 800px affecting performance for Detectron2 Mask R-CNN TensorRT Compilation

Open barathsku opened this issue 3 years ago • 7 comments

Description

In the official Detectron 2 Mask R-CNN R50-FPN 3x TensorRT compilation script, the number of predictions the model makes on an image is none if the input image size used throughout the compilation process is reduced from 1344x1344 to 512x512. There is some predictions being made at 640x640, a noticeable amount of predictions at 832x832 and a lot of predictions being made at 1344x1344. Any particular reason as to why this happens?

Environment

TensorRT Version: NVIDIA GPU: Tesla T4 NVIDIA Driver Version: 470.141.03 CUDA Version: 11.6 CUDNN Version: 8.4 Operating System: Ubuntu 20.04 Python Version (if applicable): 3.8.10 PyTorch Version (if applicable): 1.12.1+cu116 Baremetal or Container (if so, version): Using Docker (Ubuntu 20.04) file provided with TensorRT OSS

Steps To Reproduce

Follow the same instructions as mentioned in https://github.com/NVIDIA/TensorRT/tree/main/samples/python/detectron2, but modify the following:

  1. In the export_model.py file under detectron2 source code, change cfg.INPUT.MIN_SIZE_TEST and cfg.INPUT.MAX_SIZE_TEST to 512 (or size of choice)
  2. Use an input image with 512x512 size (or size of choice)
  3. In create_onnx.py line 170, change 1344 to 512 (or size of choice)

barathsku avatar Aug 24 '22 02:08 barathsku

@azhurkevich ^ ^

zerollzeng avatar Aug 25 '22 15:08 zerollzeng

Hi @zerollzeng @azhurkevich any updates on this issue?

barathsku avatar Aug 28 '22 23:08 barathsku

@barathsku This

azhurkevich avatar Aug 29 '22 13:08 azhurkevich

@azhurkevich Sorry for the late reply, thank you for your response - I have another question, assuming the SIZES and ASPECT_RATIOS under ANCHOR_GENERATOR in the default config file is changed to:

  ANCHOR_GENERATOR:
    SIZES: [[16], [32], [64], [128], [256], [512]]  # One size for each in feature map
    ASPECT_RATIOS: [[0.25, 0.5, 1.0, 2.0]]  # Three aspect ratios (same for all in feature maps)

There is an additional size (16) added. There is no p7 feature map for me to modify in the create_onnx.py file, so how can this change be done?

barathsku avatar Sep 03 '22 07:09 barathsku

Hi @azhurkevich , any updates on the above question?

barathsku avatar Sep 07 '22 03:09 barathsku

@barathsku I am OOTO. The only way to handle such customized model is to have a look at graphs with Netron before and after conversion of the vanilla model and the one that you use (only before conversion). You'll have to understand what converter does and how the code works in order to tailor it towards your specific model. Converter "as is" only guaranteed to work with publicly available Detectron 2 zoo model, it cannot handle modified models since I cannot predict how they can be modified + the amount of modifications can be massive.

In the end, please read the code and comments, visualize NN graphs before and after as well as your model before the conversion. Look for similarities and change code accordingly

azhurkevich avatar Sep 10 '22 18:09 azhurkevich

Got it, thanks :) @azhurkevich

barathsku avatar Sep 12 '22 07:09 barathsku

closing since this is solved, thanks all!

ttyio avatar Nov 23 '23 00:11 ttyio