Spaces:
Sleeping
Sleeping
File size: 772 Bytes
9477d2a 0cacdf0 9477d2a 0cacdf0 9477d2a 2ce07b3 9477d2a 0cacdf0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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() |