Last active
September 8, 2023 16:27
-
-
Save sanjibnarzary/f34d51bcaca17cf449d0456485904174 to your computer and use it in GitHub Desktop.
Testing script in Python fairseq machine translation model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if len(sys.argv) <3: | |
print("python test.py checkpoint_path data-bin bpe_code") | |
sys.exit(0) | |
else: | |
path=sys.argv[1] | |
db=sys.argv[2] | |
code=sys.argv[3] | |
from fairseq.models.transformer import TransformerModel | |
eng2brx = TransformerModel.from_pretrained( | |
path, | |
checkpoint_file='checkpoint_last.pt', | |
data_name_or_path=db, | |
bpe='subword_nmt', | |
bpe_codes=code | |
) | |
eng=input('English text: ') | |
brx=eng2brx.translate(eng) | |
print(eng) | |
print(brx) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment