nmt / app.py
erkhem-gantulga's picture
Added first generated model
d346b8a
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()