lyuwenyu / RT-DETR

[CVPR 2024] Official RT-DETR (RTDETR paddle pytorch), Real-Time DEtection TRansformer, DETRs Beat YOLOs on Real-time Object Detection. 🔥 🔥 🔥
Apache License 2.0
2.61k stars 303 forks source link

TensorRT Inference Produces Zero Value Coordinates #364

Closed rogcomfox closed 4 months ago

rogcomfox commented 4 months ago

Hi there, thank you for your great work of RT-DETR. I trained RT-DETR using my own dataset and convert the onnx model to TensorRT following this #124. when I do inference, the bounding boxes coordinates always produces zero value like this screenshot. for inference I follow your code in trtinfer.py. Screenshot 2024-07-11 185425

lyuwenyu commented 4 months ago

You can check the type of inputs

rogcomfox commented 4 months ago

for the inputs, i put all of the inputs to gpu instead of cpu like this

#for tensor backend
resized_img = T.ToTensor()(resized_img)[None].to("cuda:0", non_blocking=True)
blob = {"images" : resized_img, "orig_target_sizes": torch.tensor([[640,640]]).to("cuda:0", non_blocking=True)}
lyuwenyu commented 4 months ago

"orig_target_sizes": torch.tensor([[640,640]]).to("cuda:0", non_blocking=True)

replace this as

"orig_target_sizes": torch.tensor([[640,640]]).to(device="cuda:0", dtype=torch.int32, non_blocking=True)
rogcomfox commented 4 months ago

thank you so much for your suggestion! it finally works like a charm image