OpenNMT Forum

KeyError: 'opt'

I am trying to run this command :
onmt_translate -model checkpoints_bn_en/checkpoint.avg10.pt -src test/test.bn -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
sys.exit(main())
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/bin/translate.py”, line 47, in main
translate(opt)
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/bin/translate.py”, line 18, in translate
translator = build_translator(opt, logger=logger, report_score=True)
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/translate/translator.py”, line 29, in build_translator
fields, model, model_opt = load_test_model(opt)
File “/home/dhar/.local/lib/python3.8/site-packages/onmt/model_builder.py”, 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