japanese-denim's picture
Update app.py
6e8a28f
raw
history blame
830 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
import torch
model_checkpoint = "japanese-denim/mbart-50-finetuned-eng-to-naga"
# model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
# tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
src_lang = 'en_XX'
tgt_lang = "ng_XX"
def translate(text):
translation_pipeline = pipeline("translation",
model=model_checkpoint,
src_lang=src_lang,
tgt_lang=tgt_lang)
result = translation_pipeline(text)
return result[0]['translation_text']
gr.Interface(
translate,
[
gr.components.Textbox(label="input", placeholder = "Enter English sentence here")
],
["text"],
).launch()