TensorRT
TensorRT copied to clipboard
Input image size less than 800px affecting performance for Detectron2 Mask R-CNN TensorRT Compilation
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:
- In the
export_model.pyfile under detectron2 source code, change cfg.INPUT.MIN_SIZE_TEST and cfg.INPUT.MAX_SIZE_TEST to 512 (or size of choice) - Use an input image with 512x512 size (or size of choice)
- In create_onnx.py line 170, change 1344 to 512 (or size of choice)
@azhurkevich ^ ^
Hi @zerollzeng @azhurkevich any updates on this issue?
@barathsku This
@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?
Hi @azhurkevich , any updates on the above question?
@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
Got it, thanks :) @azhurkevich
closing since this is solved, thanks all!