Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,14 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def translate(text):
|
| 7 |
translation = pipe(text)[0]['translation_text']
|
| 8 |
return translation
|
| 9 |
-
|
| 10 |
interface = gr.Interface(
|
| 11 |
fn=translate,
|
| 12 |
inputs=gr.inputs.Textbox(label="Input Text in Bangla"),
|
|
@@ -15,4 +17,4 @@ interface = gr.Interface(
|
|
| 15 |
description="Translate Bangla text into English using a Hugging Face model."
|
| 16 |
)
|
| 17 |
if __name__ == "__main__":
|
| 18 |
-
interface.launch()
|
|
|
|
| 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.inputs.Textbox(label="Input Text in Bangla"),
|
|
|
|
| 17 |
description="Translate Bangla text into English using a Hugging Face model."
|
| 18 |
)
|
| 19 |
if __name__ == "__main__":
|
| 20 |
+
interface.launch()
|