tiny-tensorrt icon indicating copy to clipboard operation
tiny-tensorrt copied to clipboard

'pytrt.Trt' object has no attribute 'AddDynamicShapeProfile'

Open mahesh11T opened this issue 2 years ago • 1 comments

can I get help on how to run with dynamic shape input in python? can you add an example in python?

import cv2
import tritonclient.grpc as grpc_client
import time
import sys
sys.path.append("/opt/nvocdr/tiny-tensorrt/build/lib")
import pytrt
import numpy as np

#  /opt/nvocdr/tiny-tensorrt/build/lib/pytrt.cpython-310-x86_64-linux-gnu.so
# Assuming engine creation logic exists prior to this snippet
# Load the engine
engineFile = r"/opt/nvocdr/engines/ocdnet.fp16.engine"
onnx_model = r"/opt/nvocdr/onnx_model/ocdnet.onnx"

trt = pytrt.Trt()
# Create an optimization profile
min_shape = (1, 3, 736, 1280)  # Define minimum input shape
max_shape = (4, 3, 736, 1280)  # Define maximum input shape
# opt_profile = trt.create_optimization_profile()
trt.AddDynamicShapeProfile('INPUT_DATA', min_shape, max_shape)
trt.AddDynamicShapeProfile('INPUT_IMG_EXTENSION', min_shape, max_shape)

trt.BuildEngine(onnx_model, engineFile)

image

mahesh11T avatar Nov 15 '23 10:11 mahesh11T

Sorry I won't work in this project now since we had better alternatives.

E.g. you can use TensorRT's python API directly, or use trtexec or polygraphy to do the engine built quickly.

zerollzeng avatar Nov 21 '23 13:11 zerollzeng