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