EfficientAT icon indicating copy to clipboard operation
EfficientAT copied to clipboard

onnx

Open zdj97 opened this issue 1 year ago • 12 comments
trafficstars

how to convert this model to onnx type?

zdj97 avatar Mar 04 '24 03:03 zdj97

def export_onnx_model(model, input_shape, onnx_path, input_names=None, output_names=None, dynamic_axes=None):
    inputs = torch.ones(*input_shape)
    model(inputs)
    torch.onnx.export(model, inputs, onnx_path, input_names=input_names, output_names=output_names,
                      dynamic_axes=dynamic_axes)


def export_onnx(model):
    batch_size = 1
    width = 128
    height = 420
    input_shape = (batch_size, 1, width, height)
    onnx_path = "eat_dynamic_axis.onnx"
    input_names = ['feats']
    output_names = ['probe']
    dynamic_axes = {'input': {0: 'batch_size', 2: 'width', 3: 'height'},
                    'output': {0: 'batch_size', 2: 'width'}}  # adding names for better debugging
    export_onnx_model(model, input_shape, onnx_path, input_names, output_names, dynamic_axes)

@zdj97 here is my onnx export code, but onnx has the same problem like ptmobile issue (https://github.com/fschmid56/EfficientAT/issues/26)

thelou1s avatar Mar 04 '24 05:03 thelou1s

Yes. And what is the problem of ptmobile?

zdj97 avatar Mar 04 '24 05:03 zdj97

@zdj97 I updated my post, and do you mind add my email(thelou1s # yahoo.com). as we may doing the same task

thelou1s avatar Mar 04 '24 05:03 thelou1s

Yes. I will test this onnx model. If I find any question, I will email to you.

zdj97 avatar Mar 04 '24 05:03 zdj97

@zdj97 Hi, do you got the onnx model file? do you make the dynamic_axes work?

thelou1s avatar Mar 05 '24 01:03 thelou1s

I have converted ptmodel to onnxmodel. But I do not test preformance. When I test onnx preformance, I will contect you.

zdj97 avatar Mar 05 '24 03:03 zdj97

@zdj97 Hi, do you got the onnx model file? do you make the dynamic_axes work?

I have converted the mn pytorch model to onnx and do not find any question.

zdj97 avatar Apr 11 '24 05:04 zdj97

@zdj97 , Could you email me the converted onnx model file, so that I can compare it with mine. As In my use case, it performs badly. thanks

thelou1s avatar Apr 14 '24 02:04 thelou1s

@zdj97 , Could you email me the converted onnx model file, so that I can compare it with mine. As In my use case, it performs badly. thanks

Hi, please tell me your email so that i send to you.

zdj97 avatar Apr 15 '24 06:04 zdj97

@zdj97 thelou1s [At] yahoo.com

thelou1s avatar Apr 16 '24 06:04 thelou1s

@zdj97 Hi, do you got the onnx model file? do you make the dynamic_axes work?

I have converted the mn pytorch model to onnx and do not find any question.

can you convert the dymn pytorch model to onnx?

6xdax avatar Aug 27 '24 04:08 6xdax

@thelou1s @zdj97 did you have success in the end? would you kindly share your complete export code? :)

lukeandsee avatar Mar 18 '25 12:03 lukeandsee