Spaces:
Runtime error
Runtime error
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() |