Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,3 +1,24 @@
1
  import gradio as gr
 
 
2
 
3
- gr.Interface.load("models/ashokurlana/mBART-TeSum").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import torch
3
+ from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
4
 
5
+ description = "Telugu Abstractive Summarization"
6
+ title = "TeSum"
7
+
8
+ model = MBartForConditionalGeneration.from_pretrained("ashokurlana/mBART-TeSum")
9
+ device = "cuda" if torch.cuda.is_available() else "cpu"
10
+ model.to(device)
11
+ model.eval()
12
+ tokenizer = MBart50TokenizerFast.from_pretrained("ashokurlana/mBART-TeSum", src_lang="te_IN", tgt_lang="te_IN")
13
+
14
+ def summarize(text):
15
+ model_inputs = tokenizer(src_text, return_tensors="pt")
16
+ with tokenizer.as_target_tokenizer():
17
+ labels = tokenizer(tgt_text, return_tensors="pt").input_ids
18
+
19
+ return model(**model_inputs, labels=labels)
20
+
21
+ interface = gr.Interface(transcribe, inputs='text', outputs='text')
22
+ interface.launch(share=True)
23
+
24
+ # gr.Interface.load("models/ashokurlana/mBART-TeSum").launch()