GroundingDINO icon indicating copy to clipboard operation
GroundingDINO copied to clipboard

Decreasing inference time on cpu

Open M-Zubair10 opened this issue 2 years ago • 2 comments
trafficstars

Thanks for this awesome model, it does evaluate good with pretrained model

Right now i am getting 15s average inference time, any way to reduce it to 2-3s

M-Zubair10 avatar Apr 09 '23 21:04 M-Zubair10

It is a good question, but we have not explored it yet. The straightest way is to deploy the model like ONNX.

SlongLiu avatar Apr 11 '23 08:04 SlongLiu

@SlongLiu should the operations in the model already support ONNX export? e.g.

code vaguely similar to the below should work?

# Export the model
torch.onnx.export](https://pytorch.org/docs/stable/onnx.html#torch.onnx.export)(torch_model,               # model being run
                  x,                         # model input (or a tuple for multiple inputs)
                  "super_resolution.onnx",   # where to save the model (can be a file or file-like object)
                  export_params=True,        # store the trained parameter weights inside the model file
                  opset_version=10,          # the ONNX version to export the model to
                  do_constant_folding=True,  # whether to execute constant folding for optimization
                  input_names = ['input'],   # the model's input names
                  output_names = ['output'], # the model's output names
                  dynamic_axes={'input' : {0 : 'batch_size'},    # variable length axes
                                'output' : {0 : 'batch_size'}})
                                

I'll look in to optimising it with tools like OpenVINO if it does.

GeorgePearse avatar Apr 12 '23 14:04 GeorgePearse

i try to use torch.onnx.export to transfer grounding-dino to onnx, it seems like some problem , such as several logical operators are not supported by onnx. for example: torch.onnx.symbolic_registry.UnsupportedOperatorError: Exporting the operator ::_ior to ONNX opset version 13 is not supported do you know which part of model make this problem. @GeorgePearse

Weizhongjin avatar Apr 23 '23 09:04 Weizhongjin

here

oylz avatar Jun 28 '23 14:06 oylz

i try to use torch.onnx.export to transfer grounding-dino to onnx, it seems like some problem , such as several logical operators are not supported by onnx. for example: torch.onnx.symbolic_registry.UnsupportedOperatorError: Exporting the operator ::_ior to ONNX opset version 13 is not supported do you know which part of model make this problem. @GeorgePearse

Have you solve it please

Dratlan avatar Aug 01 '23 08:08 Dratlan

@SlongLiu should the operations in the model already support ONNX export? e.g.

code vaguely similar to the below should work?

# Export the model
torch.onnx.export](https://pytorch.org/docs/stable/onnx.html#torch.onnx.export)(torch_model,               # model being run
                  x,                         # model input (or a tuple for multiple inputs)
                  "super_resolution.onnx",   # where to save the model (can be a file or file-like object)
                  export_params=True,        # store the trained parameter weights inside the model file
                  opset_version=10,          # the ONNX version to export the model to
                  do_constant_folding=True,  # whether to execute constant folding for optimization
                  input_names = ['input'],   # the model's input names
                  output_names = ['output'], # the model's output names
                  dynamic_axes={'input' : {0 : 'batch_size'},    # variable length axes
                                'output' : {0 : 'batch_size'}})
                                

I'll look in to optimising it with tools like OpenVINO if it does.

am also interested in onx export code of GDINO

kobic8 avatar Aug 10 '23 10:08 kobic8