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

Adding Facebook/Encodec support for ONNX #1620

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coolyashas
Copy link

Fixes #27602

@fxmarty
Copy link
Collaborator

fxmarty commented Jan 11, 2024

Thank you @coolyashas, feel free if you need any help.

@shoh27
Copy link

shoh27 commented Mar 17, 2024

Hi,

I tried exporting the model by configuring it and incorporating 'encodec' into the TasksManager class within the tasks.py file. I tested this solution in both the source and stable versions.
main.py
model_checkpoint = "facebook/encodec_24khz" ; base_model = AutoModel.from_pretrained(model_checkpoint); onnx_path = Path(save_directory,"model_encodec.onnx") ; onnx_config_constructor = TasksManager.get_exporter_config_constructor("onnx", base_model); onnx_config = onnx_config_constructor(base_model.config); onnx_inputs, onnx_outputs = export(base_model, onnx_config, onnx_path, onnx_config.DEFAULT_ONNX_OPSET);

tasks.py
"encodec": supported_tasks_mapping( "default", "feature-extraction", onnx="EncodecOnnxConfig", ),

Regrettably, the proposed solution isn't effective. While following the example provided in the HuggingFace documentation on ONNX exporters https://huggingface.co/docs/optimum/main/en/exporters/onnx/usage_guides/contribute](onnx), I encountered an error within self._create_dummy_input_generator_classes(**kwargs).

/home/user/anaconda3/envs/onnx_from_src/lib/python3.8/site-packages/torch/nn/utils/weight_norm.py:28: UserWarning: torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm. warnings.warn("torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.") Passing the argument library_nametoget_supported_tasks_for_model_typeis required, but got library_name=None. Defaulting totransformers. An error will be raised in a future version of Optimum if library_nameis not provided. Using framework PyTorch: 2.2.1+cu121 Traceback (most recent call last): File "/home/user/anaconda3/envs/onnx_from_src/lib/python3.8/site-packages/optimum/exporters/onnx/convert.py", line 547, in export_pytorch dummy_inputs = config.generate_dummy_inputs(framework="pt", **input_shapes) File "/home/user/anaconda3/envs/onnx_from_src/lib/python3.8/site-packages/optimum/exporters/onnx/base.py", line 463, in generate_dummy_inputs dummy_inputs_generators = self._create_dummy_input_generator_classes(**kwargs) File "/home/user/anaconda3/envs/onnx_from_src/lib/python3.8/site-packages/optimum/exporters/onnx/model_configs.py", line 1917, in _create_dummy_input_generator_classes DummyAudioInputGenerator(**kwargs) TypeError: __init__() missing 2 required positional arguments: 'task' and 'normalized_config'

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

Successfully merging this pull request may close these issues.

None yet

3 participants