flichote commited on
Commit
1042ce4
·
1 Parent(s): aadf659

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -6
app.py CHANGED
@@ -58,23 +58,37 @@
58
  # out=grad.Textbox(lines=1, label="French")
59
  # grad.Interface(translate, inputs=txt, outputs=out).launch()
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  from transformers import PegasusForConditionalGeneration, PegasusTokenizer
62
  import gradio as grad
63
  mdl_name = "google/pegasus-xsum"
64
  pegasus_tkn = PegasusTokenizer.from_pretrained(mdl_name)
65
  mdl = PegasusForConditionalGeneration.from_pretrained(mdl_name)
66
 
67
-
68
-
69
-
70
  def summarize(text):
71
  tokens = pegasus_tkn(text, truncation=True, padding="longest", return_tensors="pt")
72
- txt_summary = mdl.generate(**tokens)
73
- response = pegasus_tkn.batch_decode(txt_summary, skip_special_tokens=True)
74
  return response
75
  txt=grad.Textbox(lines=10, label="English", placeholder="English Text here")
76
  out=grad.Textbox(lines=10, label="Summary")
77
  grad.Interface(summarize, inputs=txt, outputs=out).launch()
78
 
79
 
80
-
 
58
  # out=grad.Textbox(lines=1, label="French")
59
  # grad.Interface(translate, inputs=txt, outputs=out).launch()
60
 
61
+ # from transformers import PegasusForConditionalGeneration, PegasusTokenizer
62
+ # import gradio as grad
63
+ # mdl_name = "google/pegasus-xsum"
64
+ # pegasus_tkn = PegasusTokenizer.from_pretrained(mdl_name)
65
+ # mdl = PegasusForConditionalGeneration.from_pretrained(mdl_name)
66
+
67
+
68
+
69
+
70
+ # def summarize(text):
71
+ # tokens = pegasus_tkn(text, truncation=True, padding="longest", return_tensors="pt")
72
+ # txt_summary = mdl.generate(**tokens)
73
+ # response = pegasus_tkn.batch_decode(txt_summary, skip_special_tokens=True)
74
+ # return response
75
+ # txt=grad.Textbox(lines=10, label="English", placeholder="English Text here")
76
+ # out=grad.Textbox(lines=10, label="Summary")
77
+ # grad.Interface(summarize, inputs=txt, outputs=out).launch()
78
+
79
  from transformers import PegasusForConditionalGeneration, PegasusTokenizer
80
  import gradio as grad
81
  mdl_name = "google/pegasus-xsum"
82
  pegasus_tkn = PegasusTokenizer.from_pretrained(mdl_name)
83
  mdl = PegasusForConditionalGeneration.from_pretrained(mdl_name)
84
 
 
 
 
85
  def summarize(text):
86
  tokens = pegasus_tkn(text, truncation=True, padding="longest", return_tensors="pt")
87
+ translated_txt = mdl.generate(**tokens,num_return_sequences=5,max_length=200,temperature=1.5,num_beams=10)
88
+ response = pegasus_tkn.batch_decode(translated_txt, skip_special_tokens=True)
89
  return response
90
  txt=grad.Textbox(lines=10, label="English", placeholder="English Text here")
91
  out=grad.Textbox(lines=10, label="Summary")
92
  grad.Interface(summarize, inputs=txt, outputs=out).launch()
93
 
94