johnnyfivefingers commited on
Commit
c6f8e5b
1 Parent(s): 583ae7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -12,19 +12,22 @@ summarizer = pipeline("summarization", model=model_id)
12
  def summarize(text):
13
  #return "Summary: " + text
14
  text = str(text)
15
- generated_summary = summarizer(text, max_length=150, min_length = 10)
 
 
 
 
 
 
 
 
16
 
17
  fields = [text, generated_summary]
18
  with open('input.csv','a', newline='') as f:
19
  writer = csv.writer(f)
20
  writer.writerow(fields)
21
-
22
- lines = "(lines)"
23
- with open('input.csv',"r") as f:
24
- lines = f.readlines()
25
- #print(lines)
26
 
27
- return "Summary: " + str(generated_summary) + "\n\n" + str(lines)
28
 
29
  iface = gr.Interface(fn=summarize, inputs="text", outputs="text")
30
  iface.launch()
 
12
  def summarize(text):
13
  #return "Summary: " + text
14
  text = str(text)
15
+ if text == "showdata":
16
+ lines = "(lines)"
17
+ with open('input.csv',"r") as f:
18
+ lines = f.readlines()
19
+ #print(lines)
20
+ return str(lines)
21
+
22
+
23
+ generated_summary = summarizer(text, max_length=150, min_length = 10)[0]['summary_text']
24
 
25
  fields = [text, generated_summary]
26
  with open('input.csv','a', newline='') as f:
27
  writer = csv.writer(f)
28
  writer.writerow(fields)
 
 
 
 
 
29
 
30
+ return "Summary: " + str(generated_summary)
31
 
32
  iface = gr.Interface(fn=summarize, inputs="text", outputs="text")
33
  iface.launch()