This code found in this repository was adapted from this original HuggingFace repository. This repository contains two scripts that convert a fairseq data2vec1 checkpoint to HuggingFace 🤗 Transformers.
- Create a HF repo :
huggingface-cli repo create <model-name> --organization <org_of_model>
git clone https://huggingface.co/<org_of_model>/<name_of_model>
- Convert the model
./run_convert.sh \
--hf-path </path/to/local/hf/repo> \
--fairseq-path </path/to/fairseq/checkpoint> \
--size {base, large} \
[--dict </path/to/dict>] \
[--copy-fairseq-model]
- Verify models behave equally
./run_forward.py \
--hf-path </path/to/local/hf/repo> \
--fairseq-path </path/to/fairseq/checkpoint> \
[--finetuned </path/to/dict>]
- Push to hub
huggingface-cli upload <your-org>/<your-model> </path/to/local/hf/repo>
convert_data2vec1_audio_original_pytorch_checkpoint_to_pytorch.py (originally from official huggingface /transformers) was modified.
-
The fairseq model is properly imported (and class name clashes are correctly handled)
-
sampling_rateanddo_normalizeare both extracted from the fairseq's original configuration (e.g.cfg['task']['sample_rate']) instead of being guessed. -
Creates
preprocessor_config.jsonwhich the original didn't do for pre-trained (i.e. non-finetuned) models -
run_forward.pywas adapted from the wav2vec2 conversion script