This repository has been archived on 2026-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
icefall/egs/librispeech/SSL/local/convert_checkpoint_from_fairseq.py
2025-07-10 15:27:08 +08:00

19 lines
478 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, weights_only=False)
new_checkpoint = OrderedDict()
new_checkpoint["model"] = old_checkpoint["model"]
torch.save(new_checkpoint, tgt)