johnnyfivefingers commited on
Commit
e61d618
1 Parent(s): 5d1882f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -1,6 +1,15 @@
1
  import gradio as gr
2
 
3
  from transformers import pipeline
 
 
 
 
 
 
 
 
 
4
 
5
  #hub_model_id = "huggingface-course/mt5-small-finetuned-amazon-en-es"
6
  model_id = "philschmid/bart-large-cnn-samsum"
@@ -10,8 +19,15 @@ summarizer = pipeline("summarization", model=model_id)
10
 
11
  def summarize(text):
12
  #return "Summary: " + text
13
- out = summarizer(text, max_length=150, min_length = 20)
14
- return "Summary: " + str(out)
 
 
 
 
 
 
 
15
 
16
  iface = gr.Interface(fn=summarize, inputs="text", outputs="text")
17
  iface.launch()
 
1
  import gradio as gr
2
 
3
  from transformers import pipeline
4
+ import csv
5
+
6
+ foo = "An"
7
+ bar = None
8
+ baz = "Example"
9
+
10
+ fields = [foo, bar, baz]
11
+
12
+
13
 
14
  #hub_model_id = "huggingface-course/mt5-small-finetuned-amazon-en-es"
15
  model_id = "philschmid/bart-large-cnn-samsum"
 
19
 
20
  def summarize(text):
21
  #return "Summary: " + text
22
+ text = str(text)
23
+ generated_summary = summarizer(text, max_length=150, min_length = 20)
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()