balaramas commited on
Commit
63efd0b
1 Parent(s): 852ff2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -3,13 +3,15 @@ import gradio as gr
3
  import subprocess
4
  subprocess.check_call(["pip", "install", "transformers"])
5
  subprocess.check_call(["pip", "install", "torch"])
6
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
7
- tokenizer = AutoTokenizer.from_pretrained("balaramas/mbart-enhiriser")
8
- model = AutoModelForSeq2SeqLM.from_pretrained("balaramas/mbart-enhiriser")
9
-
 
10
  def summariser(ar_en, lang):
 
11
  tokenizer.src_lang = "en_XX"
12
- encoded_ar = tokenizer(ar_en, return_tensors="pt")
13
  if(lang=='Hindi'):
14
  coi='hi_IN'
15
  if(lang=='Gujrati'):
@@ -28,7 +30,7 @@ def summariser(ar_en, lang):
28
  iface = gr.Interface(
29
  fn=summariser,
30
  inputs=[gr.Textbox(label="Enter the paragraph in English", placeholder="Type here..."), gr.Radio(["Hindi", "Gujrati", "Bengali", "Tamil"], label="Language to be summarised in:")],
31
- outputs="text",
32
  title="English to Indic Summariser"
33
  )
34
  iface.launch()
 
3
  import subprocess
4
  subprocess.check_call(["pip", "install", "transformers"])
5
  subprocess.check_call(["pip", "install", "torch"])
6
+ from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
7
+ from transformers import pipeline
8
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
9
+ model = MBartForConditionalGeneration.from_pretrained("facebook/mbart-large-50-many-to-many-mmt")
10
+ tokenizer = MBart50TokenizerFast.from_pretrained("facebook/mbart-large-50-many-to-many-mmt")
11
  def summariser(ar_en, lang):
12
+ summ = summarizer(ar_en, max_length=130, min_length=30, do_sample=False)['summary_text']
13
  tokenizer.src_lang = "en_XX"
14
+ encoded_ar = tokenizer(summ, return_tensors="pt")
15
  if(lang=='Hindi'):
16
  coi='hi_IN'
17
  if(lang=='Gujrati'):
 
30
  iface = gr.Interface(
31
  fn=summariser,
32
  inputs=[gr.Textbox(label="Enter the paragraph in English", placeholder="Type here..."), gr.Radio(["Hindi", "Gujrati", "Bengali", "Tamil"], label="Language to be summarised in:")],
33
+ outputs=gr.Textbox(label="Summarised Text"),
34
  title="English to Indic Summariser"
35
  )
36
  iface.launch()