Siri23 commited on
Commit
d236641
·
verified ·
1 Parent(s): 429c106

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
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()