japanese-denim's picture
Update app.py
d096912
raw
history blame
876 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,
tokenizer = tokenizer,
src_lang='en_XX',
tgt_lang='ng_XX')
result = translation_pipeline(text)
return result[0]['translation_text']
gr.Interface(
translate,
[
gr.components.Textbox(label="input", placeholder = "Enter English sentence here")
],
["text"],
).launch()