NeMo icon indicating copy to clipboard operation
NeMo copied to clipboard

Unable to export diar_msdd_telephonic (neural diarizer) model to onnx format

Open chidalgoRR opened this issue 1 year ago • 6 comments

Describe the bug

I am trying to export the diarization MSDD telephonic model to onnx format but i get the following error:

File "/home/chidalgo/.local/lib/python3.10/site-packages/nemo/core/classes/exportable.py", line 113, in export out, descr, out_example = model._export( File "/home/chidalgo/.local/lib/python3.10/site-packages/nemo/core/classes/exportable.py", line 177, in _export input_example = self.input_module.input_example() File "/home/chidalgo/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1695, in getattr raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'") AttributeError: 'MyExportableModel' object has no attribute 'input_module'. Did you mean: 'output_module'?.

Steps/Code to reproduce bug

Here is the code i used.

import nemo from nemo.collections.asr.models import EncDecDiarLabelModel from nemo.core.classes import ModelPT, Exportable

class MyExportableModel(EncDecDiarLabelModel, ModelPT, Exportable): pass

sd_model = MyExportableModel.from_pretrained(model_name = "diar_msdd_telephonic")

sd_model.eval() sd_model.to('cuda') sd_model.export('sd_model.onnx')

Expected behavior

To get a file named sd_model.onnx with the model in onnx format

Environment overview (please complete the following information)

  • Environment location: [Bare-metal]
  • Method of NeMo install: pip install nemo_toolkit['all']

Environment details

If NVIDIA docker image is used you don't need to specify these. Otherwise, please provide:

  • Ubuntu 20.04
  • 2.1.2
  • Python 3.10.12

Additional context

i also tried with the export.py script but i get the following:

File "/home/chidalgo/.local/lib/python3.10/site-packages/nemo/core/classes/common.py", line 507, in from_config_dict raise e File "/home/chidalgo/.local/lib/python3.10/site-packages/nemo/core/classes/common.py", line 499, in from_config_dict instance = cls(cfg=config, trainer=trainer) TypeError: Can't instantiate abstract class ModelPT with abstract methods list_available_models, setup_training_data, setup_validation_data

thank you, i have seen other issues with the same bug but it has not been solved

chidalgoRR avatar Mar 30 '24 00:03 chidalgoRR

I saw someone had the same issue with ecapa tdnn model way back and it has not been solved

chidalgoRR avatar Apr 03 '24 16:04 chidalgoRR

It might not be possible to convert MSDD straightaway to onnx, as it depends on other models. @tango4j can you pls provide steps to achieve this.

nithinraok avatar Apr 04 '24 15:04 nithinraok

Thank you for responding, it would be very helpful for me if this can be solved.

chidalgoRR avatar Apr 04 '24 16:04 chidalgoRR

NeMo neural diarization class (clustering+MSDD) is not ONNX exportable. This is because pytorch linear algebra library is not fully ONNX exportable. We are working on fully neural diarization and only after fully neural diarization is released, the diarization pipeline will be ONNX exportable.

tango4j avatar Apr 04 '24 17:04 tango4j

Thank you for the quick response. Is there a way to export it to any other format that can be uploaded to triton?. I am trying to run a diarization pipeline on triton and i need to upload this model.

chidalgoRR avatar Apr 04 '24 17:04 chidalgoRR

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar May 05 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 7 days since being marked as stale.

github-actions[bot] avatar May 12 '24 01:05 github-actions[bot]