Spaces:
Runtime error
Runtime error
File size: 719 Bytes
d236641 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("csebuetnlp/banglat5_nmt_bn_en", use_fast=False)
model = AutoModelForSeq2SeqLM.from_pretrained("csebuetnlp/banglat5_nmt_bn_en")
pipe = pipeline("translation", model=model, tokenizer=tokenizer)
def translate(text):
translation = pipe(text)[0]['translation_text']
return translation
interface = gr.Interface(
fn=translate,
inputs=gr.Textbox(label="Translated Text in English"), # Updated here
title="Bangla to English Translator",
description="Translate Bangla text into English using a Hugging Face model."
)
if __name__ == "__main__":
interface.launch() |