KeyError: 'opt'

I am trying to run this command :
onmt_translate -model checkpoints_bn_en/ -src test/ -output pred_avg10.txt -gpu 0 -verbose

And the error occurs like this:
*Traceback (most recent call last):
File “/home/dhar/.local/bin/onmt_translate”, line 8, in
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/bin/”, line 47, in main
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/bin/”, line 18, in translate
translator = build_translator(opt, logger=logger, report_score=True)
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/translate/”, line 29, in build_translator
fields, model, model_opt = load_test_model(opt)
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/”, line 86, in load_test_model
model_opt = ArgumentParser.ckpt_model_opts(checkpoint[‘opt’])
KeyError: ‘opt’

How to slove it?? Thanks in advance

Your checkpoint does not seem valid. Where does it come from?

I used fairseq-train for training

Then you would need to use fairseq to do the inference…

1 Like