japanese-denim's picture
Update app.py
d4fb67d
raw
history blame contribute delete
821 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
import torch
model_checkpoint = "japanese-denim/m2m-finetuned-naga-to-eng"
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
def translate(text):
translation_pipeline = pipeline("translation",
model=model,
tokenizer = tokenizer,
src_lang='en',
tgt_lang='en')
result = translation_pipeline(text)
return result[0]['translation_text']
gr.Interface(
translate,
[
gr.components.Textbox(label="input", placeholder = "Enter Nagamese sentence here")
],
["text"],
).launch()