icefall/egs/librispeech/SSL/local/convert_checkpoint_from_fairseq.py
Yifan Yang 87843e9382
k2SSL: a Faster and Better Framework for Self-Supervised Speech Representation Learning (#1500)
* Add k2SSL

* fix flake8

* fix for black

* fix for black

* fix for black

* Update ssl_datamodule.py

* Fix bugs in HubertDataset

* update comments

* add librilight

* add checkpoint convert script

* format

---------

Co-authored-by: yifanyeung <yifanyeung@yifanyeung.local>
Co-authored-by: zzasdf <15218404468@163.com>
2024-04-04 23:29:16 +08:00

19 lines
458 B
Python

# simple script to convert a fairseq checkpoint into pytorch parameter state dict
from argparse import ArgumentParser
from collections import OrderedDict
import torch
parser = ArgumentParser()
parser.add_argument("--src")
parser.add_argument("--tgt")
args = parser.parse_args()
src = args.src
tgt = args.tgt
old_checkpoint = torch.load(src)
new_checkpoint = OrderedDict()
new_checkpoint["model"] = old_checkpoint["model"]
torch.save(new_checkpoint, tgt)