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() | |