Spaces:
Runtime error
Runtime error
File size: 830 Bytes
6e8a28f 59fd7cf bb89ea3 59fd7cf 39dc3ab 59fd7cf 39dc3ab 59fd7cf 39dc3ab 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 |
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() |