jafrilalam commited on
Commit
5076755
1 Parent(s): 3e5afd9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -27
app.py CHANGED
@@ -1,29 +1,3 @@
1
  import gradio as gr
2
- from transformers import pipeline, AutoModelForSeq2SeqLM, MBart50Tokenizer, AutoTokenizer
3
 
4
- tokenizer = AutoTokenizer.from_pretrained('facebook/mbart-large-50', src_lang="bn_IN", tgt_lang="bn_IN", use_fast=True)
5
- model = AutoModelForSeq2SeqLM.from_pretrained("jafrilalam/bangla_sentence_correction_01", use_safetensors=True)
6
-
7
- def correct_text(given_sentence):
8
- inputs = tokenizer.encode(
9
- given_sentence,
10
- truncation=True,
11
- return_tensors="pt",
12
- max_length=len(given_sentence),
13
- )
14
-
15
- output_ids = model.generate(
16
- inputs,
17
- max_new_tokens=len(given_sentence),
18
- early_stopping=True,
19
- )
20
-
21
- return tokenizer.decode(output_ids[0], skip_special_tokens=True)
22
-
23
- iface = gr.Interface(
24
- fn=correct_text,
25
- inputs=gr.Textbox(lines=4, label="Incorrect Bangla Sentence"),
26
- outputs=gr.Textbox(label="Corrected Bangla Sentence")
27
- )
28
-
29
- iface.launch(share = True)
 
1
  import gradio as gr
 
2
 
3
+ gr.load("models/jafrilalam/bangla_sentence_correction_01").launch()