fschmid56 / EfficientAT

This repository aims at providing efficient CNNs for Audio Tagging. We provide AudioSet pre-trained models ready for downstream training and extraction of audio embeddings.
MIT License
233 stars 44 forks source link

onnx #27

Open zdj97 opened 8 months ago

zdj97 commented 8 months ago

how to convert this model to onnx type?

thelou1s commented 8 months ago
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)

zdj97 commented 8 months ago

Yes. And what is the problem of ptmobile?

thelou1s commented 8 months ago

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

zdj97 commented 8 months ago

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

thelou1s commented 8 months ago

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

zdj97 commented 8 months ago

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

zdj97 commented 7 months ago

@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.

thelou1s commented 7 months ago

@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

zdj97 commented 7 months ago

@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.

thelou1s commented 7 months ago

@zdj97 thelou1s [At] yahoo.com

6xdax commented 2 months ago

@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?