Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to convet torch to onnx and then tensorrt #3

Open
kkeono2 opened this issue Nov 16, 2023 · 4 comments
Open

how to convet torch to onnx and then tensorrt #3

kkeono2 opened this issue Nov 16, 2023 · 4 comments

Comments

@kkeono2
Copy link

kkeono2 commented Nov 16, 2023

Thank you for your great work.

Do you have any plan to support model conveting implementation for onnx ?

@codet-ovd
Copy link

codet-ovd commented Nov 16, 2023

Hi,

You can use detectron2's built-in script to export the model to onnx. Also, since this codebase is built upon Detic, I believe related discussions in their Issue #61 and #107 may help you.

@gigasurgeon
Copy link

you can look at this discussion -> facebookresearch/Detic#113 (comment)

@kkeono2
Copy link
Author

kkeono2 commented Nov 17, 2023

Thanky you for rapid answering @codet-ovd

I used detectron2's built-in script (i just change set-up configuration in export_onnx.py ) to convert torch model to onnx and i have successfully converted.
However, i faced the problem with topk initialization when i converted onnx to tensorrt as below(TensorRT error message).
'''
[6] Invalid Node - /proposal_generator/TopK
This version of TensorRT only supports input K as an initializer
'''

I guess the problem with topk initialization due to varing the image_thresh per image in centernet.py.
Therefore, i fixed the image_thresh as constant value(0.1).

            if num_dets > post_nms_topk:
                cls_scores = result.scores
                # image_thresh, _ = torch.kthvalue(cls_scores.float().cpu(),num_dets - post_nms_topk + 1)
                keep = cls_scores >= 0.1 #image_thresh.item()  

I also faced the error as below. i don't know why these error is occuring.
'''
[6] Invalid Node - /roi_heads/box_pooler/level_poolers.0/If
/roi_heads/box_pooler/level_poolers.0/If_OutputLayer: IIfConditionalOutputLayer inputs must have the same shape.
'''

Can you help me solve this please?
I use TensorRT 8.5.1, ONNX 1.12.0

@kkeono2 kkeono2 changed the title torch to onnx how to convet torch to onnx and then tensorrt Nov 17, 2023
@kkeono2
Copy link
Author

kkeono2 commented Nov 17, 2023

Thank you for answering @gigasurgeon

I can convert torch model to onnx without comment the nms_and_topk line in centernet, while exporting the model.

Actually, i can't convet onnx to tensorrt as above issue.

Can you give me a suggetion to solve above issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants