Skip to content

How to convert a CKPT file into .nemo format? #7659

Closed Answered by asierhv
egorsmkv asked this question in Q&A
Discussion options

You must be logged in to vote

Recently got the same problem, here is the code i used to get a .nemo file from a .ckpt file:

checkpoint = torch.load(model_ckpt.ckpt)
torch.save(checkpoint,"ckpt2.ckpt")
model = nemo_asr.models.EncDecCTCModel.load_from_checkpoint("ckpt2.ckpt")
model.load_state_dict(checkpoint['state_dict'], strict=True)
model.save_to(output_path)

if you have an issue with tokenizer you may need to indicate the path where you store it in the new checkpoint.cfg:
checkpoint["hyper_parameters"]["cfg"]["tokenizer"]["model_path"]=os.path.join(tokenizer_path,"tokenizer.model")
checkpoint["hyper_parameters"]["cfg"]["tokenizer"]["vocab_path"]=os.path.join(tokenizer_path,"vocab.txt")
checkpoint["hyper_parameters"]…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@titu1994
Comment options

@egorsmkv
Comment options

Answer selected by titu1994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants