

TITLE
conversion wav2vec2 model from fairseq to huggingface

COMMENTS
1

REACTIONS
+1: 0
-1: 0
laugh: 0
hooray: 0
heart: 0
rocket: 0
eyes: 0

BODY
# 📚 Migration
Hi, 
trained wav2vec2 model in fairseq for my own dataset. Now i need to finetune pretrained fairseq wav2vec2 model. To train hugging face model it is asking following files.
1. config.json
2. preprocessor_config.json
3. pytorch_model.bin
4. special_tokens_map.json
5. tokenizer_config.json
6. vocab.json

To get this files i used following command for wav2vec2 base model
 cp transformers/src/transformers/models/wav2vec2/convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py .
 wget https://dl.fbaipublicfiles.com/fairseq/wav2vec/wav2vec_small_960h.pt -O ./wav2vec_small_960h.pt
 mkdir dict
 wget https://dl.fbaipublicfiles.com/fairseq/wav2vec/dict.ltr.txt
 mkdir outputs
 python convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py --pytorch_dump_folder_path ./outputs --checkpoint_path ./wav2vec_small_960h.pt --dict_path dict.ltr.txt

This following commands are working fine for wav2vec_small_960h.pt model and able to generate config.json, preprocessor_config.json, pytorch_model.bin, special_tokens_map.json,  tokenizer_config.json, vocab.json 

But i trained model using following command

fairseq-hydra-train \
    task.data=/path/to/data \
    --config-dir /path/to/fairseq-py/examples/wav2vec/config/pretraining \
    --config-name wav2vec2_base_librispeech
 i got checkpoint_mine.pt

Then i  used 

 python convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py --pytorch_dump_folder_path ./outputs --checkpoint_path ./checkpoint_mine.pt --dict_path dict.ltr.txt

I'm getting following error
File "convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py", line 255, in <module>
    convert_wav2vec2_checkpoint(
  File "env/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py", line 240, in convert_wav2vec2_checkpoint
    recursively_load_weights(model, hf_wav2vec, not is_finetuned)
  File "convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py", line 134, in recursively_load_weights
    set_recursively(hf_model, mapped_key, value, name, weight_type)
  File "convert_wav2vec2_original_pytorch_checkpoint_to_pytorch.py", line 71, in set_recursively
    hf_pointer = getattr(hf_pointer, attribute)
  File "env/lib/python3.8/site-packages/torch/nn/modules/module.py", line 947, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(

Please can any one suggest what i need to change 
why  wav2vec_small_960h.pt  and checkpoint_mine.pt are differ. I saw previous discuusions but i didn't get proper solution.
Thanks in advance