Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

I have a Whisper-based model. How can I convert it to fairseq.dict format ? #322

Open
Roland-Du opened this issue May 29, 2023 · 1 comment

Comments

@Roland-Du
Copy link

model https://huggingface.co/openai/whisper-large-v2

@Roland-Du
Copy link
Author

After using the Tiny model for training, the saved model file is in pt format
torch.save({"dims": asdict(dims), "model_state_dict": hf_state_dict}, "/root/tiny_v2.pt")

I am trying to convert the model to pt in jit format

import torch
model = torch.load('/root/tiny_v2.pt')

batch_size, channels, time = 32, 1, 16000
inputs = torch.rand(batch_size, channels, time)
traced_model = torch.jit.script(model, inputs)
#traced_model = torch.jit.trace(model, inputs)

torch.jit.save(traced_model, 'model_jit.pt')
#traced_model.save('jit_model.pt')

/usr/local/lib64/python3.9/site-packages/torch/jit/_script.py:1241: UserWarning: optimize is deprecated and has no effect. Use `with torch.jit.optimized_execution() instead
warnings.warn(
Traceback (most recent call last):
File "/home/duzg/asr/dzg.py", line 7, in
traced_model = torch.jit.script(model, inputs)
File "/usr/local/lib64/python3.9/site-packages/torch/jit/_script.py", line 1289, in script
return create_script_dict(obj)
File "/usr/local/lib64/python3.9/site-packages/torch/jit/_script.py", line 1020, in create_script_dict
return torch._C.ScriptDict(obj) # type: ignore[attr-defined]
torch.jit.Error: Unable to infer type of dictionary: Dictionary inputs to traced functions must have consistent type. Found Dict[str, int] and Dict[str, Tensor]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant