Shangkhonil's picture
Update app.py
0cacdf0 verified
raw
history blame
772 Bytes
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.inputs.Textbox(label="Input Text in Bangla"),
outputs=gr.outputs.Textbox(label="Translated Text in English"),
title="Bangla to English Translator",
description="Translate Bangla text into English using a Hugging Face model."
)
if __name__ == "__main__":
interface.launch()