nmt_en / app.py
erkhem-gantulga's picture
Initial commit
d0ba603
raw
history blame contribute delete
417 Bytes
import gradio as gr
from fairseq.models.transformer import TransformerModel
model_directory='./'
model = TransformerModel.from_pretrained(
model_directory,
checkpoint_file='model.pt',
data_name_or_path='./bin',
bpe='sentencepiece',
sentencepiece_model='./spm.model'
)
def translate(text):
return model.translate(text)
iface = gr.Interface(fn=translate, inputs="text", outputs="text")
iface.launch()