Spaces:
Runtime error
Runtime error
File size: 853 Bytes
59fd7cf bb89ea3 59fd7cf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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=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() |